feat: add card PIN management and card renewal to child wallet
- Add set PIN / change PIN multi-step flow (4-digit card PIN + 6-digit SCA PIN) with Treezor PCI DSS SCA proof generation - Add unblock PIN for blocked cards after failed attempts - Add renew card with SCA proof (same as wallet creation) - Show menu options conditionally based on hasCardPin and isPinBlocked flags - Make ScaPinView configurable with pinLength parameter (default 6) - Add hasCardPin to ChildProfileEntity and isPinBlocked to WalletCardEntity - Add EN/ES localizations for all new screens and messages
This commit is contained in:
@@ -15,6 +15,7 @@ class ScaPinView extends StatelessWidget {
|
||||
final VoidCallback onSubmit;
|
||||
final String clearPinText;
|
||||
final String? errorMessage;
|
||||
final int pinLength;
|
||||
|
||||
const ScaPinView({
|
||||
super.key,
|
||||
@@ -30,6 +31,7 @@ class ScaPinView extends StatelessWidget {
|
||||
required this.onSubmit,
|
||||
required this.clearPinText,
|
||||
this.errorMessage,
|
||||
this.pinLength = 6,
|
||||
});
|
||||
|
||||
@override
|
||||
@@ -49,7 +51,7 @@ class ScaPinView extends StatelessWidget {
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
const SizedBox(width: 44),
|
||||
_PinDots(length: pin.length, max: 6),
|
||||
_PinDots(length: pin.length, max: pinLength),
|
||||
const SizedBox(width: 12),
|
||||
SizedBox(
|
||||
width: 44,
|
||||
|
||||
@@ -8,3 +8,5 @@ export 'src/features/limits/limits_builder.dart';
|
||||
export 'src/features/goals/goals_builder.dart';
|
||||
export 'src/features/extract/extract_builder.dart';
|
||||
export 'src/features/edit_child_profile/edit_child_profile_builder.dart';
|
||||
export 'src/features/card_pin/card_pin_builder.dart';
|
||||
export 'src/features/card_pin/card_pin_view_state.dart';
|
||||
|
||||
41
modules/home/lib/src/features/card_pin/card_pin_builder.dart
Normal file
41
modules/home/lib/src/features/card_pin/card_pin_builder.dart
Normal file
@@ -0,0 +1,41 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get_it/get_it.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:navigation/navigation.dart';
|
||||
|
||||
import 'card_pin_screen.dart';
|
||||
import 'card_pin_view_state.dart';
|
||||
|
||||
class SetCardPinBuilder {
|
||||
const SetCardPinBuilder();
|
||||
|
||||
Page<void> buildPage(BuildContext context, GoRouterState state) {
|
||||
final childWalletId = state.pathParameters['childWalletId'] ?? '';
|
||||
final navigationContract = GetIt.I<NavigationContract>();
|
||||
return MaterialPage(
|
||||
key: state.pageKey,
|
||||
child: CardPinScreen(
|
||||
childId: childWalletId,
|
||||
navigation: navigationContract,
|
||||
mode: CardPinMode.set,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class ChangeCardPinBuilder {
|
||||
const ChangeCardPinBuilder();
|
||||
|
||||
Page<void> buildPage(BuildContext context, GoRouterState state) {
|
||||
final childWalletId = state.pathParameters['childWalletId'] ?? '';
|
||||
final navigationContract = GetIt.I<NavigationContract>();
|
||||
return MaterialPage(
|
||||
key: state.pageKey,
|
||||
child: CardPinScreen(
|
||||
childId: childWalletId,
|
||||
navigation: navigationContract,
|
||||
mode: CardPinMode.change,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
136
modules/home/lib/src/features/card_pin/card_pin_screen.dart
Normal file
136
modules/home/lib/src/features/card_pin/card_pin_screen.dart
Normal file
@@ -0,0 +1,136 @@
|
||||
import 'package:auth/auth.dart';
|
||||
import 'package:design_system/design_system.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:navigation/navigation.dart';
|
||||
import 'package:sf_localizations/sf_localizations.dart';
|
||||
|
||||
import 'card_pin_view_model.dart';
|
||||
import 'card_pin_view_state.dart';
|
||||
|
||||
class CardPinScreen extends ConsumerWidget {
|
||||
final String childId;
|
||||
final NavigationContract navigation;
|
||||
final CardPinMode mode;
|
||||
|
||||
const CardPinScreen({
|
||||
super.key,
|
||||
required this.childId,
|
||||
required this.navigation,
|
||||
required this.mode,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final theme = ref.watch(themePortProvider);
|
||||
final arg = (childId, mode);
|
||||
final viewState = ref.watch(cardPinViewModelProvider(arg));
|
||||
final viewModel = ref.read(cardPinViewModelProvider(arg).notifier);
|
||||
|
||||
ref.listen(cardPinViewModelProvider(arg), (prev, next) {
|
||||
if (next.success && !(prev?.success ?? false)) {
|
||||
showTopSnackbar(
|
||||
context,
|
||||
message: context.translate(I18n.cardPinSuccess),
|
||||
type: MessageType.success,
|
||||
);
|
||||
navigation.goBack();
|
||||
return;
|
||||
}
|
||||
if (next.errorMessage.isNotEmpty &&
|
||||
next.errorMessage != (prev?.errorMessage ?? '')) {
|
||||
if (next.errorMessage == 'cardPinMismatch') {
|
||||
showTopSnackbar(
|
||||
context,
|
||||
message: context.translate(I18n.cardPinMismatch),
|
||||
type: MessageType.error,
|
||||
);
|
||||
} else {
|
||||
showTopSnackbar(
|
||||
context,
|
||||
message: context.translate(I18n.cardPinError),
|
||||
type: MessageType.error,
|
||||
);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
if (viewState.isLoading) {
|
||||
return const Scaffold(body: Center(child: AppLoadingIndicator()));
|
||||
}
|
||||
|
||||
if (viewState.errorMessage.isNotEmpty && viewState.childProfile == null) {
|
||||
return Scaffold(
|
||||
body: Center(child: Text('Error: ${viewState.errorMessage}')),
|
||||
);
|
||||
}
|
||||
|
||||
final pinLength = viewState.step == CardPinStep.scaPin ? 6 : 4;
|
||||
final stepTitle = _stepTitle(context, viewState.step);
|
||||
final currentPin = switch (viewState.step) {
|
||||
CardPinStep.currentPin => viewState.currentPin,
|
||||
CardPinStep.newPin => viewState.newPin,
|
||||
CardPinStep.confirmPin => viewState.confirmPin,
|
||||
CardPinStep.scaPin => viewState.scaPin,
|
||||
};
|
||||
|
||||
return Scaffold(
|
||||
backgroundColor: theme.getColorFor(ThemeCode.backgroundSecondary),
|
||||
appBar: AppBar(
|
||||
backgroundColor: theme.getColorFor(ThemeCode.backgroundSecondary),
|
||||
leading: IconButton(
|
||||
icon: Icon(
|
||||
Icons.arrow_back,
|
||||
color: theme.getColorFor(ThemeCode.textPrimary),
|
||||
),
|
||||
onPressed: () {
|
||||
if (viewModel.isFirstStep) {
|
||||
navigation.goBack();
|
||||
} else {
|
||||
viewModel.goBack();
|
||||
}
|
||||
},
|
||||
),
|
||||
),
|
||||
body: Column(
|
||||
children: [
|
||||
Expanded(
|
||||
child: SingleChildScrollView(
|
||||
child: ScaPinView(
|
||||
title: stepTitle,
|
||||
pin: currentPin,
|
||||
pinLength: pinLength,
|
||||
isProcessing: viewState.isSigning || viewState.isSubmitting,
|
||||
processingText: context.translate(I18n.scaSigning),
|
||||
canSubmit: viewModel.canSubmitStep,
|
||||
submitText: viewState.step == CardPinStep.scaPin
|
||||
? context.translate(I18n.scaConnect)
|
||||
: context.translate(I18n.cardPinNext),
|
||||
clearPinText: context.translate(I18n.scaClearPin),
|
||||
onDigitPressed: viewModel.onDigitPressed,
|
||||
onBackspacePressed: viewModel.onBackspacePressed,
|
||||
onClearPin: viewModel.onClearPin,
|
||||
onSubmit: viewModel.onStepSubmit,
|
||||
),
|
||||
),
|
||||
),
|
||||
SafeArea(
|
||||
child: TextButton(
|
||||
onPressed: () => navigation.goBack(),
|
||||
child: Text(context.translate(I18n.cancel)),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
String _stepTitle(BuildContext context, CardPinStep step) {
|
||||
return switch (step) {
|
||||
CardPinStep.currentPin => context.translate(I18n.cardPinCurrentStep),
|
||||
CardPinStep.newPin => context.translate(I18n.cardPinNewStep),
|
||||
CardPinStep.confirmPin => context.translate(I18n.cardPinConfirmStep),
|
||||
CardPinStep.scaPin => context.translate(I18n.cardPinScaStep),
|
||||
};
|
||||
}
|
||||
}
|
||||
257
modules/home/lib/src/features/card_pin/card_pin_view_model.dart
Normal file
257
modules/home/lib/src/features/card_pin/card_pin_view_model.dart
Normal file
@@ -0,0 +1,257 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:get_it/get_it.dart';
|
||||
import 'package:sca_treezor/sca_treezor.dart';
|
||||
import 'package:sf_shared/sf_shared.dart';
|
||||
|
||||
import '../child_wallet/child_data_provider.dart';
|
||||
import 'card_pin_view_state.dart';
|
||||
|
||||
final cardPinViewModelProvider = NotifierProvider.autoDispose
|
||||
.family<CardPinViewModel, CardPinViewState, (String, CardPinMode)>(
|
||||
CardPinViewModel.new,
|
||||
);
|
||||
|
||||
class CardPinViewModel extends Notifier<CardPinViewState> {
|
||||
final (String, CardPinMode) arg;
|
||||
CardPinViewModel(this.arg);
|
||||
|
||||
String get childId => arg.$1;
|
||||
CardPinMode get mode => arg.$2;
|
||||
|
||||
late final TreezorWalletConnectionService _connectionService;
|
||||
late final TreezorWalletSignatureService _signatureService;
|
||||
|
||||
@override
|
||||
CardPinViewState build() {
|
||||
debugPrint('[CardPIN] build() mode=$mode childId=$childId');
|
||||
_connectionService = GetIt.I<TreezorWalletConnectionService>();
|
||||
_signatureService = GetIt.I<TreezorWalletSignatureService>();
|
||||
|
||||
ref.listen(childDataProvider(childId), (prev, next) {
|
||||
state = state.copyWith(
|
||||
isLoading: next.isLoading,
|
||||
childProfile: next.childProfile,
|
||||
childWallet: next.childWallet,
|
||||
device: next.device,
|
||||
errorMessage: next.errorMessage,
|
||||
);
|
||||
if (next.childProfile != null &&
|
||||
prev?.childProfile == null &&
|
||||
state.cardId.isEmpty) {
|
||||
_loadCard(next.childProfile!.walletId);
|
||||
}
|
||||
});
|
||||
|
||||
final data = ref.read(childDataProvider(childId));
|
||||
final initialStep =
|
||||
mode == CardPinMode.change ? CardPinStep.currentPin : CardPinStep.newPin;
|
||||
|
||||
final initialState = CardPinViewState(
|
||||
isLoading: data.isLoading,
|
||||
childProfile: data.childProfile,
|
||||
childWallet: data.childWallet,
|
||||
device: data.device,
|
||||
errorMessage: data.errorMessage,
|
||||
step: initialStep,
|
||||
);
|
||||
|
||||
if (data.childProfile != null) {
|
||||
Future.microtask(() => _loadCard(data.childProfile!.walletId));
|
||||
}
|
||||
|
||||
return initialState;
|
||||
}
|
||||
|
||||
Future<void> _loadCard(String walletId) async {
|
||||
debugPrint('[CardPIN] _loadCard walletId=$walletId');
|
||||
try {
|
||||
final card =
|
||||
await ref.read(treezorRepositoryProvider).getCard(walletId: walletId);
|
||||
if (!ref.mounted) return;
|
||||
debugPrint('[CardPIN] _loadCard cardId=${card.cardId} status=${card.status}');
|
||||
state = state.copyWith(cardId: card.cardId.toString());
|
||||
} catch (e) {
|
||||
debugPrint('[CardPIN] _loadCard error: $e');
|
||||
}
|
||||
}
|
||||
|
||||
String _currentStepPin() => switch (state.step) {
|
||||
CardPinStep.currentPin => state.currentPin,
|
||||
CardPinStep.newPin => state.newPin,
|
||||
CardPinStep.confirmPin => state.confirmPin,
|
||||
CardPinStep.scaPin => state.scaPin,
|
||||
};
|
||||
|
||||
int get _currentStepMaxLength =>
|
||||
state.step == CardPinStep.scaPin ? 6 : 4;
|
||||
|
||||
void onDigitPressed(String digit) {
|
||||
final current = _currentStepPin();
|
||||
if (current.length >= _currentStepMaxLength) return;
|
||||
final updated = current + digit;
|
||||
state = _updateStepPin(updated).copyWith(errorMessage: '');
|
||||
}
|
||||
|
||||
void onBackspacePressed() {
|
||||
final current = _currentStepPin();
|
||||
if (current.isEmpty) return;
|
||||
state = _updateStepPin(current.substring(0, current.length - 1));
|
||||
}
|
||||
|
||||
void onClearPin() {
|
||||
state = _updateStepPin('');
|
||||
}
|
||||
|
||||
CardPinViewState _updateStepPin(String value) => switch (state.step) {
|
||||
CardPinStep.currentPin => state.copyWith(currentPin: value),
|
||||
CardPinStep.newPin => state.copyWith(newPin: value),
|
||||
CardPinStep.confirmPin => state.copyWith(confirmPin: value),
|
||||
CardPinStep.scaPin => state.copyWith(scaPin: value),
|
||||
};
|
||||
|
||||
bool get canSubmitStep => _currentStepPin().length == _currentStepMaxLength;
|
||||
|
||||
void onStepSubmit() {
|
||||
debugPrint('[CardPIN] onStepSubmit step=${state.step}');
|
||||
switch (state.step) {
|
||||
case CardPinStep.currentPin:
|
||||
debugPrint('[CardPIN] currentPin entered, advancing to newPin');
|
||||
state = state.copyWith(step: CardPinStep.newPin, errorMessage: '');
|
||||
case CardPinStep.newPin:
|
||||
debugPrint('[CardPIN] newPin entered, advancing to confirmPin');
|
||||
state = state.copyWith(step: CardPinStep.confirmPin, errorMessage: '');
|
||||
case CardPinStep.confirmPin:
|
||||
if (state.confirmPin != state.newPin) {
|
||||
debugPrint('[CardPIN] confirmPin MISMATCH');
|
||||
state = state.copyWith(
|
||||
confirmPin: '',
|
||||
errorMessage: 'cardPinMismatch',
|
||||
);
|
||||
return;
|
||||
}
|
||||
debugPrint('[CardPIN] confirmPin matches, advancing to scaPin');
|
||||
state = state.copyWith(step: CardPinStep.scaPin, errorMessage: '');
|
||||
case CardPinStep.scaPin:
|
||||
debugPrint('[CardPIN] scaPin entered, submitting...');
|
||||
_submit();
|
||||
}
|
||||
}
|
||||
|
||||
void goBack() {
|
||||
switch (state.step) {
|
||||
case CardPinStep.currentPin:
|
||||
break;
|
||||
case CardPinStep.newPin:
|
||||
if (mode == CardPinMode.change) {
|
||||
state = state.copyWith(step: CardPinStep.currentPin, newPin: '');
|
||||
}
|
||||
case CardPinStep.confirmPin:
|
||||
state = state.copyWith(step: CardPinStep.newPin, confirmPin: '');
|
||||
case CardPinStep.scaPin:
|
||||
state = state.copyWith(step: CardPinStep.confirmPin, scaPin: '');
|
||||
}
|
||||
}
|
||||
|
||||
bool get isFirstStep =>
|
||||
(mode == CardPinMode.set && state.step == CardPinStep.newPin) ||
|
||||
(mode == CardPinMode.change && state.step == CardPinStep.currentPin);
|
||||
|
||||
Future<void> _submit() async {
|
||||
final cardId = state.cardId;
|
||||
final walletId = state.childProfile?.walletId;
|
||||
final userId = state.childProfile?.treezorUserId;
|
||||
debugPrint('[CardPIN] _submit mode=$mode cardId=$cardId walletId=$walletId userId=$userId');
|
||||
if (cardId.isEmpty || walletId == null) {
|
||||
debugPrint('[CardPIN] _submit aborted: cardId or walletId missing');
|
||||
return;
|
||||
}
|
||||
|
||||
state = state.copyWith(isSigning: true, errorMessage: '');
|
||||
|
||||
try {
|
||||
debugPrint('[CardPIN] connecting with SCA PIN...');
|
||||
await _connectionService.connectWithPin(loginPin: state.scaPin);
|
||||
if (!ref.mounted) return;
|
||||
debugPrint('[CardPIN] SCA connection successful');
|
||||
|
||||
final String scaProof;
|
||||
if (mode == CardPinMode.set) {
|
||||
final url =
|
||||
'https://savefamily.preprod.secure.treezor.co/cards/$cardId/setPIN';
|
||||
final scaInput = jsonEncode({
|
||||
'url': url,
|
||||
'body': {
|
||||
'newPIN': state.newPin,
|
||||
'confirmPIN': state.confirmPin,
|
||||
'userId': userId,
|
||||
},
|
||||
});
|
||||
debugPrint('[CardPIN] setPIN scaInput: $scaInput');
|
||||
scaProof = await _signatureService.generateJwsWithPin(
|
||||
message: '',
|
||||
input: scaInput,
|
||||
pin: state.scaPin,
|
||||
);
|
||||
debugPrint('[CardPIN] setPIN scaProof: $scaProof');
|
||||
} else {
|
||||
final url =
|
||||
'https://savefamily.preprod.secure.treezor.co/cards/$cardId/ChangePIN';
|
||||
final scaInput = jsonEncode({
|
||||
'url': url,
|
||||
'body': {
|
||||
'currentPIN': state.currentPin,
|
||||
'newPIN': state.newPin,
|
||||
'confirmPIN': state.confirmPin,
|
||||
'userId': userId,
|
||||
},
|
||||
});
|
||||
debugPrint('[CardPIN] changePIN scaInput: $scaInput');
|
||||
scaProof = await _signatureService.generateJwsWithPin(
|
||||
message: '',
|
||||
input: scaInput,
|
||||
pin: state.scaPin,
|
||||
);
|
||||
debugPrint('[CardPIN] changePIN scaProof: $scaProof');
|
||||
}
|
||||
|
||||
if (!ref.mounted) return;
|
||||
state = state.copyWith(isSigning: false, isSubmitting: true, scaPin: '');
|
||||
|
||||
if (mode == CardPinMode.set) {
|
||||
debugPrint('[CardPIN] calling backend setCardPin walletId=$walletId');
|
||||
await ref.read(treezorRepositoryProvider).setCardPin(
|
||||
walletId: walletId,
|
||||
newPin: state.newPin,
|
||||
confirmPin: state.confirmPin,
|
||||
scaProof: scaProof,
|
||||
);
|
||||
debugPrint('[CardPIN] setCardPin SUCCESS');
|
||||
} else {
|
||||
debugPrint('[CardPIN] calling backend changeCardPin walletId=$walletId');
|
||||
await ref.read(treezorRepositoryProvider).changeCardPin(
|
||||
walletId: walletId,
|
||||
currentPin: state.currentPin,
|
||||
newPin: state.newPin,
|
||||
confirmPin: state.confirmPin,
|
||||
scaProof: scaProof,
|
||||
);
|
||||
debugPrint('[CardPIN] changeCardPin SUCCESS');
|
||||
}
|
||||
|
||||
if (!ref.mounted) return;
|
||||
state = state.copyWith(isSubmitting: false, success: true);
|
||||
} catch (e) {
|
||||
debugPrint('[CardPIN] _submit ERROR: $e');
|
||||
if (!ref.mounted) return;
|
||||
state = state.copyWith(
|
||||
isSigning: false,
|
||||
isSubmitting: false,
|
||||
scaPin: '',
|
||||
errorMessage: e.toString(),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
import 'package:sf_shared/sf_shared.dart';
|
||||
|
||||
part 'card_pin_view_state.freezed.dart';
|
||||
|
||||
enum CardPinMode { set, change }
|
||||
|
||||
enum CardPinStep { currentPin, newPin, confirmPin, scaPin }
|
||||
|
||||
@freezed
|
||||
abstract class CardPinViewState with _$CardPinViewState {
|
||||
const factory CardPinViewState({
|
||||
@Default(true) bool isLoading,
|
||||
ChildProfileEntity? childProfile,
|
||||
ChildWalletEntity? childWallet,
|
||||
DeviceEntity? device,
|
||||
@Default('') String cardId,
|
||||
@Default('') String currentPin,
|
||||
@Default('') String newPin,
|
||||
@Default('') String confirmPin,
|
||||
@Default('') String scaPin,
|
||||
@Default(CardPinStep.newPin) CardPinStep step,
|
||||
@Default(false) bool isSigning,
|
||||
@Default(false) bool isSubmitting,
|
||||
@Default(false) bool success,
|
||||
@Default('') String errorMessage,
|
||||
}) = _CardPinViewState;
|
||||
}
|
||||
@@ -0,0 +1,382 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
// coverage:ignore-file
|
||||
// ignore_for_file: type=lint
|
||||
// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark
|
||||
|
||||
part of 'card_pin_view_state.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// FreezedGenerator
|
||||
// **************************************************************************
|
||||
|
||||
// dart format off
|
||||
T _$identity<T>(T value) => value;
|
||||
/// @nodoc
|
||||
mixin _$CardPinViewState {
|
||||
|
||||
bool get isLoading; ChildProfileEntity? get childProfile; ChildWalletEntity? get childWallet; DeviceEntity? get device; String get cardId; String get currentPin; String get newPin; String get confirmPin; String get scaPin; CardPinStep get step; bool get isSigning; bool get isSubmitting; bool get success; String get errorMessage;
|
||||
/// Create a copy of CardPinViewState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@pragma('vm:prefer-inline')
|
||||
$CardPinViewStateCopyWith<CardPinViewState> get copyWith => _$CardPinViewStateCopyWithImpl<CardPinViewState>(this as CardPinViewState, _$identity);
|
||||
|
||||
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is CardPinViewState&&(identical(other.isLoading, isLoading) || other.isLoading == isLoading)&&(identical(other.childProfile, childProfile) || other.childProfile == childProfile)&&(identical(other.childWallet, childWallet) || other.childWallet == childWallet)&&(identical(other.device, device) || other.device == device)&&(identical(other.cardId, cardId) || other.cardId == cardId)&&(identical(other.currentPin, currentPin) || other.currentPin == currentPin)&&(identical(other.newPin, newPin) || other.newPin == newPin)&&(identical(other.confirmPin, confirmPin) || other.confirmPin == confirmPin)&&(identical(other.scaPin, scaPin) || other.scaPin == scaPin)&&(identical(other.step, step) || other.step == step)&&(identical(other.isSigning, isSigning) || other.isSigning == isSigning)&&(identical(other.isSubmitting, isSubmitting) || other.isSubmitting == isSubmitting)&&(identical(other.success, success) || other.success == success)&&(identical(other.errorMessage, errorMessage) || other.errorMessage == errorMessage));
|
||||
}
|
||||
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,isLoading,childProfile,childWallet,device,cardId,currentPin,newPin,confirmPin,scaPin,step,isSigning,isSubmitting,success,errorMessage);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'CardPinViewState(isLoading: $isLoading, childProfile: $childProfile, childWallet: $childWallet, device: $device, cardId: $cardId, currentPin: $currentPin, newPin: $newPin, confirmPin: $confirmPin, scaPin: $scaPin, step: $step, isSigning: $isSigning, isSubmitting: $isSubmitting, success: $success, errorMessage: $errorMessage)';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract mixin class $CardPinViewStateCopyWith<$Res> {
|
||||
factory $CardPinViewStateCopyWith(CardPinViewState value, $Res Function(CardPinViewState) _then) = _$CardPinViewStateCopyWithImpl;
|
||||
@useResult
|
||||
$Res call({
|
||||
bool isLoading, ChildProfileEntity? childProfile, ChildWalletEntity? childWallet, DeviceEntity? device, String cardId, String currentPin, String newPin, String confirmPin, String scaPin, CardPinStep step, bool isSigning, bool isSubmitting, bool success, String errorMessage
|
||||
});
|
||||
|
||||
|
||||
$ChildProfileEntityCopyWith<$Res>? get childProfile;$ChildWalletEntityCopyWith<$Res>? get childWallet;$DeviceEntityCopyWith<$Res>? get device;
|
||||
|
||||
}
|
||||
/// @nodoc
|
||||
class _$CardPinViewStateCopyWithImpl<$Res>
|
||||
implements $CardPinViewStateCopyWith<$Res> {
|
||||
_$CardPinViewStateCopyWithImpl(this._self, this._then);
|
||||
|
||||
final CardPinViewState _self;
|
||||
final $Res Function(CardPinViewState) _then;
|
||||
|
||||
/// Create a copy of CardPinViewState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline') @override $Res call({Object? isLoading = null,Object? childProfile = freezed,Object? childWallet = freezed,Object? device = freezed,Object? cardId = null,Object? currentPin = null,Object? newPin = null,Object? confirmPin = null,Object? scaPin = null,Object? step = null,Object? isSigning = null,Object? isSubmitting = null,Object? success = null,Object? errorMessage = null,}) {
|
||||
return _then(_self.copyWith(
|
||||
isLoading: null == isLoading ? _self.isLoading : isLoading // ignore: cast_nullable_to_non_nullable
|
||||
as bool,childProfile: freezed == childProfile ? _self.childProfile : childProfile // ignore: cast_nullable_to_non_nullable
|
||||
as ChildProfileEntity?,childWallet: freezed == childWallet ? _self.childWallet : childWallet // ignore: cast_nullable_to_non_nullable
|
||||
as ChildWalletEntity?,device: freezed == device ? _self.device : device // ignore: cast_nullable_to_non_nullable
|
||||
as DeviceEntity?,cardId: null == cardId ? _self.cardId : cardId // ignore: cast_nullable_to_non_nullable
|
||||
as String,currentPin: null == currentPin ? _self.currentPin : currentPin // ignore: cast_nullable_to_non_nullable
|
||||
as String,newPin: null == newPin ? _self.newPin : newPin // ignore: cast_nullable_to_non_nullable
|
||||
as String,confirmPin: null == confirmPin ? _self.confirmPin : confirmPin // ignore: cast_nullable_to_non_nullable
|
||||
as String,scaPin: null == scaPin ? _self.scaPin : scaPin // ignore: cast_nullable_to_non_nullable
|
||||
as String,step: null == step ? _self.step : step // ignore: cast_nullable_to_non_nullable
|
||||
as CardPinStep,isSigning: null == isSigning ? _self.isSigning : isSigning // ignore: cast_nullable_to_non_nullable
|
||||
as bool,isSubmitting: null == isSubmitting ? _self.isSubmitting : isSubmitting // ignore: cast_nullable_to_non_nullable
|
||||
as bool,success: null == success ? _self.success : success // ignore: cast_nullable_to_non_nullable
|
||||
as bool,errorMessage: null == errorMessage ? _self.errorMessage : errorMessage // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
));
|
||||
}
|
||||
/// Create a copy of CardPinViewState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
$ChildProfileEntityCopyWith<$Res>? get childProfile {
|
||||
if (_self.childProfile == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $ChildProfileEntityCopyWith<$Res>(_self.childProfile!, (value) {
|
||||
return _then(_self.copyWith(childProfile: value));
|
||||
});
|
||||
}/// Create a copy of CardPinViewState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
$ChildWalletEntityCopyWith<$Res>? get childWallet {
|
||||
if (_self.childWallet == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $ChildWalletEntityCopyWith<$Res>(_self.childWallet!, (value) {
|
||||
return _then(_self.copyWith(childWallet: value));
|
||||
});
|
||||
}/// Create a copy of CardPinViewState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
$DeviceEntityCopyWith<$Res>? get device {
|
||||
if (_self.device == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $DeviceEntityCopyWith<$Res>(_self.device!, (value) {
|
||||
return _then(_self.copyWith(device: value));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// Adds pattern-matching-related methods to [CardPinViewState].
|
||||
extension CardPinViewStatePatterns on CardPinViewState {
|
||||
/// A variant of `map` that fallback to returning `orElse`.
|
||||
///
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case final Subclass value:
|
||||
/// return ...;
|
||||
/// case _:
|
||||
/// return orElse();
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult maybeMap<TResult extends Object?>(TResult Function( _CardPinViewState value)? $default,{required TResult orElse(),}){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _CardPinViewState() when $default != null:
|
||||
return $default(_that);case _:
|
||||
return orElse();
|
||||
|
||||
}
|
||||
}
|
||||
/// A `switch`-like method, using callbacks.
|
||||
///
|
||||
/// Callbacks receives the raw object, upcasted.
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case final Subclass value:
|
||||
/// return ...;
|
||||
/// case final Subclass2 value:
|
||||
/// return ...;
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult map<TResult extends Object?>(TResult Function( _CardPinViewState value) $default,){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _CardPinViewState():
|
||||
return $default(_that);case _:
|
||||
throw StateError('Unexpected subclass');
|
||||
|
||||
}
|
||||
}
|
||||
/// A variant of `map` that fallback to returning `null`.
|
||||
///
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case final Subclass value:
|
||||
/// return ...;
|
||||
/// case _:
|
||||
/// return null;
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult? mapOrNull<TResult extends Object?>(TResult? Function( _CardPinViewState value)? $default,){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _CardPinViewState() when $default != null:
|
||||
return $default(_that);case _:
|
||||
return null;
|
||||
|
||||
}
|
||||
}
|
||||
/// A variant of `when` that fallback to an `orElse` callback.
|
||||
///
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case Subclass(:final field):
|
||||
/// return ...;
|
||||
/// case _:
|
||||
/// return orElse();
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( bool isLoading, ChildProfileEntity? childProfile, ChildWalletEntity? childWallet, DeviceEntity? device, String cardId, String currentPin, String newPin, String confirmPin, String scaPin, CardPinStep step, bool isSigning, bool isSubmitting, bool success, String errorMessage)? $default,{required TResult orElse(),}) {final _that = this;
|
||||
switch (_that) {
|
||||
case _CardPinViewState() when $default != null:
|
||||
return $default(_that.isLoading,_that.childProfile,_that.childWallet,_that.device,_that.cardId,_that.currentPin,_that.newPin,_that.confirmPin,_that.scaPin,_that.step,_that.isSigning,_that.isSubmitting,_that.success,_that.errorMessage);case _:
|
||||
return orElse();
|
||||
|
||||
}
|
||||
}
|
||||
/// A `switch`-like method, using callbacks.
|
||||
///
|
||||
/// As opposed to `map`, this offers destructuring.
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case Subclass(:final field):
|
||||
/// return ...;
|
||||
/// case Subclass2(:final field2):
|
||||
/// return ...;
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( bool isLoading, ChildProfileEntity? childProfile, ChildWalletEntity? childWallet, DeviceEntity? device, String cardId, String currentPin, String newPin, String confirmPin, String scaPin, CardPinStep step, bool isSigning, bool isSubmitting, bool success, String errorMessage) $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _CardPinViewState():
|
||||
return $default(_that.isLoading,_that.childProfile,_that.childWallet,_that.device,_that.cardId,_that.currentPin,_that.newPin,_that.confirmPin,_that.scaPin,_that.step,_that.isSigning,_that.isSubmitting,_that.success,_that.errorMessage);case _:
|
||||
throw StateError('Unexpected subclass');
|
||||
|
||||
}
|
||||
}
|
||||
/// A variant of `when` that fallback to returning `null`
|
||||
///
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case Subclass(:final field):
|
||||
/// return ...;
|
||||
/// case _:
|
||||
/// return null;
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( bool isLoading, ChildProfileEntity? childProfile, ChildWalletEntity? childWallet, DeviceEntity? device, String cardId, String currentPin, String newPin, String confirmPin, String scaPin, CardPinStep step, bool isSigning, bool isSubmitting, bool success, String errorMessage)? $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _CardPinViewState() when $default != null:
|
||||
return $default(_that.isLoading,_that.childProfile,_that.childWallet,_that.device,_that.cardId,_that.currentPin,_that.newPin,_that.confirmPin,_that.scaPin,_that.step,_that.isSigning,_that.isSubmitting,_that.success,_that.errorMessage);case _:
|
||||
return null;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
|
||||
|
||||
class _CardPinViewState implements CardPinViewState {
|
||||
const _CardPinViewState({this.isLoading = true, this.childProfile, this.childWallet, this.device, this.cardId = '', this.currentPin = '', this.newPin = '', this.confirmPin = '', this.scaPin = '', this.step = CardPinStep.newPin, this.isSigning = false, this.isSubmitting = false, this.success = false, this.errorMessage = ''});
|
||||
|
||||
|
||||
@override@JsonKey() final bool isLoading;
|
||||
@override final ChildProfileEntity? childProfile;
|
||||
@override final ChildWalletEntity? childWallet;
|
||||
@override final DeviceEntity? device;
|
||||
@override@JsonKey() final String cardId;
|
||||
@override@JsonKey() final String currentPin;
|
||||
@override@JsonKey() final String newPin;
|
||||
@override@JsonKey() final String confirmPin;
|
||||
@override@JsonKey() final String scaPin;
|
||||
@override@JsonKey() final CardPinStep step;
|
||||
@override@JsonKey() final bool isSigning;
|
||||
@override@JsonKey() final bool isSubmitting;
|
||||
@override@JsonKey() final bool success;
|
||||
@override@JsonKey() final String errorMessage;
|
||||
|
||||
/// Create a copy of CardPinViewState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override @JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@pragma('vm:prefer-inline')
|
||||
_$CardPinViewStateCopyWith<_CardPinViewState> get copyWith => __$CardPinViewStateCopyWithImpl<_CardPinViewState>(this, _$identity);
|
||||
|
||||
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is _CardPinViewState&&(identical(other.isLoading, isLoading) || other.isLoading == isLoading)&&(identical(other.childProfile, childProfile) || other.childProfile == childProfile)&&(identical(other.childWallet, childWallet) || other.childWallet == childWallet)&&(identical(other.device, device) || other.device == device)&&(identical(other.cardId, cardId) || other.cardId == cardId)&&(identical(other.currentPin, currentPin) || other.currentPin == currentPin)&&(identical(other.newPin, newPin) || other.newPin == newPin)&&(identical(other.confirmPin, confirmPin) || other.confirmPin == confirmPin)&&(identical(other.scaPin, scaPin) || other.scaPin == scaPin)&&(identical(other.step, step) || other.step == step)&&(identical(other.isSigning, isSigning) || other.isSigning == isSigning)&&(identical(other.isSubmitting, isSubmitting) || other.isSubmitting == isSubmitting)&&(identical(other.success, success) || other.success == success)&&(identical(other.errorMessage, errorMessage) || other.errorMessage == errorMessage));
|
||||
}
|
||||
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,isLoading,childProfile,childWallet,device,cardId,currentPin,newPin,confirmPin,scaPin,step,isSigning,isSubmitting,success,errorMessage);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'CardPinViewState(isLoading: $isLoading, childProfile: $childProfile, childWallet: $childWallet, device: $device, cardId: $cardId, currentPin: $currentPin, newPin: $newPin, confirmPin: $confirmPin, scaPin: $scaPin, step: $step, isSigning: $isSigning, isSubmitting: $isSubmitting, success: $success, errorMessage: $errorMessage)';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract mixin class _$CardPinViewStateCopyWith<$Res> implements $CardPinViewStateCopyWith<$Res> {
|
||||
factory _$CardPinViewStateCopyWith(_CardPinViewState value, $Res Function(_CardPinViewState) _then) = __$CardPinViewStateCopyWithImpl;
|
||||
@override @useResult
|
||||
$Res call({
|
||||
bool isLoading, ChildProfileEntity? childProfile, ChildWalletEntity? childWallet, DeviceEntity? device, String cardId, String currentPin, String newPin, String confirmPin, String scaPin, CardPinStep step, bool isSigning, bool isSubmitting, bool success, String errorMessage
|
||||
});
|
||||
|
||||
|
||||
@override $ChildProfileEntityCopyWith<$Res>? get childProfile;@override $ChildWalletEntityCopyWith<$Res>? get childWallet;@override $DeviceEntityCopyWith<$Res>? get device;
|
||||
|
||||
}
|
||||
/// @nodoc
|
||||
class __$CardPinViewStateCopyWithImpl<$Res>
|
||||
implements _$CardPinViewStateCopyWith<$Res> {
|
||||
__$CardPinViewStateCopyWithImpl(this._self, this._then);
|
||||
|
||||
final _CardPinViewState _self;
|
||||
final $Res Function(_CardPinViewState) _then;
|
||||
|
||||
/// Create a copy of CardPinViewState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override @pragma('vm:prefer-inline') $Res call({Object? isLoading = null,Object? childProfile = freezed,Object? childWallet = freezed,Object? device = freezed,Object? cardId = null,Object? currentPin = null,Object? newPin = null,Object? confirmPin = null,Object? scaPin = null,Object? step = null,Object? isSigning = null,Object? isSubmitting = null,Object? success = null,Object? errorMessage = null,}) {
|
||||
return _then(_CardPinViewState(
|
||||
isLoading: null == isLoading ? _self.isLoading : isLoading // ignore: cast_nullable_to_non_nullable
|
||||
as bool,childProfile: freezed == childProfile ? _self.childProfile : childProfile // ignore: cast_nullable_to_non_nullable
|
||||
as ChildProfileEntity?,childWallet: freezed == childWallet ? _self.childWallet : childWallet // ignore: cast_nullable_to_non_nullable
|
||||
as ChildWalletEntity?,device: freezed == device ? _self.device : device // ignore: cast_nullable_to_non_nullable
|
||||
as DeviceEntity?,cardId: null == cardId ? _self.cardId : cardId // ignore: cast_nullable_to_non_nullable
|
||||
as String,currentPin: null == currentPin ? _self.currentPin : currentPin // ignore: cast_nullable_to_non_nullable
|
||||
as String,newPin: null == newPin ? _self.newPin : newPin // ignore: cast_nullable_to_non_nullable
|
||||
as String,confirmPin: null == confirmPin ? _self.confirmPin : confirmPin // ignore: cast_nullable_to_non_nullable
|
||||
as String,scaPin: null == scaPin ? _self.scaPin : scaPin // ignore: cast_nullable_to_non_nullable
|
||||
as String,step: null == step ? _self.step : step // ignore: cast_nullable_to_non_nullable
|
||||
as CardPinStep,isSigning: null == isSigning ? _self.isSigning : isSigning // ignore: cast_nullable_to_non_nullable
|
||||
as bool,isSubmitting: null == isSubmitting ? _self.isSubmitting : isSubmitting // ignore: cast_nullable_to_non_nullable
|
||||
as bool,success: null == success ? _self.success : success // ignore: cast_nullable_to_non_nullable
|
||||
as bool,errorMessage: null == errorMessage ? _self.errorMessage : errorMessage // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
));
|
||||
}
|
||||
|
||||
/// Create a copy of CardPinViewState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
$ChildProfileEntityCopyWith<$Res>? get childProfile {
|
||||
if (_self.childProfile == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $ChildProfileEntityCopyWith<$Res>(_self.childProfile!, (value) {
|
||||
return _then(_self.copyWith(childProfile: value));
|
||||
});
|
||||
}/// Create a copy of CardPinViewState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
$ChildWalletEntityCopyWith<$Res>? get childWallet {
|
||||
if (_self.childWallet == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $ChildWalletEntityCopyWith<$Res>(_self.childWallet!, (value) {
|
||||
return _then(_self.copyWith(childWallet: value));
|
||||
});
|
||||
}/// Create a copy of CardPinViewState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
$DeviceEntityCopyWith<$Res>? get device {
|
||||
if (_self.device == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $DeviceEntityCopyWith<$Res>(_self.device!, (value) {
|
||||
return _then(_self.copyWith(device: value));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// dart format on
|
||||
@@ -53,6 +53,13 @@ class _ChildWalletScreenState extends ConsumerState<ChildWalletScreen> {
|
||||
type: MessageType.error,
|
||||
);
|
||||
}
|
||||
if (next.renewCardSuccess && !(prev?.renewCardSuccess ?? false)) {
|
||||
showTopSnackbar(
|
||||
context,
|
||||
message: context.translate(I18n.renewCardSuccess),
|
||||
type: MessageType.success,
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
if (viewState.showPin) {
|
||||
@@ -102,6 +109,53 @@ class _ChildWalletScreenState extends ConsumerState<ChildWalletScreen> {
|
||||
);
|
||||
}
|
||||
|
||||
if (viewState.showRenewPin) {
|
||||
final viewModel = ref.read(
|
||||
childWalletViewModelProvider(widget.childId).notifier,
|
||||
);
|
||||
return Scaffold(
|
||||
backgroundColor: theme.getColorFor(ThemeCode.backgroundSecondary),
|
||||
appBar: AppBar(
|
||||
backgroundColor: theme.getColorFor(ThemeCode.backgroundSecondary),
|
||||
leading: IconButton(
|
||||
icon: Icon(
|
||||
Icons.arrow_back,
|
||||
color: theme.getColorFor(ThemeCode.textPrimary),
|
||||
),
|
||||
onPressed: viewModel.cancelRenewPin,
|
||||
),
|
||||
),
|
||||
body: SafeArea(
|
||||
child: Column(
|
||||
children: [
|
||||
Expanded(
|
||||
child: SingleChildScrollView(
|
||||
child: ScaPinView(
|
||||
title: context.translate(I18n.renewCardPinTitle),
|
||||
pin: viewState.pin,
|
||||
isProcessing:
|
||||
viewState.isSigning || viewState.isRenewingCard,
|
||||
processingText: context.translate(I18n.scaSigning),
|
||||
canSubmit: viewModel.canSubmitPin,
|
||||
submitText: context.translate(I18n.scaConnect),
|
||||
clearPinText: context.translate(I18n.scaClearPin),
|
||||
onDigitPressed: viewModel.onDigitPressed,
|
||||
onBackspacePressed: viewModel.onBackspacePressed,
|
||||
onClearPin: viewModel.onClearPin,
|
||||
onSubmit: () => viewModel.onRenewPinSubmit(),
|
||||
),
|
||||
),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: viewModel.cancelRenewPin,
|
||||
child: Text(context.translate(I18n.cancel)),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
if (viewState.isLoading) {
|
||||
return const Scaffold(body: Center(child: AppLoadingIndicator()));
|
||||
}
|
||||
@@ -175,6 +229,14 @@ class _ChildWalletScreenState extends ConsumerState<ChildWalletScreen> {
|
||||
),
|
||||
),
|
||||
),
|
||||
IconButton(
|
||||
onPressed: () => _showRenewCardConfirmation(),
|
||||
icon: Icon(
|
||||
Icons.credit_card_outlined,
|
||||
color: theme.getColorFor(ThemeCode.backgroundPrimary),
|
||||
size: 24,
|
||||
),
|
||||
),
|
||||
PopupMenuButton<String>(
|
||||
icon: Icon(
|
||||
Icons.more_vert,
|
||||
@@ -187,6 +249,16 @@ class _ChildWalletScreenState extends ConsumerState<ChildWalletScreen> {
|
||||
);
|
||||
} else if (value == 'delete') {
|
||||
_showDeleteConfirmation();
|
||||
} else if (value == 'set_pin') {
|
||||
widget.navigation.pushTo(
|
||||
AppRoutes.setCardPin(widget.childId),
|
||||
);
|
||||
} else if (value == 'change_pin') {
|
||||
widget.navigation.pushTo(
|
||||
AppRoutes.changeCardPin(widget.childId),
|
||||
);
|
||||
} else if (value == 'unblock_pin') {
|
||||
_showUnblockPinConfirmation();
|
||||
}
|
||||
},
|
||||
itemBuilder: (_) => [
|
||||
@@ -202,6 +274,45 @@ class _ChildWalletScreenState extends ConsumerState<ChildWalletScreen> {
|
||||
],
|
||||
),
|
||||
),
|
||||
if (!viewState.isPinBlocked && !(viewState.childProfile?.hasCardPin ?? false))
|
||||
PopupMenuItem(
|
||||
value: 'set_pin',
|
||||
child: Row(
|
||||
spacing: 8,
|
||||
children: [
|
||||
Icon(Icons.pin_outlined),
|
||||
Text(
|
||||
context.translate(I18n.cardPinSet),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
if (!viewState.isPinBlocked && (viewState.childProfile?.hasCardPin ?? false))
|
||||
PopupMenuItem(
|
||||
value: 'change_pin',
|
||||
child: Row(
|
||||
spacing: 8,
|
||||
children: [
|
||||
Icon(Icons.lock_reset_outlined),
|
||||
Text(
|
||||
context.translate(I18n.cardPinChange),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
if (viewState.isPinBlocked)
|
||||
PopupMenuItem(
|
||||
value: 'unblock_pin',
|
||||
child: Row(
|
||||
spacing: 8,
|
||||
children: [
|
||||
Icon(Icons.lock_open_outlined),
|
||||
Text(
|
||||
context.translate(I18n.cardPinUnblock),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
PopupMenuItem(
|
||||
value: 'delete',
|
||||
child: Row(
|
||||
@@ -504,6 +615,89 @@ class _ChildWalletScreenState extends ConsumerState<ChildWalletScreen> {
|
||||
showTopSnackbar(context, message: e.toString(), type: MessageType.error);
|
||||
}
|
||||
}
|
||||
|
||||
void _showRenewCardConfirmation() {
|
||||
final theme = ref.read(themePortProvider);
|
||||
final confirmTitle = context.translate(I18n.renewCardTitle);
|
||||
final confirmMessage = context.translate(I18n.renewCardConfirm);
|
||||
final cancelText = context.translate(I18n.cancel);
|
||||
final confirmText = context.translate(I18n.accept);
|
||||
final bgColor = theme.getColorFor(ThemeCode.backgroundPrimary);
|
||||
final shape = RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
);
|
||||
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (ctx) => AlertDialog(
|
||||
backgroundColor: bgColor,
|
||||
shape: shape,
|
||||
title: Text(confirmTitle),
|
||||
content: Text(confirmMessage),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => Navigator.of(ctx).pop(),
|
||||
child: Text(cancelText),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
Navigator.of(ctx).pop();
|
||||
ref
|
||||
.read(childWalletViewModelProvider(widget.childId).notifier)
|
||||
.startRenewCard();
|
||||
},
|
||||
child: Text(confirmText),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> _showUnblockPinConfirmation() async {
|
||||
final theme = ref.read(themePortProvider);
|
||||
final confirmTitle = context.translate(I18n.cardPinUnblock);
|
||||
final confirmMessage = context.translate(I18n.cardPinUnblockConfirm);
|
||||
final cancelText = context.translate(I18n.cancel);
|
||||
final confirmText = context.translate(I18n.accept);
|
||||
final successText = context.translate(I18n.cardPinUnblockSuccess);
|
||||
final bgColor = theme.getColorFor(ThemeCode.backgroundPrimary);
|
||||
final shape = RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
);
|
||||
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (ctx) => AlertDialog(
|
||||
backgroundColor: bgColor,
|
||||
shape: shape,
|
||||
title: Text(confirmTitle),
|
||||
content: Text(confirmMessage),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => Navigator.of(ctx).pop(),
|
||||
child: Text(cancelText),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () async {
|
||||
Navigator.of(ctx).pop();
|
||||
final viewModel = ref.read(
|
||||
childWalletViewModelProvider(widget.childId).notifier,
|
||||
);
|
||||
final success = await viewModel.unblockCardPin();
|
||||
if (success && mounted) {
|
||||
showTopSnackbar(
|
||||
context,
|
||||
message: successText,
|
||||
type: MessageType.success,
|
||||
);
|
||||
}
|
||||
},
|
||||
child: Text(confirmText),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _CardStatusSheet extends ConsumerStatefulWidget {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:get_it/get_it.dart';
|
||||
import 'package:sca_treezor/sca_treezor.dart';
|
||||
@@ -124,6 +125,7 @@ class ChildWalletViewModel extends Notifier<ChildWalletViewState> {
|
||||
cardId: card.cardId.toString(),
|
||||
cardStatus: card.status,
|
||||
locked: CardStatus.fromString(card.status).isLocked,
|
||||
isPinBlocked: card.isPinBlocked,
|
||||
);
|
||||
} catch (_) {}
|
||||
}
|
||||
@@ -244,6 +246,113 @@ class ChildWalletViewModel extends Notifier<ChildWalletViewState> {
|
||||
}
|
||||
}
|
||||
|
||||
Future<bool> unblockCardPin() async {
|
||||
final walletId = state.childProfile?.walletId;
|
||||
if (walletId == null) return false;
|
||||
|
||||
state = state.copyWith(isUpdatingCard: true, cardStatusError: '');
|
||||
|
||||
try {
|
||||
await ref.read(treezorRepositoryProvider).unblockCardPin(
|
||||
walletId: walletId,
|
||||
);
|
||||
if (!ref.mounted) return false;
|
||||
state = state.copyWith(isUpdatingCard: false);
|
||||
return true;
|
||||
} catch (e) {
|
||||
if (!ref.mounted) return false;
|
||||
state = state.copyWith(
|
||||
isUpdatingCard: false,
|
||||
cardStatusError: e.toString(),
|
||||
);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
void startRenewCard() {
|
||||
state = state.copyWith(
|
||||
showRenewPin: true,
|
||||
showPin: false,
|
||||
pin: '',
|
||||
cardStatusError: '',
|
||||
renewCardSuccess: false,
|
||||
);
|
||||
}
|
||||
|
||||
void cancelRenewPin() {
|
||||
state = state.copyWith(showRenewPin: false, pin: '');
|
||||
}
|
||||
|
||||
Future<void> onRenewPinSubmit() async {
|
||||
final childProfile = state.childProfile;
|
||||
if (childProfile == null) return;
|
||||
|
||||
state = state.copyWith(isSigning: true, cardStatusError: '');
|
||||
|
||||
try {
|
||||
debugPrint('[RenewCard] connecting with SCA PIN...');
|
||||
await _connectionService.connectWithPin(loginPin: state.pin);
|
||||
if (!ref.mounted) return;
|
||||
debugPrint('[RenewCard] SCA connection successful');
|
||||
|
||||
final user = await ref.read(userInfoProvider.future);
|
||||
if (!ref.mounted) return;
|
||||
final paymentProfile = await ref
|
||||
.read(getPaymentProfileUseCaseProvider)
|
||||
.getPaymentProfile(userId: user.id);
|
||||
if (!ref.mounted) return;
|
||||
|
||||
final walletBody = <String, dynamic>{
|
||||
'currency': 'EUR',
|
||||
'eventName': '${user.firstName} ${user.lastName}',
|
||||
'tariffId': 0,
|
||||
'userId': int.tryParse(paymentProfile.paymentProfileId) ?? 0,
|
||||
'walletTypeId': 9,
|
||||
'bic': 'TRZOESM2XXX',
|
||||
};
|
||||
|
||||
final scaInput = jsonEncode({
|
||||
'url': 'https://savefamily.preprod.secure.treezor.co/wallets',
|
||||
'body': walletBody,
|
||||
});
|
||||
debugPrint('[RenewCard] scaInput: $scaInput');
|
||||
|
||||
final scaProof = await _signatureService.generateJwsWithPin(
|
||||
message: '',
|
||||
input: scaInput,
|
||||
pin: state.pin,
|
||||
);
|
||||
debugPrint('[RenewCard] scaProof: $scaProof');
|
||||
|
||||
if (!ref.mounted) return;
|
||||
state = state.copyWith(isSigning: false, isRenewingCard: true, pin: '');
|
||||
|
||||
debugPrint('[RenewCard] calling backend renewCard childProfileId=${childProfile.id} publicToken=${paymentProfile.paymentProfileId}');
|
||||
await ref.read(treezorRepositoryProvider).renewCard(
|
||||
childProfileId: childProfile.id,
|
||||
publicToken: paymentProfile.paymentProfileId,
|
||||
scaProof: scaProof,
|
||||
);
|
||||
debugPrint('[RenewCard] renewCard SUCCESS');
|
||||
|
||||
if (!ref.mounted) return;
|
||||
state = state.copyWith(
|
||||
isRenewingCard: false,
|
||||
renewCardSuccess: true,
|
||||
showRenewPin: false,
|
||||
);
|
||||
} catch (e) {
|
||||
debugPrint('[RenewCard] ERROR: $e');
|
||||
if (!ref.mounted) return;
|
||||
state = state.copyWith(
|
||||
isSigning: false,
|
||||
isRenewingCard: false,
|
||||
pin: '',
|
||||
cardStatusError: e.toString(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
static int _cardStatusToInt(String status) {
|
||||
return CardStatus.fromString(status).apiCode;
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@ abstract class ChildWalletViewState with _$ChildWalletViewState {
|
||||
@Default('') String cardId,
|
||||
@Default('') String cardStatus,
|
||||
@Default(false) bool locked,
|
||||
@Default(false) bool isPinBlocked,
|
||||
@Default('') String errorMessage,
|
||||
@Default(false) bool isUpdatingCard,
|
||||
@Default('') String cardStatusError,
|
||||
@@ -21,6 +22,9 @@ abstract class ChildWalletViewState with _$ChildWalletViewState {
|
||||
@Default('') String selectedStatus,
|
||||
@Default('') String pin,
|
||||
@Default(false) bool isSigning,
|
||||
@Default(false) bool isRenewingCard,
|
||||
@Default(false) bool renewCardSuccess,
|
||||
@Default(false) bool showRenewPin,
|
||||
@Default(false) bool isLoadingTransactions,
|
||||
@Default([]) List<List<WalletTransactionEntity>> transactionPages,
|
||||
String? nextCursor,
|
||||
|
||||
@@ -14,7 +14,7 @@ T _$identity<T>(T value) => value;
|
||||
/// @nodoc
|
||||
mixin _$ChildWalletViewState {
|
||||
|
||||
bool get isLoading; ChildProfileEntity? get childProfile; ChildWalletEntity? get childWallet; DeviceEntity? get device; String get cardId; String get cardStatus; bool get locked; String get errorMessage; bool get isUpdatingCard; String get cardStatusError; bool get cardStatusSuccess; bool get showPin; String get selectedStatus; String get pin; bool get isSigning; bool get isLoadingTransactions; List<List<WalletTransactionEntity>> get transactionPages; String? get nextCursor; bool get isLoadingMore; int get currentPage;
|
||||
bool get isLoading; ChildProfileEntity? get childProfile; ChildWalletEntity? get childWallet; DeviceEntity? get device; String get cardId; String get cardStatus; bool get locked; bool get isPinBlocked; String get errorMessage; bool get isUpdatingCard; String get cardStatusError; bool get cardStatusSuccess; bool get showPin; String get selectedStatus; String get pin; bool get isSigning; bool get isLoadingTransactions; List<List<WalletTransactionEntity>> get transactionPages; String? get nextCursor; bool get isLoadingMore; int get currentPage;
|
||||
/// Create a copy of ChildWalletViewState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@@ -25,16 +25,16 @@ $ChildWalletViewStateCopyWith<ChildWalletViewState> get copyWith => _$ChildWalle
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is ChildWalletViewState&&(identical(other.isLoading, isLoading) || other.isLoading == isLoading)&&(identical(other.childProfile, childProfile) || other.childProfile == childProfile)&&(identical(other.childWallet, childWallet) || other.childWallet == childWallet)&&(identical(other.device, device) || other.device == device)&&(identical(other.cardId, cardId) || other.cardId == cardId)&&(identical(other.cardStatus, cardStatus) || other.cardStatus == cardStatus)&&(identical(other.locked, locked) || other.locked == locked)&&(identical(other.errorMessage, errorMessage) || other.errorMessage == errorMessage)&&(identical(other.isUpdatingCard, isUpdatingCard) || other.isUpdatingCard == isUpdatingCard)&&(identical(other.cardStatusError, cardStatusError) || other.cardStatusError == cardStatusError)&&(identical(other.cardStatusSuccess, cardStatusSuccess) || other.cardStatusSuccess == cardStatusSuccess)&&(identical(other.showPin, showPin) || other.showPin == showPin)&&(identical(other.selectedStatus, selectedStatus) || other.selectedStatus == selectedStatus)&&(identical(other.pin, pin) || other.pin == pin)&&(identical(other.isSigning, isSigning) || other.isSigning == isSigning)&&(identical(other.isLoadingTransactions, isLoadingTransactions) || other.isLoadingTransactions == isLoadingTransactions)&&const DeepCollectionEquality().equals(other.transactionPages, transactionPages)&&(identical(other.nextCursor, nextCursor) || other.nextCursor == nextCursor)&&(identical(other.isLoadingMore, isLoadingMore) || other.isLoadingMore == isLoadingMore)&&(identical(other.currentPage, currentPage) || other.currentPage == currentPage));
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is ChildWalletViewState&&(identical(other.isLoading, isLoading) || other.isLoading == isLoading)&&(identical(other.childProfile, childProfile) || other.childProfile == childProfile)&&(identical(other.childWallet, childWallet) || other.childWallet == childWallet)&&(identical(other.device, device) || other.device == device)&&(identical(other.cardId, cardId) || other.cardId == cardId)&&(identical(other.cardStatus, cardStatus) || other.cardStatus == cardStatus)&&(identical(other.locked, locked) || other.locked == locked)&&(identical(other.isPinBlocked, isPinBlocked) || other.isPinBlocked == isPinBlocked)&&(identical(other.errorMessage, errorMessage) || other.errorMessage == errorMessage)&&(identical(other.isUpdatingCard, isUpdatingCard) || other.isUpdatingCard == isUpdatingCard)&&(identical(other.cardStatusError, cardStatusError) || other.cardStatusError == cardStatusError)&&(identical(other.cardStatusSuccess, cardStatusSuccess) || other.cardStatusSuccess == cardStatusSuccess)&&(identical(other.showPin, showPin) || other.showPin == showPin)&&(identical(other.selectedStatus, selectedStatus) || other.selectedStatus == selectedStatus)&&(identical(other.pin, pin) || other.pin == pin)&&(identical(other.isSigning, isSigning) || other.isSigning == isSigning)&&(identical(other.isLoadingTransactions, isLoadingTransactions) || other.isLoadingTransactions == isLoadingTransactions)&&const DeepCollectionEquality().equals(other.transactionPages, transactionPages)&&(identical(other.nextCursor, nextCursor) || other.nextCursor == nextCursor)&&(identical(other.isLoadingMore, isLoadingMore) || other.isLoadingMore == isLoadingMore)&&(identical(other.currentPage, currentPage) || other.currentPage == currentPage));
|
||||
}
|
||||
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hashAll([runtimeType,isLoading,childProfile,childWallet,device,cardId,cardStatus,locked,errorMessage,isUpdatingCard,cardStatusError,cardStatusSuccess,showPin,selectedStatus,pin,isSigning,isLoadingTransactions,const DeepCollectionEquality().hash(transactionPages),nextCursor,isLoadingMore,currentPage]);
|
||||
int get hashCode => Object.hashAll([runtimeType,isLoading,childProfile,childWallet,device,cardId,cardStatus,locked,isPinBlocked,errorMessage,isUpdatingCard,cardStatusError,cardStatusSuccess,showPin,selectedStatus,pin,isSigning,isLoadingTransactions,const DeepCollectionEquality().hash(transactionPages),nextCursor,isLoadingMore,currentPage]);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'ChildWalletViewState(isLoading: $isLoading, childProfile: $childProfile, childWallet: $childWallet, device: $device, cardId: $cardId, cardStatus: $cardStatus, locked: $locked, errorMessage: $errorMessage, isUpdatingCard: $isUpdatingCard, cardStatusError: $cardStatusError, cardStatusSuccess: $cardStatusSuccess, showPin: $showPin, selectedStatus: $selectedStatus, pin: $pin, isSigning: $isSigning, isLoadingTransactions: $isLoadingTransactions, transactionPages: $transactionPages, nextCursor: $nextCursor, isLoadingMore: $isLoadingMore, currentPage: $currentPage)';
|
||||
return 'ChildWalletViewState(isLoading: $isLoading, childProfile: $childProfile, childWallet: $childWallet, device: $device, cardId: $cardId, cardStatus: $cardStatus, locked: $locked, isPinBlocked: $isPinBlocked, errorMessage: $errorMessage, isUpdatingCard: $isUpdatingCard, cardStatusError: $cardStatusError, cardStatusSuccess: $cardStatusSuccess, showPin: $showPin, selectedStatus: $selectedStatus, pin: $pin, isSigning: $isSigning, isLoadingTransactions: $isLoadingTransactions, transactionPages: $transactionPages, nextCursor: $nextCursor, isLoadingMore: $isLoadingMore, currentPage: $currentPage)';
|
||||
}
|
||||
|
||||
|
||||
@@ -45,7 +45,7 @@ abstract mixin class $ChildWalletViewStateCopyWith<$Res> {
|
||||
factory $ChildWalletViewStateCopyWith(ChildWalletViewState value, $Res Function(ChildWalletViewState) _then) = _$ChildWalletViewStateCopyWithImpl;
|
||||
@useResult
|
||||
$Res call({
|
||||
bool isLoading, ChildProfileEntity? childProfile, ChildWalletEntity? childWallet, DeviceEntity? device, String cardId, String cardStatus, bool locked, String errorMessage, bool isUpdatingCard, String cardStatusError, bool cardStatusSuccess, bool showPin, String selectedStatus, String pin, bool isSigning, bool isLoadingTransactions, List<List<WalletTransactionEntity>> transactionPages, String? nextCursor, bool isLoadingMore, int currentPage
|
||||
bool isLoading, ChildProfileEntity? childProfile, ChildWalletEntity? childWallet, DeviceEntity? device, String cardId, String cardStatus, bool locked, bool isPinBlocked, String errorMessage, bool isUpdatingCard, String cardStatusError, bool cardStatusSuccess, bool showPin, String selectedStatus, String pin, bool isSigning, bool isLoadingTransactions, List<List<WalletTransactionEntity>> transactionPages, String? nextCursor, bool isLoadingMore, int currentPage
|
||||
});
|
||||
|
||||
|
||||
@@ -62,7 +62,7 @@ class _$ChildWalletViewStateCopyWithImpl<$Res>
|
||||
|
||||
/// Create a copy of ChildWalletViewState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline') @override $Res call({Object? isLoading = null,Object? childProfile = freezed,Object? childWallet = freezed,Object? device = freezed,Object? cardId = null,Object? cardStatus = null,Object? locked = null,Object? errorMessage = null,Object? isUpdatingCard = null,Object? cardStatusError = null,Object? cardStatusSuccess = null,Object? showPin = null,Object? selectedStatus = null,Object? pin = null,Object? isSigning = null,Object? isLoadingTransactions = null,Object? transactionPages = null,Object? nextCursor = freezed,Object? isLoadingMore = null,Object? currentPage = null,}) {
|
||||
@pragma('vm:prefer-inline') @override $Res call({Object? isLoading = null,Object? childProfile = freezed,Object? childWallet = freezed,Object? device = freezed,Object? cardId = null,Object? cardStatus = null,Object? locked = null,Object? isPinBlocked = null,Object? errorMessage = null,Object? isUpdatingCard = null,Object? cardStatusError = null,Object? cardStatusSuccess = null,Object? showPin = null,Object? selectedStatus = null,Object? pin = null,Object? isSigning = null,Object? isLoadingTransactions = null,Object? transactionPages = null,Object? nextCursor = freezed,Object? isLoadingMore = null,Object? currentPage = null,}) {
|
||||
return _then(_self.copyWith(
|
||||
isLoading: null == isLoading ? _self.isLoading : isLoading // ignore: cast_nullable_to_non_nullable
|
||||
as bool,childProfile: freezed == childProfile ? _self.childProfile : childProfile // ignore: cast_nullable_to_non_nullable
|
||||
@@ -71,6 +71,7 @@ as ChildWalletEntity?,device: freezed == device ? _self.device : device // ignor
|
||||
as DeviceEntity?,cardId: null == cardId ? _self.cardId : cardId // ignore: cast_nullable_to_non_nullable
|
||||
as String,cardStatus: null == cardStatus ? _self.cardStatus : cardStatus // ignore: cast_nullable_to_non_nullable
|
||||
as String,locked: null == locked ? _self.locked : locked // ignore: cast_nullable_to_non_nullable
|
||||
as bool,isPinBlocked: null == isPinBlocked ? _self.isPinBlocked : isPinBlocked // ignore: cast_nullable_to_non_nullable
|
||||
as bool,errorMessage: null == errorMessage ? _self.errorMessage : errorMessage // ignore: cast_nullable_to_non_nullable
|
||||
as String,isUpdatingCard: null == isUpdatingCard ? _self.isUpdatingCard : isUpdatingCard // ignore: cast_nullable_to_non_nullable
|
||||
as bool,cardStatusError: null == cardStatusError ? _self.cardStatusError : cardStatusError // ignore: cast_nullable_to_non_nullable
|
||||
@@ -205,10 +206,10 @@ return $default(_that);case _:
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( bool isLoading, ChildProfileEntity? childProfile, ChildWalletEntity? childWallet, DeviceEntity? device, String cardId, String cardStatus, bool locked, String errorMessage, bool isUpdatingCard, String cardStatusError, bool cardStatusSuccess, bool showPin, String selectedStatus, String pin, bool isSigning, bool isLoadingTransactions, List<List<WalletTransactionEntity>> transactionPages, String? nextCursor, bool isLoadingMore, int currentPage)? $default,{required TResult orElse(),}) {final _that = this;
|
||||
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( bool isLoading, ChildProfileEntity? childProfile, ChildWalletEntity? childWallet, DeviceEntity? device, String cardId, String cardStatus, bool locked, bool isPinBlocked, String errorMessage, bool isUpdatingCard, String cardStatusError, bool cardStatusSuccess, bool showPin, String selectedStatus, String pin, bool isSigning, bool isLoadingTransactions, List<List<WalletTransactionEntity>> transactionPages, String? nextCursor, bool isLoadingMore, int currentPage)? $default,{required TResult orElse(),}) {final _that = this;
|
||||
switch (_that) {
|
||||
case _ChildWalletViewState() when $default != null:
|
||||
return $default(_that.isLoading,_that.childProfile,_that.childWallet,_that.device,_that.cardId,_that.cardStatus,_that.locked,_that.errorMessage,_that.isUpdatingCard,_that.cardStatusError,_that.cardStatusSuccess,_that.showPin,_that.selectedStatus,_that.pin,_that.isSigning,_that.isLoadingTransactions,_that.transactionPages,_that.nextCursor,_that.isLoadingMore,_that.currentPage);case _:
|
||||
return $default(_that.isLoading,_that.childProfile,_that.childWallet,_that.device,_that.cardId,_that.cardStatus,_that.locked,_that.isPinBlocked,_that.errorMessage,_that.isUpdatingCard,_that.cardStatusError,_that.cardStatusSuccess,_that.showPin,_that.selectedStatus,_that.pin,_that.isSigning,_that.isLoadingTransactions,_that.transactionPages,_that.nextCursor,_that.isLoadingMore,_that.currentPage);case _:
|
||||
return orElse();
|
||||
|
||||
}
|
||||
@@ -226,10 +227,10 @@ return $default(_that.isLoading,_that.childProfile,_that.childWallet,_that.devic
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( bool isLoading, ChildProfileEntity? childProfile, ChildWalletEntity? childWallet, DeviceEntity? device, String cardId, String cardStatus, bool locked, String errorMessage, bool isUpdatingCard, String cardStatusError, bool cardStatusSuccess, bool showPin, String selectedStatus, String pin, bool isSigning, bool isLoadingTransactions, List<List<WalletTransactionEntity>> transactionPages, String? nextCursor, bool isLoadingMore, int currentPage) $default,) {final _that = this;
|
||||
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( bool isLoading, ChildProfileEntity? childProfile, ChildWalletEntity? childWallet, DeviceEntity? device, String cardId, String cardStatus, bool locked, bool isPinBlocked, String errorMessage, bool isUpdatingCard, String cardStatusError, bool cardStatusSuccess, bool showPin, String selectedStatus, String pin, bool isSigning, bool isLoadingTransactions, List<List<WalletTransactionEntity>> transactionPages, String? nextCursor, bool isLoadingMore, int currentPage) $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _ChildWalletViewState():
|
||||
return $default(_that.isLoading,_that.childProfile,_that.childWallet,_that.device,_that.cardId,_that.cardStatus,_that.locked,_that.errorMessage,_that.isUpdatingCard,_that.cardStatusError,_that.cardStatusSuccess,_that.showPin,_that.selectedStatus,_that.pin,_that.isSigning,_that.isLoadingTransactions,_that.transactionPages,_that.nextCursor,_that.isLoadingMore,_that.currentPage);case _:
|
||||
return $default(_that.isLoading,_that.childProfile,_that.childWallet,_that.device,_that.cardId,_that.cardStatus,_that.locked,_that.isPinBlocked,_that.errorMessage,_that.isUpdatingCard,_that.cardStatusError,_that.cardStatusSuccess,_that.showPin,_that.selectedStatus,_that.pin,_that.isSigning,_that.isLoadingTransactions,_that.transactionPages,_that.nextCursor,_that.isLoadingMore,_that.currentPage);case _:
|
||||
throw StateError('Unexpected subclass');
|
||||
|
||||
}
|
||||
@@ -246,10 +247,10 @@ return $default(_that.isLoading,_that.childProfile,_that.childWallet,_that.devic
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( bool isLoading, ChildProfileEntity? childProfile, ChildWalletEntity? childWallet, DeviceEntity? device, String cardId, String cardStatus, bool locked, String errorMessage, bool isUpdatingCard, String cardStatusError, bool cardStatusSuccess, bool showPin, String selectedStatus, String pin, bool isSigning, bool isLoadingTransactions, List<List<WalletTransactionEntity>> transactionPages, String? nextCursor, bool isLoadingMore, int currentPage)? $default,) {final _that = this;
|
||||
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( bool isLoading, ChildProfileEntity? childProfile, ChildWalletEntity? childWallet, DeviceEntity? device, String cardId, String cardStatus, bool locked, bool isPinBlocked, String errorMessage, bool isUpdatingCard, String cardStatusError, bool cardStatusSuccess, bool showPin, String selectedStatus, String pin, bool isSigning, bool isLoadingTransactions, List<List<WalletTransactionEntity>> transactionPages, String? nextCursor, bool isLoadingMore, int currentPage)? $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _ChildWalletViewState() when $default != null:
|
||||
return $default(_that.isLoading,_that.childProfile,_that.childWallet,_that.device,_that.cardId,_that.cardStatus,_that.locked,_that.errorMessage,_that.isUpdatingCard,_that.cardStatusError,_that.cardStatusSuccess,_that.showPin,_that.selectedStatus,_that.pin,_that.isSigning,_that.isLoadingTransactions,_that.transactionPages,_that.nextCursor,_that.isLoadingMore,_that.currentPage);case _:
|
||||
return $default(_that.isLoading,_that.childProfile,_that.childWallet,_that.device,_that.cardId,_that.cardStatus,_that.locked,_that.isPinBlocked,_that.errorMessage,_that.isUpdatingCard,_that.cardStatusError,_that.cardStatusSuccess,_that.showPin,_that.selectedStatus,_that.pin,_that.isSigning,_that.isLoadingTransactions,_that.transactionPages,_that.nextCursor,_that.isLoadingMore,_that.currentPage);case _:
|
||||
return null;
|
||||
|
||||
}
|
||||
@@ -261,7 +262,7 @@ return $default(_that.isLoading,_that.childProfile,_that.childWallet,_that.devic
|
||||
|
||||
|
||||
class _ChildWalletViewState implements ChildWalletViewState {
|
||||
const _ChildWalletViewState({this.isLoading = true, this.childProfile, this.childWallet, this.device, this.cardId = '', this.cardStatus = '', this.locked = false, this.errorMessage = '', this.isUpdatingCard = false, this.cardStatusError = '', this.cardStatusSuccess = false, this.showPin = false, this.selectedStatus = '', this.pin = '', this.isSigning = false, this.isLoadingTransactions = false, final List<List<WalletTransactionEntity>> transactionPages = const [], this.nextCursor, this.isLoadingMore = false, this.currentPage = 0}): _transactionPages = transactionPages;
|
||||
const _ChildWalletViewState({this.isLoading = true, this.childProfile, this.childWallet, this.device, this.cardId = '', this.cardStatus = '', this.locked = false, this.isPinBlocked = false, this.errorMessage = '', this.isUpdatingCard = false, this.cardStatusError = '', this.cardStatusSuccess = false, this.showPin = false, this.selectedStatus = '', this.pin = '', this.isSigning = false, this.isLoadingTransactions = false, final List<List<WalletTransactionEntity>> transactionPages = const [], this.nextCursor, this.isLoadingMore = false, this.currentPage = 0}): _transactionPages = transactionPages;
|
||||
|
||||
|
||||
@override@JsonKey() final bool isLoading;
|
||||
@@ -271,6 +272,7 @@ class _ChildWalletViewState implements ChildWalletViewState {
|
||||
@override@JsonKey() final String cardId;
|
||||
@override@JsonKey() final String cardStatus;
|
||||
@override@JsonKey() final bool locked;
|
||||
@override@JsonKey() final bool isPinBlocked;
|
||||
@override@JsonKey() final String errorMessage;
|
||||
@override@JsonKey() final bool isUpdatingCard;
|
||||
@override@JsonKey() final String cardStatusError;
|
||||
@@ -301,16 +303,16 @@ _$ChildWalletViewStateCopyWith<_ChildWalletViewState> get copyWith => __$ChildWa
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is _ChildWalletViewState&&(identical(other.isLoading, isLoading) || other.isLoading == isLoading)&&(identical(other.childProfile, childProfile) || other.childProfile == childProfile)&&(identical(other.childWallet, childWallet) || other.childWallet == childWallet)&&(identical(other.device, device) || other.device == device)&&(identical(other.cardId, cardId) || other.cardId == cardId)&&(identical(other.cardStatus, cardStatus) || other.cardStatus == cardStatus)&&(identical(other.locked, locked) || other.locked == locked)&&(identical(other.errorMessage, errorMessage) || other.errorMessage == errorMessage)&&(identical(other.isUpdatingCard, isUpdatingCard) || other.isUpdatingCard == isUpdatingCard)&&(identical(other.cardStatusError, cardStatusError) || other.cardStatusError == cardStatusError)&&(identical(other.cardStatusSuccess, cardStatusSuccess) || other.cardStatusSuccess == cardStatusSuccess)&&(identical(other.showPin, showPin) || other.showPin == showPin)&&(identical(other.selectedStatus, selectedStatus) || other.selectedStatus == selectedStatus)&&(identical(other.pin, pin) || other.pin == pin)&&(identical(other.isSigning, isSigning) || other.isSigning == isSigning)&&(identical(other.isLoadingTransactions, isLoadingTransactions) || other.isLoadingTransactions == isLoadingTransactions)&&const DeepCollectionEquality().equals(other._transactionPages, _transactionPages)&&(identical(other.nextCursor, nextCursor) || other.nextCursor == nextCursor)&&(identical(other.isLoadingMore, isLoadingMore) || other.isLoadingMore == isLoadingMore)&&(identical(other.currentPage, currentPage) || other.currentPage == currentPage));
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is _ChildWalletViewState&&(identical(other.isLoading, isLoading) || other.isLoading == isLoading)&&(identical(other.childProfile, childProfile) || other.childProfile == childProfile)&&(identical(other.childWallet, childWallet) || other.childWallet == childWallet)&&(identical(other.device, device) || other.device == device)&&(identical(other.cardId, cardId) || other.cardId == cardId)&&(identical(other.cardStatus, cardStatus) || other.cardStatus == cardStatus)&&(identical(other.locked, locked) || other.locked == locked)&&(identical(other.isPinBlocked, isPinBlocked) || other.isPinBlocked == isPinBlocked)&&(identical(other.errorMessage, errorMessage) || other.errorMessage == errorMessage)&&(identical(other.isUpdatingCard, isUpdatingCard) || other.isUpdatingCard == isUpdatingCard)&&(identical(other.cardStatusError, cardStatusError) || other.cardStatusError == cardStatusError)&&(identical(other.cardStatusSuccess, cardStatusSuccess) || other.cardStatusSuccess == cardStatusSuccess)&&(identical(other.showPin, showPin) || other.showPin == showPin)&&(identical(other.selectedStatus, selectedStatus) || other.selectedStatus == selectedStatus)&&(identical(other.pin, pin) || other.pin == pin)&&(identical(other.isSigning, isSigning) || other.isSigning == isSigning)&&(identical(other.isLoadingTransactions, isLoadingTransactions) || other.isLoadingTransactions == isLoadingTransactions)&&const DeepCollectionEquality().equals(other._transactionPages, _transactionPages)&&(identical(other.nextCursor, nextCursor) || other.nextCursor == nextCursor)&&(identical(other.isLoadingMore, isLoadingMore) || other.isLoadingMore == isLoadingMore)&&(identical(other.currentPage, currentPage) || other.currentPage == currentPage));
|
||||
}
|
||||
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hashAll([runtimeType,isLoading,childProfile,childWallet,device,cardId,cardStatus,locked,errorMessage,isUpdatingCard,cardStatusError,cardStatusSuccess,showPin,selectedStatus,pin,isSigning,isLoadingTransactions,const DeepCollectionEquality().hash(_transactionPages),nextCursor,isLoadingMore,currentPage]);
|
||||
int get hashCode => Object.hashAll([runtimeType,isLoading,childProfile,childWallet,device,cardId,cardStatus,locked,isPinBlocked,errorMessage,isUpdatingCard,cardStatusError,cardStatusSuccess,showPin,selectedStatus,pin,isSigning,isLoadingTransactions,const DeepCollectionEquality().hash(_transactionPages),nextCursor,isLoadingMore,currentPage]);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'ChildWalletViewState(isLoading: $isLoading, childProfile: $childProfile, childWallet: $childWallet, device: $device, cardId: $cardId, cardStatus: $cardStatus, locked: $locked, errorMessage: $errorMessage, isUpdatingCard: $isUpdatingCard, cardStatusError: $cardStatusError, cardStatusSuccess: $cardStatusSuccess, showPin: $showPin, selectedStatus: $selectedStatus, pin: $pin, isSigning: $isSigning, isLoadingTransactions: $isLoadingTransactions, transactionPages: $transactionPages, nextCursor: $nextCursor, isLoadingMore: $isLoadingMore, currentPage: $currentPage)';
|
||||
return 'ChildWalletViewState(isLoading: $isLoading, childProfile: $childProfile, childWallet: $childWallet, device: $device, cardId: $cardId, cardStatus: $cardStatus, locked: $locked, isPinBlocked: $isPinBlocked, errorMessage: $errorMessage, isUpdatingCard: $isUpdatingCard, cardStatusError: $cardStatusError, cardStatusSuccess: $cardStatusSuccess, showPin: $showPin, selectedStatus: $selectedStatus, pin: $pin, isSigning: $isSigning, isLoadingTransactions: $isLoadingTransactions, transactionPages: $transactionPages, nextCursor: $nextCursor, isLoadingMore: $isLoadingMore, currentPage: $currentPage)';
|
||||
}
|
||||
|
||||
|
||||
@@ -321,7 +323,7 @@ abstract mixin class _$ChildWalletViewStateCopyWith<$Res> implements $ChildWalle
|
||||
factory _$ChildWalletViewStateCopyWith(_ChildWalletViewState value, $Res Function(_ChildWalletViewState) _then) = __$ChildWalletViewStateCopyWithImpl;
|
||||
@override @useResult
|
||||
$Res call({
|
||||
bool isLoading, ChildProfileEntity? childProfile, ChildWalletEntity? childWallet, DeviceEntity? device, String cardId, String cardStatus, bool locked, String errorMessage, bool isUpdatingCard, String cardStatusError, bool cardStatusSuccess, bool showPin, String selectedStatus, String pin, bool isSigning, bool isLoadingTransactions, List<List<WalletTransactionEntity>> transactionPages, String? nextCursor, bool isLoadingMore, int currentPage
|
||||
bool isLoading, ChildProfileEntity? childProfile, ChildWalletEntity? childWallet, DeviceEntity? device, String cardId, String cardStatus, bool locked, bool isPinBlocked, String errorMessage, bool isUpdatingCard, String cardStatusError, bool cardStatusSuccess, bool showPin, String selectedStatus, String pin, bool isSigning, bool isLoadingTransactions, List<List<WalletTransactionEntity>> transactionPages, String? nextCursor, bool isLoadingMore, int currentPage
|
||||
});
|
||||
|
||||
|
||||
@@ -338,7 +340,7 @@ class __$ChildWalletViewStateCopyWithImpl<$Res>
|
||||
|
||||
/// Create a copy of ChildWalletViewState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override @pragma('vm:prefer-inline') $Res call({Object? isLoading = null,Object? childProfile = freezed,Object? childWallet = freezed,Object? device = freezed,Object? cardId = null,Object? cardStatus = null,Object? locked = null,Object? errorMessage = null,Object? isUpdatingCard = null,Object? cardStatusError = null,Object? cardStatusSuccess = null,Object? showPin = null,Object? selectedStatus = null,Object? pin = null,Object? isSigning = null,Object? isLoadingTransactions = null,Object? transactionPages = null,Object? nextCursor = freezed,Object? isLoadingMore = null,Object? currentPage = null,}) {
|
||||
@override @pragma('vm:prefer-inline') $Res call({Object? isLoading = null,Object? childProfile = freezed,Object? childWallet = freezed,Object? device = freezed,Object? cardId = null,Object? cardStatus = null,Object? locked = null,Object? isPinBlocked = null,Object? errorMessage = null,Object? isUpdatingCard = null,Object? cardStatusError = null,Object? cardStatusSuccess = null,Object? showPin = null,Object? selectedStatus = null,Object? pin = null,Object? isSigning = null,Object? isLoadingTransactions = null,Object? transactionPages = null,Object? nextCursor = freezed,Object? isLoadingMore = null,Object? currentPage = null,}) {
|
||||
return _then(_ChildWalletViewState(
|
||||
isLoading: null == isLoading ? _self.isLoading : isLoading // ignore: cast_nullable_to_non_nullable
|
||||
as bool,childProfile: freezed == childProfile ? _self.childProfile : childProfile // ignore: cast_nullable_to_non_nullable
|
||||
@@ -347,6 +349,7 @@ as ChildWalletEntity?,device: freezed == device ? _self.device : device // ignor
|
||||
as DeviceEntity?,cardId: null == cardId ? _self.cardId : cardId // ignore: cast_nullable_to_non_nullable
|
||||
as String,cardStatus: null == cardStatus ? _self.cardStatus : cardStatus // ignore: cast_nullable_to_non_nullable
|
||||
as String,locked: null == locked ? _self.locked : locked // ignore: cast_nullable_to_non_nullable
|
||||
as bool,isPinBlocked: null == isPinBlocked ? _self.isPinBlocked : isPinBlocked // ignore: cast_nullable_to_non_nullable
|
||||
as bool,errorMessage: null == errorMessage ? _self.errorMessage : errorMessage // ignore: cast_nullable_to_non_nullable
|
||||
as String,isUpdatingCard: null == isUpdatingCard ? _self.isUpdatingCard : isUpdatingCard // ignore: cast_nullable_to_non_nullable
|
||||
as bool,cardStatusError: null == cardStatusError ? _self.cardStatusError : cardStatusError // ignore: cast_nullable_to_non_nullable
|
||||
|
||||
@@ -23,13 +23,13 @@ class CheckSessionUseCaseImpl implements CheckSessionUseCase {
|
||||
debugPrint('[CheckSession] → onboarding');
|
||||
return InitialRoute.onboarding;
|
||||
}
|
||||
return InitialRoute.login;
|
||||
// try {
|
||||
// await _userRepository.getUserInfo();
|
||||
// return InitialRoute.home;
|
||||
// } catch (e) {
|
||||
// debugPrint('[CheckSessionUseCase] error: $e');
|
||||
// return InitialRoute.login;
|
||||
// }
|
||||
// return InitialRoute.login;
|
||||
try {
|
||||
await _userRepository.getUserInfo();
|
||||
return InitialRoute.home;
|
||||
} catch (e) {
|
||||
debugPrint('[CheckSessionUseCase] error: $e');
|
||||
return InitialRoute.login;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1 +1 @@
|
||||
enum InitialRoute { login, onboarding }
|
||||
enum InitialRoute { login, home, onboarding }
|
||||
|
||||
@@ -55,7 +55,7 @@ class _SplashScreenState extends State<SplashScreen>
|
||||
final destination = switch (_route!) {
|
||||
InitialRoute.onboarding => AppRoutes.onboarding,
|
||||
InitialRoute.login => AppRoutes.login,
|
||||
// InitialRoute.home => AppRoutes.dashboardHome,
|
||||
InitialRoute.home => AppRoutes.dashboardHome,
|
||||
};
|
||||
widget.navigationContract.goTo(destination);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user