Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
87 changes: 45 additions & 42 deletions lib/ui/compact_icon_button.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import 'package:material_ui/material_ui.dart';

import '../core/platform.dart';
import '../core/theme.dart';

/// The app-wide icon action used in toolbars, footers, and sidebars.
Expand Down Expand Up @@ -44,49 +45,51 @@ class CompactIconButton extends StatelessWidget {
final scheme = Theme.of(context).colorScheme;
final extent = this.extent ?? AppControlMetrics.iconButtonExtent;

return Tooltip(
message: tooltip,
child: Semantics(
button: true,
selected: selected,
child: IconButton(
onPressed: onPressed,
icon: icon,
color: foregroundColor ?? palette.textSecondary,
padding: EdgeInsets.zero,
constraints: BoxConstraints.tightFor(width: extent, height: extent),
visualDensity: VisualDensity.standard,
style: ButtonStyle(
minimumSize: WidgetStatePropertyAll(Size.square(extent)),
maximumSize: WidgetStatePropertyAll(Size.square(extent)),
tapTargetSize:
tapTargetSize ?? AppControlMetrics.iconButtonTapTargetSize,
backgroundColor: WidgetStateProperty.resolveWith((states) {
if (states.contains(WidgetState.disabled)) {
return MergeSemantics(
child: Tooltip(
message: tooltip,
child: Semantics(
label: AppPlatform.isDesktop ? tooltip : null,
selected: selected,
child: IconButton(
onPressed: onPressed,
icon: icon,
color: foregroundColor ?? palette.textSecondary,
padding: EdgeInsets.zero,
constraints: BoxConstraints.tightFor(width: extent, height: extent),
visualDensity: VisualDensity.standard,
style: ButtonStyle(
minimumSize: WidgetStatePropertyAll(Size.square(extent)),
maximumSize: WidgetStatePropertyAll(Size.square(extent)),
tapTargetSize:
tapTargetSize ?? AppControlMetrics.iconButtonTapTargetSize,
backgroundColor: WidgetStateProperty.resolveWith((states) {
if (states.contains(WidgetState.disabled)) {
return Colors.transparent;
}
if (states.contains(WidgetState.pressed)) {
return scheme.primary.withValues(alpha: 0.10);
}
if (selected) {
return selectedBackground ?? palette.selectedBackground;
}
if (states.contains(WidgetState.hovered) ||
states.contains(WidgetState.focused)) {
return palette.hover;
}
return Colors.transparent;
}
if (states.contains(WidgetState.pressed)) {
return scheme.primary.withValues(alpha: 0.10);
}
if (selected) {
return selectedBackground ?? palette.selectedBackground;
}
if (states.contains(WidgetState.hovered) ||
states.contains(WidgetState.focused)) {
return palette.hover;
}
return Colors.transparent;
}),
overlayColor: const WidgetStatePropertyAll(Colors.transparent),
side: WidgetStateProperty.resolveWith((states) {
if (states.contains(WidgetState.focused)) {
return BorderSide(color: palette.selectedBorder, width: 1);
}
return BorderSide.none;
}),
shape: WidgetStatePropertyAll(
RoundedRectangleBorder(
borderRadius: BorderRadius.circular(radius),
}),
overlayColor: const WidgetStatePropertyAll(Colors.transparent),
side: WidgetStateProperty.resolveWith((states) {
if (states.contains(WidgetState.focused)) {
return BorderSide(color: palette.selectedBorder, width: 1);
}
return BorderSide.none;
}),
shape: WidgetStatePropertyAll(
RoundedRectangleBorder(
borderRadius: BorderRadius.circular(radius),
),
),
),
),
Expand Down
132 changes: 71 additions & 61 deletions lib/ui/draw/drawing_canvas.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1093,45 +1093,50 @@ class DrawingCanvasState extends State<DrawingCanvas> {
if (!widget.readOnly) ...[
Tooltip(
message: 'Colour and size',
child: InkWell(
key: const ValueKey('draw-style'),
onTap: () => setState(() => _styleOpen = !_styleOpen),
borderRadius: BorderRadius.circular(9),
child: Container(
height: extent,
padding: const EdgeInsets.symmetric(horizontal: 8),
decoration: _styleOpen
? BoxDecoration(
color: palette.selectedBackground,
borderRadius: BorderRadius.circular(9),
)
: null,
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
Container(
width: 14,
height: 14,
decoration: BoxDecoration(
color: _color == null
? palette.textPrimary
: Color(_color!),
shape: BoxShape.circle,
border: Border.all(
color: palette.separator,
width: 1.5,
strokeAlign: BorderSide.strokeAlignOutside,
child: Semantics(
button: true,
expanded: _styleOpen,
label: AppPlatform.isDesktop ? 'Colour and size' : null,
child: InkWell(
key: const ValueKey('draw-style'),
onTap: () => setState(() => _styleOpen = !_styleOpen),
borderRadius: BorderRadius.circular(9),
child: Container(
height: extent,
padding: const EdgeInsets.symmetric(horizontal: 8),
decoration: _styleOpen
? BoxDecoration(
color: palette.selectedBackground,
borderRadius: BorderRadius.circular(9),
)
: null,
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
Container(
width: 14,
height: 14,
decoration: BoxDecoration(
color: _color == null
? palette.textPrimary
: Color(_color!),
shape: BoxShape.circle,
border: Border.all(
color: palette.separator,
width: 1.5,
strokeAlign: BorderSide.strokeAlignOutside,
),
),
),
),
const SizedBox(width: 6),
KapyIcon(
KapyIcons.chevronDownRounded,
size: 12,
strokeWidth: 2,
color: palette.textSecondary,
),
],
const SizedBox(width: 6),
KapyIcon(
KapyIcons.chevronDownRounded,
size: 12,
strokeWidth: 2,
color: palette.textSecondary,
),
],
),
),
),
),
Expand Down Expand Up @@ -1298,31 +1303,36 @@ class _StylePanel extends StatelessWidget {
for (final (name, option) in drawColors)
Tooltip(
message: name,
child: InkWell(
key: ValueKey('draw-color-${option ?? 'ink'}'),
customBorder: const CircleBorder(),
onTap: () => onColor(option),
child: Container(
width: 30,
height: 30,
alignment: Alignment.center,
decoration: option == color
? BoxDecoration(
shape: BoxShape.circle,
border: Border.all(
color: palette.selectedBorder,
width: 2,
),
)
: null,
child: Semantics(
button: true,
selected: option == color,
label: AppPlatform.isDesktop ? name : null,
child: InkWell(
key: ValueKey('draw-color-${option ?? 'ink'}'),
customBorder: const CircleBorder(),
onTap: () => onColor(option),
child: Container(
width: 20,
height: 20,
decoration: BoxDecoration(
color: option == null
? palette.textPrimary
: Color(option),
shape: BoxShape.circle,
width: 30,
height: 30,
alignment: Alignment.center,
decoration: option == color
? BoxDecoration(
shape: BoxShape.circle,
border: Border.all(
color: palette.selectedBorder,
width: 2,
),
)
: null,
child: Container(
width: 20,
height: 20,
decoration: BoxDecoration(
color: option == null
? palette.textPrimary
: Color(option),
shape: BoxShape.circle,
),
),
),
),
Expand Down
4 changes: 4 additions & 0 deletions lib/ui/notes_list.dart
Original file line number Diff line number Diff line change
Expand Up @@ -987,9 +987,11 @@ class SeeAllLink extends StatelessWidget {
Widget build(BuildContext context) {
final palette = context.palette;
return Semantics(
container: true,
button: true,
label: 'See all pinned notes',
excludeSemantics: true,
onTap: onPressed,
child: MouseRegion(
cursor: SystemMouseCursors.click,
child: GestureDetector(
Expand Down Expand Up @@ -1051,6 +1053,7 @@ class NotesListControls extends StatelessWidget {
selected: on,
label: forCards ? 'Cards' : 'List',
excludeSemantics: true,
onTap: on ? null : () => onCardsChanged(forCards),
child: MouseRegion(
cursor: on ? MouseCursor.defer : SystemMouseCursors.click,
child: GestureDetector(
Expand Down Expand Up @@ -1168,6 +1171,7 @@ class _MediaFilterState extends State<_MediaFilter> {
expanded: open,
label: 'Media filter, $label',
excludeSemantics: true,
onTap: _toggle,
child: MouseRegion(
cursor: SystemMouseCursors.click,
child: GestureDetector(
Expand Down
11 changes: 10 additions & 1 deletion lib/ui/tonal_button.dart
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,15 @@ class TonalButton extends StatelessWidget {
);

final tooltip = this.tooltip;
return tooltip == null ? button : Tooltip(message: tooltip, child: button);
if (tooltip == null) return button;
if (label != null || !AppPlatform.isDesktop) {
return Tooltip(message: tooltip, child: button);
}
return MergeSemantics(
child: Tooltip(
message: tooltip,
child: Semantics(label: tooltip, child: button),
),
);
}
}
Loading
Loading