Compare commits
6 Commits
v1.0.0(6)
...
set-reset-
| Author | SHA1 | Date | |
|---|---|---|---|
| c80b7a9a5f | |||
| db153bb38d | |||
| 50c4529cba | |||
| b6deb4b371 | |||
| 47c7821b0c | |||
| a07e9c23ca |
@@ -39,7 +39,7 @@ Future<void> initApp(EnvironmentEnum env) async {
|
||||
await GetIt.I<TreezorWalletConnectionService>().logout();
|
||||
} catch (_) {}
|
||||
await clearSessionData();
|
||||
appRouter.go(AppRoutes.legacyLogin);
|
||||
appRouter.go(AppRoutes.login);
|
||||
},
|
||||
);
|
||||
|
||||
|
||||
@@ -21,6 +21,25 @@ import 'package:splash/splash.dart';
|
||||
|
||||
final GlobalKey<NavigatorState> rootNavigatorKey = GlobalKey<NavigatorState>();
|
||||
|
||||
final _legacyControlPanelNavKey =
|
||||
GlobalKey<NavigatorState>(debugLabel: 'legacyControlPanel');
|
||||
final _legacyDeviceMgmtNavKey =
|
||||
GlobalKey<NavigatorState>(debugLabel: 'legacyDeviceMgmt');
|
||||
final _legacyLocationNavKey =
|
||||
GlobalKey<NavigatorState>(debugLabel: 'legacyLocation');
|
||||
final _legacyChatNavKey = GlobalKey<NavigatorState>(debugLabel: 'legacyChat');
|
||||
final _legacySettingsNavKey =
|
||||
GlobalKey<NavigatorState>(debugLabel: 'legacySettings');
|
||||
|
||||
final _dashboardHomeNavKey =
|
||||
GlobalKey<NavigatorState>(debugLabel: 'dashboardHome');
|
||||
final _dashboardActivityNavKey =
|
||||
GlobalKey<NavigatorState>(debugLabel: 'dashboardActivity');
|
||||
final _dashboardNotificationsNavKey =
|
||||
GlobalKey<NavigatorState>(debugLabel: 'dashboardNotifications');
|
||||
final _dashboardProfileNavKey =
|
||||
GlobalKey<NavigatorState>(debugLabel: 'dashboardProfile');
|
||||
|
||||
late final GoRouter appRouter;
|
||||
|
||||
void configureAppRouter() {
|
||||
@@ -40,6 +59,7 @@ void configureAppRouter() {
|
||||
},
|
||||
branches: [
|
||||
StatefulShellBranch(
|
||||
navigatorKey: _legacyControlPanelNavKey,
|
||||
routes: [
|
||||
GoRoute(
|
||||
path: AppRoutes.controlPanel,
|
||||
@@ -88,6 +108,7 @@ void configureAppRouter() {
|
||||
],
|
||||
),
|
||||
StatefulShellBranch(
|
||||
navigatorKey: _legacyDeviceMgmtNavKey,
|
||||
routes: [
|
||||
GoRoute(
|
||||
path: AppRoutes.deviceManagement,
|
||||
@@ -156,6 +177,7 @@ void configureAppRouter() {
|
||||
],
|
||||
),
|
||||
StatefulShellBranch(
|
||||
navigatorKey: _legacyLocationNavKey,
|
||||
routes: [
|
||||
GoRoute(
|
||||
path: AppRoutes.legacyLocation,
|
||||
@@ -166,6 +188,7 @@ void configureAppRouter() {
|
||||
),
|
||||
// TODO: Añadir branch para Chat (tab 4)
|
||||
StatefulShellBranch(
|
||||
navigatorKey: _legacyChatNavKey,
|
||||
routes: [
|
||||
GoRoute(
|
||||
path: '${AppRoutes.legacyDashboard}/chat',
|
||||
@@ -180,6 +203,7 @@ void configureAppRouter() {
|
||||
],
|
||||
),
|
||||
StatefulShellBranch(
|
||||
navigatorKey: _legacySettingsNavKey,
|
||||
routes: [
|
||||
GoRoute(
|
||||
path: AppRoutes.settings,
|
||||
@@ -355,6 +379,7 @@ void configureAppRouter() {
|
||||
},
|
||||
branches: [
|
||||
StatefulShellBranch(
|
||||
navigatorKey: _dashboardHomeNavKey,
|
||||
routes: [
|
||||
GoRoute(
|
||||
path: AppRoutes.dashboardHome,
|
||||
@@ -402,6 +427,24 @@ void configureAppRouter() {
|
||||
pageBuilder:
|
||||
const EditChildProfileBuilder().buildPage,
|
||||
),
|
||||
GoRoute(
|
||||
path: 'set-pin',
|
||||
name: 'home_set_card_pin',
|
||||
pageBuilder:
|
||||
const SetCardPinBuilder().buildPage,
|
||||
),
|
||||
GoRoute(
|
||||
path: 'change-pin',
|
||||
name: 'home_change_card_pin',
|
||||
pageBuilder:
|
||||
const ChangeCardPinBuilder().buildPage,
|
||||
),
|
||||
GoRoute(
|
||||
path: 'renew-card',
|
||||
name: 'home_renew_card',
|
||||
pageBuilder:
|
||||
const RenewCardBuilder().buildPage,
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
@@ -409,6 +452,7 @@ void configureAppRouter() {
|
||||
],
|
||||
),
|
||||
StatefulShellBranch(
|
||||
navigatorKey: _dashboardActivityNavKey,
|
||||
routes: [
|
||||
GoRoute(
|
||||
path: AppRoutes.dashboardActivity,
|
||||
@@ -418,6 +462,7 @@ void configureAppRouter() {
|
||||
],
|
||||
),
|
||||
StatefulShellBranch(
|
||||
navigatorKey: _dashboardNotificationsNavKey,
|
||||
routes: [
|
||||
GoRoute(
|
||||
path: AppRoutes.dashboardNotifications,
|
||||
@@ -427,6 +472,7 @@ void configureAppRouter() {
|
||||
],
|
||||
),
|
||||
StatefulShellBranch(
|
||||
navigatorKey: _dashboardProfileNavKey,
|
||||
routes: [
|
||||
GoRoute(
|
||||
path: AppRoutes.dashboardProfile,
|
||||
|
||||
@@ -40,7 +40,7 @@ class SaveFamilyAppState extends ConsumerState<SaveFamilyApp>
|
||||
repository: GetIt.I<QuestiaRepository>(),
|
||||
onUnauthorized: () {
|
||||
clearSessionData();
|
||||
appRouter.go(AppRoutes.legacyLogin);
|
||||
appRouter.go(AppRoutes.login);
|
||||
},
|
||||
);
|
||||
onBeforeSessionCleared = () {
|
||||
|
||||
@@ -32,7 +32,7 @@ class OnboardingScreen extends ConsumerWidget {
|
||||
|
||||
void goToNext() {
|
||||
if (isLast) {
|
||||
navigationContract.goTo(AppRoutes.legacyLogin);
|
||||
navigationContract.goTo(AppRoutes.login);
|
||||
} else {
|
||||
pageController.nextPage(
|
||||
duration: const Duration(milliseconds: 400),
|
||||
@@ -111,7 +111,7 @@ class OnboardingScreen extends ConsumerWidget {
|
||||
? const SizedBox.shrink()
|
||||
: TextButton(
|
||||
onPressed: () =>
|
||||
navigationContract.goTo(AppRoutes.legacyLogin),
|
||||
navigationContract.goTo(AppRoutes.login),
|
||||
child: Text(
|
||||
context.translate(I18n.skip),
|
||||
style: AppFonts.stolzlStyle(
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -495,7 +495,6 @@ class SignUpViewModel extends Notifier<SignUpViewState> {
|
||||
String _emailErrorFor(String value) {
|
||||
final email = value.trim();
|
||||
if (email.isEmpty) return I18n.errorEmailRequired;
|
||||
if (email.contains('+')) return I18n.errorEmailPlusNotAllowed;
|
||||
if (!_isValidEmail(email)) return I18n.errorEmailInvalid;
|
||||
return '';
|
||||
}
|
||||
|
||||
@@ -8,3 +8,6 @@ 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';
|
||||
export 'src/features/renew_card/renew_card_builder.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
|
||||
@@ -175,6 +175,16 @@ class _ChildWalletScreenState extends ConsumerState<ChildWalletScreen> {
|
||||
),
|
||||
),
|
||||
),
|
||||
IconButton(
|
||||
onPressed: () => widget.navigation.pushTo(
|
||||
AppRoutes.renewCard(widget.childId),
|
||||
),
|
||||
icon: Icon(
|
||||
Icons.credit_card_outlined,
|
||||
color: theme.getColorFor(ThemeCode.backgroundPrimary),
|
||||
size: 24,
|
||||
),
|
||||
),
|
||||
PopupMenuButton<String>(
|
||||
icon: Icon(
|
||||
Icons.more_vert,
|
||||
@@ -187,6 +197,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 +222,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 +563,52 @@ class _ChildWalletScreenState extends ConsumerState<ChildWalletScreen> {
|
||||
showTopSnackbar(context, message: e.toString(), type: MessageType.error);
|
||||
}
|
||||
}
|
||||
|
||||
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 {
|
||||
|
||||
@@ -124,6 +124,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 +245,29 @@ 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;
|
||||
}
|
||||
}
|
||||
|
||||
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,
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
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 'renew_card_screen.dart';
|
||||
|
||||
class RenewCardBuilder {
|
||||
const RenewCardBuilder();
|
||||
|
||||
Page<void> buildPage(BuildContext context, GoRouterState state) {
|
||||
final childWalletId = state.pathParameters['childWalletId'] ?? '';
|
||||
final navigationContract = GetIt.I<NavigationContract>();
|
||||
return MaterialPage(
|
||||
key: state.pageKey,
|
||||
child: RenewCardScreen(
|
||||
childId: childWalletId,
|
||||
navigation: navigationContract,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
162
modules/home/lib/src/features/renew_card/renew_card_screen.dart
Normal file
162
modules/home/lib/src/features/renew_card/renew_card_screen.dart
Normal file
@@ -0,0 +1,162 @@
|
||||
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 'renew_card_view_model.dart';
|
||||
import 'renew_card_view_state.dart';
|
||||
|
||||
class RenewCardScreen extends ConsumerWidget {
|
||||
final String childId;
|
||||
final NavigationContract navigation;
|
||||
|
||||
const RenewCardScreen({
|
||||
super.key,
|
||||
required this.childId,
|
||||
required this.navigation,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final theme = ref.watch(themePortProvider);
|
||||
final viewState = ref.watch(renewCardViewModelProvider(childId));
|
||||
final viewModel = ref.read(renewCardViewModelProvider(childId).notifier);
|
||||
|
||||
ref.listen(renewCardViewModelProvider(childId), (prev, next) {
|
||||
if (next.success && !(prev?.success ?? false)) {
|
||||
showTopSnackbar(
|
||||
context,
|
||||
message: context.translate(I18n.renewCardSuccess),
|
||||
type: MessageType.success,
|
||||
);
|
||||
navigation.goBack();
|
||||
return;
|
||||
}
|
||||
if (next.errorMessage.isNotEmpty &&
|
||||
next.errorMessage != (prev?.errorMessage ?? '')) {
|
||||
showTopSnackbar(
|
||||
context,
|
||||
message: context.translate(I18n.renewCardError),
|
||||
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}')),
|
||||
);
|
||||
}
|
||||
|
||||
if (viewState.step == RenewCardStep.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: viewModel.goBackToToken,
|
||||
),
|
||||
),
|
||||
body: SafeArea(
|
||||
child: Column(
|
||||
children: [
|
||||
Expanded(
|
||||
child: SingleChildScrollView(
|
||||
child: ScaPinView(
|
||||
title: context.translate(I18n.renewCardPinTitle),
|
||||
pin: viewState.pin,
|
||||
isProcessing:
|
||||
viewState.isSigning || viewState.isSubmitting,
|
||||
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.onPinSubmit(),
|
||||
),
|
||||
),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () => navigation.goBack(),
|
||||
child: Text(context.translate(I18n.cancel)),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
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: () => navigation.goBack(),
|
||||
),
|
||||
),
|
||||
body: SafeArea(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 20),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
const SizedBox(height: 20),
|
||||
Text(
|
||||
context.translate(I18n.renewCardTitle),
|
||||
style: const TextStyle(
|
||||
fontSize: 24,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
Text(
|
||||
context.translate(I18n.renewCardTokenHint),
|
||||
style: const TextStyle(fontSize: 16),
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
CustomTextField(
|
||||
controller: viewModel.cardTokenController,
|
||||
hint: 'XXXXXXXXXX',
|
||||
),
|
||||
const Spacer(),
|
||||
SizedBox(
|
||||
width: double.infinity,
|
||||
child: PrimaryButton(
|
||||
onPressed: viewState.cardToken.isEmpty
|
||||
? null
|
||||
: viewModel.onCardTokenSubmit,
|
||||
text: context.translate(I18n.cardPinNext),
|
||||
color: theme.getColorFor(ThemeCode.buttonPrimary),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
Center(
|
||||
child: TextButton(
|
||||
onPressed: () => navigation.goBack(),
|
||||
child: Text(context.translate(I18n.cancel)),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,141 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:flutter/material.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 'renew_card_view_state.dart';
|
||||
|
||||
final renewCardViewModelProvider = NotifierProvider.autoDispose
|
||||
.family<RenewCardViewModel, RenewCardViewState, String>(
|
||||
RenewCardViewModel.new,
|
||||
);
|
||||
|
||||
class RenewCardViewModel extends Notifier<RenewCardViewState> {
|
||||
final String childId;
|
||||
RenewCardViewModel(this.childId);
|
||||
|
||||
late final TextEditingController cardTokenController;
|
||||
late final TreezorWalletConnectionService _connectionService;
|
||||
late final TreezorWalletSignatureService _signatureService;
|
||||
|
||||
@override
|
||||
RenewCardViewState build() {
|
||||
_connectionService = GetIt.I<TreezorWalletConnectionService>();
|
||||
_signatureService = GetIt.I<TreezorWalletSignatureService>();
|
||||
|
||||
cardTokenController = TextEditingController();
|
||||
cardTokenController.addListener(_onTokenChanged);
|
||||
ref.onDispose(_disposeControllers);
|
||||
|
||||
ref.listen(childDataProvider(childId), (prev, next) {
|
||||
state = state.copyWith(
|
||||
isLoading: next.isLoading,
|
||||
childProfile: next.childProfile,
|
||||
childWallet: next.childWallet,
|
||||
device: next.device,
|
||||
errorMessage: next.errorMessage,
|
||||
);
|
||||
});
|
||||
|
||||
final data = ref.read(childDataProvider(childId));
|
||||
return RenewCardViewState(
|
||||
isLoading: data.isLoading,
|
||||
childProfile: data.childProfile,
|
||||
childWallet: data.childWallet,
|
||||
device: data.device,
|
||||
errorMessage: data.errorMessage,
|
||||
);
|
||||
}
|
||||
|
||||
void _disposeControllers() {
|
||||
cardTokenController.removeListener(_onTokenChanged);
|
||||
cardTokenController.dispose();
|
||||
}
|
||||
|
||||
void _onTokenChanged() {
|
||||
state = state.copyWith(cardToken: cardTokenController.text.trim());
|
||||
}
|
||||
|
||||
void onCardTokenSubmit() {
|
||||
if (state.cardToken.isEmpty) return;
|
||||
state = state.copyWith(step: RenewCardStep.scaPin, pin: '', errorMessage: '');
|
||||
}
|
||||
|
||||
void goBackToToken() {
|
||||
state = state.copyWith(step: RenewCardStep.cardToken, pin: '');
|
||||
}
|
||||
|
||||
void onDigitPressed(String digit) {
|
||||
if (state.pin.length >= 6) return;
|
||||
state = state.copyWith(pin: state.pin + digit, errorMessage: '');
|
||||
}
|
||||
|
||||
void onBackspacePressed() {
|
||||
if (state.pin.isEmpty) return;
|
||||
state = state.copyWith(pin: state.pin.substring(0, state.pin.length - 1));
|
||||
}
|
||||
|
||||
void onClearPin() {
|
||||
state = state.copyWith(pin: '');
|
||||
}
|
||||
|
||||
bool get canSubmitPin => state.pin.length == 6;
|
||||
|
||||
Future<void> onPinSubmit() async {
|
||||
final childProfile = state.childProfile;
|
||||
final cardToken = state.cardToken;
|
||||
if (childProfile == null || cardToken.isEmpty) return;
|
||||
|
||||
state = state.copyWith(isSigning: true, errorMessage: '');
|
||||
|
||||
try {
|
||||
debugPrint('[RenewCard] connecting with SCA PIN...');
|
||||
await _connectionService.connectWithPin(loginPin: state.pin);
|
||||
if (!ref.mounted) return;
|
||||
debugPrint('[RenewCard] SCA connection successful');
|
||||
|
||||
final url =
|
||||
'https://savefamily.sandbox.treezor.co/v1/cards/$cardToken/public-token-activation';
|
||||
final scaInput = jsonEncode({
|
||||
'url': url,
|
||||
'body': <String, dynamic>{},
|
||||
});
|
||||
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, isSubmitting: true, pin: '');
|
||||
|
||||
debugPrint('[RenewCard] calling backend renewCard childProfileId=${childProfile.id} publicToken=$cardToken');
|
||||
await ref.read(treezorRepositoryProvider).renewCard(
|
||||
childProfileId: childProfile.id,
|
||||
publicToken: cardToken,
|
||||
scaProof: scaProof,
|
||||
);
|
||||
debugPrint('[RenewCard] renewCard SUCCESS');
|
||||
|
||||
if (!ref.mounted) return;
|
||||
ref.read(walletRefreshProvider.notifier).refresh();
|
||||
state = state.copyWith(isSubmitting: false, success: true);
|
||||
} catch (e) {
|
||||
debugPrint('[RenewCard] ERROR: $e');
|
||||
if (!ref.mounted) return;
|
||||
state = state.copyWith(
|
||||
isSigning: false,
|
||||
isSubmitting: false,
|
||||
pin: '',
|
||||
errorMessage: e.toString(),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
import 'package:sf_shared/sf_shared.dart';
|
||||
|
||||
part 'renew_card_view_state.freezed.dart';
|
||||
|
||||
enum RenewCardStep { cardToken, scaPin }
|
||||
|
||||
@freezed
|
||||
abstract class RenewCardViewState with _$RenewCardViewState {
|
||||
const factory RenewCardViewState({
|
||||
@Default(true) bool isLoading,
|
||||
ChildProfileEntity? childProfile,
|
||||
ChildWalletEntity? childWallet,
|
||||
DeviceEntity? device,
|
||||
@Default('') String cardToken,
|
||||
@Default('') String pin,
|
||||
@Default(RenewCardStep.cardToken) RenewCardStep step,
|
||||
@Default(false) bool isSigning,
|
||||
@Default(false) bool isSubmitting,
|
||||
@Default(false) bool success,
|
||||
@Default('') String errorMessage,
|
||||
}) = _RenewCardViewState;
|
||||
}
|
||||
@@ -0,0 +1,373 @@
|
||||
// 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 'renew_card_view_state.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// FreezedGenerator
|
||||
// **************************************************************************
|
||||
|
||||
// dart format off
|
||||
T _$identity<T>(T value) => value;
|
||||
/// @nodoc
|
||||
mixin _$RenewCardViewState {
|
||||
|
||||
bool get isLoading; ChildProfileEntity? get childProfile; ChildWalletEntity? get childWallet; DeviceEntity? get device; String get cardToken; String get pin; RenewCardStep get step; bool get isSigning; bool get isSubmitting; bool get success; String get errorMessage;
|
||||
/// Create a copy of RenewCardViewState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@pragma('vm:prefer-inline')
|
||||
$RenewCardViewStateCopyWith<RenewCardViewState> get copyWith => _$RenewCardViewStateCopyWithImpl<RenewCardViewState>(this as RenewCardViewState, _$identity);
|
||||
|
||||
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is RenewCardViewState&&(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.cardToken, cardToken) || other.cardToken == cardToken)&&(identical(other.pin, pin) || other.pin == pin)&&(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,cardToken,pin,step,isSigning,isSubmitting,success,errorMessage);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'RenewCardViewState(isLoading: $isLoading, childProfile: $childProfile, childWallet: $childWallet, device: $device, cardToken: $cardToken, pin: $pin, step: $step, isSigning: $isSigning, isSubmitting: $isSubmitting, success: $success, errorMessage: $errorMessage)';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract mixin class $RenewCardViewStateCopyWith<$Res> {
|
||||
factory $RenewCardViewStateCopyWith(RenewCardViewState value, $Res Function(RenewCardViewState) _then) = _$RenewCardViewStateCopyWithImpl;
|
||||
@useResult
|
||||
$Res call({
|
||||
bool isLoading, ChildProfileEntity? childProfile, ChildWalletEntity? childWallet, DeviceEntity? device, String cardToken, String pin, RenewCardStep step, bool isSigning, bool isSubmitting, bool success, String errorMessage
|
||||
});
|
||||
|
||||
|
||||
$ChildProfileEntityCopyWith<$Res>? get childProfile;$ChildWalletEntityCopyWith<$Res>? get childWallet;$DeviceEntityCopyWith<$Res>? get device;
|
||||
|
||||
}
|
||||
/// @nodoc
|
||||
class _$RenewCardViewStateCopyWithImpl<$Res>
|
||||
implements $RenewCardViewStateCopyWith<$Res> {
|
||||
_$RenewCardViewStateCopyWithImpl(this._self, this._then);
|
||||
|
||||
final RenewCardViewState _self;
|
||||
final $Res Function(RenewCardViewState) _then;
|
||||
|
||||
/// Create a copy of RenewCardViewState
|
||||
/// 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? cardToken = null,Object? pin = 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?,cardToken: null == cardToken ? _self.cardToken : cardToken // ignore: cast_nullable_to_non_nullable
|
||||
as String,pin: null == pin ? _self.pin : pin // ignore: cast_nullable_to_non_nullable
|
||||
as String,step: null == step ? _self.step : step // ignore: cast_nullable_to_non_nullable
|
||||
as RenewCardStep,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 RenewCardViewState
|
||||
/// 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 RenewCardViewState
|
||||
/// 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 RenewCardViewState
|
||||
/// 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 [RenewCardViewState].
|
||||
extension RenewCardViewStatePatterns on RenewCardViewState {
|
||||
/// 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( _RenewCardViewState value)? $default,{required TResult orElse(),}){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _RenewCardViewState() 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( _RenewCardViewState value) $default,){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _RenewCardViewState():
|
||||
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( _RenewCardViewState value)? $default,){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _RenewCardViewState() 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 cardToken, String pin, RenewCardStep step, bool isSigning, bool isSubmitting, bool success, String errorMessage)? $default,{required TResult orElse(),}) {final _that = this;
|
||||
switch (_that) {
|
||||
case _RenewCardViewState() when $default != null:
|
||||
return $default(_that.isLoading,_that.childProfile,_that.childWallet,_that.device,_that.cardToken,_that.pin,_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 cardToken, String pin, RenewCardStep step, bool isSigning, bool isSubmitting, bool success, String errorMessage) $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _RenewCardViewState():
|
||||
return $default(_that.isLoading,_that.childProfile,_that.childWallet,_that.device,_that.cardToken,_that.pin,_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 cardToken, String pin, RenewCardStep step, bool isSigning, bool isSubmitting, bool success, String errorMessage)? $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _RenewCardViewState() when $default != null:
|
||||
return $default(_that.isLoading,_that.childProfile,_that.childWallet,_that.device,_that.cardToken,_that.pin,_that.step,_that.isSigning,_that.isSubmitting,_that.success,_that.errorMessage);case _:
|
||||
return null;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
|
||||
|
||||
class _RenewCardViewState implements RenewCardViewState {
|
||||
const _RenewCardViewState({this.isLoading = true, this.childProfile, this.childWallet, this.device, this.cardToken = '', this.pin = '', this.step = RenewCardStep.cardToken, 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 cardToken;
|
||||
@override@JsonKey() final String pin;
|
||||
@override@JsonKey() final RenewCardStep 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 RenewCardViewState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override @JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@pragma('vm:prefer-inline')
|
||||
_$RenewCardViewStateCopyWith<_RenewCardViewState> get copyWith => __$RenewCardViewStateCopyWithImpl<_RenewCardViewState>(this, _$identity);
|
||||
|
||||
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is _RenewCardViewState&&(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.cardToken, cardToken) || other.cardToken == cardToken)&&(identical(other.pin, pin) || other.pin == pin)&&(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,cardToken,pin,step,isSigning,isSubmitting,success,errorMessage);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'RenewCardViewState(isLoading: $isLoading, childProfile: $childProfile, childWallet: $childWallet, device: $device, cardToken: $cardToken, pin: $pin, step: $step, isSigning: $isSigning, isSubmitting: $isSubmitting, success: $success, errorMessage: $errorMessage)';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract mixin class _$RenewCardViewStateCopyWith<$Res> implements $RenewCardViewStateCopyWith<$Res> {
|
||||
factory _$RenewCardViewStateCopyWith(_RenewCardViewState value, $Res Function(_RenewCardViewState) _then) = __$RenewCardViewStateCopyWithImpl;
|
||||
@override @useResult
|
||||
$Res call({
|
||||
bool isLoading, ChildProfileEntity? childProfile, ChildWalletEntity? childWallet, DeviceEntity? device, String cardToken, String pin, RenewCardStep 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 __$RenewCardViewStateCopyWithImpl<$Res>
|
||||
implements _$RenewCardViewStateCopyWith<$Res> {
|
||||
__$RenewCardViewStateCopyWithImpl(this._self, this._then);
|
||||
|
||||
final _RenewCardViewState _self;
|
||||
final $Res Function(_RenewCardViewState) _then;
|
||||
|
||||
/// Create a copy of RenewCardViewState
|
||||
/// 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? cardToken = null,Object? pin = null,Object? step = null,Object? isSigning = null,Object? isSubmitting = null,Object? success = null,Object? errorMessage = null,}) {
|
||||
return _then(_RenewCardViewState(
|
||||
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?,cardToken: null == cardToken ? _self.cardToken : cardToken // ignore: cast_nullable_to_non_nullable
|
||||
as String,pin: null == pin ? _self.pin : pin // ignore: cast_nullable_to_non_nullable
|
||||
as String,step: null == step ? _self.step : step // ignore: cast_nullable_to_non_nullable
|
||||
as RenewCardStep,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 RenewCardViewState
|
||||
/// 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 RenewCardViewState
|
||||
/// 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 RenewCardViewState
|
||||
/// 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
|
||||
@@ -15,7 +15,6 @@ mixin SignUpFormValidation {
|
||||
String emailErrorFor(String value) {
|
||||
final email = value.trim();
|
||||
if (email.isEmpty) return I18n.errorEmailRequired;
|
||||
if (email.contains('+')) return I18n.errorEmailPlusNotAllowed;
|
||||
if (!_emailRegex.hasMatch(email)) return I18n.errorEmailInvalid;
|
||||
return '';
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ class CheckSessionUseCaseImpl implements CheckSessionUseCase {
|
||||
debugPrint('[CheckSession] → onboarding');
|
||||
return InitialRoute.onboarding;
|
||||
}
|
||||
|
||||
// return InitialRoute.login;
|
||||
try {
|
||||
await _userRepository.getUserInfo();
|
||||
return InitialRoute.home;
|
||||
|
||||
@@ -53,9 +53,9 @@ class _SplashScreenState extends State<SplashScreen>
|
||||
if (!_animationDone || _route == null || !mounted) return;
|
||||
|
||||
final destination = switch (_route!) {
|
||||
InitialRoute.onboarding => AppRoutes.legacyOnboarding,
|
||||
InitialRoute.login => AppRoutes.legacyLogin,
|
||||
InitialRoute.home => AppRoutes.controlPanel,
|
||||
InitialRoute.onboarding => AppRoutes.onboarding,
|
||||
InitialRoute.login => AppRoutes.login,
|
||||
InitialRoute.home => AppRoutes.dashboardHome,
|
||||
};
|
||||
widget.navigationContract.goTo(destination);
|
||||
}
|
||||
|
||||
@@ -7,6 +7,6 @@
|
||||
<versions>
|
||||
<version>2.6.4</version>
|
||||
</versions>
|
||||
<lastUpdated>20260322000000</lastUpdated>
|
||||
<lastUpdated>20260324000000</lastUpdated>
|
||||
</versioning>
|
||||
</metadata>
|
||||
|
||||
@@ -1 +1 @@
|
||||
ec3c2e29f6fe8ca84eadd369212dff2b
|
||||
60e0101847630ce6dcc19b1e46fb081c
|
||||
@@ -1 +1 @@
|
||||
df5c1d0c2331a0f608264e4d5f14b9492f5eb2aa
|
||||
09ac1da2fb43d606168060ea769ec889804c3ed7
|
||||
@@ -31,6 +31,12 @@ class AppRoutes {
|
||||
'${childWallet(childWalletId)}/extract';
|
||||
static String editChildProfile(String childWalletId) =>
|
||||
'${childWallet(childWalletId)}/edit';
|
||||
static String setCardPin(String childWalletId) =>
|
||||
'${childWallet(childWalletId)}/set-pin';
|
||||
static String changeCardPin(String childWalletId) =>
|
||||
'${childWallet(childWalletId)}/change-pin';
|
||||
static String renewCard(String childWalletId) =>
|
||||
'${childWallet(childWalletId)}/renew-card';
|
||||
static const dashboardActivity = '$dashboard/activity';
|
||||
static const dashboardNotifications = '$dashboard/notifications';
|
||||
static const dashboardProfile = '$dashboard/profile';
|
||||
|
||||
@@ -22,13 +22,13 @@ class TreezorTokenInterceptor extends Interceptor {
|
||||
// _onTokenExpired();
|
||||
// Future.delayed(const Duration(seconds: 2), () => _handling = false);
|
||||
// }
|
||||
// else if (err.response?.statusCode == 500) {
|
||||
// _handling = true;
|
||||
// _onTokenExpired();
|
||||
// Future.delayed(const Duration(seconds: 2), () => _handling = false);
|
||||
// }
|
||||
if (err.response?.statusCode == 500) {
|
||||
_handling = true;
|
||||
_onTokenExpired();
|
||||
Future.delayed(const Duration(seconds: 2), () => _handling = false);
|
||||
}
|
||||
// else
|
||||
if (err.response?.statusCode == 401) {
|
||||
else if (err.response?.statusCode == 401) {
|
||||
_handling = true;
|
||||
_onUnauthorized();
|
||||
Future.delayed(const Duration(seconds: 2), () => _handling = false);
|
||||
|
||||
@@ -631,5 +631,27 @@
|
||||
"callHistoryEmpty": "Keine Anrufe aufgezeichnet",
|
||||
"callIncoming": "Eingehend",
|
||||
"callOutgoing": "Ausgehend",
|
||||
"callMissed": "Verpasst"
|
||||
"callMissed": "Verpasst",
|
||||
"cardPinSet": "PIN festlegen",
|
||||
"cardPinChange": "PIN ändern",
|
||||
"cardPinUnblock": "PIN entsperren",
|
||||
"cardPinSetTitle": "Karten-PIN festlegen",
|
||||
"cardPinChangeTitle": "Karten-PIN ändern",
|
||||
"cardPinCurrentStep": "Aktuelle PIN eingeben",
|
||||
"cardPinNewStep": "Neue PIN eingeben",
|
||||
"cardPinConfirmStep": "Neue PIN bestätigen",
|
||||
"cardPinScaStep": "Sicherheits-PIN eingeben",
|
||||
"cardPinNext": "Weiter",
|
||||
"cardPinMismatch": "PINs stimmen nicht überein, bitte erneut versuchen",
|
||||
"cardPinSuccess": "Karten-PIN erfolgreich aktualisiert",
|
||||
"cardPinError": "Fehler beim Aktualisieren der Karten-PIN",
|
||||
"cardPinUnblockConfirm": "Möchten Sie die Karten-PIN wirklich entsperren?",
|
||||
"cardPinUnblockSuccess": "Karten-PIN erfolgreich entsperrt",
|
||||
"cardPinUnblockError": "Fehler beim Entsperren der Karten-PIN",
|
||||
"renewCardTitle": "Karte erneuern",
|
||||
"renewCardConfirm": "Möchten Sie die Karte wirklich erneuern? Eine neue Karte wird ausgestellt.",
|
||||
"renewCardTokenHint": "Code der neuen Karte eingeben",
|
||||
"renewCardPinTitle": "Sicherheits-PIN eingeben, um die Karte zu erneuern",
|
||||
"renewCardSuccess": "Karte erfolgreich erneuert",
|
||||
"renewCardError": "Fehler beim Erneuern der Karte"
|
||||
}
|
||||
|
||||
@@ -763,5 +763,27 @@
|
||||
"callHistoryEmpty": "No calls recorded",
|
||||
"callIncoming": "Incoming",
|
||||
"callOutgoing": "Outgoing",
|
||||
"callMissed": "Missed"
|
||||
"callMissed": "Missed",
|
||||
"cardPinSet": "Set PIN",
|
||||
"cardPinChange": "Change PIN",
|
||||
"cardPinUnblock": "Unblock PIN",
|
||||
"cardPinSetTitle": "Set card PIN",
|
||||
"cardPinChangeTitle": "Change card PIN",
|
||||
"cardPinCurrentStep": "Enter current PIN",
|
||||
"cardPinNewStep": "Enter new PIN",
|
||||
"cardPinConfirmStep": "Confirm new PIN",
|
||||
"cardPinScaStep": "Enter your security PIN",
|
||||
"cardPinNext": "Next",
|
||||
"cardPinMismatch": "PINs do not match, please try again",
|
||||
"cardPinSuccess": "Card PIN updated successfully",
|
||||
"cardPinError": "Error updating card PIN",
|
||||
"cardPinUnblockConfirm": "Are you sure you want to unblock the card PIN?",
|
||||
"cardPinUnblockSuccess": "Card PIN unblocked successfully",
|
||||
"cardPinUnblockError": "Error unblocking card PIN",
|
||||
"renewCardTitle": "Renew card",
|
||||
"renewCardConfirm": "Are you sure you want to renew the card? A new card will be issued.",
|
||||
"renewCardTokenHint": "Enter the new card code",
|
||||
"renewCardPinTitle": "Enter your security PIN to renew the card",
|
||||
"renewCardSuccess": "Card renewed successfully",
|
||||
"renewCardError": "Error renewing card"
|
||||
}
|
||||
|
||||
@@ -761,5 +761,27 @@
|
||||
"callHistoryEmpty": "No hay llamadas registradas",
|
||||
"callIncoming": "Entrantes",
|
||||
"callOutgoing": "Salientes",
|
||||
"callMissed": "Perdidas"
|
||||
"callMissed": "Perdidas",
|
||||
"cardPinSet": "Establecer PIN",
|
||||
"cardPinChange": "Cambiar PIN",
|
||||
"cardPinUnblock": "Desbloquear PIN",
|
||||
"cardPinSetTitle": "Establecer PIN de tarjeta",
|
||||
"cardPinChangeTitle": "Cambiar PIN de tarjeta",
|
||||
"cardPinCurrentStep": "Introduce el PIN actual",
|
||||
"cardPinNewStep": "Introduce el nuevo PIN",
|
||||
"cardPinConfirmStep": "Confirma el nuevo PIN",
|
||||
"cardPinScaStep": "Introduce tu PIN de seguridad",
|
||||
"cardPinNext": "Siguiente",
|
||||
"cardPinMismatch": "Los PIN no coinciden, inténtalo de nuevo",
|
||||
"cardPinSuccess": "PIN de tarjeta actualizado correctamente",
|
||||
"cardPinError": "Error al actualizar el PIN de tarjeta",
|
||||
"cardPinUnblockConfirm": "¿Estás seguro de que quieres desbloquear el PIN de la tarjeta?",
|
||||
"cardPinUnblockSuccess": "PIN de tarjeta desbloqueado correctamente",
|
||||
"cardPinUnblockError": "Error al desbloquear el PIN de tarjeta",
|
||||
"renewCardTitle": "Renovar tarjeta",
|
||||
"renewCardConfirm": "¿Estás seguro de que quieres renovar la tarjeta? Se emitirá una nueva tarjeta.",
|
||||
"renewCardTokenHint": "Introduce el código de la nueva tarjeta",
|
||||
"renewCardPinTitle": "Introduce tu PIN de seguridad para renovar la tarjeta",
|
||||
"renewCardSuccess": "Tarjeta renovada correctamente",
|
||||
"renewCardError": "Error al renovar la tarjeta"
|
||||
}
|
||||
|
||||
@@ -631,5 +631,27 @@
|
||||
"callHistoryEmpty": "Aucun appel enregistré",
|
||||
"callIncoming": "Entrants",
|
||||
"callOutgoing": "Sortants",
|
||||
"callMissed": "Manqués"
|
||||
"callMissed": "Manqués",
|
||||
"cardPinSet": "Définir le PIN",
|
||||
"cardPinChange": "Changer le PIN",
|
||||
"cardPinUnblock": "Débloquer le PIN",
|
||||
"cardPinSetTitle": "Définir le PIN de la carte",
|
||||
"cardPinChangeTitle": "Changer le PIN de la carte",
|
||||
"cardPinCurrentStep": "Entrez le PIN actuel",
|
||||
"cardPinNewStep": "Entrez le nouveau PIN",
|
||||
"cardPinConfirmStep": "Confirmez le nouveau PIN",
|
||||
"cardPinScaStep": "Entrez votre PIN de sécurité",
|
||||
"cardPinNext": "Suivant",
|
||||
"cardPinMismatch": "Les PIN ne correspondent pas, veuillez réessayer",
|
||||
"cardPinSuccess": "PIN de la carte mis à jour avec succès",
|
||||
"cardPinError": "Erreur lors de la mise à jour du PIN de la carte",
|
||||
"cardPinUnblockConfirm": "Êtes-vous sûr de vouloir débloquer le PIN de la carte ?",
|
||||
"cardPinUnblockSuccess": "PIN de la carte débloqué avec succès",
|
||||
"cardPinUnblockError": "Erreur lors du déblocage du PIN de la carte",
|
||||
"renewCardTitle": "Renouveler la carte",
|
||||
"renewCardConfirm": "Êtes-vous sûr de vouloir renouveler la carte ? Une nouvelle carte sera émise.",
|
||||
"renewCardTokenHint": "Entrez le code de la nouvelle carte",
|
||||
"renewCardPinTitle": "Entrez votre PIN de sécurité pour renouveler la carte",
|
||||
"renewCardSuccess": "Carte renouvelée avec succès",
|
||||
"renewCardError": "Erreur lors du renouvellement de la carte"
|
||||
}
|
||||
|
||||
@@ -631,5 +631,27 @@
|
||||
"callHistoryEmpty": "Nessuna chiamata registrata",
|
||||
"callIncoming": "In arrivo",
|
||||
"callOutgoing": "In uscita",
|
||||
"callMissed": "Perse"
|
||||
"callMissed": "Perse",
|
||||
"cardPinSet": "Imposta PIN",
|
||||
"cardPinChange": "Cambia PIN",
|
||||
"cardPinUnblock": "Sblocca PIN",
|
||||
"cardPinSetTitle": "Imposta il PIN della carta",
|
||||
"cardPinChangeTitle": "Cambia il PIN della carta",
|
||||
"cardPinCurrentStep": "Inserisci il PIN attuale",
|
||||
"cardPinNewStep": "Inserisci il nuovo PIN",
|
||||
"cardPinConfirmStep": "Conferma il nuovo PIN",
|
||||
"cardPinScaStep": "Inserisci il tuo PIN di sicurezza",
|
||||
"cardPinNext": "Avanti",
|
||||
"cardPinMismatch": "I PIN non corrispondono, riprova",
|
||||
"cardPinSuccess": "PIN della carta aggiornato con successo",
|
||||
"cardPinError": "Errore nell'aggiornamento del PIN della carta",
|
||||
"cardPinUnblockConfirm": "Sei sicuro di voler sbloccare il PIN della carta?",
|
||||
"cardPinUnblockSuccess": "PIN della carta sbloccato con successo",
|
||||
"cardPinUnblockError": "Errore nello sblocco del PIN della carta",
|
||||
"renewCardTitle": "Rinnova carta",
|
||||
"renewCardConfirm": "Sei sicuro di voler rinnovare la carta? Verrà emessa una nuova carta.",
|
||||
"renewCardTokenHint": "Inserisci il codice della nuova carta",
|
||||
"renewCardPinTitle": "Inserisci il tuo PIN di sicurezza per rinnovare la carta",
|
||||
"renewCardSuccess": "Carta rinnovata con successo",
|
||||
"renewCardError": "Errore nel rinnovo della carta"
|
||||
}
|
||||
|
||||
@@ -631,5 +631,27 @@
|
||||
"callHistoryEmpty": "Nenhuma chamada registrada",
|
||||
"callIncoming": "Recebidas",
|
||||
"callOutgoing": "Efetuadas",
|
||||
"callMissed": "Perdidas"
|
||||
"callMissed": "Perdidas",
|
||||
"cardPinSet": "Definir PIN",
|
||||
"cardPinChange": "Alterar PIN",
|
||||
"cardPinUnblock": "Desbloquear PIN",
|
||||
"cardPinSetTitle": "Definir PIN do cartão",
|
||||
"cardPinChangeTitle": "Alterar PIN do cartão",
|
||||
"cardPinCurrentStep": "Introduza o PIN atual",
|
||||
"cardPinNewStep": "Introduza o novo PIN",
|
||||
"cardPinConfirmStep": "Confirme o novo PIN",
|
||||
"cardPinScaStep": "Introduza o seu PIN de segurança",
|
||||
"cardPinNext": "Seguinte",
|
||||
"cardPinMismatch": "Os PINs não coincidem, tente novamente",
|
||||
"cardPinSuccess": "PIN do cartão atualizado com sucesso",
|
||||
"cardPinError": "Erro ao atualizar o PIN do cartão",
|
||||
"cardPinUnblockConfirm": "Tem a certeza de que deseja desbloquear o PIN do cartão?",
|
||||
"cardPinUnblockSuccess": "PIN do cartão desbloqueado com sucesso",
|
||||
"cardPinUnblockError": "Erro ao desbloquear o PIN do cartão",
|
||||
"renewCardTitle": "Renovar cartão",
|
||||
"renewCardConfirm": "Tem a certeza de que deseja renovar o cartão? Será emitido um novo cartão.",
|
||||
"renewCardTokenHint": "Introduza o código do novo cartão",
|
||||
"renewCardPinTitle": "Introduza o seu PIN de segurança para renovar o cartão",
|
||||
"renewCardSuccess": "Cartão renovado com sucesso",
|
||||
"renewCardError": "Erro ao renovar o cartão"
|
||||
}
|
||||
|
||||
@@ -768,4 +768,26 @@ class I18n {
|
||||
static const String noPhotosAvailable = 'noPhotosAvailable';
|
||||
static const String yesterday = 'yesterday';
|
||||
static const String measure = 'measure';
|
||||
static const String cardPinSet = 'cardPinSet';
|
||||
static const String cardPinChange = 'cardPinChange';
|
||||
static const String cardPinUnblock = 'cardPinUnblock';
|
||||
static const String cardPinSetTitle = 'cardPinSetTitle';
|
||||
static const String cardPinChangeTitle = 'cardPinChangeTitle';
|
||||
static const String cardPinCurrentStep = 'cardPinCurrentStep';
|
||||
static const String cardPinNewStep = 'cardPinNewStep';
|
||||
static const String cardPinConfirmStep = 'cardPinConfirmStep';
|
||||
static const String cardPinScaStep = 'cardPinScaStep';
|
||||
static const String cardPinNext = 'cardPinNext';
|
||||
static const String cardPinMismatch = 'cardPinMismatch';
|
||||
static const String cardPinSuccess = 'cardPinSuccess';
|
||||
static const String cardPinError = 'cardPinError';
|
||||
static const String cardPinUnblockConfirm = 'cardPinUnblockConfirm';
|
||||
static const String cardPinUnblockSuccess = 'cardPinUnblockSuccess';
|
||||
static const String cardPinUnblockError = 'cardPinUnblockError';
|
||||
static const String renewCardTitle = 'renewCardTitle';
|
||||
static const String renewCardConfirm = 'renewCardConfirm';
|
||||
static const String renewCardTokenHint = 'renewCardTokenHint';
|
||||
static const String renewCardPinTitle = 'renewCardPinTitle';
|
||||
static const String renewCardSuccess = 'renewCardSuccess';
|
||||
static const String renewCardError = 'renewCardError';
|
||||
}
|
||||
|
||||
@@ -94,4 +94,27 @@ abstract class TreezorRemoteDatasource {
|
||||
required String walletId,
|
||||
required WalletLimitsModel limits,
|
||||
});
|
||||
|
||||
Future<void> setCardPin({
|
||||
required String walletId,
|
||||
required String newPin,
|
||||
required String confirmPin,
|
||||
required String scaProof,
|
||||
});
|
||||
|
||||
Future<void> changeCardPin({
|
||||
required String walletId,
|
||||
required String currentPin,
|
||||
required String newPin,
|
||||
required String confirmPin,
|
||||
required String scaProof,
|
||||
});
|
||||
|
||||
Future<void> unblockCardPin({required String walletId});
|
||||
|
||||
Future<void> renewCard({
|
||||
required String childProfileId,
|
||||
required String publicToken,
|
||||
required String scaProof,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -549,6 +549,91 @@ class TreezorRemoteDatasourceImpl implements TreezorRemoteDatasource {
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> setCardPin({
|
||||
required String walletId,
|
||||
required String newPin,
|
||||
required String confirmPin,
|
||||
required String scaProof,
|
||||
}) async {
|
||||
try {
|
||||
await _repository.put<void>(
|
||||
'/wallets/$walletId/card/set-pin',
|
||||
body: <String, dynamic>{
|
||||
'newPin': newPin,
|
||||
'confirmPin': confirmPin,
|
||||
'scaProof': scaProof,
|
||||
},
|
||||
);
|
||||
} on DioException catch (error) {
|
||||
throw _mapDioError(
|
||||
error,
|
||||
defaultMessage: 'Error in /wallets/$walletId/card/set-pin',
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> changeCardPin({
|
||||
required String walletId,
|
||||
required String currentPin,
|
||||
required String newPin,
|
||||
required String confirmPin,
|
||||
required String scaProof,
|
||||
}) async {
|
||||
try {
|
||||
await _repository.put<void>(
|
||||
'/wallets/$walletId/card/change-pin',
|
||||
body: <String, dynamic>{
|
||||
'currentPin': currentPin,
|
||||
'newPin': newPin,
|
||||
'confirmPin': confirmPin,
|
||||
'scaProof': scaProof,
|
||||
},
|
||||
);
|
||||
} on DioException catch (error) {
|
||||
throw _mapDioError(
|
||||
error,
|
||||
defaultMessage: 'Error in /wallets/$walletId/card/change-pin',
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> unblockCardPin({required String walletId}) async {
|
||||
try {
|
||||
await _repository.put<void>('/wallets/$walletId/card/unblock-pin');
|
||||
} on DioException catch (error) {
|
||||
throw _mapDioError(
|
||||
error,
|
||||
defaultMessage: 'Error in /wallets/$walletId/card/unblock-pin',
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> renewCard({
|
||||
required String childProfileId,
|
||||
required String publicToken,
|
||||
required String scaProof,
|
||||
}) async {
|
||||
try {
|
||||
await _repository.put<void>(
|
||||
'/child-profiles/$childProfileId/renew-card',
|
||||
body: <String, dynamic>{
|
||||
'publicToken': publicToken,
|
||||
'scaProof': scaProof,
|
||||
},
|
||||
);
|
||||
} on DioException catch (error) {
|
||||
throw _mapDioError(
|
||||
error,
|
||||
defaultMessage:
|
||||
'Error in /child-profiles/$childProfileId/renew-card',
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Exception _mapDioError(DioException error, {required String defaultMessage}) {
|
||||
|
||||
@@ -30,6 +30,7 @@ abstract class ChildProfileModel with _$ChildProfileModel {
|
||||
required String treezorUserId,
|
||||
required String address,
|
||||
required int createdAt,
|
||||
@Default(false) bool hasCardPin,
|
||||
}) = _ChildProfileModel;
|
||||
|
||||
factory ChildProfileModel.fromJson(Map<String, dynamic> json) =>
|
||||
@@ -49,6 +50,7 @@ extension ChildProfileModelMapper on ChildProfileModel {
|
||||
treezorUserId: treezorUserId,
|
||||
address: address,
|
||||
createdAt: createdAt,
|
||||
hasCardPin: hasCardPin,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -293,7 +293,7 @@ as int,
|
||||
/// @nodoc
|
||||
mixin _$ChildProfileModel {
|
||||
|
||||
String get id; String get deviceIdentificator; String get parentId; String get firstName; String get lastName; int get bornAt; String get walletId; String get treezorUserId; String get address; int get createdAt;
|
||||
String get id; String get deviceIdentificator; String get parentId; String get firstName; String get lastName; int get bornAt; String get walletId; String get treezorUserId; String get address; int get createdAt; bool get hasCardPin;
|
||||
/// Create a copy of ChildProfileModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@@ -306,16 +306,16 @@ $ChildProfileModelCopyWith<ChildProfileModel> get copyWith => _$ChildProfileMode
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is ChildProfileModel&&(identical(other.id, id) || other.id == id)&&(identical(other.deviceIdentificator, deviceIdentificator) || other.deviceIdentificator == deviceIdentificator)&&(identical(other.parentId, parentId) || other.parentId == parentId)&&(identical(other.firstName, firstName) || other.firstName == firstName)&&(identical(other.lastName, lastName) || other.lastName == lastName)&&(identical(other.bornAt, bornAt) || other.bornAt == bornAt)&&(identical(other.walletId, walletId) || other.walletId == walletId)&&(identical(other.treezorUserId, treezorUserId) || other.treezorUserId == treezorUserId)&&(identical(other.address, address) || other.address == address)&&(identical(other.createdAt, createdAt) || other.createdAt == createdAt));
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is ChildProfileModel&&(identical(other.id, id) || other.id == id)&&(identical(other.deviceIdentificator, deviceIdentificator) || other.deviceIdentificator == deviceIdentificator)&&(identical(other.parentId, parentId) || other.parentId == parentId)&&(identical(other.firstName, firstName) || other.firstName == firstName)&&(identical(other.lastName, lastName) || other.lastName == lastName)&&(identical(other.bornAt, bornAt) || other.bornAt == bornAt)&&(identical(other.walletId, walletId) || other.walletId == walletId)&&(identical(other.treezorUserId, treezorUserId) || other.treezorUserId == treezorUserId)&&(identical(other.address, address) || other.address == address)&&(identical(other.createdAt, createdAt) || other.createdAt == createdAt)&&(identical(other.hasCardPin, hasCardPin) || other.hasCardPin == hasCardPin));
|
||||
}
|
||||
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,id,deviceIdentificator,parentId,firstName,lastName,bornAt,walletId,treezorUserId,address,createdAt);
|
||||
int get hashCode => Object.hash(runtimeType,id,deviceIdentificator,parentId,firstName,lastName,bornAt,walletId,treezorUserId,address,createdAt,hasCardPin);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'ChildProfileModel(id: $id, deviceIdentificator: $deviceIdentificator, parentId: $parentId, firstName: $firstName, lastName: $lastName, bornAt: $bornAt, walletId: $walletId, treezorUserId: $treezorUserId, address: $address, createdAt: $createdAt)';
|
||||
return 'ChildProfileModel(id: $id, deviceIdentificator: $deviceIdentificator, parentId: $parentId, firstName: $firstName, lastName: $lastName, bornAt: $bornAt, walletId: $walletId, treezorUserId: $treezorUserId, address: $address, createdAt: $createdAt, hasCardPin: $hasCardPin)';
|
||||
}
|
||||
|
||||
|
||||
@@ -326,7 +326,7 @@ abstract mixin class $ChildProfileModelCopyWith<$Res> {
|
||||
factory $ChildProfileModelCopyWith(ChildProfileModel value, $Res Function(ChildProfileModel) _then) = _$ChildProfileModelCopyWithImpl;
|
||||
@useResult
|
||||
$Res call({
|
||||
String id, String deviceIdentificator, String parentId, String firstName, String lastName, int bornAt, String walletId, String treezorUserId, String address, int createdAt
|
||||
String id, String deviceIdentificator, String parentId, String firstName, String lastName, int bornAt, String walletId, String treezorUserId, String address, int createdAt, bool hasCardPin
|
||||
});
|
||||
|
||||
|
||||
@@ -343,7 +343,7 @@ class _$ChildProfileModelCopyWithImpl<$Res>
|
||||
|
||||
/// Create a copy of ChildProfileModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline') @override $Res call({Object? id = null,Object? deviceIdentificator = null,Object? parentId = null,Object? firstName = null,Object? lastName = null,Object? bornAt = null,Object? walletId = null,Object? treezorUserId = null,Object? address = null,Object? createdAt = null,}) {
|
||||
@pragma('vm:prefer-inline') @override $Res call({Object? id = null,Object? deviceIdentificator = null,Object? parentId = null,Object? firstName = null,Object? lastName = null,Object? bornAt = null,Object? walletId = null,Object? treezorUserId = null,Object? address = null,Object? createdAt = null,Object? hasCardPin = null,}) {
|
||||
return _then(_self.copyWith(
|
||||
id: null == id ? _self.id : id // ignore: cast_nullable_to_non_nullable
|
||||
as String,deviceIdentificator: null == deviceIdentificator ? _self.deviceIdentificator : deviceIdentificator // ignore: cast_nullable_to_non_nullable
|
||||
@@ -355,7 +355,8 @@ as int,walletId: null == walletId ? _self.walletId : walletId // ignore: cast_nu
|
||||
as String,treezorUserId: null == treezorUserId ? _self.treezorUserId : treezorUserId // ignore: cast_nullable_to_non_nullable
|
||||
as String,address: null == address ? _self.address : address // ignore: cast_nullable_to_non_nullable
|
||||
as String,createdAt: null == createdAt ? _self.createdAt : createdAt // ignore: cast_nullable_to_non_nullable
|
||||
as int,
|
||||
as int,hasCardPin: null == hasCardPin ? _self.hasCardPin : hasCardPin // ignore: cast_nullable_to_non_nullable
|
||||
as bool,
|
||||
));
|
||||
}
|
||||
|
||||
@@ -440,10 +441,10 @@ return $default(_that);case _:
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( String id, String deviceIdentificator, String parentId, String firstName, String lastName, int bornAt, String walletId, String treezorUserId, String address, int createdAt)? $default,{required TResult orElse(),}) {final _that = this;
|
||||
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( String id, String deviceIdentificator, String parentId, String firstName, String lastName, int bornAt, String walletId, String treezorUserId, String address, int createdAt, bool hasCardPin)? $default,{required TResult orElse(),}) {final _that = this;
|
||||
switch (_that) {
|
||||
case _ChildProfileModel() when $default != null:
|
||||
return $default(_that.id,_that.deviceIdentificator,_that.parentId,_that.firstName,_that.lastName,_that.bornAt,_that.walletId,_that.treezorUserId,_that.address,_that.createdAt);case _:
|
||||
return $default(_that.id,_that.deviceIdentificator,_that.parentId,_that.firstName,_that.lastName,_that.bornAt,_that.walletId,_that.treezorUserId,_that.address,_that.createdAt,_that.hasCardPin);case _:
|
||||
return orElse();
|
||||
|
||||
}
|
||||
@@ -461,10 +462,10 @@ return $default(_that.id,_that.deviceIdentificator,_that.parentId,_that.firstNam
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( String id, String deviceIdentificator, String parentId, String firstName, String lastName, int bornAt, String walletId, String treezorUserId, String address, int createdAt) $default,) {final _that = this;
|
||||
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( String id, String deviceIdentificator, String parentId, String firstName, String lastName, int bornAt, String walletId, String treezorUserId, String address, int createdAt, bool hasCardPin) $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _ChildProfileModel():
|
||||
return $default(_that.id,_that.deviceIdentificator,_that.parentId,_that.firstName,_that.lastName,_that.bornAt,_that.walletId,_that.treezorUserId,_that.address,_that.createdAt);case _:
|
||||
return $default(_that.id,_that.deviceIdentificator,_that.parentId,_that.firstName,_that.lastName,_that.bornAt,_that.walletId,_that.treezorUserId,_that.address,_that.createdAt,_that.hasCardPin);case _:
|
||||
throw StateError('Unexpected subclass');
|
||||
|
||||
}
|
||||
@@ -481,10 +482,10 @@ return $default(_that.id,_that.deviceIdentificator,_that.parentId,_that.firstNam
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( String id, String deviceIdentificator, String parentId, String firstName, String lastName, int bornAt, String walletId, String treezorUserId, String address, int createdAt)? $default,) {final _that = this;
|
||||
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( String id, String deviceIdentificator, String parentId, String firstName, String lastName, int bornAt, String walletId, String treezorUserId, String address, int createdAt, bool hasCardPin)? $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _ChildProfileModel() when $default != null:
|
||||
return $default(_that.id,_that.deviceIdentificator,_that.parentId,_that.firstName,_that.lastName,_that.bornAt,_that.walletId,_that.treezorUserId,_that.address,_that.createdAt);case _:
|
||||
return $default(_that.id,_that.deviceIdentificator,_that.parentId,_that.firstName,_that.lastName,_that.bornAt,_that.walletId,_that.treezorUserId,_that.address,_that.createdAt,_that.hasCardPin);case _:
|
||||
return null;
|
||||
|
||||
}
|
||||
@@ -496,7 +497,7 @@ return $default(_that.id,_that.deviceIdentificator,_that.parentId,_that.firstNam
|
||||
@JsonSerializable()
|
||||
|
||||
class _ChildProfileModel implements ChildProfileModel {
|
||||
const _ChildProfileModel({required this.id, required this.deviceIdentificator, required this.parentId, required this.firstName, required this.lastName, required this.bornAt, required this.walletId, required this.treezorUserId, required this.address, required this.createdAt});
|
||||
const _ChildProfileModel({required this.id, required this.deviceIdentificator, required this.parentId, required this.firstName, required this.lastName, required this.bornAt, required this.walletId, required this.treezorUserId, required this.address, required this.createdAt, this.hasCardPin = false});
|
||||
factory _ChildProfileModel.fromJson(Map<String, dynamic> json) => _$ChildProfileModelFromJson(json);
|
||||
|
||||
@override final String id;
|
||||
@@ -509,6 +510,7 @@ class _ChildProfileModel implements ChildProfileModel {
|
||||
@override final String treezorUserId;
|
||||
@override final String address;
|
||||
@override final int createdAt;
|
||||
@override@JsonKey() final bool hasCardPin;
|
||||
|
||||
/// Create a copy of ChildProfileModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@@ -523,16 +525,16 @@ Map<String, dynamic> toJson() {
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is _ChildProfileModel&&(identical(other.id, id) || other.id == id)&&(identical(other.deviceIdentificator, deviceIdentificator) || other.deviceIdentificator == deviceIdentificator)&&(identical(other.parentId, parentId) || other.parentId == parentId)&&(identical(other.firstName, firstName) || other.firstName == firstName)&&(identical(other.lastName, lastName) || other.lastName == lastName)&&(identical(other.bornAt, bornAt) || other.bornAt == bornAt)&&(identical(other.walletId, walletId) || other.walletId == walletId)&&(identical(other.treezorUserId, treezorUserId) || other.treezorUserId == treezorUserId)&&(identical(other.address, address) || other.address == address)&&(identical(other.createdAt, createdAt) || other.createdAt == createdAt));
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is _ChildProfileModel&&(identical(other.id, id) || other.id == id)&&(identical(other.deviceIdentificator, deviceIdentificator) || other.deviceIdentificator == deviceIdentificator)&&(identical(other.parentId, parentId) || other.parentId == parentId)&&(identical(other.firstName, firstName) || other.firstName == firstName)&&(identical(other.lastName, lastName) || other.lastName == lastName)&&(identical(other.bornAt, bornAt) || other.bornAt == bornAt)&&(identical(other.walletId, walletId) || other.walletId == walletId)&&(identical(other.treezorUserId, treezorUserId) || other.treezorUserId == treezorUserId)&&(identical(other.address, address) || other.address == address)&&(identical(other.createdAt, createdAt) || other.createdAt == createdAt)&&(identical(other.hasCardPin, hasCardPin) || other.hasCardPin == hasCardPin));
|
||||
}
|
||||
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,id,deviceIdentificator,parentId,firstName,lastName,bornAt,walletId,treezorUserId,address,createdAt);
|
||||
int get hashCode => Object.hash(runtimeType,id,deviceIdentificator,parentId,firstName,lastName,bornAt,walletId,treezorUserId,address,createdAt,hasCardPin);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'ChildProfileModel(id: $id, deviceIdentificator: $deviceIdentificator, parentId: $parentId, firstName: $firstName, lastName: $lastName, bornAt: $bornAt, walletId: $walletId, treezorUserId: $treezorUserId, address: $address, createdAt: $createdAt)';
|
||||
return 'ChildProfileModel(id: $id, deviceIdentificator: $deviceIdentificator, parentId: $parentId, firstName: $firstName, lastName: $lastName, bornAt: $bornAt, walletId: $walletId, treezorUserId: $treezorUserId, address: $address, createdAt: $createdAt, hasCardPin: $hasCardPin)';
|
||||
}
|
||||
|
||||
|
||||
@@ -543,7 +545,7 @@ abstract mixin class _$ChildProfileModelCopyWith<$Res> implements $ChildProfileM
|
||||
factory _$ChildProfileModelCopyWith(_ChildProfileModel value, $Res Function(_ChildProfileModel) _then) = __$ChildProfileModelCopyWithImpl;
|
||||
@override @useResult
|
||||
$Res call({
|
||||
String id, String deviceIdentificator, String parentId, String firstName, String lastName, int bornAt, String walletId, String treezorUserId, String address, int createdAt
|
||||
String id, String deviceIdentificator, String parentId, String firstName, String lastName, int bornAt, String walletId, String treezorUserId, String address, int createdAt, bool hasCardPin
|
||||
});
|
||||
|
||||
|
||||
@@ -560,7 +562,7 @@ class __$ChildProfileModelCopyWithImpl<$Res>
|
||||
|
||||
/// Create a copy of ChildProfileModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override @pragma('vm:prefer-inline') $Res call({Object? id = null,Object? deviceIdentificator = null,Object? parentId = null,Object? firstName = null,Object? lastName = null,Object? bornAt = null,Object? walletId = null,Object? treezorUserId = null,Object? address = null,Object? createdAt = null,}) {
|
||||
@override @pragma('vm:prefer-inline') $Res call({Object? id = null,Object? deviceIdentificator = null,Object? parentId = null,Object? firstName = null,Object? lastName = null,Object? bornAt = null,Object? walletId = null,Object? treezorUserId = null,Object? address = null,Object? createdAt = null,Object? hasCardPin = null,}) {
|
||||
return _then(_ChildProfileModel(
|
||||
id: null == id ? _self.id : id // ignore: cast_nullable_to_non_nullable
|
||||
as String,deviceIdentificator: null == deviceIdentificator ? _self.deviceIdentificator : deviceIdentificator // ignore: cast_nullable_to_non_nullable
|
||||
@@ -572,7 +574,8 @@ as int,walletId: null == walletId ? _self.walletId : walletId // ignore: cast_nu
|
||||
as String,treezorUserId: null == treezorUserId ? _self.treezorUserId : treezorUserId // ignore: cast_nullable_to_non_nullable
|
||||
as String,address: null == address ? _self.address : address // ignore: cast_nullable_to_non_nullable
|
||||
as String,createdAt: null == createdAt ? _self.createdAt : createdAt // ignore: cast_nullable_to_non_nullable
|
||||
as int,
|
||||
as int,hasCardPin: null == hasCardPin ? _self.hasCardPin : hasCardPin // ignore: cast_nullable_to_non_nullable
|
||||
as bool,
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
@@ -38,6 +38,7 @@ _ChildProfileModel _$ChildProfileModelFromJson(Map<String, dynamic> json) =>
|
||||
treezorUserId: json['treezorUserId'] as String,
|
||||
address: json['address'] as String,
|
||||
createdAt: (json['createdAt'] as num).toInt(),
|
||||
hasCardPin: json['hasCardPin'] as bool? ?? false,
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$ChildProfileModelToJson(_ChildProfileModel instance) =>
|
||||
@@ -52,4 +53,5 @@ Map<String, dynamic> _$ChildProfileModelToJson(_ChildProfileModel instance) =>
|
||||
'treezorUserId': instance.treezorUserId,
|
||||
'address': instance.address,
|
||||
'createdAt': instance.createdAt,
|
||||
'hasCardPin': instance.hasCardPin,
|
||||
};
|
||||
|
||||
@@ -11,6 +11,7 @@ abstract class WalletCardModel with _$WalletCardModel {
|
||||
required int walletId,
|
||||
required int userId,
|
||||
required String status,
|
||||
@Default(false) bool isPinBlocked,
|
||||
}) = _WalletCardModel;
|
||||
|
||||
factory WalletCardModel.fromJson(Map<String, dynamic> json) =>
|
||||
@@ -24,6 +25,7 @@ extension WalletCardModelMapper on WalletCardModel {
|
||||
walletId: walletId,
|
||||
userId: userId,
|
||||
status: status,
|
||||
isPinBlocked: isPinBlocked,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ T _$identity<T>(T value) => value;
|
||||
/// @nodoc
|
||||
mixin _$WalletCardModel {
|
||||
|
||||
int get cardId; int get walletId; int get userId; String get status;
|
||||
int get cardId; int get walletId; int get userId; String get status; bool get isPinBlocked;
|
||||
/// Create a copy of WalletCardModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@@ -28,16 +28,16 @@ $WalletCardModelCopyWith<WalletCardModel> get copyWith => _$WalletCardModelCopyW
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is WalletCardModel&&(identical(other.cardId, cardId) || other.cardId == cardId)&&(identical(other.walletId, walletId) || other.walletId == walletId)&&(identical(other.userId, userId) || other.userId == userId)&&(identical(other.status, status) || other.status == status));
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is WalletCardModel&&(identical(other.cardId, cardId) || other.cardId == cardId)&&(identical(other.walletId, walletId) || other.walletId == walletId)&&(identical(other.userId, userId) || other.userId == userId)&&(identical(other.status, status) || other.status == status)&&(identical(other.isPinBlocked, isPinBlocked) || other.isPinBlocked == isPinBlocked));
|
||||
}
|
||||
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,cardId,walletId,userId,status);
|
||||
int get hashCode => Object.hash(runtimeType,cardId,walletId,userId,status,isPinBlocked);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'WalletCardModel(cardId: $cardId, walletId: $walletId, userId: $userId, status: $status)';
|
||||
return 'WalletCardModel(cardId: $cardId, walletId: $walletId, userId: $userId, status: $status, isPinBlocked: $isPinBlocked)';
|
||||
}
|
||||
|
||||
|
||||
@@ -48,7 +48,7 @@ abstract mixin class $WalletCardModelCopyWith<$Res> {
|
||||
factory $WalletCardModelCopyWith(WalletCardModel value, $Res Function(WalletCardModel) _then) = _$WalletCardModelCopyWithImpl;
|
||||
@useResult
|
||||
$Res call({
|
||||
int cardId, int walletId, int userId, String status
|
||||
int cardId, int walletId, int userId, String status, bool isPinBlocked
|
||||
});
|
||||
|
||||
|
||||
@@ -65,13 +65,14 @@ class _$WalletCardModelCopyWithImpl<$Res>
|
||||
|
||||
/// Create a copy of WalletCardModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline') @override $Res call({Object? cardId = null,Object? walletId = null,Object? userId = null,Object? status = null,}) {
|
||||
@pragma('vm:prefer-inline') @override $Res call({Object? cardId = null,Object? walletId = null,Object? userId = null,Object? status = null,Object? isPinBlocked = null,}) {
|
||||
return _then(_self.copyWith(
|
||||
cardId: null == cardId ? _self.cardId : cardId // ignore: cast_nullable_to_non_nullable
|
||||
as int,walletId: null == walletId ? _self.walletId : walletId // ignore: cast_nullable_to_non_nullable
|
||||
as int,userId: null == userId ? _self.userId : userId // ignore: cast_nullable_to_non_nullable
|
||||
as int,status: null == status ? _self.status : status // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
as String,isPinBlocked: null == isPinBlocked ? _self.isPinBlocked : isPinBlocked // ignore: cast_nullable_to_non_nullable
|
||||
as bool,
|
||||
));
|
||||
}
|
||||
|
||||
@@ -156,10 +157,10 @@ return $default(_that);case _:
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( int cardId, int walletId, int userId, String status)? $default,{required TResult orElse(),}) {final _that = this;
|
||||
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( int cardId, int walletId, int userId, String status, bool isPinBlocked)? $default,{required TResult orElse(),}) {final _that = this;
|
||||
switch (_that) {
|
||||
case _WalletCardModel() when $default != null:
|
||||
return $default(_that.cardId,_that.walletId,_that.userId,_that.status);case _:
|
||||
return $default(_that.cardId,_that.walletId,_that.userId,_that.status,_that.isPinBlocked);case _:
|
||||
return orElse();
|
||||
|
||||
}
|
||||
@@ -177,10 +178,10 @@ return $default(_that.cardId,_that.walletId,_that.userId,_that.status);case _:
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( int cardId, int walletId, int userId, String status) $default,) {final _that = this;
|
||||
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( int cardId, int walletId, int userId, String status, bool isPinBlocked) $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _WalletCardModel():
|
||||
return $default(_that.cardId,_that.walletId,_that.userId,_that.status);case _:
|
||||
return $default(_that.cardId,_that.walletId,_that.userId,_that.status,_that.isPinBlocked);case _:
|
||||
throw StateError('Unexpected subclass');
|
||||
|
||||
}
|
||||
@@ -197,10 +198,10 @@ return $default(_that.cardId,_that.walletId,_that.userId,_that.status);case _:
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( int cardId, int walletId, int userId, String status)? $default,) {final _that = this;
|
||||
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( int cardId, int walletId, int userId, String status, bool isPinBlocked)? $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _WalletCardModel() when $default != null:
|
||||
return $default(_that.cardId,_that.walletId,_that.userId,_that.status);case _:
|
||||
return $default(_that.cardId,_that.walletId,_that.userId,_that.status,_that.isPinBlocked);case _:
|
||||
return null;
|
||||
|
||||
}
|
||||
@@ -212,13 +213,14 @@ return $default(_that.cardId,_that.walletId,_that.userId,_that.status);case _:
|
||||
@JsonSerializable()
|
||||
|
||||
class _WalletCardModel implements WalletCardModel {
|
||||
const _WalletCardModel({required this.cardId, required this.walletId, required this.userId, required this.status});
|
||||
const _WalletCardModel({required this.cardId, required this.walletId, required this.userId, required this.status, this.isPinBlocked = false});
|
||||
factory _WalletCardModel.fromJson(Map<String, dynamic> json) => _$WalletCardModelFromJson(json);
|
||||
|
||||
@override final int cardId;
|
||||
@override final int walletId;
|
||||
@override final int userId;
|
||||
@override final String status;
|
||||
@override@JsonKey() final bool isPinBlocked;
|
||||
|
||||
/// Create a copy of WalletCardModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@@ -233,16 +235,16 @@ Map<String, dynamic> toJson() {
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is _WalletCardModel&&(identical(other.cardId, cardId) || other.cardId == cardId)&&(identical(other.walletId, walletId) || other.walletId == walletId)&&(identical(other.userId, userId) || other.userId == userId)&&(identical(other.status, status) || other.status == status));
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is _WalletCardModel&&(identical(other.cardId, cardId) || other.cardId == cardId)&&(identical(other.walletId, walletId) || other.walletId == walletId)&&(identical(other.userId, userId) || other.userId == userId)&&(identical(other.status, status) || other.status == status)&&(identical(other.isPinBlocked, isPinBlocked) || other.isPinBlocked == isPinBlocked));
|
||||
}
|
||||
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,cardId,walletId,userId,status);
|
||||
int get hashCode => Object.hash(runtimeType,cardId,walletId,userId,status,isPinBlocked);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'WalletCardModel(cardId: $cardId, walletId: $walletId, userId: $userId, status: $status)';
|
||||
return 'WalletCardModel(cardId: $cardId, walletId: $walletId, userId: $userId, status: $status, isPinBlocked: $isPinBlocked)';
|
||||
}
|
||||
|
||||
|
||||
@@ -253,7 +255,7 @@ abstract mixin class _$WalletCardModelCopyWith<$Res> implements $WalletCardModel
|
||||
factory _$WalletCardModelCopyWith(_WalletCardModel value, $Res Function(_WalletCardModel) _then) = __$WalletCardModelCopyWithImpl;
|
||||
@override @useResult
|
||||
$Res call({
|
||||
int cardId, int walletId, int userId, String status
|
||||
int cardId, int walletId, int userId, String status, bool isPinBlocked
|
||||
});
|
||||
|
||||
|
||||
@@ -270,13 +272,14 @@ class __$WalletCardModelCopyWithImpl<$Res>
|
||||
|
||||
/// Create a copy of WalletCardModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override @pragma('vm:prefer-inline') $Res call({Object? cardId = null,Object? walletId = null,Object? userId = null,Object? status = null,}) {
|
||||
@override @pragma('vm:prefer-inline') $Res call({Object? cardId = null,Object? walletId = null,Object? userId = null,Object? status = null,Object? isPinBlocked = null,}) {
|
||||
return _then(_WalletCardModel(
|
||||
cardId: null == cardId ? _self.cardId : cardId // ignore: cast_nullable_to_non_nullable
|
||||
as int,walletId: null == walletId ? _self.walletId : walletId // ignore: cast_nullable_to_non_nullable
|
||||
as int,userId: null == userId ? _self.userId : userId // ignore: cast_nullable_to_non_nullable
|
||||
as int,status: null == status ? _self.status : status // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
as String,isPinBlocked: null == isPinBlocked ? _self.isPinBlocked : isPinBlocked // ignore: cast_nullable_to_non_nullable
|
||||
as bool,
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@ _WalletCardModel _$WalletCardModelFromJson(Map<String, dynamic> json) =>
|
||||
walletId: (json['walletId'] as num).toInt(),
|
||||
userId: (json['userId'] as num).toInt(),
|
||||
status: json['status'] as String,
|
||||
isPinBlocked: json['isPinBlocked'] as bool? ?? false,
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$WalletCardModelToJson(_WalletCardModel instance) =>
|
||||
@@ -20,4 +21,5 @@ Map<String, dynamic> _$WalletCardModelToJson(_WalletCardModel instance) =>
|
||||
'walletId': instance.walletId,
|
||||
'userId': instance.userId,
|
||||
'status': instance.status,
|
||||
'isPinBlocked': instance.isPinBlocked,
|
||||
};
|
||||
|
||||
@@ -325,4 +325,54 @@ class TreezorRepositoryImpl implements TreezorRepository {
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> setCardPin({
|
||||
required String walletId,
|
||||
required String newPin,
|
||||
required String confirmPin,
|
||||
required String scaProof,
|
||||
}) async {
|
||||
await _remote.setCardPin(
|
||||
walletId: walletId,
|
||||
newPin: newPin,
|
||||
confirmPin: confirmPin,
|
||||
scaProof: scaProof,
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> changeCardPin({
|
||||
required String walletId,
|
||||
required String currentPin,
|
||||
required String newPin,
|
||||
required String confirmPin,
|
||||
required String scaProof,
|
||||
}) async {
|
||||
await _remote.changeCardPin(
|
||||
walletId: walletId,
|
||||
currentPin: currentPin,
|
||||
newPin: newPin,
|
||||
confirmPin: confirmPin,
|
||||
scaProof: scaProof,
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> unblockCardPin({required String walletId}) async {
|
||||
await _remote.unblockCardPin(walletId: walletId);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> renewCard({
|
||||
required String childProfileId,
|
||||
required String publicToken,
|
||||
required String scaProof,
|
||||
}) async {
|
||||
await _remote.renewCard(
|
||||
childProfileId: childProfileId,
|
||||
publicToken: publicToken,
|
||||
scaProof: scaProof,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,5 +15,6 @@ abstract class ChildProfileEntity with _$ChildProfileEntity {
|
||||
required String treezorUserId,
|
||||
required String address,
|
||||
required int createdAt,
|
||||
@Default(false) bool hasCardPin,
|
||||
}) = _ChildProfileEntity;
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ T _$identity<T>(T value) => value;
|
||||
/// @nodoc
|
||||
mixin _$ChildProfileEntity {
|
||||
|
||||
String get id; String get deviceIdentificator; String get parentId; String get firstName; String get lastName; int get bornAt; String get walletId; String get treezorUserId; String get address; int get createdAt;
|
||||
String get id; String get deviceIdentificator; String get parentId; String get firstName; String get lastName; int get bornAt; String get walletId; String get treezorUserId; String get address; int get createdAt; bool get hasCardPin;
|
||||
/// Create a copy of ChildProfileEntity
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@@ -25,16 +25,16 @@ $ChildProfileEntityCopyWith<ChildProfileEntity> get copyWith => _$ChildProfileEn
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is ChildProfileEntity&&(identical(other.id, id) || other.id == id)&&(identical(other.deviceIdentificator, deviceIdentificator) || other.deviceIdentificator == deviceIdentificator)&&(identical(other.parentId, parentId) || other.parentId == parentId)&&(identical(other.firstName, firstName) || other.firstName == firstName)&&(identical(other.lastName, lastName) || other.lastName == lastName)&&(identical(other.bornAt, bornAt) || other.bornAt == bornAt)&&(identical(other.walletId, walletId) || other.walletId == walletId)&&(identical(other.treezorUserId, treezorUserId) || other.treezorUserId == treezorUserId)&&(identical(other.address, address) || other.address == address)&&(identical(other.createdAt, createdAt) || other.createdAt == createdAt));
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is ChildProfileEntity&&(identical(other.id, id) || other.id == id)&&(identical(other.deviceIdentificator, deviceIdentificator) || other.deviceIdentificator == deviceIdentificator)&&(identical(other.parentId, parentId) || other.parentId == parentId)&&(identical(other.firstName, firstName) || other.firstName == firstName)&&(identical(other.lastName, lastName) || other.lastName == lastName)&&(identical(other.bornAt, bornAt) || other.bornAt == bornAt)&&(identical(other.walletId, walletId) || other.walletId == walletId)&&(identical(other.treezorUserId, treezorUserId) || other.treezorUserId == treezorUserId)&&(identical(other.address, address) || other.address == address)&&(identical(other.createdAt, createdAt) || other.createdAt == createdAt)&&(identical(other.hasCardPin, hasCardPin) || other.hasCardPin == hasCardPin));
|
||||
}
|
||||
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,id,deviceIdentificator,parentId,firstName,lastName,bornAt,walletId,treezorUserId,address,createdAt);
|
||||
int get hashCode => Object.hash(runtimeType,id,deviceIdentificator,parentId,firstName,lastName,bornAt,walletId,treezorUserId,address,createdAt,hasCardPin);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'ChildProfileEntity(id: $id, deviceIdentificator: $deviceIdentificator, parentId: $parentId, firstName: $firstName, lastName: $lastName, bornAt: $bornAt, walletId: $walletId, treezorUserId: $treezorUserId, address: $address, createdAt: $createdAt)';
|
||||
return 'ChildProfileEntity(id: $id, deviceIdentificator: $deviceIdentificator, parentId: $parentId, firstName: $firstName, lastName: $lastName, bornAt: $bornAt, walletId: $walletId, treezorUserId: $treezorUserId, address: $address, createdAt: $createdAt, hasCardPin: $hasCardPin)';
|
||||
}
|
||||
|
||||
|
||||
@@ -45,7 +45,7 @@ abstract mixin class $ChildProfileEntityCopyWith<$Res> {
|
||||
factory $ChildProfileEntityCopyWith(ChildProfileEntity value, $Res Function(ChildProfileEntity) _then) = _$ChildProfileEntityCopyWithImpl;
|
||||
@useResult
|
||||
$Res call({
|
||||
String id, String deviceIdentificator, String parentId, String firstName, String lastName, int bornAt, String walletId, String treezorUserId, String address, int createdAt
|
||||
String id, String deviceIdentificator, String parentId, String firstName, String lastName, int bornAt, String walletId, String treezorUserId, String address, int createdAt, bool hasCardPin
|
||||
});
|
||||
|
||||
|
||||
@@ -62,7 +62,7 @@ class _$ChildProfileEntityCopyWithImpl<$Res>
|
||||
|
||||
/// Create a copy of ChildProfileEntity
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline') @override $Res call({Object? id = null,Object? deviceIdentificator = null,Object? parentId = null,Object? firstName = null,Object? lastName = null,Object? bornAt = null,Object? walletId = null,Object? treezorUserId = null,Object? address = null,Object? createdAt = null,}) {
|
||||
@pragma('vm:prefer-inline') @override $Res call({Object? id = null,Object? deviceIdentificator = null,Object? parentId = null,Object? firstName = null,Object? lastName = null,Object? bornAt = null,Object? walletId = null,Object? treezorUserId = null,Object? address = null,Object? createdAt = null,Object? hasCardPin = null,}) {
|
||||
return _then(_self.copyWith(
|
||||
id: null == id ? _self.id : id // ignore: cast_nullable_to_non_nullable
|
||||
as String,deviceIdentificator: null == deviceIdentificator ? _self.deviceIdentificator : deviceIdentificator // ignore: cast_nullable_to_non_nullable
|
||||
@@ -74,7 +74,8 @@ as int,walletId: null == walletId ? _self.walletId : walletId // ignore: cast_nu
|
||||
as String,treezorUserId: null == treezorUserId ? _self.treezorUserId : treezorUserId // ignore: cast_nullable_to_non_nullable
|
||||
as String,address: null == address ? _self.address : address // ignore: cast_nullable_to_non_nullable
|
||||
as String,createdAt: null == createdAt ? _self.createdAt : createdAt // ignore: cast_nullable_to_non_nullable
|
||||
as int,
|
||||
as int,hasCardPin: null == hasCardPin ? _self.hasCardPin : hasCardPin // ignore: cast_nullable_to_non_nullable
|
||||
as bool,
|
||||
));
|
||||
}
|
||||
|
||||
@@ -159,10 +160,10 @@ return $default(_that);case _:
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( String id, String deviceIdentificator, String parentId, String firstName, String lastName, int bornAt, String walletId, String treezorUserId, String address, int createdAt)? $default,{required TResult orElse(),}) {final _that = this;
|
||||
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( String id, String deviceIdentificator, String parentId, String firstName, String lastName, int bornAt, String walletId, String treezorUserId, String address, int createdAt, bool hasCardPin)? $default,{required TResult orElse(),}) {final _that = this;
|
||||
switch (_that) {
|
||||
case _ChildProfileEntity() when $default != null:
|
||||
return $default(_that.id,_that.deviceIdentificator,_that.parentId,_that.firstName,_that.lastName,_that.bornAt,_that.walletId,_that.treezorUserId,_that.address,_that.createdAt);case _:
|
||||
return $default(_that.id,_that.deviceIdentificator,_that.parentId,_that.firstName,_that.lastName,_that.bornAt,_that.walletId,_that.treezorUserId,_that.address,_that.createdAt,_that.hasCardPin);case _:
|
||||
return orElse();
|
||||
|
||||
}
|
||||
@@ -180,10 +181,10 @@ return $default(_that.id,_that.deviceIdentificator,_that.parentId,_that.firstNam
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( String id, String deviceIdentificator, String parentId, String firstName, String lastName, int bornAt, String walletId, String treezorUserId, String address, int createdAt) $default,) {final _that = this;
|
||||
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( String id, String deviceIdentificator, String parentId, String firstName, String lastName, int bornAt, String walletId, String treezorUserId, String address, int createdAt, bool hasCardPin) $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _ChildProfileEntity():
|
||||
return $default(_that.id,_that.deviceIdentificator,_that.parentId,_that.firstName,_that.lastName,_that.bornAt,_that.walletId,_that.treezorUserId,_that.address,_that.createdAt);case _:
|
||||
return $default(_that.id,_that.deviceIdentificator,_that.parentId,_that.firstName,_that.lastName,_that.bornAt,_that.walletId,_that.treezorUserId,_that.address,_that.createdAt,_that.hasCardPin);case _:
|
||||
throw StateError('Unexpected subclass');
|
||||
|
||||
}
|
||||
@@ -200,10 +201,10 @@ return $default(_that.id,_that.deviceIdentificator,_that.parentId,_that.firstNam
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( String id, String deviceIdentificator, String parentId, String firstName, String lastName, int bornAt, String walletId, String treezorUserId, String address, int createdAt)? $default,) {final _that = this;
|
||||
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( String id, String deviceIdentificator, String parentId, String firstName, String lastName, int bornAt, String walletId, String treezorUserId, String address, int createdAt, bool hasCardPin)? $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _ChildProfileEntity() when $default != null:
|
||||
return $default(_that.id,_that.deviceIdentificator,_that.parentId,_that.firstName,_that.lastName,_that.bornAt,_that.walletId,_that.treezorUserId,_that.address,_that.createdAt);case _:
|
||||
return $default(_that.id,_that.deviceIdentificator,_that.parentId,_that.firstName,_that.lastName,_that.bornAt,_that.walletId,_that.treezorUserId,_that.address,_that.createdAt,_that.hasCardPin);case _:
|
||||
return null;
|
||||
|
||||
}
|
||||
@@ -215,7 +216,7 @@ return $default(_that.id,_that.deviceIdentificator,_that.parentId,_that.firstNam
|
||||
|
||||
|
||||
class _ChildProfileEntity implements ChildProfileEntity {
|
||||
const _ChildProfileEntity({required this.id, required this.deviceIdentificator, required this.parentId, required this.firstName, required this.lastName, required this.bornAt, required this.walletId, required this.treezorUserId, required this.address, required this.createdAt});
|
||||
const _ChildProfileEntity({required this.id, required this.deviceIdentificator, required this.parentId, required this.firstName, required this.lastName, required this.bornAt, required this.walletId, required this.treezorUserId, required this.address, required this.createdAt, this.hasCardPin = false});
|
||||
|
||||
|
||||
@override final String id;
|
||||
@@ -228,6 +229,7 @@ class _ChildProfileEntity implements ChildProfileEntity {
|
||||
@override final String treezorUserId;
|
||||
@override final String address;
|
||||
@override final int createdAt;
|
||||
@override@JsonKey() final bool hasCardPin;
|
||||
|
||||
/// Create a copy of ChildProfileEntity
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@@ -239,16 +241,16 @@ _$ChildProfileEntityCopyWith<_ChildProfileEntity> get copyWith => __$ChildProfil
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is _ChildProfileEntity&&(identical(other.id, id) || other.id == id)&&(identical(other.deviceIdentificator, deviceIdentificator) || other.deviceIdentificator == deviceIdentificator)&&(identical(other.parentId, parentId) || other.parentId == parentId)&&(identical(other.firstName, firstName) || other.firstName == firstName)&&(identical(other.lastName, lastName) || other.lastName == lastName)&&(identical(other.bornAt, bornAt) || other.bornAt == bornAt)&&(identical(other.walletId, walletId) || other.walletId == walletId)&&(identical(other.treezorUserId, treezorUserId) || other.treezorUserId == treezorUserId)&&(identical(other.address, address) || other.address == address)&&(identical(other.createdAt, createdAt) || other.createdAt == createdAt));
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is _ChildProfileEntity&&(identical(other.id, id) || other.id == id)&&(identical(other.deviceIdentificator, deviceIdentificator) || other.deviceIdentificator == deviceIdentificator)&&(identical(other.parentId, parentId) || other.parentId == parentId)&&(identical(other.firstName, firstName) || other.firstName == firstName)&&(identical(other.lastName, lastName) || other.lastName == lastName)&&(identical(other.bornAt, bornAt) || other.bornAt == bornAt)&&(identical(other.walletId, walletId) || other.walletId == walletId)&&(identical(other.treezorUserId, treezorUserId) || other.treezorUserId == treezorUserId)&&(identical(other.address, address) || other.address == address)&&(identical(other.createdAt, createdAt) || other.createdAt == createdAt)&&(identical(other.hasCardPin, hasCardPin) || other.hasCardPin == hasCardPin));
|
||||
}
|
||||
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,id,deviceIdentificator,parentId,firstName,lastName,bornAt,walletId,treezorUserId,address,createdAt);
|
||||
int get hashCode => Object.hash(runtimeType,id,deviceIdentificator,parentId,firstName,lastName,bornAt,walletId,treezorUserId,address,createdAt,hasCardPin);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'ChildProfileEntity(id: $id, deviceIdentificator: $deviceIdentificator, parentId: $parentId, firstName: $firstName, lastName: $lastName, bornAt: $bornAt, walletId: $walletId, treezorUserId: $treezorUserId, address: $address, createdAt: $createdAt)';
|
||||
return 'ChildProfileEntity(id: $id, deviceIdentificator: $deviceIdentificator, parentId: $parentId, firstName: $firstName, lastName: $lastName, bornAt: $bornAt, walletId: $walletId, treezorUserId: $treezorUserId, address: $address, createdAt: $createdAt, hasCardPin: $hasCardPin)';
|
||||
}
|
||||
|
||||
|
||||
@@ -259,7 +261,7 @@ abstract mixin class _$ChildProfileEntityCopyWith<$Res> implements $ChildProfile
|
||||
factory _$ChildProfileEntityCopyWith(_ChildProfileEntity value, $Res Function(_ChildProfileEntity) _then) = __$ChildProfileEntityCopyWithImpl;
|
||||
@override @useResult
|
||||
$Res call({
|
||||
String id, String deviceIdentificator, String parentId, String firstName, String lastName, int bornAt, String walletId, String treezorUserId, String address, int createdAt
|
||||
String id, String deviceIdentificator, String parentId, String firstName, String lastName, int bornAt, String walletId, String treezorUserId, String address, int createdAt, bool hasCardPin
|
||||
});
|
||||
|
||||
|
||||
@@ -276,7 +278,7 @@ class __$ChildProfileEntityCopyWithImpl<$Res>
|
||||
|
||||
/// Create a copy of ChildProfileEntity
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override @pragma('vm:prefer-inline') $Res call({Object? id = null,Object? deviceIdentificator = null,Object? parentId = null,Object? firstName = null,Object? lastName = null,Object? bornAt = null,Object? walletId = null,Object? treezorUserId = null,Object? address = null,Object? createdAt = null,}) {
|
||||
@override @pragma('vm:prefer-inline') $Res call({Object? id = null,Object? deviceIdentificator = null,Object? parentId = null,Object? firstName = null,Object? lastName = null,Object? bornAt = null,Object? walletId = null,Object? treezorUserId = null,Object? address = null,Object? createdAt = null,Object? hasCardPin = null,}) {
|
||||
return _then(_ChildProfileEntity(
|
||||
id: null == id ? _self.id : id // ignore: cast_nullable_to_non_nullable
|
||||
as String,deviceIdentificator: null == deviceIdentificator ? _self.deviceIdentificator : deviceIdentificator // ignore: cast_nullable_to_non_nullable
|
||||
@@ -288,7 +290,8 @@ as int,walletId: null == walletId ? _self.walletId : walletId // ignore: cast_nu
|
||||
as String,treezorUserId: null == treezorUserId ? _self.treezorUserId : treezorUserId // ignore: cast_nullable_to_non_nullable
|
||||
as String,address: null == address ? _self.address : address // ignore: cast_nullable_to_non_nullable
|
||||
as String,createdAt: null == createdAt ? _self.createdAt : createdAt // ignore: cast_nullable_to_non_nullable
|
||||
as int,
|
||||
as int,hasCardPin: null == hasCardPin ? _self.hasCardPin : hasCardPin // ignore: cast_nullable_to_non_nullable
|
||||
as bool,
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
@@ -9,5 +9,6 @@ abstract class WalletCardEntity with _$WalletCardEntity {
|
||||
required int walletId,
|
||||
required int userId,
|
||||
required String status,
|
||||
@Default(false) bool isPinBlocked,
|
||||
}) = _WalletCardEntity;
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ T _$identity<T>(T value) => value;
|
||||
/// @nodoc
|
||||
mixin _$WalletCardEntity {
|
||||
|
||||
int get cardId; int get walletId; int get userId; String get status;
|
||||
int get cardId; int get walletId; int get userId; String get status; bool get isPinBlocked;
|
||||
/// Create a copy of WalletCardEntity
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@@ -25,16 +25,16 @@ $WalletCardEntityCopyWith<WalletCardEntity> get copyWith => _$WalletCardEntityCo
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is WalletCardEntity&&(identical(other.cardId, cardId) || other.cardId == cardId)&&(identical(other.walletId, walletId) || other.walletId == walletId)&&(identical(other.userId, userId) || other.userId == userId)&&(identical(other.status, status) || other.status == status));
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is WalletCardEntity&&(identical(other.cardId, cardId) || other.cardId == cardId)&&(identical(other.walletId, walletId) || other.walletId == walletId)&&(identical(other.userId, userId) || other.userId == userId)&&(identical(other.status, status) || other.status == status)&&(identical(other.isPinBlocked, isPinBlocked) || other.isPinBlocked == isPinBlocked));
|
||||
}
|
||||
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,cardId,walletId,userId,status);
|
||||
int get hashCode => Object.hash(runtimeType,cardId,walletId,userId,status,isPinBlocked);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'WalletCardEntity(cardId: $cardId, walletId: $walletId, userId: $userId, status: $status)';
|
||||
return 'WalletCardEntity(cardId: $cardId, walletId: $walletId, userId: $userId, status: $status, isPinBlocked: $isPinBlocked)';
|
||||
}
|
||||
|
||||
|
||||
@@ -45,7 +45,7 @@ abstract mixin class $WalletCardEntityCopyWith<$Res> {
|
||||
factory $WalletCardEntityCopyWith(WalletCardEntity value, $Res Function(WalletCardEntity) _then) = _$WalletCardEntityCopyWithImpl;
|
||||
@useResult
|
||||
$Res call({
|
||||
int cardId, int walletId, int userId, String status
|
||||
int cardId, int walletId, int userId, String status, bool isPinBlocked
|
||||
});
|
||||
|
||||
|
||||
@@ -62,13 +62,14 @@ class _$WalletCardEntityCopyWithImpl<$Res>
|
||||
|
||||
/// Create a copy of WalletCardEntity
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline') @override $Res call({Object? cardId = null,Object? walletId = null,Object? userId = null,Object? status = null,}) {
|
||||
@pragma('vm:prefer-inline') @override $Res call({Object? cardId = null,Object? walletId = null,Object? userId = null,Object? status = null,Object? isPinBlocked = null,}) {
|
||||
return _then(_self.copyWith(
|
||||
cardId: null == cardId ? _self.cardId : cardId // ignore: cast_nullable_to_non_nullable
|
||||
as int,walletId: null == walletId ? _self.walletId : walletId // ignore: cast_nullable_to_non_nullable
|
||||
as int,userId: null == userId ? _self.userId : userId // ignore: cast_nullable_to_non_nullable
|
||||
as int,status: null == status ? _self.status : status // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
as String,isPinBlocked: null == isPinBlocked ? _self.isPinBlocked : isPinBlocked // ignore: cast_nullable_to_non_nullable
|
||||
as bool,
|
||||
));
|
||||
}
|
||||
|
||||
@@ -153,10 +154,10 @@ return $default(_that);case _:
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( int cardId, int walletId, int userId, String status)? $default,{required TResult orElse(),}) {final _that = this;
|
||||
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( int cardId, int walletId, int userId, String status, bool isPinBlocked)? $default,{required TResult orElse(),}) {final _that = this;
|
||||
switch (_that) {
|
||||
case _WalletCardEntity() when $default != null:
|
||||
return $default(_that.cardId,_that.walletId,_that.userId,_that.status);case _:
|
||||
return $default(_that.cardId,_that.walletId,_that.userId,_that.status,_that.isPinBlocked);case _:
|
||||
return orElse();
|
||||
|
||||
}
|
||||
@@ -174,10 +175,10 @@ return $default(_that.cardId,_that.walletId,_that.userId,_that.status);case _:
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( int cardId, int walletId, int userId, String status) $default,) {final _that = this;
|
||||
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( int cardId, int walletId, int userId, String status, bool isPinBlocked) $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _WalletCardEntity():
|
||||
return $default(_that.cardId,_that.walletId,_that.userId,_that.status);case _:
|
||||
return $default(_that.cardId,_that.walletId,_that.userId,_that.status,_that.isPinBlocked);case _:
|
||||
throw StateError('Unexpected subclass');
|
||||
|
||||
}
|
||||
@@ -194,10 +195,10 @@ return $default(_that.cardId,_that.walletId,_that.userId,_that.status);case _:
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( int cardId, int walletId, int userId, String status)? $default,) {final _that = this;
|
||||
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( int cardId, int walletId, int userId, String status, bool isPinBlocked)? $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _WalletCardEntity() when $default != null:
|
||||
return $default(_that.cardId,_that.walletId,_that.userId,_that.status);case _:
|
||||
return $default(_that.cardId,_that.walletId,_that.userId,_that.status,_that.isPinBlocked);case _:
|
||||
return null;
|
||||
|
||||
}
|
||||
@@ -209,13 +210,14 @@ return $default(_that.cardId,_that.walletId,_that.userId,_that.status);case _:
|
||||
|
||||
|
||||
class _WalletCardEntity implements WalletCardEntity {
|
||||
const _WalletCardEntity({required this.cardId, required this.walletId, required this.userId, required this.status});
|
||||
const _WalletCardEntity({required this.cardId, required this.walletId, required this.userId, required this.status, this.isPinBlocked = false});
|
||||
|
||||
|
||||
@override final int cardId;
|
||||
@override final int walletId;
|
||||
@override final int userId;
|
||||
@override final String status;
|
||||
@override@JsonKey() final bool isPinBlocked;
|
||||
|
||||
/// Create a copy of WalletCardEntity
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@@ -227,16 +229,16 @@ _$WalletCardEntityCopyWith<_WalletCardEntity> get copyWith => __$WalletCardEntit
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is _WalletCardEntity&&(identical(other.cardId, cardId) || other.cardId == cardId)&&(identical(other.walletId, walletId) || other.walletId == walletId)&&(identical(other.userId, userId) || other.userId == userId)&&(identical(other.status, status) || other.status == status));
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is _WalletCardEntity&&(identical(other.cardId, cardId) || other.cardId == cardId)&&(identical(other.walletId, walletId) || other.walletId == walletId)&&(identical(other.userId, userId) || other.userId == userId)&&(identical(other.status, status) || other.status == status)&&(identical(other.isPinBlocked, isPinBlocked) || other.isPinBlocked == isPinBlocked));
|
||||
}
|
||||
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,cardId,walletId,userId,status);
|
||||
int get hashCode => Object.hash(runtimeType,cardId,walletId,userId,status,isPinBlocked);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'WalletCardEntity(cardId: $cardId, walletId: $walletId, userId: $userId, status: $status)';
|
||||
return 'WalletCardEntity(cardId: $cardId, walletId: $walletId, userId: $userId, status: $status, isPinBlocked: $isPinBlocked)';
|
||||
}
|
||||
|
||||
|
||||
@@ -247,7 +249,7 @@ abstract mixin class _$WalletCardEntityCopyWith<$Res> implements $WalletCardEnti
|
||||
factory _$WalletCardEntityCopyWith(_WalletCardEntity value, $Res Function(_WalletCardEntity) _then) = __$WalletCardEntityCopyWithImpl;
|
||||
@override @useResult
|
||||
$Res call({
|
||||
int cardId, int walletId, int userId, String status
|
||||
int cardId, int walletId, int userId, String status, bool isPinBlocked
|
||||
});
|
||||
|
||||
|
||||
@@ -264,13 +266,14 @@ class __$WalletCardEntityCopyWithImpl<$Res>
|
||||
|
||||
/// Create a copy of WalletCardEntity
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override @pragma('vm:prefer-inline') $Res call({Object? cardId = null,Object? walletId = null,Object? userId = null,Object? status = null,}) {
|
||||
@override @pragma('vm:prefer-inline') $Res call({Object? cardId = null,Object? walletId = null,Object? userId = null,Object? status = null,Object? isPinBlocked = null,}) {
|
||||
return _then(_WalletCardEntity(
|
||||
cardId: null == cardId ? _self.cardId : cardId // ignore: cast_nullable_to_non_nullable
|
||||
as int,walletId: null == walletId ? _self.walletId : walletId // ignore: cast_nullable_to_non_nullable
|
||||
as int,userId: null == userId ? _self.userId : userId // ignore: cast_nullable_to_non_nullable
|
||||
as int,status: null == status ? _self.status : status // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
as String,isPinBlocked: null == isPinBlocked ? _self.isPinBlocked : isPinBlocked // ignore: cast_nullable_to_non_nullable
|
||||
as bool,
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
@@ -100,4 +100,27 @@ abstract class TreezorRepository {
|
||||
required String walletId,
|
||||
required WalletLimitsEntity limits,
|
||||
});
|
||||
|
||||
Future<void> setCardPin({
|
||||
required String walletId,
|
||||
required String newPin,
|
||||
required String confirmPin,
|
||||
required String scaProof,
|
||||
});
|
||||
|
||||
Future<void> changeCardPin({
|
||||
required String walletId,
|
||||
required String currentPin,
|
||||
required String newPin,
|
||||
required String confirmPin,
|
||||
required String scaProof,
|
||||
});
|
||||
|
||||
Future<void> unblockCardPin({required String walletId});
|
||||
|
||||
Future<void> renewCard({
|
||||
required String childProfileId,
|
||||
required String publicToken,
|
||||
required String scaProof,
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user