From cd39582fab56ddfa30b3dca8385c0495d523adc1 Mon Sep 17 00:00:00 2001 From: David Djordjevic Date: Fri, 5 Apr 2024 09:51:27 +0200 Subject: [PATCH] Update widget_toolkkit_qr theme fields --- .../lib/src/base/theme/qr_scanner_theme.dart | 99 +++++-------- .../base/theme/qr_scanner_theme.tailor.dart | 135 +++++++++--------- .../views/camera_permission.dart | 14 +- .../views/qr_scanner_component.dart | 5 +- .../factory/qr_scanner_page_factory.dart | 3 +- 5 files changed, 114 insertions(+), 142 deletions(-) diff --git a/packages/widget_toolkit_qr/lib/src/base/theme/qr_scanner_theme.dart b/packages/widget_toolkit_qr/lib/src/base/theme/qr_scanner_theme.dart index db16d78a..c4dd0c30 100644 --- a/packages/widget_toolkit_qr/lib/src/base/theme/qr_scanner_theme.dart +++ b/packages/widget_toolkit_qr/lib/src/base/theme/qr_scanner_theme.dart @@ -8,17 +8,14 @@ part 'qr_scanner_theme.tailor.dart'; class QrScannerTheme extends ThemeExtension with _$QrScannerThemeTailorMixin { const QrScannerTheme({ - required this.cameraPermission1, - required this.cameraPermission2, - required this.cameraPermission3, - required this.cameraPermission4, - required this.cameraPermission5, - required this.cameraPermission6, - required this.qrScannerPage1, - required this.qrScannerPage2, - required this.qrScannerPage3, - required this.qrScannerPage4, - required this.qrScannerPage5, + required this.cameraPermissionPadding, + required this.cameraPermissionBorderPadding, + required this.cameraPermissionContentPadding, + required this.cameraPermissionIconPadding, + required this.cameraPermissionTitlePadding, + required this.qrScannerComponentPadding, + required this.qrScannerCameraPadding, + required this.qrScannerProgressIndicatorPadding, required this.qrScannerSubtitlePadding, required this.backButtonMarginEdgeInsets, required this.backButtonPaddingEdgeInsets, @@ -62,46 +59,33 @@ class QrScannerTheme extends ThemeExtension /// region Themes QrScannerTheme.light() - : cameraPermission1 = EdgeInsets.symmetric( + : cameraPermissionPadding = EdgeInsets.symmetric( horizontal: WidgetToolkitDesignSystem.light().spacings.m, ), - cameraPermission2 = EdgeInsets.only( + cameraPermissionBorderPadding = EdgeInsets.only( top: WidgetToolkitDesignSystem.light().spacings.xs, bottom: WidgetToolkitDesignSystem.light().spacings.m, ), - cameraPermission3 = EdgeInsets.all( + cameraPermissionContentPadding = EdgeInsets.all( WidgetToolkitDesignSystem.light().spacings.m, ), - cameraPermission4 = EdgeInsets.only( + cameraPermissionIconPadding = EdgeInsets.only( right: WidgetToolkitDesignSystem.light().spacings.m, ), - cameraPermission5 = EdgeInsets.only( + cameraPermissionTitlePadding = EdgeInsets.only( bottom: WidgetToolkitDesignSystem.light().spacings.xs, ), - cameraPermission6 = EdgeInsets.symmetric( - vertical: WidgetToolkitDesignSystem.light().spacings.m, - ), - qrScannerPage1 = EdgeInsets.only( - left: WidgetToolkitDesignSystem.light().spacings.m, - right: WidgetToolkitDesignSystem.light().spacings.m, - bottom: WidgetToolkitDesignSystem.light().spacings.m, - ), - qrScannerPage2 = EdgeInsets.only( + qrScannerComponentPadding = EdgeInsets.only( left: WidgetToolkitDesignSystem.light().spacings.xxxl, right: WidgetToolkitDesignSystem.light().spacings.xxxl, ), - qrScannerPage3 = + qrScannerCameraPadding = EdgeInsets.all(WidgetToolkitDesignSystem.light().spacings.xss), - qrScannerPage4 = EdgeInsets.only( + qrScannerProgressIndicatorPadding = EdgeInsets.only( left: WidgetToolkitDesignSystem.light().spacings.m, right: WidgetToolkitDesignSystem.light().spacings.m, bottom: WidgetToolkitDesignSystem.light().spacings.xxxl, ), - qrScannerPage5 = EdgeInsets.only( - left: WidgetToolkitDesignSystem.light().spacings.m, - right: WidgetToolkitDesignSystem.light().spacings.m, - bottom: WidgetToolkitDesignSystem.light().spacings.xxl, - ), qrScannerSubtitlePadding = EdgeInsets.only( top: WidgetToolkitDesignSystem.light().spacings.xs1), backButtonMarginEdgeInsets = EdgeInsets.only( @@ -168,46 +152,33 @@ class QrScannerTheme extends ThemeExtension linearProgressIndicatorColor = _HexColor(_qrFrameBlueColorHex); QrScannerTheme.dark() - : cameraPermission1 = EdgeInsets.symmetric( + : cameraPermissionPadding = EdgeInsets.symmetric( horizontal: WidgetToolkitDesignSystem.dark().spacings.m, ), - cameraPermission2 = EdgeInsets.only( + cameraPermissionBorderPadding = EdgeInsets.only( top: WidgetToolkitDesignSystem.dark().spacings.xs, bottom: WidgetToolkitDesignSystem.dark().spacings.m, ), - cameraPermission3 = EdgeInsets.all( + cameraPermissionContentPadding = EdgeInsets.all( WidgetToolkitDesignSystem.dark().spacings.m, ), - cameraPermission4 = EdgeInsets.only( + cameraPermissionIconPadding = EdgeInsets.only( right: WidgetToolkitDesignSystem.dark().spacings.m, ), - cameraPermission5 = EdgeInsets.only( + cameraPermissionTitlePadding = EdgeInsets.only( bottom: WidgetToolkitDesignSystem.dark().spacings.xs, ), - cameraPermission6 = EdgeInsets.symmetric( - vertical: WidgetToolkitDesignSystem.dark().spacings.m, - ), - qrScannerPage1 = EdgeInsets.only( - left: WidgetToolkitDesignSystem.dark().spacings.m, - right: WidgetToolkitDesignSystem.dark().spacings.m, - bottom: WidgetToolkitDesignSystem.dark().spacings.m, - ), - qrScannerPage2 = EdgeInsets.only( + qrScannerComponentPadding = EdgeInsets.only( left: WidgetToolkitDesignSystem.dark().spacings.xxxl, right: WidgetToolkitDesignSystem.dark().spacings.xxxl, ), - qrScannerPage3 = + qrScannerCameraPadding = EdgeInsets.all(WidgetToolkitDesignSystem.dark().spacings.xss), - qrScannerPage4 = EdgeInsets.only( + qrScannerProgressIndicatorPadding = EdgeInsets.only( left: WidgetToolkitDesignSystem.dark().spacings.m, right: WidgetToolkitDesignSystem.dark().spacings.m, bottom: WidgetToolkitDesignSystem.dark().spacings.xxxl, ), - qrScannerPage5 = EdgeInsets.only( - left: WidgetToolkitDesignSystem.dark().spacings.m, - right: WidgetToolkitDesignSystem.dark().spacings.m, - bottom: WidgetToolkitDesignSystem.dark().spacings.xxl, - ), qrScannerSubtitlePadding = EdgeInsets.only( top: WidgetToolkitDesignSystem.light().spacings.xs1), backButtonMarginEdgeInsets = EdgeInsets.only( @@ -361,28 +332,22 @@ class QrScannerTheme extends ThemeExtension final SvgFile backButtonArrowLeft; @override - final EdgeInsets cameraPermission1; - @override - final EdgeInsets cameraPermission2; + final EdgeInsets cameraPermissionPadding; @override - final EdgeInsets cameraPermission3; + final EdgeInsets cameraPermissionBorderPadding; @override - final EdgeInsets cameraPermission4; + final EdgeInsets cameraPermissionContentPadding; @override - final EdgeInsets cameraPermission5; + final EdgeInsets cameraPermissionIconPadding; @override - final EdgeInsets cameraPermission6; + final EdgeInsets cameraPermissionTitlePadding; @override - final EdgeInsets qrScannerPage1; - @override - final EdgeInsets qrScannerPage2; - @override - final EdgeInsets qrScannerPage3; + final EdgeInsets qrScannerComponentPadding; @override - final EdgeInsets qrScannerPage4; + final EdgeInsets qrScannerCameraPadding; @override - final EdgeInsets qrScannerPage5; + final EdgeInsets qrScannerProgressIndicatorPadding; } extension ThemeContextExtension on BuildContext { diff --git a/packages/widget_toolkit_qr/lib/src/base/theme/qr_scanner_theme.tailor.dart b/packages/widget_toolkit_qr/lib/src/base/theme/qr_scanner_theme.tailor.dart index e474e82a..3b358d5d 100644 --- a/packages/widget_toolkit_qr/lib/src/base/theme/qr_scanner_theme.tailor.dart +++ b/packages/widget_toolkit_qr/lib/src/base/theme/qr_scanner_theme.tailor.dart @@ -47,17 +47,14 @@ mixin _$QrScannerThemeTailorMixin on ThemeExtension { SvgFile get backButtonCloseIcon; SvgFile get qrScanAreaIcon; SvgFile get backButtonArrowLeft; - EdgeInsets get cameraPermission1; - EdgeInsets get cameraPermission2; - EdgeInsets get cameraPermission3; - EdgeInsets get cameraPermission4; - EdgeInsets get cameraPermission5; - EdgeInsets get cameraPermission6; - EdgeInsets get qrScannerPage1; - EdgeInsets get qrScannerPage2; - EdgeInsets get qrScannerPage3; - EdgeInsets get qrScannerPage4; - EdgeInsets get qrScannerPage5; + EdgeInsets get cameraPermissionPadding; + EdgeInsets get cameraPermissionBorderPadding; + EdgeInsets get cameraPermissionContentPadding; + EdgeInsets get cameraPermissionIconPadding; + EdgeInsets get cameraPermissionTitlePadding; + EdgeInsets get qrScannerComponentPadding; + EdgeInsets get qrScannerCameraPadding; + EdgeInsets get qrScannerProgressIndicatorPadding; @override QrScannerTheme copyWith({ @@ -99,17 +96,14 @@ mixin _$QrScannerThemeTailorMixin on ThemeExtension { SvgFile? backButtonCloseIcon, SvgFile? qrScanAreaIcon, SvgFile? backButtonArrowLeft, - EdgeInsets? cameraPermission1, - EdgeInsets? cameraPermission2, - EdgeInsets? cameraPermission3, - EdgeInsets? cameraPermission4, - EdgeInsets? cameraPermission5, - EdgeInsets? cameraPermission6, - EdgeInsets? qrScannerPage1, - EdgeInsets? qrScannerPage2, - EdgeInsets? qrScannerPage3, - EdgeInsets? qrScannerPage4, - EdgeInsets? qrScannerPage5, + EdgeInsets? cameraPermissionPadding, + EdgeInsets? cameraPermissionBorderPadding, + EdgeInsets? cameraPermissionContentPadding, + EdgeInsets? cameraPermissionIconPadding, + EdgeInsets? cameraPermissionTitlePadding, + EdgeInsets? qrScannerComponentPadding, + EdgeInsets? qrScannerCameraPadding, + EdgeInsets? qrScannerProgressIndicatorPadding, }) { return QrScannerTheme( qrScannerSubtitlePadding: @@ -175,17 +169,22 @@ mixin _$QrScannerThemeTailorMixin on ThemeExtension { backButtonCloseIcon: backButtonCloseIcon ?? this.backButtonCloseIcon, qrScanAreaIcon: qrScanAreaIcon ?? this.qrScanAreaIcon, backButtonArrowLeft: backButtonArrowLeft ?? this.backButtonArrowLeft, - cameraPermission1: cameraPermission1 ?? this.cameraPermission1, - cameraPermission2: cameraPermission2 ?? this.cameraPermission2, - cameraPermission3: cameraPermission3 ?? this.cameraPermission3, - cameraPermission4: cameraPermission4 ?? this.cameraPermission4, - cameraPermission5: cameraPermission5 ?? this.cameraPermission5, - cameraPermission6: cameraPermission6 ?? this.cameraPermission6, - qrScannerPage1: qrScannerPage1 ?? this.qrScannerPage1, - qrScannerPage2: qrScannerPage2 ?? this.qrScannerPage2, - qrScannerPage3: qrScannerPage3 ?? this.qrScannerPage3, - qrScannerPage4: qrScannerPage4 ?? this.qrScannerPage4, - qrScannerPage5: qrScannerPage5 ?? this.qrScannerPage5, + cameraPermissionPadding: + cameraPermissionPadding ?? this.cameraPermissionPadding, + cameraPermissionBorderPadding: + cameraPermissionBorderPadding ?? this.cameraPermissionBorderPadding, + cameraPermissionContentPadding: + cameraPermissionContentPadding ?? this.cameraPermissionContentPadding, + cameraPermissionIconPadding: + cameraPermissionIconPadding ?? this.cameraPermissionIconPadding, + cameraPermissionTitlePadding: + cameraPermissionTitlePadding ?? this.cameraPermissionTitlePadding, + qrScannerComponentPadding: + qrScannerComponentPadding ?? this.qrScannerComponentPadding, + qrScannerCameraPadding: + qrScannerCameraPadding ?? this.qrScannerCameraPadding, + qrScannerProgressIndicatorPadding: qrScannerProgressIndicatorPadding ?? + this.qrScannerProgressIndicatorPadding, ); } @@ -274,17 +273,27 @@ mixin _$QrScannerThemeTailorMixin on ThemeExtension { qrScanAreaIcon: t < 0.5 ? qrScanAreaIcon : other.qrScanAreaIcon, backButtonArrowLeft: t < 0.5 ? backButtonArrowLeft : other.backButtonArrowLeft, - cameraPermission1: t < 0.5 ? cameraPermission1 : other.cameraPermission1, - cameraPermission2: t < 0.5 ? cameraPermission2 : other.cameraPermission2, - cameraPermission3: t < 0.5 ? cameraPermission3 : other.cameraPermission3, - cameraPermission4: t < 0.5 ? cameraPermission4 : other.cameraPermission4, - cameraPermission5: t < 0.5 ? cameraPermission5 : other.cameraPermission5, - cameraPermission6: t < 0.5 ? cameraPermission6 : other.cameraPermission6, - qrScannerPage1: t < 0.5 ? qrScannerPage1 : other.qrScannerPage1, - qrScannerPage2: t < 0.5 ? qrScannerPage2 : other.qrScannerPage2, - qrScannerPage3: t < 0.5 ? qrScannerPage3 : other.qrScannerPage3, - qrScannerPage4: t < 0.5 ? qrScannerPage4 : other.qrScannerPage4, - qrScannerPage5: t < 0.5 ? qrScannerPage5 : other.qrScannerPage5, + cameraPermissionPadding: + t < 0.5 ? cameraPermissionPadding : other.cameraPermissionPadding, + cameraPermissionBorderPadding: t < 0.5 + ? cameraPermissionBorderPadding + : other.cameraPermissionBorderPadding, + cameraPermissionContentPadding: t < 0.5 + ? cameraPermissionContentPadding + : other.cameraPermissionContentPadding, + cameraPermissionIconPadding: t < 0.5 + ? cameraPermissionIconPadding + : other.cameraPermissionIconPadding, + cameraPermissionTitlePadding: t < 0.5 + ? cameraPermissionTitlePadding + : other.cameraPermissionTitlePadding, + qrScannerComponentPadding: + t < 0.5 ? qrScannerComponentPadding : other.qrScannerComponentPadding, + qrScannerCameraPadding: + t < 0.5 ? qrScannerCameraPadding : other.qrScannerCameraPadding, + qrScannerProgressIndicatorPadding: t < 0.5 + ? qrScannerProgressIndicatorPadding + : other.qrScannerProgressIndicatorPadding, ); } @@ -353,17 +362,14 @@ mixin _$QrScannerThemeTailorMixin on ThemeExtension { const DeepCollectionEquality().equals(backButtonCloseIcon, other.backButtonCloseIcon) && const DeepCollectionEquality().equals(qrScanAreaIcon, other.qrScanAreaIcon) && const DeepCollectionEquality().equals(backButtonArrowLeft, other.backButtonArrowLeft) && - const DeepCollectionEquality().equals(cameraPermission1, other.cameraPermission1) && - const DeepCollectionEquality().equals(cameraPermission2, other.cameraPermission2) && - const DeepCollectionEquality().equals(cameraPermission3, other.cameraPermission3) && - const DeepCollectionEquality().equals(cameraPermission4, other.cameraPermission4) && - const DeepCollectionEquality().equals(cameraPermission5, other.cameraPermission5) && - const DeepCollectionEquality().equals(cameraPermission6, other.cameraPermission6) && - const DeepCollectionEquality().equals(qrScannerPage1, other.qrScannerPage1) && - const DeepCollectionEquality().equals(qrScannerPage2, other.qrScannerPage2) && - const DeepCollectionEquality().equals(qrScannerPage3, other.qrScannerPage3) && - const DeepCollectionEquality().equals(qrScannerPage4, other.qrScannerPage4) && - const DeepCollectionEquality().equals(qrScannerPage5, other.qrScannerPage5)); + const DeepCollectionEquality().equals(cameraPermissionPadding, other.cameraPermissionPadding) && + const DeepCollectionEquality().equals(cameraPermissionBorderPadding, other.cameraPermissionBorderPadding) && + const DeepCollectionEquality().equals(cameraPermissionContentPadding, other.cameraPermissionContentPadding) && + const DeepCollectionEquality().equals(cameraPermissionIconPadding, other.cameraPermissionIconPadding) && + const DeepCollectionEquality().equals(cameraPermissionTitlePadding, other.cameraPermissionTitlePadding) && + const DeepCollectionEquality().equals(qrScannerComponentPadding, other.qrScannerComponentPadding) && + const DeepCollectionEquality().equals(qrScannerCameraPadding, other.qrScannerCameraPadding) && + const DeepCollectionEquality().equals(qrScannerProgressIndicatorPadding, other.qrScannerProgressIndicatorPadding)); } @override @@ -410,17 +416,14 @@ mixin _$QrScannerThemeTailorMixin on ThemeExtension { const DeepCollectionEquality().hash(backButtonCloseIcon), const DeepCollectionEquality().hash(qrScanAreaIcon), const DeepCollectionEquality().hash(backButtonArrowLeft), - const DeepCollectionEquality().hash(cameraPermission1), - const DeepCollectionEquality().hash(cameraPermission2), - const DeepCollectionEquality().hash(cameraPermission3), - const DeepCollectionEquality().hash(cameraPermission4), - const DeepCollectionEquality().hash(cameraPermission5), - const DeepCollectionEquality().hash(cameraPermission6), - const DeepCollectionEquality().hash(qrScannerPage1), - const DeepCollectionEquality().hash(qrScannerPage2), - const DeepCollectionEquality().hash(qrScannerPage3), - const DeepCollectionEquality().hash(qrScannerPage4), - const DeepCollectionEquality().hash(qrScannerPage5), + const DeepCollectionEquality().hash(cameraPermissionPadding), + const DeepCollectionEquality().hash(cameraPermissionBorderPadding), + const DeepCollectionEquality().hash(cameraPermissionContentPadding), + const DeepCollectionEquality().hash(cameraPermissionIconPadding), + const DeepCollectionEquality().hash(cameraPermissionTitlePadding), + const DeepCollectionEquality().hash(qrScannerComponentPadding), + const DeepCollectionEquality().hash(qrScannerCameraPadding), + const DeepCollectionEquality().hash(qrScannerProgressIndicatorPadding), ]); } } diff --git a/packages/widget_toolkit_qr/lib/src/lib_qr_scanner/views/camera_permission.dart b/packages/widget_toolkit_qr/lib/src/lib_qr_scanner/views/camera_permission.dart index 5c4a6ba9..dd13c5e8 100644 --- a/packages/widget_toolkit_qr/lib/src/lib_qr_scanner/views/camera_permission.dart +++ b/packages/widget_toolkit_qr/lib/src/lib_qr_scanner/views/camera_permission.dart @@ -68,12 +68,12 @@ class _CameraPermissionWidget extends StatelessWidget { @override Widget build(BuildContext context) => Padding( - padding: context.qrScannerTheme.cameraPermission1, + padding: context.qrScannerTheme.cameraPermissionPadding, child: SingleChildScrollView( child: Column( children: [ Padding( - padding: context.qrScannerTheme.cameraPermission2, + padding: context.qrScannerTheme.cameraPermissionBorderPadding, child: Container( decoration: BoxDecoration( borderRadius: BorderRadius.circular( @@ -85,13 +85,15 @@ class _CameraPermissionWidget extends StatelessWidget { ), ), child: Padding( - padding: context.qrScannerTheme.cameraPermission3, + padding: + context.qrScannerTheme.cameraPermissionContentPadding, child: Row( mainAxisSize: MainAxisSize.max, crossAxisAlignment: CrossAxisAlignment.start, children: [ Padding( - padding: context.qrScannerTheme.cameraPermission4, + padding: context + .qrScannerTheme.cameraPermissionIconPadding, child: context.qrScannerTheme.cameraIcon, ), Expanded( @@ -99,8 +101,8 @@ class _CameraPermissionWidget extends StatelessWidget { crossAxisAlignment: CrossAxisAlignment.start, children: [ Padding( - padding: - context.qrScannerTheme.cameraPermission5, + padding: context.qrScannerTheme + .cameraPermissionTitlePadding, child: Text( cameraAccessTitleText ?? defaultCameraAccessTitleText, diff --git a/packages/widget_toolkit_qr/lib/src/lib_qr_scanner/views/qr_scanner_component.dart b/packages/widget_toolkit_qr/lib/src/lib_qr_scanner/views/qr_scanner_component.dart index 267a4a04..f608107f 100644 --- a/packages/widget_toolkit_qr/lib/src/lib_qr_scanner/views/qr_scanner_component.dart +++ b/packages/widget_toolkit_qr/lib/src/lib_qr_scanner/views/qr_scanner_component.dart @@ -53,7 +53,7 @@ class QrScannerComponent extends StatelessWidget { child: Stack( children: [ Padding( - padding: context.qrScannerTheme.qrScannerPage3, + padding: context.qrScannerTheme.qrScannerCameraPadding, child: RxBlocListener, bool>( state: (bloc) => bloc.states.hasCameraPermission, listener: (ctx, permission) { @@ -129,7 +129,8 @@ class QrScannerComponent extends StatelessWidget { ? Align( alignment: Alignment.bottomCenter, child: Padding( - padding: context.qrScannerTheme.qrScannerPage4, + padding: + context.qrScannerTheme.qrScannerProgressIndicatorPadding, child: PrimeLinearProgressIndicator( borderRadius: context.qrScannerTheme.qrScannerPageXS, ), diff --git a/packages/widget_toolkit_qr/test/lib_qr_scanner/factory/qr_scanner_page_factory.dart b/packages/widget_toolkit_qr/test/lib_qr_scanner/factory/qr_scanner_page_factory.dart index cb74e716..98249703 100644 --- a/packages/widget_toolkit_qr/test/lib_qr_scanner/factory/qr_scanner_page_factory.dart +++ b/packages/widget_toolkit_qr/test/lib_qr_scanner/factory/qr_scanner_page_factory.dart @@ -45,7 +45,8 @@ Widget qrScannerPageFactory({ children: [ Center( child: Padding( - padding: context.qrScannerTheme.qrScannerPage2, + padding: context + .qrScannerTheme.qrScannerComponentPadding, child: const QrScannerComponent(), ), ),