Skip to content

Commit

Permalink
deps!: Update to Flutter 3.27.0
Browse files Browse the repository at this point in the history
fix: Use new Color / opacity values
test: Update tests for color changes
  • Loading branch information
thelukewalton committed Dec 31, 2024
1 parent 9c529fc commit 24ee385
Show file tree
Hide file tree
Showing 16 changed files with 181 additions and 119 deletions.
3 changes: 3 additions & 0 deletions .fvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"flutter": "3.27.0"
}
5 changes: 2 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ doc/api/
*.js.deps
*.js.map
.env
.fvm/flutter_sdk
.pub-cache/
.pub/
/coverage/**/
Expand Down Expand Up @@ -143,9 +142,9 @@ $RECYCLE.BIN/
*.msp
*.lnk
**/Generated.xcconfig
.fvmrc
**/node_modules/
package-lock.json
/appium
/coverage
/.coverage
/.coverage
.fvm/
2 changes: 1 addition & 1 deletion example/macos/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ SPEC CHECKSUMS:
FlutterMacOS: 8f6f14fa908a6fb3fba0cd85dbd81ec4b251fb24
path_provider_foundation: 2b6b4c569c0fb62ec74538f866245ac84301af46
shared_preferences_foundation: fcdcbc04712aee1108ac7fda236f363274528f78
sqflite_darwin: a553b1fd6fe66f53bbb0fe5b4f5bab93f08d7a13
sqflite_darwin: 5a7236e3b501866c1c9befc6771dfd73ffb8702d
url_launcher_macos: c82c93949963e55b228a30115bd219499a6fe404

