diff --git a/ios/Podfile.lock b/ios/Podfile.lock index 2120b0e..b854701 100644 --- a/ios/Podfile.lock +++ b/ios/Podfile.lock @@ -262,7 +262,7 @@ SPEC CHECKSUMS: DKPhotoGallery: fdfad5125a9fdda9cc57df834d49df790dbb4179 file_picker: 817ab1d8cd2da9d2da412a417162deee3500fc95 Flutter: f04841e97a9d0b0a8025694d0796dd46242b2854 - fluttertoast: 74526702fea2c060ea55dde75895b7e1bde1c86b + fluttertoast: eb263d302cc92e04176c053d2385237e9f43fad0 google_mlkit_barcode_scanning: 4805cc8281f41915a13f8bbb7223291e982b6836 google_mlkit_commons: e9070f57232c3a3e4bd42fdfa621bb1f4bb3e709 google_mlkit_entity_extraction: 19d5b9c2f5049b2145747bbc8c7601b5b7e71e56 diff --git a/l10n.yaml b/l10n.yaml new file mode 100644 index 0000000..4e6692e --- /dev/null +++ b/l10n.yaml @@ -0,0 +1,3 @@ +arb-dir: lib/l10n +template-arb-file: app_en.arb +output-localization-file: app_localizations.dart \ No newline at end of file diff --git a/lib/app/settings.freezed.dart b/lib/app/settings.freezed.dart index ab1a5d1..7703b2a 100644 --- a/lib/app/settings.freezed.dart +++ b/lib/app/settings.freezed.dart @@ -32,29 +32,33 @@ mixin _$VoucherVaultSettings { abstract class $VoucherVaultSettingsCopyWith<$Res> { factory $VoucherVaultSettingsCopyWith(VoucherVaultSettings value, $Res Function(VoucherVaultSettings) then) = - _$VoucherVaultSettingsCopyWithImpl<$Res>; + _$VoucherVaultSettingsCopyWithImpl<$Res, VoucherVaultSettings>; + @useResult $Res call({bool smartScan}); } /// @nodoc -class _$VoucherVaultSettingsCopyWithImpl<$Res> +class _$VoucherVaultSettingsCopyWithImpl<$Res, + $Val extends VoucherVaultSettings> implements $VoucherVaultSettingsCopyWith<$Res> { _$VoucherVaultSettingsCopyWithImpl(this._value, this._then); - final VoucherVaultSettings _value; // ignore: unused_field - final $Res Function(VoucherVaultSettings) _then; + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + @pragma('vm:prefer-inline') @override $Res call({ - Object? smartScan = freezed, + Object? smartScan = null, }) { return _then(_value.copyWith( - smartScan: smartScan == freezed + smartScan: null == smartScan ? _value.smartScan : smartScan // ignore: cast_nullable_to_non_nullable as bool, - )); + ) as $Val); } } @@ -65,26 +69,25 @@ abstract class _$$_VoucherVaultSettingsCopyWith<$Res> $Res Function(_$_VoucherVaultSettings) then) = __$$_VoucherVaultSettingsCopyWithImpl<$Res>; @override + @useResult $Res call({bool smartScan}); } /// @nodoc class __$$_VoucherVaultSettingsCopyWithImpl<$Res> - extends _$VoucherVaultSettingsCopyWithImpl<$Res> + extends _$VoucherVaultSettingsCopyWithImpl<$Res, _$_VoucherVaultSettings> implements _$$_VoucherVaultSettingsCopyWith<$Res> { __$$_VoucherVaultSettingsCopyWithImpl(_$_VoucherVaultSettings _value, $Res Function(_$_VoucherVaultSettings) _then) - : super(_value, (v) => _then(v as _$_VoucherVaultSettings)); - - @override - _$_VoucherVaultSettings get _value => super._value as _$_VoucherVaultSettings; + : super(_value, _then); + @pragma('vm:prefer-inline') @override $Res call({ - Object? smartScan = freezed, + Object? smartScan = null, }) { return _then(_$_VoucherVaultSettings( - smartScan: smartScan == freezed + smartScan: null == smartScan ? _value.smartScan : smartScan // ignore: cast_nullable_to_non_nullable as bool, @@ -114,16 +117,17 @@ class _$_VoucherVaultSettings implements _VoucherVaultSettings { return identical(this, other) || (other.runtimeType == runtimeType && other is _$_VoucherVaultSettings && - const DeepCollectionEquality().equals(other.smartScan, smartScan)); + (identical(other.smartScan, smartScan) || + other.smartScan == smartScan)); } @JsonKey(ignore: true) @override - int get hashCode => - Object.hash(runtimeType, const DeepCollectionEquality().hash(smartScan)); + int get hashCode => Object.hash(runtimeType, smartScan); @JsonKey(ignore: true) @override + @pragma('vm:prefer-inline') _$$_VoucherVaultSettingsCopyWith<_$_VoucherVaultSettings> get copyWith => __$$_VoucherVaultSettingsCopyWithImpl<_$_VoucherVaultSettings>( this, _$identity); diff --git a/lib/app/voucher_vault_app.dart b/lib/app/voucher_vault_app.dart index c71a43a..9fe7b01 100644 --- a/lib/app/voucher_vault_app.dart +++ b/lib/app/voucher_vault_app.dart @@ -6,6 +6,8 @@ import 'package:functional_widget_annotation/functional_widget_annotation.dart'; import 'package:vouchervault/app/app.dart'; import 'package:vouchervault/auth/auth.dart'; import 'package:vouchervault/vouchers/vouchers.dart'; +import 'package:flutter_localizations/flutter_localizations.dart'; +import 'package:flutter_gen/gen_l10n/app_localizations.dart'; part 'voucher_vault_app.g.dart'; @@ -41,7 +43,12 @@ Widget __app() => AtomBuilder((context, watch, child) { ), navigatorObservers: [routeObserver], localizationsDelegates: const [ + AppLocalizations.delegate, + GlobalMaterialLocalizations.delegate, + GlobalWidgetsLocalizations.delegate, + GlobalCupertinoLocalizations.delegate, FormBuilderLocalizations.delegate, ], + supportedLocales: AppLocalizations.supportedLocales, ); }); diff --git a/lib/auth/model.freezed.dart b/lib/auth/model.freezed.dart index c436162..6a48fe9 100644 --- a/lib/auth/model.freezed.dart +++ b/lib/auth/model.freezed.dart @@ -37,8 +37,8 @@ mixin _$AuthState { throw _privateConstructorUsedError; @optionalTypeArgs TResult? whenOrNull({ - TResult Function()? unauthenticated, - TResult Function(AuthenticatedReason reason)? authenticated, + TResult? Function()? unauthenticated, + TResult? Function(AuthenticatedReason reason)? authenticated, }) => throw _privateConstructorUsedError; @optionalTypeArgs @@ -56,8 +56,8 @@ mixin _$AuthState { throw _privateConstructorUsedError; @optionalTypeArgs TResult? mapOrNull({ - TResult Function(Unauthenticated value)? unauthenticated, - TResult Function(Authenticated value)? authenticated, + TResult? Function(Unauthenticated value)? unauthenticated, + TResult? Function(Authenticated value)? authenticated, }) => throw _privateConstructorUsedError; @optionalTypeArgs @@ -73,16 +73,18 @@ mixin _$AuthState { /// @nodoc abstract class $AuthStateCopyWith<$Res> { factory $AuthStateCopyWith(AuthState value, $Res Function(AuthState) then) = - _$AuthStateCopyWithImpl<$Res>; + _$AuthStateCopyWithImpl<$Res, AuthState>; } /// @nodoc -class _$AuthStateCopyWithImpl<$Res> implements $AuthStateCopyWith<$Res> { +class _$AuthStateCopyWithImpl<$Res, $Val extends AuthState> + implements $AuthStateCopyWith<$Res> { _$AuthStateCopyWithImpl(this._value, this._then); - final AuthState _value; // ignore: unused_field - final $Res Function(AuthState) _then; + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; } /// @nodoc @@ -94,14 +96,11 @@ abstract class _$$UnauthenticatedCopyWith<$Res> { /// @nodoc class __$$UnauthenticatedCopyWithImpl<$Res> - extends _$AuthStateCopyWithImpl<$Res> + extends _$AuthStateCopyWithImpl<$Res, _$Unauthenticated> implements _$$UnauthenticatedCopyWith<$Res> { __$$UnauthenticatedCopyWithImpl( _$Unauthenticated _value, $Res Function(_$Unauthenticated) _then) - : super(_value, (v) => _then(v as _$Unauthenticated)); - - @override - _$Unauthenticated get _value => super._value as _$Unauthenticated; + : super(_value, _then); } /// @nodoc @@ -144,8 +143,8 @@ class _$Unauthenticated extends Unauthenticated { @override @optionalTypeArgs TResult? whenOrNull({ - TResult Function()? unauthenticated, - TResult Function(AuthenticatedReason reason)? authenticated, + TResult? Function()? unauthenticated, + TResult? Function(AuthenticatedReason reason)? authenticated, }) { return unauthenticated?.call(); } @@ -175,8 +174,8 @@ class _$Unauthenticated extends Unauthenticated { @override @optionalTypeArgs TResult? mapOrNull({ - TResult Function(Unauthenticated value)? unauthenticated, - TResult Function(Authenticated value)? authenticated, + TResult? Function(Unauthenticated value)? unauthenticated, + TResult? Function(Authenticated value)? authenticated, }) { return unauthenticated?.call(this); } @@ -215,25 +214,25 @@ abstract class _$$AuthenticatedCopyWith<$Res> { factory _$$AuthenticatedCopyWith( _$Authenticated value, $Res Function(_$Authenticated) then) = __$$AuthenticatedCopyWithImpl<$Res>; + @useResult $Res call({AuthenticatedReason reason}); } /// @nodoc -class __$$AuthenticatedCopyWithImpl<$Res> extends _$AuthStateCopyWithImpl<$Res> +class __$$AuthenticatedCopyWithImpl<$Res> + extends _$AuthStateCopyWithImpl<$Res, _$Authenticated> implements _$$AuthenticatedCopyWith<$Res> { __$$AuthenticatedCopyWithImpl( _$Authenticated _value, $Res Function(_$Authenticated) _then) - : super(_value, (v) => _then(v as _$Authenticated)); - - @override - _$Authenticated get _value => super._value as _$Authenticated; + : super(_value, _then); + @pragma('vm:prefer-inline') @override $Res call({ - Object? reason = freezed, + Object? reason = null, }) { return _then(_$Authenticated( - reason == freezed + null == reason ? _value.reason : reason // ignore: cast_nullable_to_non_nullable as AuthenticatedReason, @@ -267,16 +266,16 @@ class _$Authenticated extends Authenticated { return identical(this, other) || (other.runtimeType == runtimeType && other is _$Authenticated && - const DeepCollectionEquality().equals(other.reason, reason)); + (identical(other.reason, reason) || other.reason == reason)); } @JsonKey(ignore: true) @override - int get hashCode => - Object.hash(runtimeType, const DeepCollectionEquality().hash(reason)); + int get hashCode => Object.hash(runtimeType, reason); @JsonKey(ignore: true) @override + @pragma('vm:prefer-inline') _$$AuthenticatedCopyWith<_$Authenticated> get copyWith => __$$AuthenticatedCopyWithImpl<_$Authenticated>(this, _$identity); @@ -292,8 +291,8 @@ class _$Authenticated extends Authenticated { @override @optionalTypeArgs TResult? whenOrNull({ - TResult Function()? unauthenticated, - TResult Function(AuthenticatedReason reason)? authenticated, + TResult? Function()? unauthenticated, + TResult? Function(AuthenticatedReason reason)? authenticated, }) { return authenticated?.call(reason); } @@ -323,8 +322,8 @@ class _$Authenticated extends Authenticated { @override @optionalTypeArgs TResult? mapOrNull({ - TResult Function(Unauthenticated value)? unauthenticated, - TResult Function(Authenticated value)? authenticated, + TResult? Function(Unauthenticated value)? unauthenticated, + TResult? Function(Authenticated value)? authenticated, }) { return authenticated?.call(this); } diff --git a/lib/l10n/app_en.arb b/lib/l10n/app_en.arb new file mode 100644 index 0000000..1abe4fc --- /dev/null +++ b/lib/l10n/app_en.arb @@ -0,0 +1,28 @@ +{ + "vouchers": "Vouchers", + "edit": "Edit", + "close": "Close", + "copiedToClipboard": "Copied to clipboard", + "areYouSure": "Are you sure?", + "confirmRemoveVoucher": "That you want to remove this voucher?", + "cancel": "Cancel", + "remove": "Remove", + "howMuchSpend": "How much did you spend?", + "amount": "Amount", + "ok": "OK", + "addVoucher": "Add voucher", + "editVoucher": "Edit voucher", + "create": "Create", + "update": "Update", + "scanBarcode": "Scan barcode", + "description": "Description", + "code": "Code", + "expires": "Expires", + "removeOnceExpired": "Remove once expired", + "balance": "Balance", + "notes": "Notes", + "import": "Import", + "export": "Export", + "appLock": "App lock", + "smartScan": "Smart scan" +} diff --git a/lib/l10n/app_fr.arb b/lib/l10n/app_fr.arb new file mode 100644 index 0000000..78de035 --- /dev/null +++ b/lib/l10n/app_fr.arb @@ -0,0 +1,24 @@ +{ + "vouchers": "Mes bons", + "edit": "Modifier", + "close": "Fermer", + "copiedToClipboard": "Copié dans le presse-papier", + "areYouSure": "Etes-vous sûr?", + "confirmRemoveVoucher": "De vouloir supprimer ce bon?", + "cancel": "Annuler", + "remove": "Supprimer", + "howMuchSpend": "Quel montant avez-vous depensé?", + "amount": "Montant", + "ok": "Valider", + "addVoucher": "Ajouter un bon", + "editVoucher": "Modifier ce bon", + "create": "Créer", + "update": "Modifier", + "scanBarcode": "Scanner un code barre", + "description": "Description", + "code": "Code", + "expires": "Date d'expiration", + "removeOnceExpired": "Supprimer une fois expiré", + "balance": "Solde", + "notes": "Notes" +} diff --git a/lib/shared/voucher_details/voucher_details.dart b/lib/shared/voucher_details/voucher_details.dart index d71dafe..9d53381 100644 --- a/lib/shared/voucher_details/voucher_details.dart +++ b/lib/shared/voucher_details/voucher_details.dart @@ -5,9 +5,12 @@ import 'package:functional_widget_annotation/functional_widget_annotation.dart'; import 'package:vouchervault/app/app.dart'; import 'package:vouchervault/lib/lib.dart'; import 'package:vouchervault/vouchers/models/voucher.dart'; +import 'package:intl/intl.dart'; part 'voucher_details.g.dart'; +final formatCurrency = NumberFormat.simpleCurrency(); + List buildVoucherDetails( BuildContext context, Voucher voucher, { @@ -15,6 +18,7 @@ List buildVoucherDetails( Option space = const None(), bool includeNotes = false, }) => + intersperse(SizedBox( height: space.p(O.getOrElse(() => AppTheme.space1)), ))([ @@ -25,11 +29,11 @@ List buildVoucherDetails( formatExpires(dt), ) ])), - ...voucher.balanceOption.p(O.map(millisToString)).p(ifSomeList((b) => [ + ...voucher.balanceDoubleOption.p(ifSomeList((b) => [ _VoucherDetailRow( textColor, Icons.account_balance, - '\$$b', + formatCurrency.format(b), ), ])), ...voucher.notesOption diff --git a/lib/voucher_form/barcode_scanner/models/barcode_result.freezed.dart b/lib/voucher_form/barcode_scanner/models/barcode_result.freezed.dart index 0700714..5f21114 100644 --- a/lib/voucher_form/barcode_scanner/models/barcode_result.freezed.dart +++ b/lib/voucher_form/barcode_scanner/models/barcode_result.freezed.dart @@ -30,7 +30,8 @@ mixin _$BarcodeResult { abstract class $BarcodeResultCopyWith<$Res> { factory $BarcodeResultCopyWith( BarcodeResult value, $Res Function(BarcodeResult) then) = - _$BarcodeResultCopyWithImpl<$Res>; + _$BarcodeResultCopyWithImpl<$Res, BarcodeResult>; + @useResult $Res call( {Barcode barcode, Option merchant, @@ -39,39 +40,41 @@ abstract class $BarcodeResultCopyWith<$Res> { } /// @nodoc -class _$BarcodeResultCopyWithImpl<$Res> +class _$BarcodeResultCopyWithImpl<$Res, $Val extends BarcodeResult> implements $BarcodeResultCopyWith<$Res> { _$BarcodeResultCopyWithImpl(this._value, this._then); - final BarcodeResult _value; // ignore: unused_field - final $Res Function(BarcodeResult) _then; + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + @pragma('vm:prefer-inline') @override $Res call({ - Object? barcode = freezed, - Object? merchant = freezed, - Object? balance = freezed, - Object? expires = freezed, + Object? barcode = null, + Object? merchant = null, + Object? balance = null, + Object? expires = null, }) { return _then(_value.copyWith( - barcode: barcode == freezed + barcode: null == barcode ? _value.barcode : barcode // ignore: cast_nullable_to_non_nullable as Barcode, - merchant: merchant == freezed + merchant: null == merchant ? _value.merchant : merchant // ignore: cast_nullable_to_non_nullable as Option, - balance: balance == freezed + balance: null == balance ? _value.balance : balance // ignore: cast_nullable_to_non_nullable as Option, - expires: expires == freezed + expires: null == expires ? _value.expires : expires // ignore: cast_nullable_to_non_nullable as Option, - )); + ) as $Val); } } @@ -82,6 +85,7 @@ abstract class _$$_BarcodeResultCopyWith<$Res> _$_BarcodeResult value, $Res Function(_$_BarcodeResult) then) = __$$_BarcodeResultCopyWithImpl<$Res>; @override + @useResult $Res call( {Barcode barcode, Option merchant, @@ -91,36 +95,34 @@ abstract class _$$_BarcodeResultCopyWith<$Res> /// @nodoc class __$$_BarcodeResultCopyWithImpl<$Res> - extends _$BarcodeResultCopyWithImpl<$Res> + extends _$BarcodeResultCopyWithImpl<$Res, _$_BarcodeResult> implements _$$_BarcodeResultCopyWith<$Res> { __$$_BarcodeResultCopyWithImpl( _$_BarcodeResult _value, $Res Function(_$_BarcodeResult) _then) - : super(_value, (v) => _then(v as _$_BarcodeResult)); - - @override - _$_BarcodeResult get _value => super._value as _$_BarcodeResult; + : super(_value, _then); + @pragma('vm:prefer-inline') @override $Res call({ - Object? barcode = freezed, - Object? merchant = freezed, - Object? balance = freezed, - Object? expires = freezed, + Object? barcode = null, + Object? merchant = null, + Object? balance = null, + Object? expires = null, }) { return _then(_$_BarcodeResult( - barcode: barcode == freezed + barcode: null == barcode ? _value.barcode : barcode // ignore: cast_nullable_to_non_nullable as Barcode, - merchant: merchant == freezed + merchant: null == merchant ? _value.merchant : merchant // ignore: cast_nullable_to_non_nullable as Option, - balance: balance == freezed + balance: null == balance ? _value.balance : balance // ignore: cast_nullable_to_non_nullable as Option, - expires: expires == freezed + expires: null == expires ? _value.expires : expires // ignore: cast_nullable_to_non_nullable as Option, @@ -159,22 +161,20 @@ class _$_BarcodeResult implements _BarcodeResult { return identical(this, other) || (other.runtimeType == runtimeType && other is _$_BarcodeResult && - const DeepCollectionEquality().equals(other.barcode, barcode) && - const DeepCollectionEquality().equals(other.merchant, merchant) && - const DeepCollectionEquality().equals(other.balance, balance) && - const DeepCollectionEquality().equals(other.expires, expires)); + (identical(other.barcode, barcode) || other.barcode == barcode) && + (identical(other.merchant, merchant) || + other.merchant == merchant) && + (identical(other.balance, balance) || other.balance == balance) && + (identical(other.expires, expires) || other.expires == expires)); } @override - int get hashCode => Object.hash( - runtimeType, - const DeepCollectionEquality().hash(barcode), - const DeepCollectionEquality().hash(merchant), - const DeepCollectionEquality().hash(balance), - const DeepCollectionEquality().hash(expires)); + int get hashCode => + Object.hash(runtimeType, barcode, merchant, balance, expires); @JsonKey(ignore: true) @override + @pragma('vm:prefer-inline') _$$_BarcodeResultCopyWith<_$_BarcodeResult> get copyWith => __$$_BarcodeResultCopyWithImpl<_$_BarcodeResult>(this, _$identity); } diff --git a/lib/voucher_form/barcode_scanner/models/ml_context.freezed.dart b/lib/voucher_form/barcode_scanner/models/ml_context.freezed.dart index b6ef8cb..1e81885 100644 --- a/lib/voucher_form/barcode_scanner/models/ml_context.freezed.dart +++ b/lib/voucher_form/barcode_scanner/models/ml_context.freezed.dart @@ -28,7 +28,8 @@ mixin _$MlContext { /// @nodoc abstract class $MlContextCopyWith<$Res> { factory $MlContextCopyWith(MlContext value, $Res Function(MlContext) then) = - _$MlContextCopyWithImpl<$Res>; + _$MlContextCopyWithImpl<$Res, MlContext>; + @useResult $Res call( {TextRecognizer textRecognizer, BarcodeScanner barcodeScanner, @@ -36,33 +37,36 @@ abstract class $MlContextCopyWith<$Res> { } /// @nodoc -class _$MlContextCopyWithImpl<$Res> implements $MlContextCopyWith<$Res> { +class _$MlContextCopyWithImpl<$Res, $Val extends MlContext> + implements $MlContextCopyWith<$Res> { _$MlContextCopyWithImpl(this._value, this._then); - final MlContext _value; // ignore: unused_field - final $Res Function(MlContext) _then; + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + @pragma('vm:prefer-inline') @override $Res call({ - Object? textRecognizer = freezed, - Object? barcodeScanner = freezed, - Object? entityExtractor = freezed, + Object? textRecognizer = null, + Object? barcodeScanner = null, + Object? entityExtractor = null, }) { return _then(_value.copyWith( - textRecognizer: textRecognizer == freezed + textRecognizer: null == textRecognizer ? _value.textRecognizer : textRecognizer // ignore: cast_nullable_to_non_nullable as TextRecognizer, - barcodeScanner: barcodeScanner == freezed + barcodeScanner: null == barcodeScanner ? _value.barcodeScanner : barcodeScanner // ignore: cast_nullable_to_non_nullable as BarcodeScanner, - entityExtractor: entityExtractor == freezed + entityExtractor: null == entityExtractor ? _value.entityExtractor : entityExtractor // ignore: cast_nullable_to_non_nullable as EntityExtractor, - )); + ) as $Val); } } @@ -72,6 +76,7 @@ abstract class _$$_MlContextCopyWith<$Res> implements $MlContextCopyWith<$Res> { _$_MlContext value, $Res Function(_$_MlContext) then) = __$$_MlContextCopyWithImpl<$Res>; @override + @useResult $Res call( {TextRecognizer textRecognizer, BarcodeScanner barcodeScanner, @@ -79,31 +84,30 @@ abstract class _$$_MlContextCopyWith<$Res> implements $MlContextCopyWith<$Res> { } /// @nodoc -class __$$_MlContextCopyWithImpl<$Res> extends _$MlContextCopyWithImpl<$Res> +class __$$_MlContextCopyWithImpl<$Res> + extends _$MlContextCopyWithImpl<$Res, _$_MlContext> implements _$$_MlContextCopyWith<$Res> { __$$_MlContextCopyWithImpl( _$_MlContext _value, $Res Function(_$_MlContext) _then) - : super(_value, (v) => _then(v as _$_MlContext)); - - @override - _$_MlContext get _value => super._value as _$_MlContext; + : super(_value, _then); + @pragma('vm:prefer-inline') @override $Res call({ - Object? textRecognizer = freezed, - Object? barcodeScanner = freezed, - Object? entityExtractor = freezed, + Object? textRecognizer = null, + Object? barcodeScanner = null, + Object? entityExtractor = null, }) { return _then(_$_MlContext( - textRecognizer: textRecognizer == freezed + textRecognizer: null == textRecognizer ? _value.textRecognizer : textRecognizer // ignore: cast_nullable_to_non_nullable as TextRecognizer, - barcodeScanner: barcodeScanner == freezed + barcodeScanner: null == barcodeScanner ? _value.barcodeScanner : barcodeScanner // ignore: cast_nullable_to_non_nullable as BarcodeScanner, - entityExtractor: entityExtractor == freezed + entityExtractor: null == entityExtractor ? _value.entityExtractor : entityExtractor // ignore: cast_nullable_to_non_nullable as EntityExtractor, @@ -136,23 +140,21 @@ class _$_MlContext implements _MlContext { return identical(this, other) || (other.runtimeType == runtimeType && other is _$_MlContext && - const DeepCollectionEquality() - .equals(other.textRecognizer, textRecognizer) && - const DeepCollectionEquality() - .equals(other.barcodeScanner, barcodeScanner) && - const DeepCollectionEquality() - .equals(other.entityExtractor, entityExtractor)); + (identical(other.textRecognizer, textRecognizer) || + other.textRecognizer == textRecognizer) && + (identical(other.barcodeScanner, barcodeScanner) || + other.barcodeScanner == barcodeScanner) && + (identical(other.entityExtractor, entityExtractor) || + other.entityExtractor == entityExtractor)); } @override - int get hashCode => Object.hash( - runtimeType, - const DeepCollectionEquality().hash(textRecognizer), - const DeepCollectionEquality().hash(barcodeScanner), - const DeepCollectionEquality().hash(entityExtractor)); + int get hashCode => + Object.hash(runtimeType, textRecognizer, barcodeScanner, entityExtractor); @JsonKey(ignore: true) @override + @pragma('vm:prefer-inline') _$$_MlContextCopyWith<_$_MlContext> get copyWith => __$$_MlContextCopyWithImpl<_$_MlContext>(this, _$identity); } diff --git a/lib/voucher_form/barcode_scanner/models/ml_error.freezed.dart b/lib/voucher_form/barcode_scanner/models/ml_error.freezed.dart index 6b293fe..2799a56 100644 --- a/lib/voucher_form/barcode_scanner/models/ml_error.freezed.dart +++ b/lib/voucher_form/barcode_scanner/models/ml_error.freezed.dart @@ -25,9 +25,9 @@ mixin _$MlError { throw _privateConstructorUsedError; @optionalTypeArgs TResult? whenOrNull({ - TResult Function()? barcodeNotFound, - TResult Function(String message)? pickerError, - TResult Function(String op, dynamic err)? mlkitError, + TResult? Function()? barcodeNotFound, + TResult? Function(String message)? pickerError, + TResult? Function(String op, dynamic err)? mlkitError, }) => throw _privateConstructorUsedError; @optionalTypeArgs @@ -47,9 +47,9 @@ mixin _$MlError { throw _privateConstructorUsedError; @optionalTypeArgs TResult? mapOrNull({ - TResult Function(_MlErrorBarcodeNotFound value)? barcodeNotFound, - TResult Function(_MlErrorPicker value)? pickerError, - TResult Function(_MlErrorMlKit value)? mlkitError, + TResult? Function(_MlErrorBarcodeNotFound value)? barcodeNotFound, + TResult? Function(_MlErrorPicker value)? pickerError, + TResult? Function(_MlErrorMlKit value)? mlkitError, }) => throw _privateConstructorUsedError; @optionalTypeArgs @@ -65,16 +65,18 @@ mixin _$MlError { /// @nodoc abstract class $MlErrorCopyWith<$Res> { factory $MlErrorCopyWith(MlError value, $Res Function(MlError) then) = - _$MlErrorCopyWithImpl<$Res>; + _$MlErrorCopyWithImpl<$Res, MlError>; } /// @nodoc -class _$MlErrorCopyWithImpl<$Res> implements $MlErrorCopyWith<$Res> { +class _$MlErrorCopyWithImpl<$Res, $Val extends MlError> + implements $MlErrorCopyWith<$Res> { _$MlErrorCopyWithImpl(this._value, this._then); - final MlError _value; // ignore: unused_field - final $Res Function(MlError) _then; + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; } /// @nodoc @@ -86,15 +88,11 @@ abstract class _$$_MlErrorBarcodeNotFoundCopyWith<$Res> { /// @nodoc class __$$_MlErrorBarcodeNotFoundCopyWithImpl<$Res> - extends _$MlErrorCopyWithImpl<$Res> + extends _$MlErrorCopyWithImpl<$Res, _$_MlErrorBarcodeNotFound> implements _$$_MlErrorBarcodeNotFoundCopyWith<$Res> { __$$_MlErrorBarcodeNotFoundCopyWithImpl(_$_MlErrorBarcodeNotFound _value, $Res Function(_$_MlErrorBarcodeNotFound) _then) - : super(_value, (v) => _then(v as _$_MlErrorBarcodeNotFound)); - - @override - _$_MlErrorBarcodeNotFound get _value => - super._value as _$_MlErrorBarcodeNotFound; + : super(_value, _then); } /// @nodoc @@ -130,9 +128,9 @@ class _$_MlErrorBarcodeNotFound extends _MlErrorBarcodeNotFound { @override @optionalTypeArgs TResult? whenOrNull({ - TResult Function()? barcodeNotFound, - TResult Function(String message)? pickerError, - TResult Function(String op, dynamic err)? mlkitError, + TResult? Function()? barcodeNotFound, + TResult? Function(String message)? pickerError, + TResult? Function(String op, dynamic err)? mlkitError, }) { return barcodeNotFound?.call(); } @@ -164,9 +162,9 @@ class _$_MlErrorBarcodeNotFound extends _MlErrorBarcodeNotFound { @override @optionalTypeArgs TResult? mapOrNull({ - TResult Function(_MlErrorBarcodeNotFound value)? barcodeNotFound, - TResult Function(_MlErrorPicker value)? pickerError, - TResult Function(_MlErrorMlKit value)? mlkitError, + TResult? Function(_MlErrorBarcodeNotFound value)? barcodeNotFound, + TResult? Function(_MlErrorPicker value)? pickerError, + TResult? Function(_MlErrorMlKit value)? mlkitError, }) { return barcodeNotFound?.call(this); } @@ -196,25 +194,25 @@ abstract class _$$_MlErrorPickerCopyWith<$Res> { factory _$$_MlErrorPickerCopyWith( _$_MlErrorPicker value, $Res Function(_$_MlErrorPicker) then) = __$$_MlErrorPickerCopyWithImpl<$Res>; + @useResult $Res call({String message}); } /// @nodoc -class __$$_MlErrorPickerCopyWithImpl<$Res> extends _$MlErrorCopyWithImpl<$Res> +class __$$_MlErrorPickerCopyWithImpl<$Res> + extends _$MlErrorCopyWithImpl<$Res, _$_MlErrorPicker> implements _$$_MlErrorPickerCopyWith<$Res> { __$$_MlErrorPickerCopyWithImpl( _$_MlErrorPicker _value, $Res Function(_$_MlErrorPicker) _then) - : super(_value, (v) => _then(v as _$_MlErrorPicker)); - - @override - _$_MlErrorPicker get _value => super._value as _$_MlErrorPicker; + : super(_value, _then); + @pragma('vm:prefer-inline') @override $Res call({ - Object? message = freezed, + Object? message = null, }) { return _then(_$_MlErrorPicker( - message == freezed + null == message ? _value.message : message // ignore: cast_nullable_to_non_nullable as String, @@ -240,15 +238,15 @@ class _$_MlErrorPicker extends _MlErrorPicker { return identical(this, other) || (other.runtimeType == runtimeType && other is _$_MlErrorPicker && - const DeepCollectionEquality().equals(other.message, message)); + (identical(other.message, message) || other.message == message)); } @override - int get hashCode => - Object.hash(runtimeType, const DeepCollectionEquality().hash(message)); + int get hashCode => Object.hash(runtimeType, message); @JsonKey(ignore: true) @override + @pragma('vm:prefer-inline') _$$_MlErrorPickerCopyWith<_$_MlErrorPicker> get copyWith => __$$_MlErrorPickerCopyWithImpl<_$_MlErrorPicker>(this, _$identity); @@ -265,9 +263,9 @@ class _$_MlErrorPicker extends _MlErrorPicker { @override @optionalTypeArgs TResult? whenOrNull({ - TResult Function()? barcodeNotFound, - TResult Function(String message)? pickerError, - TResult Function(String op, dynamic err)? mlkitError, + TResult? Function()? barcodeNotFound, + TResult? Function(String message)? pickerError, + TResult? Function(String op, dynamic err)? mlkitError, }) { return pickerError?.call(message); } @@ -299,9 +297,9 @@ class _$_MlErrorPicker extends _MlErrorPicker { @override @optionalTypeArgs TResult? mapOrNull({ - TResult Function(_MlErrorBarcodeNotFound value)? barcodeNotFound, - TResult Function(_MlErrorPicker value)? pickerError, - TResult Function(_MlErrorMlKit value)? mlkitError, + TResult? Function(_MlErrorBarcodeNotFound value)? barcodeNotFound, + TResult? Function(_MlErrorPicker value)? pickerError, + TResult? Function(_MlErrorMlKit value)? mlkitError, }) { return pickerError?.call(this); } @@ -336,30 +334,30 @@ abstract class _$$_MlErrorMlKitCopyWith<$Res> { factory _$$_MlErrorMlKitCopyWith( _$_MlErrorMlKit value, $Res Function(_$_MlErrorMlKit) then) = __$$_MlErrorMlKitCopyWithImpl<$Res>; + @useResult $Res call({String op, dynamic err}); } /// @nodoc -class __$$_MlErrorMlKitCopyWithImpl<$Res> extends _$MlErrorCopyWithImpl<$Res> +class __$$_MlErrorMlKitCopyWithImpl<$Res> + extends _$MlErrorCopyWithImpl<$Res, _$_MlErrorMlKit> implements _$$_MlErrorMlKitCopyWith<$Res> { __$$_MlErrorMlKitCopyWithImpl( _$_MlErrorMlKit _value, $Res Function(_$_MlErrorMlKit) _then) - : super(_value, (v) => _then(v as _$_MlErrorMlKit)); - - @override - _$_MlErrorMlKit get _value => super._value as _$_MlErrorMlKit; + : super(_value, _then); + @pragma('vm:prefer-inline') @override $Res call({ - Object? op = freezed, - Object? err = freezed, + Object? op = null, + Object? err = null, }) { return _then(_$_MlErrorMlKit( - op: op == freezed + op: null == op ? _value.op : op // ignore: cast_nullable_to_non_nullable as String, - err: err == freezed + err: null == err ? _value.err : err // ignore: cast_nullable_to_non_nullable as dynamic, @@ -387,18 +385,17 @@ class _$_MlErrorMlKit extends _MlErrorMlKit { return identical(this, other) || (other.runtimeType == runtimeType && other is _$_MlErrorMlKit && - const DeepCollectionEquality().equals(other.op, op) && + (identical(other.op, op) || other.op == op) && const DeepCollectionEquality().equals(other.err, err)); } @override - int get hashCode => Object.hash( - runtimeType, - const DeepCollectionEquality().hash(op), - const DeepCollectionEquality().hash(err)); + int get hashCode => + Object.hash(runtimeType, op, const DeepCollectionEquality().hash(err)); @JsonKey(ignore: true) @override + @pragma('vm:prefer-inline') _$$_MlErrorMlKitCopyWith<_$_MlErrorMlKit> get copyWith => __$$_MlErrorMlKitCopyWithImpl<_$_MlErrorMlKit>(this, _$identity); @@ -415,9 +412,9 @@ class _$_MlErrorMlKit extends _MlErrorMlKit { @override @optionalTypeArgs TResult? whenOrNull({ - TResult Function()? barcodeNotFound, - TResult Function(String message)? pickerError, - TResult Function(String op, dynamic err)? mlkitError, + TResult? Function()? barcodeNotFound, + TResult? Function(String message)? pickerError, + TResult? Function(String op, dynamic err)? mlkitError, }) { return mlkitError?.call(op, err); } @@ -449,9 +446,9 @@ class _$_MlErrorMlKit extends _MlErrorMlKit { @override @optionalTypeArgs TResult? mapOrNull({ - TResult Function(_MlErrorBarcodeNotFound value)? barcodeNotFound, - TResult Function(_MlErrorPicker value)? pickerError, - TResult Function(_MlErrorMlKit value)? mlkitError, + TResult? Function(_MlErrorBarcodeNotFound value)? barcodeNotFound, + TResult? Function(_MlErrorPicker value)? pickerError, + TResult? Function(_MlErrorMlKit value)? mlkitError, }) { return mlkitError?.call(this); } diff --git a/lib/voucher_form/barcode_scanner/widgets/barcode_button.dart b/lib/voucher_form/barcode_scanner/widgets/barcode_button.dart index 7fc3251..dcc1a0d 100644 --- a/lib/voucher_form/barcode_scanner/widgets/barcode_button.dart +++ b/lib/voucher_form/barcode_scanner/widgets/barcode_button.dart @@ -7,6 +7,7 @@ import 'package:fpdt/option.dart' as O; import 'package:functional_widget_annotation/functional_widget_annotation.dart'; import 'package:vouchervault/app/app.dart'; import 'package:vouchervault/lib/lib.dart'; +import 'package:flutter_gen/gen_l10n/app_localizations.dart'; part 'barcode_button.g.dart'; @@ -45,6 +46,6 @@ Widget _barcodeButton( child: Center( child: _barcodeWidget(barcodeType, optionOfString(data)) .p(O.alt(() => _autoSizeText(data))) - .p(O.getOrElse(() => const Text('Scan barcode'))), + .p(O.getOrElse(() => Text(AppLocalizations.of(context)!.scanBarcode))), ), ); diff --git a/lib/voucher_form/barcode_scanner/widgets/scanner_dialog.dart b/lib/voucher_form/barcode_scanner/widgets/scanner_dialog.dart index 02f83bd..933d99a 100644 --- a/lib/voucher_form/barcode_scanner/widgets/scanner_dialog.dart +++ b/lib/voucher_form/barcode_scanner/widgets/scanner_dialog.dart @@ -10,6 +10,7 @@ import 'package:fpdt/reader_task_either.dart' as RTE; import 'package:functional_widget_annotation/functional_widget_annotation.dart'; import 'package:vouchervault/app/app.dart'; import 'package:vouchervault/voucher_form/voucher_form.dart'; +import 'package:flutter_gen/gen_l10n/app_localizations.dart'; part 'scanner_dialog.g.dart'; @@ -100,11 +101,17 @@ Widget __previewDialog( icon: const Icon(Icons.add_photo_alternate), onPressed: onPressedPicker, ), - SizedBox(width: AppTheme.space3), - ElevatedButton( - onPressed: onPressedFlash, - child: const Text('Toggle flash'), - ), + ...controller.p(O.fold( + () => [], + (controller) => [ + SizedBox(width: AppTheme.space3), + IconButton( + color: Colors.white, + onPressed: onPressedFlash, + icon: _FlashIcon(controller: controller), + ), + ], + )), SizedBox(width: AppTheme.space3), ElevatedButton( style: ElevatedButton.styleFrom( @@ -112,7 +119,7 @@ Widget __previewDialog( foregroundColor: Colors.black, ), onPressed: () => Navigator.of(context).pop(), - child: const Text('Cancel'), + child: Text(AppLocalizations.of(context)!.cancel), ), ], ), @@ -132,3 +139,17 @@ Widget __cameraPreview({ width: controller.value.previewSize!.height, child: controller.buildPreview(), ); + +@hwidget +Widget __flashIcon({ + required CameraController controller, +}) { + final mode = useListenableSelector( + controller, + () => controller.value.flashMode, + ); + + return mode != FlashMode.torch + ? const Icon(Icons.flash_on) + : const Icon(Icons.flash_off); +} diff --git a/lib/voucher_form/barcode_scanner/widgets/scanner_dialog.g.dart b/lib/voucher_form/barcode_scanner/widgets/scanner_dialog.g.dart index 02d9137..bd57246 100644 --- a/lib/voucher_form/barcode_scanner/widgets/scanner_dialog.g.dart +++ b/lib/voucher_form/barcode_scanner/widgets/scanner_dialog.g.dart @@ -56,3 +56,15 @@ class _CameraPreview extends StatelessWidget { Widget build(BuildContext _context) => __cameraPreview(controller: controller); } + +class _FlashIcon extends HookWidget { + const _FlashIcon({ + Key? key, + required this.controller, + }) : super(key: key); + + final CameraController controller; + + @override + Widget build(BuildContext _context) => __flashIcon(controller: controller); +} diff --git a/lib/voucher_form/widgets/dialog.dart b/lib/voucher_form/widgets/dialog.dart index 0178d2b..fcc5a75 100644 --- a/lib/voucher_form/widgets/dialog.dart +++ b/lib/voucher_form/widgets/dialog.dart @@ -8,6 +8,7 @@ import 'package:vouchervault/shared/scaffold/app_scaffold.dart'; import 'package:vouchervault/voucher_form/voucher_form.dart'; import 'package:vouchervault/vouchers/vouchers.dart'; import 'package:flutter_hooks/flutter_hooks.dart'; +import 'package:flutter_gen/gen_l10n/app_localizations.dart'; part 'dialog.g.dart'; @@ -18,12 +19,12 @@ Widget _voucherFormDialog( }) { final formKey = useMemoized(() => GlobalKey()); final title = initialValue.p(O.fold( - () => 'Add voucher', - (_) => 'Edit voucher', + () => AppLocalizations.of(context)!.addVoucher, + (_) => AppLocalizations.of(context)!.editVoucher, )); final action = initialValue.p(O.fold( - () => 'Create', - (_) => 'Update', + () => AppLocalizations.of(context)!.create, + (_) => AppLocalizations.of(context)!.update, )); return AppScaffold( diff --git a/lib/voucher_form/widgets/form.dart b/lib/voucher_form/widgets/form.dart index 506a5b5..d13dfce 100644 --- a/lib/voucher_form/widgets/form.dart +++ b/lib/voucher_form/widgets/form.dart @@ -11,6 +11,7 @@ import 'package:vouchervault/voucher_form/voucher_form.dart'; import 'package:vouchervault/vouchers/vouchers.dart' show Voucher, VoucherCodeType, VoucherColor; import 'package:vouchervault/vouchers/vouchers.dart' as V; +import 'package:flutter_gen/gen_l10n/app_localizations.dart'; part 'form.g.dart'; @@ -54,9 +55,9 @@ Widget voucherForm( FormBuilderTextField( name: 'description', textCapitalization: TextCapitalization.words, - decoration: const InputDecoration( - border: OutlineInputBorder(), - labelText: 'Description', + decoration: InputDecoration( + border: const OutlineInputBorder(), + labelText: AppLocalizations.of(context)!.description, ), validator: FormBuilderValidators.required(), valueTransformer: optionOfString.c(O.toNullable), @@ -68,7 +69,7 @@ Widget voucherForm( validator: FormBuilderValidators.required(), builder: (field) => BarcodeScannerField( launchScannerImmediately: true, - labelText: 'Code', + labelText: AppLocalizations.of(context)!.code, onChange: field.didChange, errorText: optionOfString(field.errorText), initialValue: field.value ?? '', @@ -113,7 +114,7 @@ Widget voucherForm( resetIcon: null, decoration: InputDecoration( border: const OutlineInputBorder(), - labelText: 'Expires', + labelText: AppLocalizations.of(context)!.expires, suffixIcon: _resetIconButton(formKey, 'expires'), ), valueTransformer: O @@ -124,7 +125,7 @@ Widget voucherForm( FormBuilderSwitch( name: 'removeOnceExpired', title: Text( - 'Remove once expired', + AppLocalizations.of(context)!.removeOnceExpired, style: theme.textTheme.bodyLarge, ), decoration: const InputDecoration( @@ -141,7 +142,7 @@ Widget voucherForm( ), decoration: InputDecoration( border: const OutlineInputBorder(), - labelText: 'Balance', + labelText: AppLocalizations.of(context)!.balance, suffixIcon: _resetIconButton(formKey, 'balanceMilliunits'), ), ), @@ -152,9 +153,9 @@ Widget voucherForm( minLines: 2, maxLines: null, textCapitalization: TextCapitalization.sentences, - decoration: const InputDecoration( - border: OutlineInputBorder(), - labelText: 'Notes', + decoration: InputDecoration( + border: const OutlineInputBorder(), + labelText: AppLocalizations.of(context)!.notes, ), ), SizedBox(height: AppTheme.space3), diff --git a/lib/vouchers/dialog/voucher_dialog.dart b/lib/vouchers/dialog/voucher_dialog.dart index b914519..e0e7cd8 100644 --- a/lib/vouchers/dialog/voucher_dialog.dart +++ b/lib/vouchers/dialog/voucher_dialog.dart @@ -11,6 +11,7 @@ import 'package:vouchervault/vouchers/vouchers.dart' as V; import 'package:vouchervault/vouchers/vouchers.dart' show Voucher, VoucherCodeType; import 'package:vouchervault/shared/voucher_details/voucher_details.dart'; +import 'package:flutter_gen/gen_l10n/app_localizations.dart'; export 'voucher_dialog_container.dart'; export 'voucher_spend_dialog.dart'; @@ -88,7 +89,7 @@ Widget _voucherDialog( SizedBox(width: AppTheme.space3), ElevatedButton( onPressed: onEdit, - child: const Text('Edit'), + child: Text(AppLocalizations.of(context)!.edit), ), SizedBox(width: AppTheme.space3), ElevatedButton( @@ -97,7 +98,7 @@ Widget _voucherDialog( foregroundColor: Colors.black, ), onPressed: onClose, - child: const Text('Close'), + child: Text(AppLocalizations.of(context)!.close), ), ], ), diff --git a/lib/vouchers/dialog/voucher_dialog_container.dart b/lib/vouchers/dialog/voucher_dialog_container.dart index 28aaec7..01555be 100644 --- a/lib/vouchers/dialog/voucher_dialog_container.dart +++ b/lib/vouchers/dialog/voucher_dialog_container.dart @@ -12,6 +12,7 @@ import 'package:vouchervault/hooks/hooks.dart'; import 'package:vouchervault/lib/navigator.dart'; import 'package:vouchervault/voucher_form/voucher_form.dart'; import 'package:vouchervault/vouchers/vouchers.dart'; +import 'package:flutter_gen/gen_l10n/app_localizations.dart'; part 'voucher_dialog_container.g.dart'; @@ -33,7 +34,7 @@ Widget _voucherDialogContainer( final onTapBarcode = useCallback( () => v.code.p(O.map((code) { Clipboard.setData(ClipboardData(text: code)); - Fluttertoast.showToast(msg: 'Copied to clipboard'); + Fluttertoast.showToast(msg: AppLocalizations.of(context)!.copiedToClipboard); })), [v.code], ); @@ -87,16 +88,16 @@ TaskOption _showRemoveDialog( showDialogTO( context: context, builder: (context) => AlertDialog( - title: const Text('Are you sure?'), - content: const Text('That you want to remove this voucher?'), + title: Text(AppLocalizations.of(context)!.areYouSure), + content: Text(AppLocalizations.of(context)!.confirmRemoveVoucher), actions: [ TextButton( onPressed: () => Navigator.pop(context, false), - child: const Text('Cancel'), + child: Text(AppLocalizations.of(context)!.cancel), ), TextButton( onPressed: () => onPressed(context), - child: const Text('Remove'), + child: Text(AppLocalizations.of(context)!.remove), ), ], ), diff --git a/lib/vouchers/dialog/voucher_spend_dialog.dart b/lib/vouchers/dialog/voucher_spend_dialog.dart index d173abc..0753802 100644 --- a/lib/vouchers/dialog/voucher_spend_dialog.dart +++ b/lib/vouchers/dialog/voucher_spend_dialog.dart @@ -1,6 +1,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_hooks/flutter_hooks.dart'; import 'package:functional_widget_annotation/functional_widget_annotation.dart'; +import 'package:flutter_gen/gen_l10n/app_localizations.dart'; part 'voucher_spend_dialog.g.dart'; @@ -10,12 +11,12 @@ Widget _voucherSpendDialog(BuildContext context) { void submit() => Navigator.pop(context, amount.value); return AlertDialog( - title: const Text('How much did you spend?'), + title: Text(AppLocalizations.of(context)!.howMuchSpend), content: TextField( autofocus: true, - decoration: const InputDecoration( - border: OutlineInputBorder(), - labelText: 'Amount', + decoration: InputDecoration( + border: const OutlineInputBorder(), + labelText: AppLocalizations.of(context)!.amount, ), keyboardType: const TextInputType.numberWithOptions(signed: true), onChanged: (s) => amount.value = s, @@ -24,11 +25,11 @@ Widget _voucherSpendDialog(BuildContext context) { actions: [ TextButton( onPressed: () => Navigator.pop(context, null), - child: const Text('Cancel'), + child: Text(AppLocalizations.of(context)!.cancel), ), TextButton( onPressed: submit, - child: const Text('OK'), + child: Text(AppLocalizations.of(context)!.ok), ), ], ); diff --git a/lib/vouchers/menu/vouchers_menu.dart b/lib/vouchers/menu/vouchers_menu.dart index 730bddd..23845dd 100644 --- a/lib/vouchers/menu/vouchers_menu.dart +++ b/lib/vouchers/menu/vouchers_menu.dart @@ -1,26 +1,32 @@ import 'package:flutter/material.dart'; import 'package:functional_widget_annotation/functional_widget_annotation.dart'; +import 'package:flutter_gen/gen_l10n/app_localizations.dart'; part 'vouchers_menu.g.dart'; enum VouchersMenuAction { - import(label: "Import"), - export(label: "Export"), - authentication( - label: "App lock", - hasCheckbox: true, - ), - smartScan( - label: "Smart scan", - hasCheckbox: true, - ); + import, + export, + authentication(hasCheckbox: true), + smartScan(hasCheckbox: true); const VouchersMenuAction({ - required this.label, this.hasCheckbox = false, }); - final String label; + String label(AppLocalizations locales) { + switch (this) { + case VouchersMenuAction.import: + return locales.import; + case VouchersMenuAction.export: + return locales.export; + case VouchersMenuAction.authentication: + return locales.appLock; + case VouchersMenuAction.smartScan: + return locales.smartScan; + } + } + final bool hasCheckbox; } @@ -38,7 +44,7 @@ Widget vouchersMenu({ enabled: !disabled.contains(a), child: Row( children: [ - Text(a.label), + Text(a.label(AppLocalizations.of(context)!)), if (a.hasCheckbox) ...[ const Spacer(), Checkbox( diff --git a/lib/vouchers/models/state.freezed.dart b/lib/vouchers/models/state.freezed.dart index 06e3df9..8f771be 100644 --- a/lib/vouchers/models/state.freezed.dart +++ b/lib/vouchers/models/state.freezed.dart @@ -27,29 +27,32 @@ mixin _$VouchersState { abstract class $VouchersStateCopyWith<$Res> { factory $VouchersStateCopyWith( VouchersState value, $Res Function(VouchersState) then) = - _$VouchersStateCopyWithImpl<$Res>; + _$VouchersStateCopyWithImpl<$Res, VouchersState>; + @useResult $Res call({IList vouchers}); } /// @nodoc -class _$VouchersStateCopyWithImpl<$Res> +class _$VouchersStateCopyWithImpl<$Res, $Val extends VouchersState> implements $VouchersStateCopyWith<$Res> { _$VouchersStateCopyWithImpl(this._value, this._then); - final VouchersState _value; // ignore: unused_field - final $Res Function(VouchersState) _then; + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + @pragma('vm:prefer-inline') @override $Res call({ - Object? vouchers = freezed, + Object? vouchers = null, }) { return _then(_value.copyWith( - vouchers: vouchers == freezed + vouchers: null == vouchers ? _value.vouchers : vouchers // ignore: cast_nullable_to_non_nullable as IList, - )); + ) as $Val); } } @@ -60,26 +63,25 @@ abstract class _$$_VouchersStateCopyWith<$Res> _$_VouchersState value, $Res Function(_$_VouchersState) then) = __$$_VouchersStateCopyWithImpl<$Res>; @override + @useResult $Res call({IList vouchers}); } /// @nodoc class __$$_VouchersStateCopyWithImpl<$Res> - extends _$VouchersStateCopyWithImpl<$Res> + extends _$VouchersStateCopyWithImpl<$Res, _$_VouchersState> implements _$$_VouchersStateCopyWith<$Res> { __$$_VouchersStateCopyWithImpl( _$_VouchersState _value, $Res Function(_$_VouchersState) _then) - : super(_value, (v) => _then(v as _$_VouchersState)); - - @override - _$_VouchersState get _value => super._value as _$_VouchersState; + : super(_value, _then); + @pragma('vm:prefer-inline') @override $Res call({ - Object? vouchers = freezed, + Object? vouchers = null, }) { return _then(_$_VouchersState( - vouchers == freezed + null == vouchers ? _value.vouchers : vouchers // ignore: cast_nullable_to_non_nullable as IList, @@ -114,6 +116,7 @@ class _$_VouchersState extends _VouchersState { @JsonKey(ignore: true) @override + @pragma('vm:prefer-inline') _$$_VouchersStateCopyWith<_$_VouchersState> get copyWith => __$$_VouchersStateCopyWithImpl<_$_VouchersState>(this, _$identity); } diff --git a/lib/vouchers/models/voucher.freezed.dart b/lib/vouchers/models/voucher.freezed.dart index fbe8715..c1f90dc 100644 --- a/lib/vouchers/models/voucher.freezed.dart +++ b/lib/vouchers/models/voucher.freezed.dart @@ -39,7 +39,8 @@ mixin _$Voucher { /// @nodoc abstract class $VoucherCopyWith<$Res> { factory $VoucherCopyWith(Voucher value, $Res Function(Voucher) then) = - _$VoucherCopyWithImpl<$Res>; + _$VoucherCopyWithImpl<$Res, Voucher>; + @useResult $Res call( {O.Option uuid, String description, @@ -54,68 +55,71 @@ abstract class $VoucherCopyWith<$Res> { } /// @nodoc -class _$VoucherCopyWithImpl<$Res> implements $VoucherCopyWith<$Res> { +class _$VoucherCopyWithImpl<$Res, $Val extends Voucher> + implements $VoucherCopyWith<$Res> { _$VoucherCopyWithImpl(this._value, this._then); - final Voucher _value; // ignore: unused_field - final $Res Function(Voucher) _then; + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + @pragma('vm:prefer-inline') @override $Res call({ - Object? uuid = freezed, - Object? description = freezed, - Object? code = freezed, - Object? codeType = freezed, - Object? expires = freezed, - Object? removeOnceExpired = freezed, - Object? balance = freezed, - Object? balanceMilliunits = freezed, - Object? notes = freezed, - Object? color = freezed, + Object? uuid = null, + Object? description = null, + Object? code = null, + Object? codeType = null, + Object? expires = null, + Object? removeOnceExpired = null, + Object? balance = null, + Object? balanceMilliunits = null, + Object? notes = null, + Object? color = null, }) { return _then(_value.copyWith( - uuid: uuid == freezed + uuid: null == uuid ? _value.uuid : uuid // ignore: cast_nullable_to_non_nullable as O.Option, - description: description == freezed + description: null == description ? _value.description : description // ignore: cast_nullable_to_non_nullable as String, - code: code == freezed + code: null == code ? _value.code : code // ignore: cast_nullable_to_non_nullable as O.Option, - codeType: codeType == freezed + codeType: null == codeType ? _value.codeType : codeType // ignore: cast_nullable_to_non_nullable as VoucherCodeType, - expires: expires == freezed + expires: null == expires ? _value.expires : expires // ignore: cast_nullable_to_non_nullable as O.Option, - removeOnceExpired: removeOnceExpired == freezed + removeOnceExpired: null == removeOnceExpired ? _value.removeOnceExpired : removeOnceExpired // ignore: cast_nullable_to_non_nullable as bool, - balance: balance == freezed + balance: null == balance ? _value.balance : balance // ignore: cast_nullable_to_non_nullable as O.Option, - balanceMilliunits: balanceMilliunits == freezed + balanceMilliunits: null == balanceMilliunits ? _value.balanceMilliunits : balanceMilliunits // ignore: cast_nullable_to_non_nullable as O.Option, - notes: notes == freezed + notes: null == notes ? _value.notes : notes // ignore: cast_nullable_to_non_nullable as String, - color: color == freezed + color: null == color ? _value.color : color // ignore: cast_nullable_to_non_nullable as VoucherColor, - )); + ) as $Val); } } @@ -125,6 +129,7 @@ abstract class _$$_VoucherCopyWith<$Res> implements $VoucherCopyWith<$Res> { _$_Voucher value, $Res Function(_$_Voucher) then) = __$$_VoucherCopyWithImpl<$Res>; @override + @useResult $Res call( {O.Option uuid, String description, @@ -139,65 +144,64 @@ abstract class _$$_VoucherCopyWith<$Res> implements $VoucherCopyWith<$Res> { } /// @nodoc -class __$$_VoucherCopyWithImpl<$Res> extends _$VoucherCopyWithImpl<$Res> +class __$$_VoucherCopyWithImpl<$Res> + extends _$VoucherCopyWithImpl<$Res, _$_Voucher> implements _$$_VoucherCopyWith<$Res> { __$$_VoucherCopyWithImpl(_$_Voucher _value, $Res Function(_$_Voucher) _then) - : super(_value, (v) => _then(v as _$_Voucher)); - - @override - _$_Voucher get _value => super._value as _$_Voucher; + : super(_value, _then); + @pragma('vm:prefer-inline') @override $Res call({ - Object? uuid = freezed, - Object? description = freezed, - Object? code = freezed, - Object? codeType = freezed, - Object? expires = freezed, - Object? removeOnceExpired = freezed, - Object? balance = freezed, - Object? balanceMilliunits = freezed, - Object? notes = freezed, - Object? color = freezed, + Object? uuid = null, + Object? description = null, + Object? code = null, + Object? codeType = null, + Object? expires = null, + Object? removeOnceExpired = null, + Object? balance = null, + Object? balanceMilliunits = null, + Object? notes = null, + Object? color = null, }) { return _then(_$_Voucher( - uuid: uuid == freezed + uuid: null == uuid ? _value.uuid : uuid // ignore: cast_nullable_to_non_nullable as O.Option, - description: description == freezed + description: null == description ? _value.description : description // ignore: cast_nullable_to_non_nullable as String, - code: code == freezed + code: null == code ? _value.code : code // ignore: cast_nullable_to_non_nullable as O.Option, - codeType: codeType == freezed + codeType: null == codeType ? _value.codeType : codeType // ignore: cast_nullable_to_non_nullable as VoucherCodeType, - expires: expires == freezed + expires: null == expires ? _value.expires : expires // ignore: cast_nullable_to_non_nullable as O.Option, - removeOnceExpired: removeOnceExpired == freezed + removeOnceExpired: null == removeOnceExpired ? _value.removeOnceExpired : removeOnceExpired // ignore: cast_nullable_to_non_nullable as bool, - balance: balance == freezed + balance: null == balance ? _value.balance : balance // ignore: cast_nullable_to_non_nullable as O.Option, - balanceMilliunits: balanceMilliunits == freezed + balanceMilliunits: null == balanceMilliunits ? _value.balanceMilliunits : balanceMilliunits // ignore: cast_nullable_to_non_nullable as O.Option, - notes: notes == freezed + notes: null == notes ? _value.notes : notes // ignore: cast_nullable_to_non_nullable as String, - color: color == freezed + color: null == color ? _value.color : color // ignore: cast_nullable_to_non_nullable as VoucherColor, @@ -265,38 +269,40 @@ class _$_Voucher extends _Voucher { return identical(this, other) || (other.runtimeType == runtimeType && other is _$_Voucher && - const DeepCollectionEquality().equals(other.uuid, uuid) && - const DeepCollectionEquality() - .equals(other.description, description) && - const DeepCollectionEquality().equals(other.code, code) && - const DeepCollectionEquality().equals(other.codeType, codeType) && - const DeepCollectionEquality().equals(other.expires, expires) && - const DeepCollectionEquality() - .equals(other.removeOnceExpired, removeOnceExpired) && - const DeepCollectionEquality().equals(other.balance, balance) && - const DeepCollectionEquality() - .equals(other.balanceMilliunits, balanceMilliunits) && - const DeepCollectionEquality().equals(other.notes, notes) && - const DeepCollectionEquality().equals(other.color, color)); + (identical(other.uuid, uuid) || other.uuid == uuid) && + (identical(other.description, description) || + other.description == description) && + (identical(other.code, code) || other.code == code) && + (identical(other.codeType, codeType) || + other.codeType == codeType) && + (identical(other.expires, expires) || other.expires == expires) && + (identical(other.removeOnceExpired, removeOnceExpired) || + other.removeOnceExpired == removeOnceExpired) && + (identical(other.balance, balance) || other.balance == balance) && + (identical(other.balanceMilliunits, balanceMilliunits) || + other.balanceMilliunits == balanceMilliunits) && + (identical(other.notes, notes) || other.notes == notes) && + (identical(other.color, color) || other.color == color)); } @JsonKey(ignore: true) @override int get hashCode => Object.hash( runtimeType, - const DeepCollectionEquality().hash(uuid), - const DeepCollectionEquality().hash(description), - const DeepCollectionEquality().hash(code), - const DeepCollectionEquality().hash(codeType), - const DeepCollectionEquality().hash(expires), - const DeepCollectionEquality().hash(removeOnceExpired), - const DeepCollectionEquality().hash(balance), - const DeepCollectionEquality().hash(balanceMilliunits), - const DeepCollectionEquality().hash(notes), - const DeepCollectionEquality().hash(color)); + uuid, + description, + code, + codeType, + expires, + removeOnceExpired, + balance, + balanceMilliunits, + notes, + color); @JsonKey(ignore: true) @override + @pragma('vm:prefer-inline') _$$_VoucherCopyWith<_$_Voucher> get copyWith => __$$_VoucherCopyWithImpl<_$_Voucher>(this, _$identity); diff --git a/lib/vouchers/vouchers_screen.dart b/lib/vouchers/vouchers_screen.dart index 31296aa..9e1d4d1 100644 --- a/lib/vouchers/vouchers_screen.dart +++ b/lib/vouchers/vouchers_screen.dart @@ -9,12 +9,13 @@ import 'package:vouchervault/lib/navigator.dart'; import 'package:vouchervault/shared/scaffold/scaffold.dart'; import 'package:vouchervault/voucher_form/voucher_form.dart'; import 'package:vouchervault/vouchers/vouchers.dart'; +import 'package:flutter_gen/gen_l10n/app_localizations.dart'; part 'vouchers_screen.g.dart'; @swidget Widget _vouchersScreen(BuildContext context) => AppScaffold( - title: 'Vouchers', + title: AppLocalizations.of(context)!.vouchers, actions: const [VouchersMenuContainer()], slivers: [ SliverPadding( diff --git a/pubspec.lock b/pubspec.lock index 245c5b9..91781e6 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -133,28 +133,28 @@ packages: name: camera_android url: "https://pub.dartlang.org" source: hosted - version: "0.10.0+4" + version: "0.10.1" camera_avfoundation: dependency: transitive description: name: camera_avfoundation url: "https://pub.dartlang.org" source: hosted - version: "0.9.8+6" + version: "0.9.9" camera_platform_interface: dependency: transitive description: name: camera_platform_interface url: "https://pub.dartlang.org" source: hosted - version: "2.3.1" + version: "2.3.2" camera_web: dependency: transitive description: name: camera_web url: "https://pub.dartlang.org" source: hosted - version: "0.3.0+1" + version: "0.3.1" characters: dependency: transitive description: @@ -280,7 +280,7 @@ packages: name: file_picker url: "https://pub.dartlang.org" source: hosted - version: "5.2.3" + version: "5.2.4" fixnum: dependency: transitive description: @@ -361,7 +361,7 @@ packages: name: fluttertoast url: "https://pub.dartlang.org" source: hosted - version: "8.1.1" + version: "8.1.2" form_builder_validators: dependency: "direct main" description: diff --git a/pubspec.yaml b/pubspec.yaml index 73c6c66..c500843 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,5 +1,5 @@ name: vouchervault -description: A new Flutter project. +description: An app for storing vouchers and loyalty cards publish_to: "none" version: 1.2.0 @@ -55,6 +55,7 @@ dev_dependencies: flutter: uses-material-design: true + generate: true fonts: - family: Alegreya Sans