Skip to content

Commit

Permalink
Update item picker theme and the language picker themes to use latest…
Browse files Browse the repository at this point in the history
… tailor theme approach
  • Loading branch information
DDavidPrime committed Mar 29, 2024
1 parent 9e75d7c commit df8872d
Show file tree
Hide file tree
Showing 21 changed files with 532 additions and 555 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@
<key>CFBundleVersion</key>
<string>1.0</string>
<key>MinimumOSVersion</key>
<string>11.0</string>
<string>12.0</string>
</dict>
</plist>
2 changes: 1 addition & 1 deletion packages/widget_toolkit/example/ios/Podfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Uncomment this line to define a global platform for your project
# platform :ios, '11.0'
# platform :ios, '12.0'

# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
ENV['COCOAPODS_DISABLE_STATS'] = 'true'
Expand Down
8 changes: 4 additions & 4 deletions packages/widget_toolkit/example/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ EXTERNAL SOURCES:
:path: ".symlinks/plugins/url_launcher_ios/ios"

SPEC CHECKSUMS:
Flutter: f04841e97a9d0b0a8025694d0796dd46242b2854
url_launcher_ios: 08a3dfac5fb39e8759aeb0abbd5d9480f30fc8b4
Flutter: e0871f40cf51350855a761d2e70bf5af5b9b5de7
url_launcher_ios: bbd758c6e7f9fd7b5b1d4cde34d2b95fcce5e812

PODFILE CHECKSUM: ef19549a9bc3046e7bb7d2fab4d021637c0c58a3
PODFILE CHECKSUM: c4c93c5f6502fe2754f48404d3594bf779584011

