Skip to content

Commit 02177f6

Browse files
authored
chore: DCM fixes (#583)
* chore: prefer `const BorderRadius.all` * chore: sort private members * chore: ignore lint * chore: bump version & changelog
1 parent 8994f8b commit 02177f6

File tree

11 files changed

+136
-118
lines changed

11 files changed

+136
-118
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
## [2.2.0+3]
2+
* Address DCM lints:
3+
* Prefer `const BorderRadius.all`
4+
* Sort private members
5+
16
## [2.2.0+2]
27
* Formatter updates
38

example/pubspec.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ packages:
182182
path: ".."
183183
relative: true
184184
source: path
185-
version: "2.2.0+2"
185+
version: "2.2.0+3"
186186
macos_window_utils:
187187
dependency: transitive
188188
description:

lib/src/buttons/checkbox.dart

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,24 @@ class _CheckboxStack extends StatelessWidget {
193193
final bool isMainWindow;
194194
final double size;
195195

196+
Color _getCheckmarkColor() {
197+
if (isDisabled) {
198+
return const MacosColor.fromRGBO(172, 172, 172, 1.0);
199+
}
200+
201+
if (theme.brightness.isDark) {
202+
return theme.accentColor == AccentColor.graphite && isMainWindow
203+
? MacosColors.black
204+
: MacosColors.white;
205+
}
206+
207+
if (theme.isMainWindow == false) {
208+
return MacosColors.black;
209+
}
210+
211+
return MacosColors.white;
212+
}
213+
196214
@override
197215
Widget build(BuildContext context) {
198216
final icon = value == false
@@ -214,24 +232,6 @@ class _CheckboxStack extends StatelessWidget {
214232
],
215233
);
216234
}
217-
218-
Color _getCheckmarkColor() {
219-
if (isDisabled) {
220-
return const MacosColor.fromRGBO(172, 172, 172, 1.0);
221-
}
222-
223-
if (theme.brightness.isDark) {
224-
return theme.accentColor == AccentColor.graphite && isMainWindow
225-
? MacosColors.black
226-
: MacosColors.white;
227-
}
228-
229-
if (theme.isMainWindow == false) {
230-
return MacosColors.black;
231-
}
232-
233-
return MacosColors.white;
234-
}
235235
}
236236

237237
/// A widget that paints an inner drop shadow for the checkbox in light mode.

lib/src/buttons/popup_button.dart

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1407,7 +1407,9 @@ class _UpDownCaretsPainter extends CustomPainter {
14071407

14081408
/// Draw background
14091409
canvas.drawRRect(
1410-
BorderRadius.circular(radius).toRRect(Offset.zero & size),
1410+
const BorderRadius.all(
1411+
Radius.circular(radius),
1412+
).toRRect(Offset.zero & size),
14111413
Paint()..color = backgroundColor,
14121414
);
14131415

lib/src/buttons/pulldown_button.dart

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1093,7 +1093,9 @@ class _DownCaretPainter extends CustomPainter {
10931093

10941094
/// Draw background
10951095
canvas.drawRRect(
1096-
BorderRadius.circular(radius).toRRect(Offset.zero & size),
1096+
const BorderRadius.all(
1097+
Radius.circular(radius),
1098+
).toRRect(Offset.zero & size),
10971099
Paint()..color = backgroundColor,
10981100
);
10991101

lib/src/fields/text_field.dart

Lines changed: 44 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -951,6 +951,7 @@ class _MacosTextFieldState extends State<MacosTextField>
951951

952952
@override
953953
bool get selectionEnabled => widget.selectionEnabled;
954+
954955
// End of API for TextSelectionGestureDetectorBuilderDelegate.
955956

956957
@override
@@ -1185,49 +1186,6 @@ class _MacosTextFieldState extends State<MacosTextField>
11851186
);
11861187
}
11871188

1188-
@override
1189-
void restoreState(RestorationBucket? oldBucket, bool initialRestore) {
1190-
if (_controller != null) {
1191-
_registerController();
1192-
}
1193-
}
1194-
1195-
@override
1196-
String? get restorationId => widget.restorationId;
1197-
1198-
@override
1199-
void dispose() {
1200-
_focusNode?.dispose();
1201-
_controller?.dispose();
1202-
_effectiveFocusNode.removeListener(_handleFocusChanged);
1203-
super.dispose();
1204-
}
1205-
1206-
EditableTextState get _editableText => editableTextKey.currentState!;
1207-
1208-
@override
1209-
bool get wantKeepAlive => _controller?.value.text.isNotEmpty == true;
1210-
1211-
// True if any surrounding decoration widgets will be shown.
1212-
bool get _hasDecoration {
1213-
return widget.placeholder != null ||
1214-
widget.clearButtonMode != OverlayVisibilityMode.never ||
1215-
widget.prefix != null ||
1216-
widget.suffix != null;
1217-
}
1218-
1219-
// Provide default behavior if widget.textAlignVertical is not set.
1220-
// TextField has top alignment by default, unless it has decoration
1221-
// like a prefix or suffix, in which case it's aligned to the center.
1222-
TextAlignVertical get _textAlignVertical {
1223-
if (widget.textAlignVertical != null) {
1224-
return widget.textAlignVertical!;
1225-
}
1226-
return widget.maxLines == null || widget.maxLines! > 1
1227-
? TextAlignVertical.center
1228-
: TextAlignVertical.top;
1229-
}
1230-
12311189
Color? _resolveAccentColor(BuildContext context, AccentColor? accentColor) {
12321190
if (accentColor == null) {
12331191
return null;
@@ -1276,6 +1234,49 @@ class _MacosTextFieldState extends State<MacosTextField>
12761234
}
12771235
}
12781236