PODFILE CHECKSUM: 353c8bcc5d5b0994e508d035b5431cfe18c1dea7
Expand Down
4 changes: 4 additions & 0 deletions example/macos/Runner/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,8 @@ class AppDelegate: FlutterAppDelegate {
override func applicationShouldTerminateAfterLastWindowClosed(_ sender: NSApplication) -> Bool {
return true
}

override func applicationSupportsSecureRestorableState(_ app: NSApplication) -> Bool {
return true
}
}
2 changes: 1 addition & 1 deletion lib/src/components/dial_pad/dial_pad.dart
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ class ZetaDialPadButton extends StatelessWidget {
decoration: ShapeDecoration(
shape: const CircleBorder(),
color: colors.warm.shade10,
shadows: [BoxShadow(color: Colors.black.withOpacity(0.15), blurRadius: 4, offset: const Offset(0, 2))],
shadows: [BoxShadow(color: Colors.black.withValues(alpha: 0.15), blurRadius: 4, offset: const Offset(0, 2))],
),
child: Material(
color: Colors.transparent,
Expand Down
22 changes: 11 additions & 11 deletions lib/src/components/switch/material_switch.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1011,9 +1011,9 @@ class _SwitchDefaultsM3 extends SwitchThemeData {
return WidgetStateProperty.resolveWith((Set<WidgetState> states) {
if (states.contains(WidgetState.disabled)) {
if (states.contains(WidgetState.selected)) {
return _colors.surface.withOpacity(1);
return _colors.surface.withValues(alpha: 1);
}
return _colors.onSurface.withOpacity(0.38);
return _colors.onSurface.withValues(alpha: 0.38);
}
if (states.contains(WidgetState.selected)) {
if (states.contains(WidgetState.pressed)) {
Expand Down Expand Up @@ -1045,9 +1045,9 @@ class _SwitchDefaultsM3 extends SwitchThemeData {
return WidgetStateProperty.resolveWith((Set<WidgetState> states) {
if (states.contains(WidgetState.disabled)) {
if (states.contains(WidgetState.selected)) {
return _colors.onSurface.withOpacity(0.12);
return _colors.onSurface.withValues(alpha: 0.12);
}
return _colors.surfaceContainerHighest.withOpacity(0.12);
return _colors.surfaceContainerHighest.withValues(alpha: 0.12);
}
if (states.contains(WidgetState.selected)) {
if (states.contains(WidgetState.pressed)) {
Expand Down Expand Up @@ -1081,7 +1081,7 @@ class _SwitchDefaultsM3 extends SwitchThemeData {
return Colors.transparent;
}
if (states.contains(WidgetState.disabled)) {
return _colors.onSurface.withOpacity(0.12);
return _colors.onSurface.withValues(alpha: 0.12);
}
return _colors.outline;
});
Expand All @@ -1092,24 +1092,24 @@ class _SwitchDefaultsM3 extends SwitchThemeData {
return WidgetStateProperty.resolveWith((Set<WidgetState> states) {
if (states.contains(WidgetState.selected)) {
if (states.contains(WidgetState.pressed)) {
return _colors.primary.withOpacity(0.12);
return _colors.primary.withValues(alpha: 0.12);
}
if (states.contains(WidgetState.hovered)) {
return _colors.primary.withOpacity(0.08);
return _colors.primary.withValues(alpha: 0.08);
}
if (states.contains(WidgetState.focused)) {
return _colors.primary.withOpacity(0.12);
return _colors.primary.withValues(alpha: 0.12);
}
return null;
}
if (states.contains(WidgetState.pressed)) {
return _colors.onSurface.withOpacity(0.12);
return _colors.onSurface.withValues(alpha: 0.12);
}
if (states.contains(WidgetState.hovered)) {
return _colors.onSurface.withOpacity(0.08);
return _colors.onSurface.withValues(alpha: 0.08);
}
if (states.contains(WidgetState.focused)) {
return _colors.onSurface.withOpacity(0.12);
return _colors.onSurface.withValues(alpha: 0.12);
}
return null;
});
Expand Down
29 changes: 22 additions & 7 deletions lib/src/theme/color_extensions.dart
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,13 @@ extension ZetaColorExtensions on Color {
Color brighten([int amount = 10]) {
if (amount <= 0) return this;
if (amount > 100) return Colors.white;
final Color color = Color.fromARGB(
alpha,
math.max(0, math.min(255, red - (255 * -(amount / 100)).round())),
math.max(0, math.min(255, green - (255 * -(amount / 100)).round())),
math.max(0, math.min(255, blue - (255 * -(amount / 100)).round())),

return Color.fromARGB(
_intAlpha,
math.max(0, math.min(255, _intRed - (255 * -(amount / 100)).round())),
math.max(0, math.min(255, _intGreen - (255 * -(amount / 100)).round())),
math.max(0, math.min(255, _intBlue - (255 * -(amount / 100)).round())),
);
return color;
}

/// Lightens the color with the given integer percentage amount.
Expand Down Expand Up @@ -169,7 +169,7 @@ extension ZetaColorExtensions on Color {

/// Return uppercase Flutter style hex code string of the color.
String get hexCode {
return value.toRadixString(16).toUpperCase().padLeft(8, '0');
return intValue.toRadixString(16).toUpperCase().padLeft(8, '0');
}

/// Applies lightness percentage to color.
Expand Down Expand Up @@ -304,4 +304,19 @@ extension ZetaColorExtensions on Color {
}) {
return adjustContrast(on: on, target: standard.targetContrast);
}

int get _intAlpha => _floatToInt8(a);
int get _intRed => _floatToInt8(r);
int get _intGreen => _floatToInt8(g);
int get _intBlue => _floatToInt8(b);

int _floatToInt8(double x) {
return (x * 255.0).round() & 0xff;
}

/// Returns the integer value of the color.
int get intValue {
// TODO(UX-1353): Remove this method as int color values should be removed
return _intAlpha << 24 | _intRed << 16 | _intGreen << 8 | _intBlue;
}
}
9 changes: 4 additions & 5 deletions lib/src/theme/color_swatch.dart
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class ZetaColorSwatch extends ColorSwatch<int> with EquatableMixin {
return ZetaColorSwatch(
contrast: contrast,
brightness: brightness,
primary: primary.value,
primary: primary.intValue,
swatch: primary.generateSwatch(background: background),
).apply(brightness: brightness);
}
Expand Down Expand Up @@ -188,14 +188,13 @@ class ZetaColorSwatch extends ColorSwatch<int> with EquatableMixin {
return ZetaColorSwatch(
contrast: contrast,
brightness: brightness,
primary: swatch[primaryIndex]!.value,
primary: swatch[primaryIndex]!.intValue,
swatch: swatch,
);
}

@override
List<Object?> get props => [
super.value,
brightness,
contrast,
shade10,
Expand Down Expand Up @@ -256,7 +255,7 @@ class ZetaPureColorSwatch extends ColorSwatch<int> with EquatableMixin {

return ZetaPureColorSwatch(
brightness: brightness,
primary: this[500]!.value,
primary: this[500]!.intValue,
swatch: {
0: this[0]!,
500: this[500]!,
Expand All @@ -266,5 +265,5 @@ class ZetaPureColorSwatch extends ColorSwatch<int> with EquatableMixin {
}

@override
List<Object?> get props => [super.value, shade0, shade500, shade1000];
List<Object?> get props => [shade0, shade500, shade1000];
}
2 changes: 1 addition & 1 deletion test/src/components/badge/indicator_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ void main() {
});
group('Content Tests', () {
final debugFillProperties = {
'color': 'MaterialColor(primary value: Color(0xffff9800))',
'color': Colors.orange.toString(),
'icon': 'IconData(U+F04B6)',
'inverse': 'true',
'rounded': 'false',
Expand Down
3 changes: 1 addition & 2 deletions test/src/components/badge/priority_pill_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ void main() {
'rounded': 'false',
'isBadge': 'false',
'index': '"1"',
'customColor':
'ZetaColorSwatch(4278219750, Brightness.light, ZetaContrast.aa, Color(0xfff1f8ff), Color(0xffe2f1ff), Color(0xffb7dbff), Color(0xff7ebeff), Color(0xff599fe5), Color(0xff0073e6), Color(0xff0061c2), Color(0xff004d99), Color(0xff002c58), Color(0xff101b25))',
'customColor': ZetaColorBase.blue.toString(),
'type': 'urgent',
'size': 'large',
};
Expand Down
20 changes: 1 addition & 19 deletions test/src/components/tooltip/tooltip_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ void main() {
final debugFillProperties = {
'rounded': 'null',
'padding': 'EdgeInsets.all(8.0)',
'color': 'MaterialColor(primary value: Color(0xffffc107))',
'color': Colors.amber.toString(),
'textStyle': 'TextStyle(inherit: true, size: 9.0)',
'arrowDirection': 'down',
'maxWidth': '170.0',
Expand All @@ -46,24 +46,6 @@ void main() {
debugFillProperties,
);

testWidgets('debugFillProperties works correctly', (WidgetTester tester) async {
final diagnostics = DiagnosticPropertiesBuilder();
const ZetaTooltip(
padding: EdgeInsets.all(8),
color: Colors.amber,
textStyle: TextStyle(fontSize: 9),
maxWidth: 170,
child: Text('Rounded tooltip'),
).debugFillProperties(diagnostics);

expect(diagnostics.finder('rounded'), 'null');
expect(diagnostics.finder('padding'), 'EdgeInsets.all(8.0)');
expect(diagnostics.finder('color').toLowerCase(), contains(Colors.amber.hexCode.toLowerCase()));
expect(diagnostics.finder('textStyle'), contains('size: 9.0'));
expect(diagnostics.finder('arrowDirection'), 'down');
expect(diagnostics.finder('maxWidth'), '170.0');
});

testWidgets('renders with default properties', (WidgetTester tester) async {
await tester.pumpWidget(
const TestApp(
Expand Down
31 changes: 22 additions & 9 deletions test/src/components/tooltip/tooltip_test.mocks.dart
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ class _FakeZetaColors_1 extends _i1.SmartFake implements _i2.ZetaColors {
);
}

class _FakeZetaRadiiSemantics_2 extends _i1.SmartFake implements _i2.ZetaRadiiSemantics {
class _FakeZetaRadiiSemantics_2 extends _i1.SmartFake
implements _i2.ZetaRadiiSemantics {
_FakeZetaRadiiSemantics_2(
Object parent,
Invocation parentInvocation,
Expand All @@ -54,7 +55,8 @@ class _FakeZetaRadiiSemantics_2 extends _i1.SmartFake implements _i2.ZetaRadiiSe
);
}

class _FakeZetaSpacingSemantics_3 extends _i1.SmartFake implements _i2.ZetaSpacingSemantics {
class _FakeZetaSpacingSemantics_3 extends _i1.SmartFake
implements _i2.ZetaSpacingSemantics {
_FakeZetaSpacingSemantics_3(
Object parent,
Invocation parentInvocation,
Expand All @@ -74,10 +76,12 @@ class _FakeWidget_4 extends _i1.SmartFake implements _i3.Widget {
);

@override
String toString({_i4.DiagnosticLevel? minLevel = _i4.DiagnosticLevel.info}) => super.toString();
String toString({_i4.DiagnosticLevel? minLevel = _i4.DiagnosticLevel.info}) =>
super.toString();
}

class _FakeInheritedElement_5 extends _i1.SmartFake implements _i3.InheritedElement {
class _FakeInheritedElement_5 extends _i1.SmartFake
implements _i3.InheritedElement {
_FakeInheritedElement_5(
Object parent,
Invocation parentInvocation,
Expand All @@ -87,10 +91,12 @@ class _FakeInheritedElement_5 extends _i1.SmartFake implements _i3.InheritedElem
);

@override
String toString({_i4.DiagnosticLevel? minLevel = _i4.DiagnosticLevel.info}) => super.toString();
String toString({_i4.DiagnosticLevel? minLevel = _i4.DiagnosticLevel.info}) =>
super.toString();
}

class _FakeDiagnosticsNode_6 extends _i1.SmartFake implements _i4.DiagnosticsNode {
class _FakeDiagnosticsNode_6 extends _i1.SmartFake
implements _i4.DiagnosticsNode {
_FakeDiagnosticsNode_6(
Object parent,
Invocation parentInvocation,
Expand Down Expand Up @@ -205,7 +211,8 @@ class MockZeta extends _i1.Mock implements _i2.Zeta {
) as _i3.Widget);

@override
bool updateShouldNotify(_i3.InheritedWidget? oldWidget) => (super.noSuchMethod(
bool updateShouldNotify(_i3.InheritedWidget? oldWidget) =>
(super.noSuchMethod(
Invocation.method(
#updateShouldNotify,
[oldWidget],
Expand All @@ -215,7 +222,8 @@ class MockZeta extends _i1.Mock implements _i2.Zeta {
) as bool);

@override
void debugFillProperties(_i4.DiagnosticPropertiesBuilder? properties) => super.noSuchMethod(
void debugFillProperties(_i4.DiagnosticPropertiesBuilder? properties) =>
super.noSuchMethod(
Invocation.method(
#debugFillProperties,
[properties],
Expand Down Expand Up @@ -310,6 +318,7 @@ class MockZeta extends _i1.Mock implements _i2.Zeta {
String? prefixLineOne = r'',
String? prefixOtherLines,
_i4.DiagnosticLevel? minLevel = _i4.DiagnosticLevel.debug,
int? wrapWidth = 65,
}) =>
(super.noSuchMethod(
Invocation.method(
Expand All @@ -319,6 +328,7 @@ class MockZeta extends _i1.Mock implements _i2.Zeta {
#prefixLineOne: prefixLineOne,
#prefixOtherLines: prefixOtherLines,
#minLevel: minLevel,
#wrapWidth: wrapWidth,
},
),
returnValue: _i6.dummyValue<String>(
Expand All @@ -330,6 +340,7 @@ class MockZeta extends _i1.Mock implements _i2.Zeta {
#prefixLineOne: prefixLineOne,
#prefixOtherLines: prefixOtherLines,
#minLevel: minLevel,
#wrapWidth: wrapWidth,
},
),
),
Expand All @@ -342,6 +353,7 @@ class MockZeta extends _i1.Mock implements _i2.Zeta {
#prefixLineOne: prefixLineOne,
#prefixOtherLines: prefixOtherLines,
#minLevel: minLevel,
#wrapWidth: wrapWidth,
},
),
),
Expand Down Expand Up @@ -396,5 +408,6 @@ class MockZeta extends _i1.Mock implements _i2.Zeta {
) as List<_i4.DiagnosticsNode>);

@override
String toString({_i4.DiagnosticLevel? minLevel = _i4.DiagnosticLevel.info}) => super.toString();
String toString({_i4.DiagnosticLevel? minLevel = _i4.DiagnosticLevel.info}) =>
super.toString();
}
Loading

0 comments on commit 24ee385

Please sign in to comment.