COCOAPODS: 1.12.1
COCOAPODS: 1.14.3
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@
97C146E61CF9000F007C117D /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 1300;
LastUpgradeCheck = 1510;
ORGANIZATIONNAME = "";
TargetAttributes = {
97C146ED1CF9000F007C117D = {
Expand Down Expand Up @@ -343,7 +343,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SUPPORTED_PLATFORMS = iphoneos;
Expand Down Expand Up @@ -420,7 +420,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
Expand Down Expand Up @@ -469,7 +469,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SUPPORTED_PLATFORMS = iphoneos;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1300"
LastUpgradeVersion = "1510"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
4 changes: 2 additions & 2 deletions packages/widget_toolkit/example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@ class MyApp extends StatelessWidget {
theme: ThemeData.light()
.copyWith(colorScheme: ColorScheme.fromSwatch(), extensions: [
WidgetToolkitTheme.light,
ItemPickerTheme.light,
ItemPickerTheme.light(),
SearchPickerTheme.light,
TextFieldDialogTheme.light,
EditAddressTheme.light,
]),
darkTheme: ThemeData.dark()
.copyWith(colorScheme: ColorScheme.fromSwatch(), extensions: [
WidgetToolkitTheme.dark,
ItemPickerTheme.dark,
ItemPickerTheme.dark(),
SearchPickerTheme.dark,
TextFieldDialogTheme.dark,
EditAddressTheme.dark,
Expand Down
2 changes: 1 addition & 1 deletion packages/widget_toolkit/example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -744,7 +744,7 @@ packages:
path: ".."
relative: true
source: path
version: "0.0.2-dev.2"
version: "0.0.2-dev.3"
xml:
dependency: transitive
description:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,40 +5,47 @@ import '../../base/theme/design_system/widget_toolkit_design_system.dart';

part 'item_picker_theme.tailor.dart';

@Tailor(themeGetter: ThemeGetter.none)
class _$ItemPickerTheme {
/// region ItemPickerPage
static List<EdgeInsets> titlePadding = [
EdgeInsets.only(
bottom: WidgetToolkitDesignSystem.light().spacings.m,
left: WidgetToolkitDesignSystem.light().spacings.xs),
EdgeInsets.only(
bottom: WidgetToolkitDesignSystem.light().spacings.m,
left: WidgetToolkitDesignSystem.light().spacings.xs),
];

static List<TextStyle> titleStyle = [
WidgetToolkitDesignSystem.light().typography.titleStyle,
WidgetToolkitDesignSystem.dark().typography.titleStyle,
];

static List<EdgeInsets> errorPadding = [
EdgeInsets.zero,
EdgeInsets.zero,
];

static List<EdgeInsets> contentListPadding = [
EdgeInsets.zero,
EdgeInsets.zero,
];

static List<EdgeInsets> footerPadding = [
EdgeInsets.only(top: WidgetToolkitDesignSystem.light().spacings.m),
EdgeInsets.only(top: WidgetToolkitDesignSystem.light().spacings.m),
];

/// endregion
@TailorMixinComponent()
class ItemPickerTheme extends ThemeExtension<ItemPickerTheme>
with _$ItemPickerThemeTailorMixin {
const ItemPickerTheme({
required this.titlePadding,
required this.titleStyle,
required this.errorPadding,
required this.contentListPadding,
required this.footerPadding,
});

@override
final EdgeInsets titlePadding;
@override
final TextStyle titleStyle;
@override
final EdgeInsets errorPadding;
@override
final EdgeInsets contentListPadding;
@override
final EdgeInsets footerPadding;

ItemPickerTheme.light()
: titlePadding = EdgeInsets.only(
bottom: WidgetToolkitDesignSystem.light().spacings.m,
left: WidgetToolkitDesignSystem.light().spacings.xs),
titleStyle = WidgetToolkitDesignSystem.light().typography.titleStyle,
errorPadding = EdgeInsets.zero,
contentListPadding = EdgeInsets.zero,
footerPadding =
EdgeInsets.only(top: WidgetToolkitDesignSystem.light().spacings.m);

ItemPickerTheme.dark()
: titlePadding = EdgeInsets.only(
bottom: WidgetToolkitDesignSystem.light().spacings.m,
left: WidgetToolkitDesignSystem.light().spacings.xs),
titleStyle = WidgetToolkitDesignSystem.dark().typography.titleStyle,
errorPadding = EdgeInsets.zero,
contentListPadding = EdgeInsets.zero,
footerPadding =
EdgeInsets.only(top: WidgetToolkitDesignSystem.dark().spacings.m);
}

extension ItemPickerThemeContextExtension on BuildContext {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,58 +8,27 @@ part of 'item_picker_theme.dart';
// TailorAnnotationsGenerator
// **************************************************************************

class ItemPickerTheme extends ThemeExtension<ItemPickerTheme> {
const ItemPickerTheme({
required this.contentListPadding,
required this.errorPadding,
required this.footerPadding,
required this.titlePadding,
required this.titleStyle,
});

final EdgeInsets contentListPadding;
final EdgeInsets errorPadding;
final EdgeInsets footerPadding;

/// region ItemPickerPage
final EdgeInsets titlePadding;
final TextStyle titleStyle;

static final ItemPickerTheme light = ItemPickerTheme(
contentListPadding: _$ItemPickerTheme.contentListPadding[0],
errorPadding: _$ItemPickerTheme.errorPadding[0],
footerPadding: _$ItemPickerTheme.footerPadding[0],
titlePadding: _$ItemPickerTheme.titlePadding[0],
titleStyle: _$ItemPickerTheme.titleStyle[0],
);

static final ItemPickerTheme dark = ItemPickerTheme(
contentListPadding: _$ItemPickerTheme.contentListPadding[1],
errorPadding: _$ItemPickerTheme.errorPadding[1],
footerPadding: _$ItemPickerTheme.footerPadding[1],
titlePadding: _$ItemPickerTheme.titlePadding[1],
titleStyle: _$ItemPickerTheme.titleStyle[1],
);

static final themes = [
light,
dark,
];
mixin _$ItemPickerThemeTailorMixin on ThemeExtension<ItemPickerTheme> {
EdgeInsets get titlePadding;
TextStyle get titleStyle;
EdgeInsets get errorPadding;
EdgeInsets get contentListPadding;
EdgeInsets get footerPadding;

@override
ItemPickerTheme copyWith({
EdgeInsets? contentListPadding,
EdgeInsets? errorPadding,
EdgeInsets? footerPadding,
EdgeInsets? titlePadding,
TextStyle? titleStyle,
EdgeInsets? errorPadding,
EdgeInsets? contentListPadding,
EdgeInsets? footerPadding,
}) {
return ItemPickerTheme(
contentListPadding: contentListPadding ?? this.contentListPadding,
errorPadding: errorPadding ?? this.errorPadding,
footerPadding: footerPadding ?? this.footerPadding,
titlePadding: titlePadding ?? this.titlePadding,
titleStyle: titleStyle ?? this.titleStyle,
errorPadding: errorPadding ?? this.errorPadding,
contentListPadding: contentListPadding ?? this.contentListPadding,
footerPadding: footerPadding ?? this.footerPadding,
);
}

Expand All @@ -68,12 +37,12 @@ class ItemPickerTheme extends ThemeExtension<ItemPickerTheme> {
covariant ThemeExtension<ItemPickerTheme>? other, double t) {
if (other is! ItemPickerTheme) return this as ItemPickerTheme;
return ItemPickerTheme(
titlePadding: t < 0.5 ? titlePadding : other.titlePadding,
titleStyle: TextStyle.lerp(titleStyle, other.titleStyle, t)!,
errorPadding: t < 0.5 ? errorPadding : other.errorPadding,
contentListPadding:
t < 0.5 ? contentListPadding : other.contentListPadding,
errorPadding: t < 0.5 ? errorPadding : other.errorPadding,
footerPadding: t < 0.5 ? footerPadding : other.footerPadding,
titlePadding: t < 0.5 ? titlePadding : other.titlePadding,
titleStyle: TextStyle.lerp(titleStyle, other.titleStyle, t)!,
);
}

Expand All @@ -83,26 +52,26 @@ class ItemPickerTheme extends ThemeExtension<ItemPickerTheme> {
(other.runtimeType == runtimeType &&
other is ItemPickerTheme &&
const DeepCollectionEquality()
.equals(contentListPadding, other.contentListPadding) &&
.equals(titlePadding, other.titlePadding) &&
const DeepCollectionEquality()
.equals(errorPadding, other.errorPadding) &&
.equals(titleStyle, other.titleStyle) &&
const DeepCollectionEquality()
.equals(footerPadding, other.footerPadding) &&
.equals(errorPadding, other.errorPadding) &&
const DeepCollectionEquality()
.equals(titlePadding, other.titlePadding) &&
.equals(contentListPadding, other.contentListPadding) &&
const DeepCollectionEquality()
.equals(titleStyle, other.titleStyle));
.equals(footerPadding, other.footerPadding));
}

@override
int get hashCode {
return Object.hash(
runtimeType.hashCode,
const DeepCollectionEquality().hash(contentListPadding),
const DeepCollectionEquality().hash(errorPadding),
const DeepCollectionEquality().hash(footerPadding),
const DeepCollectionEquality().hash(titlePadding),
const DeepCollectionEquality().hash(titleStyle),
const DeepCollectionEquality().hash(errorPadding),
const DeepCollectionEquality().hash(contentListPadding),
const DeepCollectionEquality().hash(footerPadding),
);
}
}
Loading

0 comments on commit df8872d

Please sign in to comment.