Skip to content

Commit

Permalink
chore(UX-1347): Update to Flutter 3.27.x (#232)
Browse files Browse the repository at this point in the history
chore: Update publignore to not ignore docs (#230)
deps!: Update to Flutter 3.27.0
fix: Use new Color / opacity values
test: Update tests for color changes
ci: Use 3.27.x for GH Actions
  • Loading branch information
thelukewalton authored Dec 31, 2024
1 parent b1729e3 commit 21fd9d9
Show file tree
Hide file tree
Showing 21 changed files with 89 additions and 83 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"
}
2 changes: 1 addition & 1 deletion .github/workflows/on-main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
with:
cache: true
channel: stable
flutter-version: 3.24.x # TODO UX-1347
flutter-version: 3.27.x
- name: Setup flutter
run: flutter pub get
- name: Build example app
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/on-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
with:
cache: true
channel: stable
flutter-version: 3.24.x # TODO UX-1347
flutter-version: 3.27.x
- name: Install dependencies
run: flutter pub get
- name: Format code
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
with:
cache: true
channel: stable
flutter-version: 3.24.x # TODO UX-1347
flutter-version: 3.27.x
- run: dart run build_runner build --delete-conflicting-outputs
- uses: ZebraDevs/flutter-code-quality@main
with:
Expand Down Expand Up @@ -54,7 +54,7 @@ jobs:
with:
cache: true
channel: stable
flutter-version: 3.24.x # TODO UX-1347
flutter-version: 3.27.x
- name: Setup flutter
run: flutter pub get
- name: Build example app
Expand Down
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/
1 change: 0 additions & 1 deletion .pubignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ appium/
test/
build/
coverage/
doc/
coverage.sh
example/example.iml
example/assets/
Expand Down
2 changes: 1 addition & 1 deletion .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
".": "0.20.1"
".": "0.20.2"
}
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Changelog

## [0.20.2](https://github.com/ZebraDevs/zeta_flutter/compare/v0.20.1...v0.20.2) (2024-12-20)


### ⛓️ Dependencies

* **automated:** Update icons ([#225](https://github.com/ZebraDevs/zeta_flutter/issues/225)) ([b1729e3](https://github.com/ZebraDevs/zeta_flutter/commit/b1729e3a99e74b5eaf0c81b2003c10229bf83b59))

## [0.20.1](https://github.com/ZebraDevs/zeta_flutter/compare/v0.20.0...v0.20.1) (2024-12-13)


Expand Down
2 changes: 1 addition & 1 deletion example/lib/home.dart
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ class _HomeState extends State<Home> {
final _theme = theme..sort((a, b) => a.name.compareTo(b.name));
return ExampleScaffold(
// x-release-please-start-version
name: 'zeta_flutter v0.20.1',
name: 'zeta_flutter v0.20.2',
// x-release-please-end
child: SingleChildScrollView(
child: Column(
Expand Down
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 example/widgetbook/pages/introduction.dart
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ class _IntroductionWidgetbookState extends State<IntroductionWidgetbook> {
Expanded(
child: Text(
// x-release-please-start-version
'zeta_flutter v0.20.1',
'zeta_flutter v0.20.2',
// x-release-please-end
style: ZetaTextStyles.displayLarge.copyWith(fontSize: largeScreen ? null : 24),
),
Expand Down
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 pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: zeta_flutter
version: 0.20.1
version: 0.20.2
description: Zeta is the new, formal, standardized Zebra Design System based off
the successes of ZDS (Zebra Design System). This package is in pre-release,
and so many aspects are incomplete.
Expand Down
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
21 changes: 1 addition & 20 deletions test/src/components/tooltip/tooltip_test.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
// ignore_for_file: avoid_dynamic_calls
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:mockito/annotations.dart';
Expand Down Expand Up @@ -30,7 +29,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 +45,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
Loading

0 comments on commit 21fd9d9

Please sign in to comment.