1237+
@override
1238+
void restoreState(RestorationBucket? oldBucket, bool initialRestore) {
1239+
if (_controller != null) {
1240+
_registerController();
1241+
}
1242+
}
1243+
1244+
@override
1245+
String? get restorationId => widget.restorationId;
1246+
1247+
@override
1248+
void dispose() {
1249+
_focusNode?.dispose();
1250+
_controller?.dispose();
1251+
_effectiveFocusNode.removeListener(_handleFocusChanged);
1252+
super.dispose();
1253+
}
1254+
1255+
EditableTextState get _editableText => editableTextKey.currentState!;
1256+
1257+
@override
1258+
bool get wantKeepAlive => _controller?.value.text.isNotEmpty == true;
1259+
1260+
// True if any surrounding decoration widgets will be shown.
1261+
bool get _hasDecoration {
1262+
return widget.placeholder != null ||
1263+
widget.clearButtonMode != OverlayVisibilityMode.never ||
1264+
widget.prefix != null ||
1265+
widget.suffix != null;
1266+
}
1267+
1268+
// Provide default behavior if widget.textAlignVertical is not set.
1269+
// TextField has top alignment by default, unless it has decoration
1270+
// like a prefix or suffix, in which case it's aligned to the center.
1271+
TextAlignVertical get _textAlignVertical {
1272+
if (widget.textAlignVertical != null) {
1273+
return widget.textAlignVertical!;
1274+
}
1275+
return widget.maxLines == null || widget.maxLines! > 1
1276+
? TextAlignVertical.center
1277+
: TextAlignVertical.top;
1278+
}
1279+
12791280
@override
12801281
// ignore: code-metrics
12811282
Widget build(BuildContext context) {

lib/src/indicators/capacity_indicators.dart

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,9 @@ class _CapacityCellPainter extends CustomPainter {
225225

226226
/// Draw background
227227
canvas.drawRRect(
228-
BorderRadius.circular(radius).toRRect(Offset.zero & size),
228+
const BorderRadius.all(
229+
Radius.circular(radius),
230+
).toRRect(Offset.zero & size),
229231
Paint()..color = backgroundColor,
230232
);
231233

@@ -242,7 +244,9 @@ class _CapacityCellPainter extends CustomPainter {
242244

243245
/// Draw border
244246
canvas.drawRRect(
245-
BorderRadius.circular(radius).toRRect(Offset.zero & size),
247+
const BorderRadius.all(
248+
Radius.circular(radius),
249+
).toRRect(Offset.zero & size),
246250
Paint()
247251
..color = borderColor
248252
..style = PaintingStyle.stroke

lib/src/layout/sidebar/sidebar_items.dart

Lines changed: 52 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -228,13 +228,33 @@ class _SidebarHeaderItem extends StatelessWidget {
228228
bool get hasLeading => item.leading != null;
229229
bool get hasTrailing => item.trailing != null;
230230

231+
DefaultTextStyle _buildLabelWithDefaultTextStyle(
232+
TextStyle labelStyle,
233+
BuildContext context,
234+
) {
235+
final isDarkModeEnabled = MacosTheme.of(context).brightness.isDark;
236+
237+
return DefaultTextStyle(
238+
style: labelStyle.copyWith(
239+
fontWeight: FontWeight.bold,
240+
fontSize: (labelStyle.fontSize ?? 14.0) * 0.85,
241+
color: isDarkModeEnabled
242+
? MacosColors.white.withValues(alpha: 0.3)
243+
: MacosColors.black.withValues(alpha: 0.3),
244+
overflow: TextOverflow.ellipsis,
245+
),
246+
child: item.label,
247+
);
248+
}
249+
231250
@override
232251
Widget build(BuildContext context) {
233252
assert(debugCheckHasMacosTheme(context));
234253
final theme = MacosTheme.of(context);
235254

236255
final double spacing = 10.0 + theme.visualDensity.horizontal;
237256
final itemSize = _SidebarItemsConfiguration.of(context).itemSize;
257+
238258
TextStyle? labelStyle;
239259
switch (itemSize) {
240260
case SidebarItemSize.small:
@@ -289,25 +309,6 @@ class _SidebarHeaderItem extends StatelessWidget {
289309
),
290310
);
291311
}
292-
293-
DefaultTextStyle _buildLabelWithDefaultTextStyle(
294-
TextStyle labelStyle,
295-
BuildContext context,
296-
) {
297-
final isDarkModeEnabled = MacosTheme.of(context).brightness.isDark;
298-
299-
return DefaultTextStyle(
300-
style: labelStyle.copyWith(
301-
fontWeight: FontWeight.bold,
302-
fontSize: (labelStyle.fontSize ?? 14.0) * 0.85,
303-
color: isDarkModeEnabled
304-
? MacosColors.white.withValues(alpha: 0.3)
305-
: MacosColors.black.withValues(alpha: 0.3),
306-
overflow: TextOverflow.ellipsis,
307-
),
308-
child: item.label,
309-
);
310-
}
311312
}
312313

313314
/// A macOS style navigation-list item intended for use in a [Sidebar]
@@ -336,6 +337,36 @@ class _SidebarItem extends StatelessWidget {
336337

337338
void _handleActionTap() => onClick?.call();
338339

340+
DefaultTextStyle _buildLabelWithDefaultTextStyle(
341+
TextStyle labelStyle,
342+
Color selectedColor,
343+
BuildContext context,
344+
) {
345+
if (item.section ?? true) {
346+
final isDarkModeEnabled = MacosTheme.of(context).brightness.isDark;
347+
348+
return DefaultTextStyle(
349+
style: labelStyle.copyWith(
350+
fontWeight: FontWeight.bold,
351+
fontSize: (labelStyle.fontSize ?? 14.0) * 0.85,
352+
color: isDarkModeEnabled
353+
? MacosColors.white.withValues(alpha: 0.3)
354+
: MacosColors.black.withValues(alpha: 0.3),
355+
overflow: TextOverflow.ellipsis,
356+
),
357+
child: item.label,
358+
);
359+
}
360+
361+
return DefaultTextStyle(
362+
style: labelStyle.copyWith(
363+
color: selected ? textLuminance(selectedColor) : null,
364+
overflow: TextOverflow.ellipsis,
365+
),
366+
child: item.label,
367+
);
368+
}
369+
339370
Map<Type, Action<Intent>> get _actionMap => <Type, Action<Intent>>{
340371
ActivateIntent: CallbackAction<ActivateIntent>(
341372
onInvoke: (ActivateIntent intent) => _handleActionTap(),
@@ -344,8 +375,8 @@ class _SidebarItem extends StatelessWidget {
344375
onInvoke: (ButtonActivateIntent intent) => _handleActionTap(),
345376
),
346377
};
347-
348378
bool get hasLeading => item.leading != null;
379+
349380
bool get hasTrailing => item.trailing != null;
350381

351382
@override
@@ -366,6 +397,7 @@ class _SidebarItem extends StatelessWidget {
366397

367398
final double spacing = 10.0 + theme.visualDensity.horizontal;
368399
final itemSize = _SidebarItemsConfiguration.of(context).itemSize;
400+
369401
TextStyle? labelStyle;
370402
switch (itemSize) {
371403
case SidebarItemSize.small:
@@ -442,36 +474,6 @@ class _SidebarItem extends StatelessWidget {
442474
),
443475
);
444476
}
445-
446-
DefaultTextStyle _buildLabelWithDefaultTextStyle(
447-
TextStyle labelStyle,
448-
Color selectedColor,
449-
BuildContext context,
450-
) {
451-
if (item.section ?? true) {
452-
final isDarkModeEnabled = MacosTheme.of(context).brightness.isDark;
453-
454-
return DefaultTextStyle(
455-
style: labelStyle.copyWith(
456-
fontWeight: FontWeight.bold,
457-
fontSize: (labelStyle.fontSize ?? 14.0) * 0.85,
458-
color: isDarkModeEnabled
459-
? MacosColors.white.withValues(alpha: 0.3)
460-
: MacosColors.black.withValues(alpha: 0.3),
461-
overflow: TextOverflow.ellipsis,
462-
),
463-
child: item.label,
464-
);
465-
}
466-
467-
return DefaultTextStyle(
468-
style: labelStyle.copyWith(
469-
color: selected ? textLuminance(selectedColor) : null,
470-
overflow: TextOverflow.ellipsis,
471-
),
472-
child: item.label,
473-
);
474-
}
475477
}
476478

477479
class _DisclosureSidebarHeaderItem extends StatefulWidget {

pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: macos_ui
22
description: Flutter widgets and themes implementing the current macOS design language.
3-
version: 2.2.0+2
3+
version: 2.2.0+3
44
homepage: "https://macosui.dev"
55
repository: "https://github.com/GroovinChip/macos_ui"
66

test/buttons/pulldown_button_test.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// ignore_for_file: prefer-trailing-comma
2+
13
import 'package:flutter/cupertino.dart';
24
import 'package:flutter/foundation.dart';
35
import 'package:flutter_test/flutter_test.dart';

0 commit comments

Comments
 (0)