Skip to content

Commit

Permalink
Fix android 15 (#89)
Browse files Browse the repository at this point in the history
* value and withOpacity deprecated, using colorValues extension and withValue

* update flutter version in ci

* ypdate android compile version to 15
  • Loading branch information
EdwynZN authored Dec 14, 2024
1 parent 5a3522f commit 09463cf
Show file tree
Hide file tree
Showing 18 changed files with 72 additions and 60 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/qa.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ on:
env:
java_version: '17'
ruby_version: '2.7.2'
flutter_version: '3.24.4'
flutter_version: '3.27.0'

jobs:
android-QA:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ on:
env:
java_version: '17'
ruby_version: '2.7.2'
flutter_version: '3.24.4'
flutter_version: '3.27.0'

jobs:
android-internal:
Expand Down
3 changes: 2 additions & 1 deletion android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ android {
defaultConfig {
applicationId "com.dartz.amiibo_network"
minSdkVersion flutter.minSdkVersion
targetSdkVersion 34
targetSdkVersion 35
compileSdkVersion 35
multiDexEnabled true
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import 'package:amiibo_network/affiliation_product/presentation/widget/amazon_af
import 'package:amiibo_network/resources/resources.dart';
import 'package:amiibo_network/riverpod/amiibo_provider.dart';
import 'package:amiibo_network/riverpod/preferences_provider.dart';
import 'package:amiibo_network/utils/color_utils.dart';
import 'package:flutter/material.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';
import 'package:material_color_utilities/material_color_utilities.dart';
Expand All @@ -26,8 +27,8 @@ class AmazonAffiliationButton extends HookConsumerWidget {
?.resolve(state);
if (color != null) {
final int value = Blend.hctHue(
color.value,
amazonColor.value,
color.colorValue,
amazonColor.colorValue,
0.75,
);
return Color(value);
Expand All @@ -41,8 +42,8 @@ class AmazonAffiliationButton extends HookConsumerWidget {
?.resolve(state);
if (color != null) {
final int value = Blend.hctHue(
color.value,
amazonColor.value,
color.colorValue,
amazonColor.colorValue,
0.5,
);
return Color(value);
Expand Down Expand Up @@ -78,8 +79,8 @@ class AmazonAffiliationIconButton extends HookConsumerWidget {
final color = style?.backgroundColor?.resolve(state);
if (color != null) {
final int value = Blend.hctHue(
color.value,
amazonColor.value,
color.colorValue,
amazonColor.colorValue,
0.15,
);
return Color(value);
Expand All @@ -90,8 +91,8 @@ class AmazonAffiliationIconButton extends HookConsumerWidget {
final color = style?.foregroundColor?.resolve(state);
if (color != null) {
final int value = Blend.hctHue(
color.value,
amazonColor.value,
color.colorValue,
amazonColor.colorValue,
0.25,
);
return Color(value);
Expand Down
12 changes: 6 additions & 6 deletions lib/repository/theme_mode_scheme_repository.dart
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ class AmiiboTheme3 implements AmiiboTheme {

ThemeData _themeFromScheme(ColorScheme scheme,
[bool useSurfaceElevation = true]) {
final overlay = scheme.primary.withOpacity(0.24);
final overlay = scheme.primary.withValues(alpha: 0.24);
final inverseBrightness = scheme.brightness == Brightness.light
? Brightness.dark
: Brightness.light;
Expand Down Expand Up @@ -428,7 +428,7 @@ class AmiiboTheme3 implements AmiiboTheme {
borderRadius: BorderRadius.all(Radius.circular(8.0)),
),
elevation: !useSurfaceElevation ? 0 : 4.0,
shadowColor: scheme.surface.withOpacity(0.12),
shadowColor: scheme.surface.withValues(alpha: 0.12),
surfaceTintColor: scheme.surfaceTint,
),
checkboxTheme: CheckboxThemeData(
Expand Down Expand Up @@ -538,7 +538,7 @@ class AmiiboTheme3 implements AmiiboTheme {
),
focusColor: scheme.inversePrimary,
fontFamily: null,
highlightColor: scheme.primaryContainer.withOpacity(0.38),
highlightColor: scheme.primaryContainer.withValues(alpha: 0.38),
hintColor: Colors.black38,
hoverColor: scheme.primaryContainer,
iconTheme: IconThemeData(color: scheme.onSurface),
Expand Down Expand Up @@ -678,7 +678,7 @@ class AmiiboTheme3 implements AmiiboTheme {
),
behavior: SnackBarBehavior.floating,
),
splashColor: scheme.tertiaryContainer.withOpacity(0.24),
splashColor: scheme.tertiaryContainer.withValues(alpha: 0.24),
switchTheme: SwitchThemeData(
thumbColor: WidgetStateProperty.resolveWith<Color?>((states) {
if (states.contains(WidgetState.disabled)) {
Expand All @@ -696,9 +696,9 @@ class AmiiboTheme3 implements AmiiboTheme {
return null;
} else if (states.contains(WidgetState.focused) ||
states.contains(WidgetState.pressed)) {
return scheme.onPrimaryContainer.withOpacity(0.24);
return scheme.onPrimaryContainer.withValues(alpha: 0.24);
} else if (states.contains(WidgetState.selected)) {
return scheme.primary.withOpacity(0.24);
return scheme.primary.withValues(alpha: 0.24);
}
return null;
}),
Expand Down
5 changes: 3 additions & 2 deletions lib/resources/material3_schemes.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import 'dart:convert';

import 'package:amiibo_network/resources/theme_material3_schemes.dart';
import 'package:amiibo_network/utils/color_utils.dart';
import 'package:flutter/material.dart';
import 'package:freezed_annotation/freezed_annotation.dart';

Expand Down Expand Up @@ -194,7 +195,7 @@ class ColorConverter extends JsonConverter<Color, int> {

@override
int toJson(Color color) {
return color.value;
return color.colorValue;
}
}

Expand All @@ -206,7 +207,7 @@ class ColorOrNullConverter extends JsonConverter<Color?, int?> {

@override
int? toJson(Color? color) {
return color == null ? null : color.value;
return color == null ? null : color.colorValue;
}
}

Expand Down
37 changes: 19 additions & 18 deletions lib/resources/theme_material3_schemes.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'package:amiibo_network/resources/material3_schemes.dart';
import 'package:amiibo_network/utils/color_utils.dart';
import 'package:flutter/material.dart';
import 'package:material_color_utilities/material_color_utilities.dart';

Expand All @@ -8,7 +9,7 @@ ColorScheme blendScheme(
[double amount = 0.3]
) {
Color _harmonize(Color original, Color destiny) => Color(
Blend.hctHue(original.value, destiny.value, amount),
Blend.hctHue(original.colorValue, destiny.colorValue, amount),
);
return ColorScheme(
brightness: originalScheme.brightness,
Expand Down Expand Up @@ -81,7 +82,7 @@ class TonalColor extends ColorSwatch<int> {
///
/// The `primary` argument should be the 32 bit ARGB value of one of the
/// values in the swatch, as would be passed to the [Color.new] constructor
/// for that same color, and as is exposed by [value]. (This is distinct from
/// for that same color, and as is exposed by [colorValue]. (This is distinct from
/// the specific index of the color in the swatch.)
const TonalColor(super.primary, super.swatch);

Expand Down Expand Up @@ -130,22 +131,22 @@ class TonalColor extends ColorSwatch<int> {
TonalColor blend(Color sourceColor) {
final blend = Blend.harmonize;
return TonalColor(
blend(value, sourceColor.value),
blend(colorValue, sourceColor.colorValue),
<int, Color>{
0: Color(blend(this[0]!.value, sourceColor.value)),
10: Color(blend(this[10]!.value, sourceColor.value)),
20: Color(blend(this[20]!.value, sourceColor.value)),
30: Color(blend(this[30]!.value, sourceColor.value)),
40: Color(blend(this[40]!.value, sourceColor.value)),
50: Color(blend(this[50]!.value, sourceColor.value)),
60: Color(blend(this[60]!.value, sourceColor.value)),
70: Color(blend(this[70]!.value, sourceColor.value)),
80: Color(blend(this[80]!.value, sourceColor.value)),
90: Color(blend(this[90]!.value, sourceColor.value)),
95: Color(blend(this[95]!.value, sourceColor.value)),
98: Color(blend(this[98]!.value, sourceColor.value)),
99: Color(blend(this[99]!.value, sourceColor.value)),
100: Color(blend(this[100]!.value, sourceColor.value)),
0: Color(blend(this[0]!.colorValue, sourceColor.colorValue)),
10: Color(blend(this[10]!.colorValue, sourceColor.colorValue)),
20: Color(blend(this[20]!.colorValue, sourceColor.colorValue)),
30: Color(blend(this[30]!.colorValue, sourceColor.colorValue)),
40: Color(blend(this[40]!.colorValue, sourceColor.colorValue)),
50: Color(blend(this[50]!.colorValue, sourceColor.colorValue)),
60: Color(blend(this[60]!.colorValue, sourceColor.colorValue)),
70: Color(blend(this[70]!.colorValue, sourceColor.colorValue)),
80: Color(blend(this[80]!.colorValue, sourceColor.colorValue)),
90: Color(blend(this[90]!.colorValue, sourceColor.colorValue)),
95: Color(blend(this[95]!.colorValue, sourceColor.colorValue)),
98: Color(blend(this[98]!.colorValue, sourceColor.colorValue)),
99: Color(blend(this[99]!.colorValue, sourceColor.colorValue)),
100: Color(blend(this[100]!.colorValue, sourceColor.colorValue)),
},
);
}
Expand All @@ -154,7 +155,7 @@ class TonalColor extends ColorSwatch<int> {
final swatch = ColorSwatch.lerp(a, b, t);
if (swatch == null) return null;
return TonalColor(
swatch.value,
swatch.colorValue,
<int, Color>{
0: swatch[0]!,
10: swatch[10]!,
Expand Down
6 changes: 3 additions & 3 deletions lib/screen/search_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class SearchScreen extends HookConsumerWidget {
isCollapsed: true,
hintText: translate.category(amiiboCategory),
hintStyle: style?.copyWith(
color: style.color?.withOpacity(0.5),
color: style.color?.withValues(alpha: 0.5),
),
border: InputBorder.none,
),
Expand Down Expand Up @@ -221,8 +221,8 @@ class _SliverPersistentHeader extends SliverPersistentHeaderDelegate {
stops: const [0.3, 0.6, 0.9],
colors: [
_color,
_color.withOpacity(0.85),
_color.withOpacity(0.2),
_color.withValues(alpha: 0.85),
_color.withValues(alpha: 0.2),
],
),
),
Expand Down
3 changes: 0 additions & 3 deletions lib/service/service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,6 @@ interface class Service {
where &= Cond.like('amiiboSeries', '%$search%');
break;
case AmiiboCategory.All:
default:
where = And();
}
if (category != AmiiboCategory.AmiiboSeries && hiddenCategories != null) {
Expand Down Expand Up @@ -250,8 +249,6 @@ interface class Service {
return Cond.like('gameSeries', '%$filter%');
case SearchCategory.AmiiboSeries:
return Cond.like('amiiboSeries', '%$filter%');
default:
return And();
}
}

Expand Down
12 changes: 12 additions & 0 deletions lib/utils/color_utils.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import 'dart:ui';

extension ColorX on Color {

int get colorValue {
int floatToInt8(double x) => (x * 255.0).round() & 0xff;
return floatToInt8(a) << 24 |
floatToInt8(r) << 16 |
floatToInt8(g) << 8 |
floatToInt8(b) << 0;
}
}
1 change: 0 additions & 1 deletion lib/utils/format_color_on_theme.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ Color? colorOnThemeMode(ThemeMode mode, Brightness brightness) {
case ThemeMode.dark:
return Colors.white54;
case ThemeMode.system:
default:
return brightness == Brightness.dark ? Colors.white54 : null;
}
}
8 changes: 4 additions & 4 deletions lib/widget/amiibo_button_toggle.dart
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ class WishedOutlinedButton extends ConsumerWidget {
final S translate = S.of(context);
final preferencesPalette =
Theme.of(context).extension<PreferencesExtension>()!;
final color = preferencesPalette.wishContainer.withOpacity(0.24);
final color = preferencesPalette.wishContainer.withValues(alpha: 0.24);
return IconButton.outlined(
style: const ButtonStyle(
shape: WidgetStatePropertyAll(
Expand Down Expand Up @@ -132,7 +132,7 @@ class OwnedOutlinedButton extends ConsumerWidget {
final S translate = S.of(context);
final preferencesPalette =
Theme.of(context).extension<PreferencesExtension>()!;
final color = preferencesPalette.ownContainer.withOpacity(0.24);
final color = preferencesPalette.ownContainer.withValues(alpha: 0.24);
return IconButton.outlined(
style: const ButtonStyle(
shape: WidgetStatePropertyAll(
Expand Down Expand Up @@ -204,7 +204,7 @@ class WishedButton extends ConsumerWidget {
final S translate = S.of(context);
final preferencesPalette =
Theme.of(context).extension<PreferencesExtension>()!;
final color = preferencesPalette.wishContainer.withOpacity(0.24);
final color = preferencesPalette.wishContainer.withValues(alpha: 0.24);
return IconButton(
style: const ButtonStyle(
tapTargetSize: MaterialTapTargetSize.shrinkWrap,
Expand Down Expand Up @@ -258,7 +258,7 @@ class OwnedButton extends ConsumerWidget {
final S translate = S.of(context);
final preferencesPalette =
Theme.of(context).extension<PreferencesExtension>()!;
final color = preferencesPalette.ownContainer.withOpacity(0.24);
final color = preferencesPalette.ownContainer.withValues(alpha: 0.24);
return IconButton(
style: const ButtonStyle(
tapTargetSize: MaterialTapTargetSize.shrinkWrap,
Expand Down
2 changes: 1 addition & 1 deletion lib/widget/detail/user_preferences_card.dart
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,7 @@ class ColumnButton extends StatelessWidget {
shape: WidgetStatePropertyAll(RoundedRectangleBorder()),
visualDensity: const VisualDensity(vertical: -2.0),
),
highlightColor: color?.withOpacity(0.16),
highlightColor: color?.withValues(alpha: 0.16),
icon: isDisabled
? const Icon(Icons.remove_circle_sharp)
: switch (effect) {
Expand Down
4 changes: 2 additions & 2 deletions lib/widget/drawer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ class _CollectionDrawerState extends ConsumerState<CollectionDrawer> {
),
selectedTileColor: preferencesExtension
.ownContainer
.withOpacity(0.54),
.withValues(alpha: 0.54),
selectedColor:
preferencesExtension.onOwnContainer,
selected: isOwned,
Expand All @@ -193,7 +193,7 @@ class _CollectionDrawerState extends ConsumerState<CollectionDrawer> {
),
selectedTileColor: preferencesExtension
.wishContainer
.withOpacity(0.54),
.withValues(alpha: 0.54),
selectedColor:
preferencesExtension.onWishContainer,
selected: isWishlist,
Expand Down
8 changes: 4 additions & 4 deletions lib/widget/preferences_bottomsheet.dart
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class _BottomSheetSort extends StatelessWidget {
surfaceTintColor: theme.colorScheme.surfaceTint,
clipBehavior: Clip.antiAlias,
child: ListTileTheme.merge(
//selectedTileColor: theme.selectedRowColor.withOpacity(0.16),
//selectedTileColor: theme.selectedRowColor.withValues(alpha: 0.16),
contentPadding: const EdgeInsets.symmetric(horizontal: 16.0),
dense: true,
style: ListTileStyle.drawer,
Expand Down Expand Up @@ -84,7 +84,7 @@ class _BottomSheetSort extends StatelessWidget {
style: theme.textTheme.bodyLarge,
),
inactiveTrackColor:
theme.disabledColor.withOpacity(0.12),
theme.disabledColor.withValues(alpha: 0.12),
value: pref.usePercentage,
onChanged: (value) async => await ref
.read(personalProvider.notifier)
Expand All @@ -99,7 +99,7 @@ class _BottomSheetSort extends StatelessWidget {
style: theme.textTheme.bodyLarge,
),
inactiveTrackColor:
theme.disabledColor.withOpacity(0.12),
theme.disabledColor.withValues(alpha: 0.12),
value: pref.useGrid,
onChanged: (value) async => await ref
.read(personalProvider.notifier)
Expand Down Expand Up @@ -138,7 +138,7 @@ class _BottomSheetSort extends StatelessWidget {
),
isThreeLine: true,
inactiveTrackColor:
theme.disabledColor.withOpacity(0.12),
theme.disabledColor.withValues(alpha: 0.12),
value: ref.watch(ownTypesCategoryProvider),
onChanged: (value) async => await ref
.read(personalProvider.notifier)
Expand Down
2 changes: 1 addition & 1 deletion lib/widget/single_stat.dart
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ class _StatContainer extends StatelessWidget {
text: ' $subtitle',
style: TextStyle(
fontSize: 12.0,
color: theme.colorScheme.onSurface.withOpacity(0.72),
color: theme.colorScheme.onSurface.withValues(alpha: 0.72),
fontFeatures: const [
FontFeature.tabularFigures(),
],
Expand Down
Loading

0 comments on commit 09463cf

Please sign in to comment.