Compare commits
12 Commits
feature/re
...
feature/pe
| Author | SHA1 | Date | |
|---|---|---|---|
| fa36037aac | |||
| c9e2adf692 | |||
| 995b69eb65 | |||
| 88269c40f8 | |||
| f1226b4c18 | |||
| b636550619 | |||
| 797d236547 | |||
| 90447ce9a0 | |||
| 22ef648b41 | |||
| 4eb4ac81ce | |||
| 904cfee2a9 | |||
| 69b3cf358a |
@@ -1,5 +1,7 @@
|
||||
PODS:
|
||||
- Flutter (1.0.0)
|
||||
- flutter_contacts (0.0.1):
|
||||
- Flutter
|
||||
- flutter_native_splash (2.4.3):
|
||||
- Flutter
|
||||
- flutter_treezor_entrust_sdk_bridge (0.0.1):
|
||||
@@ -23,6 +25,7 @@ PODS:
|
||||
|
||||
DEPENDENCIES:
|
||||
- Flutter (from `Flutter`)
|
||||
- flutter_contacts (from `.symlinks/plugins/flutter_contacts/ios`)
|
||||
- flutter_native_splash (from `.symlinks/plugins/flutter_native_splash/ios`)
|
||||
- flutter_treezor_entrust_sdk_bridge (from `.symlinks/plugins/flutter_treezor_entrust_sdk_bridge/ios`)
|
||||
- mobile_scanner (from `.symlinks/plugins/mobile_scanner/darwin`)
|
||||
@@ -35,6 +38,8 @@ DEPENDENCIES:
|
||||
EXTERNAL SOURCES:
|
||||
Flutter:
|
||||
:path: Flutter
|
||||
flutter_contacts:
|
||||
:path: ".symlinks/plugins/flutter_contacts/ios"
|
||||
flutter_native_splash:
|
||||
:path: ".symlinks/plugins/flutter_native_splash/ios"
|
||||
flutter_treezor_entrust_sdk_bridge:
|
||||
@@ -54,6 +59,7 @@ EXTERNAL SOURCES:
|
||||
|
||||
SPEC CHECKSUMS:
|
||||
Flutter: cabc95a1d2626b1b06e7179b784ebcf0c0cde467
|
||||
flutter_contacts: edb1c5ce76aa433e20e6cb14c615f4c0b66e0983
|
||||
flutter_native_splash: df59bb2e1421aa0282cb2e95618af4dcb0c56c29
|
||||
flutter_treezor_entrust_sdk_bridge: 4c2c94fb74ab57576e8d49f5f2a4b214e41141fe
|
||||
mobile_scanner: 77265f3dc8d580810e91849d4a0811a90467ed5e
|
||||
|
||||
@@ -47,8 +47,14 @@
|
||||
<true/>
|
||||
<key>UIStatusBarHidden</key>
|
||||
<true/>
|
||||
<key>NSContactsUsageDescription</key>
|
||||
<string>Necesitamos acceso a tus contactos para seleccionar números de teléfono.</string>
|
||||
<key>NSCameraUsageDescription</key>
|
||||
<string>Necesitamos la cámara para escanear códigos QR</string>
|
||||
<key>NSLocationWhenInUseUsageDescription</key>
|
||||
<string>Usamos tu ubicación para verificar la seguridad de las transacciones.</string>
|
||||
<key>NSLocationAlwaysAndWhenInUseUsageDescription</key>
|
||||
<string>Usamos tu ubicación para verificar la seguridad de las transacciones.</string>
|
||||
<key>UIViewControllerBasedStatusBarAppearance</key>
|
||||
<false/>
|
||||
<key>NSFaceIDUsageDescription</key>
|
||||
|
||||
@@ -47,8 +47,14 @@
|
||||
<true/>
|
||||
<key>UIStatusBarHidden</key>
|
||||
<true/>
|
||||
<key>NSContactsUsageDescription</key>
|
||||
<string>Necesitamos acceso a tus contactos para seleccionar números de teléfono.</string>
|
||||
<key>NSCameraUsageDescription</key>
|
||||
<string>Necesitamos la cámara para escanear códigos QR</string>
|
||||
<key>NSLocationWhenInUseUsageDescription</key>
|
||||
<string>Usamos tu ubicación para verificar la seguridad de las transacciones.</string>
|
||||
<key>NSLocationAlwaysAndWhenInUseUsageDescription</key>
|
||||
<string>Usamos tu ubicación para verificar la seguridad de las transacciones.</string>
|
||||
<key>UIViewControllerBasedStatusBarAppearance</key>
|
||||
<false/>
|
||||
<key>NSFaceIDUsageDescription</key>
|
||||
|
||||
@@ -386,6 +386,12 @@ void configureAppRouter() {
|
||||
name: 'home_extract',
|
||||
pageBuilder: const ExtractBuilder().buildPage,
|
||||
),
|
||||
GoRoute(
|
||||
path: 'edit',
|
||||
name: 'home_edit_child_profile',
|
||||
pageBuilder:
|
||||
const EditChildProfileBuilder().buildPage,
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
@@ -427,6 +433,12 @@ void configureAppRouter() {
|
||||
name: 'profile_settings',
|
||||
pageBuilder: const ProfileSettingsBuilder().buildPage,
|
||||
routes: [
|
||||
GoRoute(
|
||||
path: 'edit-personal-data',
|
||||
name: 'profile_edit_personal_data',
|
||||
pageBuilder:
|
||||
const EditPersonalDataBuilder().buildPage,
|
||||
),
|
||||
GoRoute(
|
||||
path: 'payment-methods',
|
||||
name: 'profile_payment_methods',
|
||||
|
||||
@@ -47,12 +47,21 @@ class SaveFamilyAppState extends ConsumerState<SaveFamilyApp>
|
||||
walletHeartbeat.stop();
|
||||
legacyHeartbeat.stop();
|
||||
};
|
||||
// walletHeartbeat.start();
|
||||
legacyHeartbeat.start();
|
||||
appRouter.routerDelegate.addListener(_onRouteChanged);
|
||||
}
|
||||
|
||||
void _onRouteChanged() {
|
||||
final location = appRouter.routerDelegate.currentConfiguration.uri.path;
|
||||
if (location.startsWith(AppRoutes.legacyDashboard)) {
|
||||
legacyHeartbeat.start();
|
||||
} else {
|
||||
legacyHeartbeat.stop();
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
appRouter.routerDelegate.removeListener(_onRouteChanged);
|
||||
walletHeartbeat.stop();
|
||||
legacyHeartbeat.stop();
|
||||
WidgetsBinding.instance.removeObserver(this);
|
||||
@@ -65,7 +74,7 @@ class SaveFamilyAppState extends ConsumerState<SaveFamilyApp>
|
||||
ref.read(appLifecycleStateProvider.notifier).setState(state);
|
||||
if (state == AppLifecycleState.resumed) {
|
||||
// walletHeartbeat.start();
|
||||
legacyHeartbeat.start();
|
||||
_onRouteChanged();
|
||||
ref.read(permissionsProvider.notifier).checkPermissions();
|
||||
} else if (state == AppLifecycleState.paused) {
|
||||
// walletHeartbeat.stop();
|
||||
|
||||
@@ -16,7 +16,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev
|
||||
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
|
||||
# In Windows, build-name is used as the major, minor, and patch parts
|
||||
# of the product and file versions while build-number is used as the build suffix.
|
||||
version: 1.0.0+1
|
||||
version: 1.0.0+4
|
||||
|
||||
environment:
|
||||
sdk: ^3.9.2
|
||||
|
||||
Binary file not shown.
File diff suppressed because one or more lines are too long
@@ -1,5 +1,6 @@
|
||||
export 'src/presentation/activity_screen.dart';
|
||||
export 'src/widgets/activity_list.dart';
|
||||
export 'src/widgets/pagination_bar.dart';
|
||||
export 'src/widgets/transaction_tile.dart';
|
||||
export 'src/activity_builder.dart';
|
||||
export 'src/providers/activity_providers.dart';
|
||||
|
||||
@@ -17,7 +17,7 @@ class GetWalletTransactionsUseCaseImpl implements GetWalletTransactionsUseCase {
|
||||
required String walletId,
|
||||
Map<String, dynamic>? queryParameters,
|
||||
}) {
|
||||
return _repository.getWalletTransactions(
|
||||
return _repository.getWalletOperations(
|
||||
walletId: walletId,
|
||||
queryParameters: queryParameters,
|
||||
);
|
||||
|
||||
@@ -5,6 +5,7 @@ import 'package:sf_shared/sf_shared.dart';
|
||||
import 'package:sf_localizations/sf_localizations.dart';
|
||||
import 'package:activity/src/presentation/state/activity_view_model.dart';
|
||||
import 'package:activity/src/presentation/state/activity_view_state.dart';
|
||||
import 'package:activity/src/widgets/pagination_bar.dart';
|
||||
import 'package:activity/src/widgets/transaction_tile.dart';
|
||||
|
||||
class ActivityScreen extends ConsumerStatefulWidget {
|
||||
@@ -173,7 +174,7 @@ class _ActivityScreenState extends ConsumerState<ActivityScreen> {
|
||||
return _buildError(context, theme, viewState.errorMessage);
|
||||
}
|
||||
|
||||
if (viewState.transactions.isEmpty) {
|
||||
if (viewState.transactionPages.isEmpty) {
|
||||
return Center(
|
||||
child: Text(
|
||||
context.translate(I18n.activityNoTransactions),
|
||||
@@ -185,38 +186,48 @@ class _ActivityScreenState extends ConsumerState<ActivityScreen> {
|
||||
);
|
||||
}
|
||||
|
||||
final walletId = viewState.selectedTab!.walletId;
|
||||
final balanceAsync = ref.watch(walletBalanceProvider(walletId));
|
||||
final currentTransactions = viewState.transactionPages[viewState.currentPage];
|
||||
|
||||
return RefreshIndicator(
|
||||
onRefresh: () =>
|
||||
ref.read(activityViewModelProvider.notifier).loadTabs(),
|
||||
child: ListView.builder(
|
||||
child: ListView(
|
||||
physics: const AlwaysScrollableScrollPhysics(),
|
||||
padding: const EdgeInsets.symmetric(horizontal: 24),
|
||||
itemCount: viewState.transactions.length + 1,
|
||||
itemBuilder: (context, index) {
|
||||
if (index == 0) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.only(bottom: 16),
|
||||
child: balanceAsync.when(
|
||||
loading: () =>
|
||||
const Center(child: AppLoadingIndicator(size: 48)),
|
||||
error: (_, __) => const SizedBox.shrink(),
|
||||
data: (balance) => WalletBalanceBlock(
|
||||
availableBalance: balance.availableBalance,
|
||||
allocatedBalance: balance.allocatedBalance,
|
||||
totalBalance: balance.totalBalance,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
final transaction = viewState.transactions[index - 1];
|
||||
return Padding(
|
||||
padding: const EdgeInsets.only(bottom: 12),
|
||||
child: TransactionTile(transaction: transaction),
|
||||
);
|
||||
},
|
||||
children: [
|
||||
// TODO: WalletBalanceBlock temporarily hidden
|
||||
// final walletId = viewState.selectedTab!.walletId;
|
||||
// final balanceAsync = ref.watch(walletBalanceProvider(walletId));
|
||||
// Padding(
|
||||
// padding: const EdgeInsets.only(bottom: 16),
|
||||
// child: balanceAsync.when(
|
||||
// loading: () =>
|
||||
// const Center(child: AppLoadingIndicator(size: 48)),
|
||||
// error: (_, __) => const SizedBox.shrink(),
|
||||
// data: (balance) => WalletBalanceBlock(
|
||||
// availableBalance: balance.availableBalance,
|
||||
// allocatedBalance: balance.allocatedBalance,
|
||||
// totalBalance: balance.totalBalance,
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
...currentTransactions.map(
|
||||
(tx) => Padding(
|
||||
padding: const EdgeInsets.only(bottom: 12),
|
||||
child: TransactionTile(transaction: tx),
|
||||
),
|
||||
),
|
||||
PaginationBar(
|
||||
currentPage: viewState.currentPage,
|
||||
totalPages: viewState.transactionPages.length,
|
||||
hasMore: viewState.nextCursor != null,
|
||||
isLoadingMore: viewState.isLoadingMore,
|
||||
onPageChanged: (page) =>
|
||||
ref.read(activityViewModelProvider.notifier).setPage(page),
|
||||
onLoadMore: () =>
|
||||
ref.read(activityViewModelProvider.notifier).loadMore(),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -73,20 +73,27 @@ class ActivityViewModel extends Notifier<ActivityViewState> {
|
||||
final tab = state.selectedTab;
|
||||
if (tab == null) return;
|
||||
|
||||
state = state.copyWith(isLoadingTransactions: true, errorMessage: '');
|
||||
state = state.copyWith(
|
||||
isLoadingTransactions: true,
|
||||
errorMessage: '',
|
||||
transactionPages: [],
|
||||
nextCursor: null,
|
||||
currentPage: 0,
|
||||
);
|
||||
|
||||
try {
|
||||
final query = TransactionsQuery(
|
||||
walletId: tab.walletId,
|
||||
dateFilter: state.selectedDateFilter,
|
||||
);
|
||||
final transactions =
|
||||
final response =
|
||||
await ref.read(walletTransactionsProvider(query).future);
|
||||
|
||||
if (!ref.mounted) return;
|
||||
state = state.copyWith(
|
||||
isLoadingTransactions: false,
|
||||
transactions: transactions,
|
||||
transactionPages: [response.items],
|
||||
nextCursor: response.nextCursor,
|
||||
);
|
||||
} catch (e) {
|
||||
if (!ref.mounted) return;
|
||||
@@ -97,6 +104,38 @@ class ActivityViewModel extends Notifier<ActivityViewState> {
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> loadMore() async {
|
||||
final tab = state.selectedTab;
|
||||
if (tab == null || state.isLoadingMore || state.nextCursor == null) return;
|
||||
|
||||
state = state.copyWith(isLoadingMore: true);
|
||||
|
||||
try {
|
||||
final query = TransactionsQuery(
|
||||
walletId: tab.walletId,
|
||||
dateFilter: state.selectedDateFilter,
|
||||
cursor: state.nextCursor,
|
||||
);
|
||||
final response =
|
||||
await ref.read(walletTransactionsProvider(query).future);
|
||||
|
||||
if (!ref.mounted) return;
|
||||
state = state.copyWith(
|
||||
isLoadingMore: false,
|
||||
transactionPages: [...state.transactionPages, response.items],
|
||||
nextCursor: response.nextCursor,
|
||||
currentPage: state.transactionPages.length,
|
||||
);
|
||||
} catch (e) {
|
||||
if (!ref.mounted) return;
|
||||
state = state.copyWith(isLoadingMore: false);
|
||||
}
|
||||
}
|
||||
|
||||
void setPage(int page) {
|
||||
state = state.copyWith(currentPage: page);
|
||||
}
|
||||
|
||||
void selectWallet(int index) {
|
||||
if (index == state.selectedWalletIndex) return;
|
||||
state = state.copyWith(selectedWalletIndex: index);
|
||||
|
||||
@@ -14,7 +14,10 @@ abstract class ActivityViewState with _$ActivityViewState {
|
||||
@Default([]) List<WalletTab> tabs,
|
||||
@Default(0) int selectedWalletIndex,
|
||||
@Default(DateFilter.today) DateFilter selectedDateFilter,
|
||||
@Default([]) List<WalletTransactionEntity> transactions,
|
||||
@Default([]) List<List<WalletTransactionEntity>> transactionPages,
|
||||
String? nextCursor,
|
||||
@Default(false) bool isLoadingMore,
|
||||
@Default(0) int currentPage,
|
||||
@Default('') String errorMessage,
|
||||
}) = _ActivityViewState;
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ T _$identity<T>(T value) => value;
|
||||
/// @nodoc
|
||||
mixin _$ActivityViewState {
|
||||
|
||||
bool get isLoading; bool get isLoadingTransactions; List<WalletTab> get tabs; int get selectedWalletIndex; DateFilter get selectedDateFilter; List<WalletTransactionEntity> get transactions; String get errorMessage;
|
||||
bool get isLoading; bool get isLoadingTransactions; List<WalletTab> get tabs; int get selectedWalletIndex; DateFilter get selectedDateFilter; List<List<WalletTransactionEntity>> get transactionPages; String? get nextCursor; bool get isLoadingMore; int get currentPage; String get errorMessage;
|
||||
/// Create a copy of ActivityViewState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@@ -25,16 +25,16 @@ $ActivityViewStateCopyWith<ActivityViewState> get copyWith => _$ActivityViewStat
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is ActivityViewState&&(identical(other.isLoading, isLoading) || other.isLoading == isLoading)&&(identical(other.isLoadingTransactions, isLoadingTransactions) || other.isLoadingTransactions == isLoadingTransactions)&&const DeepCollectionEquality().equals(other.tabs, tabs)&&(identical(other.selectedWalletIndex, selectedWalletIndex) || other.selectedWalletIndex == selectedWalletIndex)&&(identical(other.selectedDateFilter, selectedDateFilter) || other.selectedDateFilter == selectedDateFilter)&&const DeepCollectionEquality().equals(other.transactions, transactions)&&(identical(other.errorMessage, errorMessage) || other.errorMessage == errorMessage));
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is ActivityViewState&&(identical(other.isLoading, isLoading) || other.isLoading == isLoading)&&(identical(other.isLoadingTransactions, isLoadingTransactions) || other.isLoadingTransactions == isLoadingTransactions)&&const DeepCollectionEquality().equals(other.tabs, tabs)&&(identical(other.selectedWalletIndex, selectedWalletIndex) || other.selectedWalletIndex == selectedWalletIndex)&&(identical(other.selectedDateFilter, selectedDateFilter) || other.selectedDateFilter == selectedDateFilter)&&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)&&(identical(other.errorMessage, errorMessage) || other.errorMessage == errorMessage));
|
||||
}
|
||||
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,isLoading,isLoadingTransactions,const DeepCollectionEquality().hash(tabs),selectedWalletIndex,selectedDateFilter,const DeepCollectionEquality().hash(transactions),errorMessage);
|
||||
int get hashCode => Object.hash(runtimeType,isLoading,isLoadingTransactions,const DeepCollectionEquality().hash(tabs),selectedWalletIndex,selectedDateFilter,const DeepCollectionEquality().hash(transactionPages),nextCursor,isLoadingMore,currentPage,errorMessage);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'ActivityViewState(isLoading: $isLoading, isLoadingTransactions: $isLoadingTransactions, tabs: $tabs, selectedWalletIndex: $selectedWalletIndex, selectedDateFilter: $selectedDateFilter, transactions: $transactions, errorMessage: $errorMessage)';
|
||||
return 'ActivityViewState(isLoading: $isLoading, isLoadingTransactions: $isLoadingTransactions, tabs: $tabs, selectedWalletIndex: $selectedWalletIndex, selectedDateFilter: $selectedDateFilter, transactionPages: $transactionPages, nextCursor: $nextCursor, isLoadingMore: $isLoadingMore, currentPage: $currentPage, errorMessage: $errorMessage)';
|
||||
}
|
||||
|
||||
|
||||
@@ -45,7 +45,7 @@ abstract mixin class $ActivityViewStateCopyWith<$Res> {
|
||||
factory $ActivityViewStateCopyWith(ActivityViewState value, $Res Function(ActivityViewState) _then) = _$ActivityViewStateCopyWithImpl;
|
||||
@useResult
|
||||
$Res call({
|
||||
bool isLoading, bool isLoadingTransactions, List<WalletTab> tabs, int selectedWalletIndex, DateFilter selectedDateFilter, List<WalletTransactionEntity> transactions, String errorMessage
|
||||
bool isLoading, bool isLoadingTransactions, List<WalletTab> tabs, int selectedWalletIndex, DateFilter selectedDateFilter, List<List<WalletTransactionEntity>> transactionPages, String? nextCursor, bool isLoadingMore, int currentPage, String errorMessage
|
||||
});
|
||||
|
||||
|
||||
@@ -62,15 +62,18 @@ class _$ActivityViewStateCopyWithImpl<$Res>
|
||||
|
||||
/// Create a copy of ActivityViewState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline') @override $Res call({Object? isLoading = null,Object? isLoadingTransactions = null,Object? tabs = null,Object? selectedWalletIndex = null,Object? selectedDateFilter = null,Object? transactions = null,Object? errorMessage = null,}) {
|
||||
@pragma('vm:prefer-inline') @override $Res call({Object? isLoading = null,Object? isLoadingTransactions = null,Object? tabs = null,Object? selectedWalletIndex = null,Object? selectedDateFilter = null,Object? transactionPages = null,Object? nextCursor = freezed,Object? isLoadingMore = null,Object? currentPage = null,Object? errorMessage = null,}) {
|
||||
return _then(_self.copyWith(
|
||||
isLoading: null == isLoading ? _self.isLoading : isLoading // ignore: cast_nullable_to_non_nullable
|
||||
as bool,isLoadingTransactions: null == isLoadingTransactions ? _self.isLoadingTransactions : isLoadingTransactions // ignore: cast_nullable_to_non_nullable
|
||||
as bool,tabs: null == tabs ? _self.tabs : tabs // ignore: cast_nullable_to_non_nullable
|
||||
as List<WalletTab>,selectedWalletIndex: null == selectedWalletIndex ? _self.selectedWalletIndex : selectedWalletIndex // ignore: cast_nullable_to_non_nullable
|
||||
as int,selectedDateFilter: null == selectedDateFilter ? _self.selectedDateFilter : selectedDateFilter // ignore: cast_nullable_to_non_nullable
|
||||
as DateFilter,transactions: null == transactions ? _self.transactions : transactions // ignore: cast_nullable_to_non_nullable
|
||||
as List<WalletTransactionEntity>,errorMessage: null == errorMessage ? _self.errorMessage : errorMessage // ignore: cast_nullable_to_non_nullable
|
||||
as DateFilter,transactionPages: null == transactionPages ? _self.transactionPages : transactionPages // ignore: cast_nullable_to_non_nullable
|
||||
as List<List<WalletTransactionEntity>>,nextCursor: freezed == nextCursor ? _self.nextCursor : nextCursor // ignore: cast_nullable_to_non_nullable
|
||||
as String?,isLoadingMore: null == isLoadingMore ? _self.isLoadingMore : isLoadingMore // ignore: cast_nullable_to_non_nullable
|
||||
as bool,currentPage: null == currentPage ? _self.currentPage : currentPage // ignore: cast_nullable_to_non_nullable
|
||||
as int,errorMessage: null == errorMessage ? _self.errorMessage : errorMessage // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
));
|
||||
}
|
||||
@@ -156,10 +159,10 @@ return $default(_that);case _:
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( bool isLoading, bool isLoadingTransactions, List<WalletTab> tabs, int selectedWalletIndex, DateFilter selectedDateFilter, List<WalletTransactionEntity> transactions, String errorMessage)? $default,{required TResult orElse(),}) {final _that = this;
|
||||
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( bool isLoading, bool isLoadingTransactions, List<WalletTab> tabs, int selectedWalletIndex, DateFilter selectedDateFilter, List<List<WalletTransactionEntity>> transactionPages, String? nextCursor, bool isLoadingMore, int currentPage, String errorMessage)? $default,{required TResult orElse(),}) {final _that = this;
|
||||
switch (_that) {
|
||||
case _ActivityViewState() when $default != null:
|
||||
return $default(_that.isLoading,_that.isLoadingTransactions,_that.tabs,_that.selectedWalletIndex,_that.selectedDateFilter,_that.transactions,_that.errorMessage);case _:
|
||||
return $default(_that.isLoading,_that.isLoadingTransactions,_that.tabs,_that.selectedWalletIndex,_that.selectedDateFilter,_that.transactionPages,_that.nextCursor,_that.isLoadingMore,_that.currentPage,_that.errorMessage);case _:
|
||||
return orElse();
|
||||
|
||||
}
|
||||
@@ -177,10 +180,10 @@ return $default(_that.isLoading,_that.isLoadingTransactions,_that.tabs,_that.sel
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( bool isLoading, bool isLoadingTransactions, List<WalletTab> tabs, int selectedWalletIndex, DateFilter selectedDateFilter, List<WalletTransactionEntity> transactions, String errorMessage) $default,) {final _that = this;
|
||||
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( bool isLoading, bool isLoadingTransactions, List<WalletTab> tabs, int selectedWalletIndex, DateFilter selectedDateFilter, List<List<WalletTransactionEntity>> transactionPages, String? nextCursor, bool isLoadingMore, int currentPage, String errorMessage) $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _ActivityViewState():
|
||||
return $default(_that.isLoading,_that.isLoadingTransactions,_that.tabs,_that.selectedWalletIndex,_that.selectedDateFilter,_that.transactions,_that.errorMessage);case _:
|
||||
return $default(_that.isLoading,_that.isLoadingTransactions,_that.tabs,_that.selectedWalletIndex,_that.selectedDateFilter,_that.transactionPages,_that.nextCursor,_that.isLoadingMore,_that.currentPage,_that.errorMessage);case _:
|
||||
throw StateError('Unexpected subclass');
|
||||
|
||||
}
|
||||
@@ -197,10 +200,10 @@ return $default(_that.isLoading,_that.isLoadingTransactions,_that.tabs,_that.sel
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( bool isLoading, bool isLoadingTransactions, List<WalletTab> tabs, int selectedWalletIndex, DateFilter selectedDateFilter, List<WalletTransactionEntity> transactions, String errorMessage)? $default,) {final _that = this;
|
||||
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( bool isLoading, bool isLoadingTransactions, List<WalletTab> tabs, int selectedWalletIndex, DateFilter selectedDateFilter, List<List<WalletTransactionEntity>> transactionPages, String? nextCursor, bool isLoadingMore, int currentPage, String errorMessage)? $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _ActivityViewState() when $default != null:
|
||||
return $default(_that.isLoading,_that.isLoadingTransactions,_that.tabs,_that.selectedWalletIndex,_that.selectedDateFilter,_that.transactions,_that.errorMessage);case _:
|
||||
return $default(_that.isLoading,_that.isLoadingTransactions,_that.tabs,_that.selectedWalletIndex,_that.selectedDateFilter,_that.transactionPages,_that.nextCursor,_that.isLoadingMore,_that.currentPage,_that.errorMessage);case _:
|
||||
return null;
|
||||
|
||||
}
|
||||
@@ -212,7 +215,7 @@ return $default(_that.isLoading,_that.isLoadingTransactions,_that.tabs,_that.sel
|
||||
|
||||
|
||||
class _ActivityViewState extends ActivityViewState {
|
||||
const _ActivityViewState({this.isLoading = false, this.isLoadingTransactions = false, final List<WalletTab> tabs = const [], this.selectedWalletIndex = 0, this.selectedDateFilter = DateFilter.today, final List<WalletTransactionEntity> transactions = const [], this.errorMessage = ''}): _tabs = tabs,_transactions = transactions,super._();
|
||||
const _ActivityViewState({this.isLoading = false, this.isLoadingTransactions = false, final List<WalletTab> tabs = const [], this.selectedWalletIndex = 0, this.selectedDateFilter = DateFilter.today, final List<List<WalletTransactionEntity>> transactionPages = const [], this.nextCursor, this.isLoadingMore = false, this.currentPage = 0, this.errorMessage = ''}): _tabs = tabs,_transactionPages = transactionPages,super._();
|
||||
|
||||
|
||||
@override@JsonKey() final bool isLoading;
|
||||
@@ -226,13 +229,16 @@ class _ActivityViewState extends ActivityViewState {
|
||||
|
||||
@override@JsonKey() final int selectedWalletIndex;
|
||||
@override@JsonKey() final DateFilter selectedDateFilter;
|
||||
final List<WalletTransactionEntity> _transactions;
|
||||
@override@JsonKey() List<WalletTransactionEntity> get transactions {
|
||||
if (_transactions is EqualUnmodifiableListView) return _transactions;
|
||||
final List<List<WalletTransactionEntity>> _transactionPages;
|
||||
@override@JsonKey() List<List<WalletTransactionEntity>> get transactionPages {
|
||||
if (_transactionPages is EqualUnmodifiableListView) return _transactionPages;
|
||||
// ignore: implicit_dynamic_type
|
||||
return EqualUnmodifiableListView(_transactions);
|
||||
return EqualUnmodifiableListView(_transactionPages);
|
||||
}
|
||||
|
||||
@override final String? nextCursor;
|
||||
@override@JsonKey() final bool isLoadingMore;
|
||||
@override@JsonKey() final int currentPage;
|
||||
@override@JsonKey() final String errorMessage;
|
||||
|
||||
/// Create a copy of ActivityViewState
|
||||
@@ -245,16 +251,16 @@ _$ActivityViewStateCopyWith<_ActivityViewState> get copyWith => __$ActivityViewS
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is _ActivityViewState&&(identical(other.isLoading, isLoading) || other.isLoading == isLoading)&&(identical(other.isLoadingTransactions, isLoadingTransactions) || other.isLoadingTransactions == isLoadingTransactions)&&const DeepCollectionEquality().equals(other._tabs, _tabs)&&(identical(other.selectedWalletIndex, selectedWalletIndex) || other.selectedWalletIndex == selectedWalletIndex)&&(identical(other.selectedDateFilter, selectedDateFilter) || other.selectedDateFilter == selectedDateFilter)&&const DeepCollectionEquality().equals(other._transactions, _transactions)&&(identical(other.errorMessage, errorMessage) || other.errorMessage == errorMessage));
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is _ActivityViewState&&(identical(other.isLoading, isLoading) || other.isLoading == isLoading)&&(identical(other.isLoadingTransactions, isLoadingTransactions) || other.isLoadingTransactions == isLoadingTransactions)&&const DeepCollectionEquality().equals(other._tabs, _tabs)&&(identical(other.selectedWalletIndex, selectedWalletIndex) || other.selectedWalletIndex == selectedWalletIndex)&&(identical(other.selectedDateFilter, selectedDateFilter) || other.selectedDateFilter == selectedDateFilter)&&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)&&(identical(other.errorMessage, errorMessage) || other.errorMessage == errorMessage));
|
||||
}
|
||||
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,isLoading,isLoadingTransactions,const DeepCollectionEquality().hash(_tabs),selectedWalletIndex,selectedDateFilter,const DeepCollectionEquality().hash(_transactions),errorMessage);
|
||||
int get hashCode => Object.hash(runtimeType,isLoading,isLoadingTransactions,const DeepCollectionEquality().hash(_tabs),selectedWalletIndex,selectedDateFilter,const DeepCollectionEquality().hash(_transactionPages),nextCursor,isLoadingMore,currentPage,errorMessage);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'ActivityViewState(isLoading: $isLoading, isLoadingTransactions: $isLoadingTransactions, tabs: $tabs, selectedWalletIndex: $selectedWalletIndex, selectedDateFilter: $selectedDateFilter, transactions: $transactions, errorMessage: $errorMessage)';
|
||||
return 'ActivityViewState(isLoading: $isLoading, isLoadingTransactions: $isLoadingTransactions, tabs: $tabs, selectedWalletIndex: $selectedWalletIndex, selectedDateFilter: $selectedDateFilter, transactionPages: $transactionPages, nextCursor: $nextCursor, isLoadingMore: $isLoadingMore, currentPage: $currentPage, errorMessage: $errorMessage)';
|
||||
}
|
||||
|
||||
|
||||
@@ -265,7 +271,7 @@ abstract mixin class _$ActivityViewStateCopyWith<$Res> implements $ActivityViewS
|
||||
factory _$ActivityViewStateCopyWith(_ActivityViewState value, $Res Function(_ActivityViewState) _then) = __$ActivityViewStateCopyWithImpl;
|
||||
@override @useResult
|
||||
$Res call({
|
||||
bool isLoading, bool isLoadingTransactions, List<WalletTab> tabs, int selectedWalletIndex, DateFilter selectedDateFilter, List<WalletTransactionEntity> transactions, String errorMessage
|
||||
bool isLoading, bool isLoadingTransactions, List<WalletTab> tabs, int selectedWalletIndex, DateFilter selectedDateFilter, List<List<WalletTransactionEntity>> transactionPages, String? nextCursor, bool isLoadingMore, int currentPage, String errorMessage
|
||||
});
|
||||
|
||||
|
||||
@@ -282,15 +288,18 @@ class __$ActivityViewStateCopyWithImpl<$Res>
|
||||
|
||||
/// Create a copy of ActivityViewState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override @pragma('vm:prefer-inline') $Res call({Object? isLoading = null,Object? isLoadingTransactions = null,Object? tabs = null,Object? selectedWalletIndex = null,Object? selectedDateFilter = null,Object? transactions = null,Object? errorMessage = null,}) {
|
||||
@override @pragma('vm:prefer-inline') $Res call({Object? isLoading = null,Object? isLoadingTransactions = null,Object? tabs = null,Object? selectedWalletIndex = null,Object? selectedDateFilter = null,Object? transactionPages = null,Object? nextCursor = freezed,Object? isLoadingMore = null,Object? currentPage = null,Object? errorMessage = null,}) {
|
||||
return _then(_ActivityViewState(
|
||||
isLoading: null == isLoading ? _self.isLoading : isLoading // ignore: cast_nullable_to_non_nullable
|
||||
as bool,isLoadingTransactions: null == isLoadingTransactions ? _self.isLoadingTransactions : isLoadingTransactions // ignore: cast_nullable_to_non_nullable
|
||||
as bool,tabs: null == tabs ? _self._tabs : tabs // ignore: cast_nullable_to_non_nullable
|
||||
as List<WalletTab>,selectedWalletIndex: null == selectedWalletIndex ? _self.selectedWalletIndex : selectedWalletIndex // ignore: cast_nullable_to_non_nullable
|
||||
as int,selectedDateFilter: null == selectedDateFilter ? _self.selectedDateFilter : selectedDateFilter // ignore: cast_nullable_to_non_nullable
|
||||
as DateFilter,transactions: null == transactions ? _self._transactions : transactions // ignore: cast_nullable_to_non_nullable
|
||||
as List<WalletTransactionEntity>,errorMessage: null == errorMessage ? _self.errorMessage : errorMessage // ignore: cast_nullable_to_non_nullable
|
||||
as DateFilter,transactionPages: null == transactionPages ? _self._transactionPages : transactionPages // ignore: cast_nullable_to_non_nullable
|
||||
as List<List<WalletTransactionEntity>>,nextCursor: freezed == nextCursor ? _self.nextCursor : nextCursor // ignore: cast_nullable_to_non_nullable
|
||||
as String?,isLoadingMore: null == isLoadingMore ? _self.isLoadingMore : isLoadingMore // ignore: cast_nullable_to_non_nullable
|
||||
as bool,currentPage: null == currentPage ? _self.currentPage : currentPage // ignore: cast_nullable_to_non_nullable
|
||||
as int,errorMessage: null == errorMessage ? _self.errorMessage : errorMessage // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
));
|
||||
}
|
||||
|
||||
103
modules/activity/lib/src/widgets/pagination_bar.dart
Normal file
103
modules/activity/lib/src/widgets/pagination_bar.dart
Normal file
@@ -0,0 +1,103 @@
|
||||
import 'package:design_system/design_system.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
|
||||
class PaginationBar extends ConsumerWidget {
|
||||
final int currentPage;
|
||||
final int totalPages;
|
||||
final bool hasMore;
|
||||
final bool isLoadingMore;
|
||||
final ValueChanged<int> onPageChanged;
|
||||
final VoidCallback onLoadMore;
|
||||
|
||||
const PaginationBar({
|
||||
super.key,
|
||||
required this.currentPage,
|
||||
required this.totalPages,
|
||||
required this.hasMore,
|
||||
required this.isLoadingMore,
|
||||
required this.onPageChanged,
|
||||
required this.onLoadMore,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final theme = ref.watch(themePortProvider);
|
||||
final textColor = theme.getColorFor(ThemeCode.textPrimary);
|
||||
final primaryColor = theme.getColorFor(ThemeCode.buttonPrimary);
|
||||
|
||||
return Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 12),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
IconButton(
|
||||
onPressed: currentPage > 0
|
||||
? () => onPageChanged(currentPage - 1)
|
||||
: null,
|
||||
icon: Icon(Icons.chevron_left, color: currentPage > 0 ? primaryColor : Colors.grey),
|
||||
iconSize: 28,
|
||||
constraints: const BoxConstraints(minWidth: 36, minHeight: 36),
|
||||
padding: EdgeInsets.zero,
|
||||
),
|
||||
Flexible(
|
||||
child: SingleChildScrollView(
|
||||
scrollDirection: Axis.horizontal,
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: List.generate(totalPages, (index) {
|
||||
final isSelected = index == currentPage;
|
||||
return GestureDetector(
|
||||
onTap: () => onPageChanged(index),
|
||||
child: Container(
|
||||
width: 32,
|
||||
height: 32,
|
||||
margin: const EdgeInsets.symmetric(horizontal: 4),
|
||||
decoration: BoxDecoration(
|
||||
color: isSelected ? primaryColor : Colors.transparent,
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
border: isSelected ? null : Border.all(color: Colors.grey.shade300),
|
||||
),
|
||||
alignment: Alignment.center,
|
||||
child: Text(
|
||||
'${index + 1}',
|
||||
style: TextStyle(
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: isSelected ? Colors.white : textColor,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}),
|
||||
),
|
||||
),
|
||||
),
|
||||
if (hasMore)
|
||||
isLoadingMore
|
||||
? const Padding(
|
||||
padding: EdgeInsets.only(left: 8),
|
||||
child: AppLoadingIndicator(size: 20),
|
||||
)
|
||||
: IconButton(
|
||||
onPressed: onLoadMore,
|
||||
icon: Icon(Icons.add_circle_outline, color: primaryColor),
|
||||
iconSize: 28,
|
||||
constraints: const BoxConstraints(minWidth: 36, minHeight: 36),
|
||||
padding: EdgeInsets.zero,
|
||||
tooltip: 'Load more',
|
||||
),
|
||||
IconButton(
|
||||
onPressed: currentPage < totalPages - 1
|
||||
? () => onPageChanged(currentPage + 1)
|
||||
: null,
|
||||
icon: Icon(Icons.chevron_right, color: currentPage < totalPages - 1 ? primaryColor : Colors.grey),
|
||||
iconSize: 28,
|
||||
constraints: const BoxConstraints(minWidth: 36, minHeight: 36),
|
||||
padding: EdgeInsets.zero,
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
import 'package:design_system/design_system.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
import 'package:sf_shared/sf_shared.dart';
|
||||
import 'package:sf_localizations/sf_localizations.dart';
|
||||
|
||||
@@ -12,9 +13,18 @@ class TransactionTile extends ConsumerWidget {
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final theme = ref.watch(themePortProvider);
|
||||
final color = _color(transaction.transactionType);
|
||||
final icon = _icon(transaction.transactionType);
|
||||
final label = context.translate(_i18nKey(transaction.transactionType));
|
||||
final isDeclined = transaction.status == 'DECLINED';
|
||||
final isCredit = transaction.direction == 'CREDIT';
|
||||
final color = isDeclined ? Colors.grey : _color(transaction.operationType);
|
||||
final icon = _icon(transaction.operationType);
|
||||
final label = transaction.merchantName ??
|
||||
context.translate(_i18nKey(transaction.operationType));
|
||||
final amountPrefix = isCredit ? '+' : '-';
|
||||
final amountColor = isDeclined
|
||||
? Colors.grey
|
||||
: isCredit
|
||||
? Colors.green
|
||||
: Colors.red;
|
||||
|
||||
return Container(
|
||||
padding: const EdgeInsets.all(16),
|
||||
@@ -41,19 +51,27 @@ class TransactionTile extends ConsumerWidget {
|
||||
),
|
||||
),
|
||||
Text(
|
||||
'${transaction.amount} ${transaction.currency}',
|
||||
'$amountPrefix${transaction.amount.toStringAsFixed(2)} ${transaction.currency}',
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.bold,
|
||||
fontSize: 16,
|
||||
color: theme.getColorFor(ThemeCode.textPrimary),
|
||||
color: amountColor,
|
||||
decoration: isDeclined ? TextDecoration.lineThrough : null,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
if (transaction.name.isNotEmpty) ...[
|
||||
if (transaction.messageToUser != null &&
|
||||
transaction.messageToUser!.isNotEmpty) ...[
|
||||
const SizedBox(height: 8),
|
||||
Text(
|
||||
transaction.name,
|
||||
transaction.messageToUser!,
|
||||
style: const TextStyle(fontSize: 13, color: Colors.red),
|
||||
),
|
||||
] else if (transaction.label.isNotEmpty) ...[
|
||||
const SizedBox(height: 8),
|
||||
Text(
|
||||
transaction.label,
|
||||
style: TextStyle(
|
||||
fontSize: 14,
|
||||
color: theme.getColorFor(ThemeCode.textPrimary),
|
||||
@@ -61,12 +79,65 @@ class TransactionTile extends ConsumerWidget {
|
||||
),
|
||||
],
|
||||
const SizedBox(height: 4),
|
||||
Text(
|
||||
transaction.executionDate,
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
color: theme.getColorFor(ThemeCode.textPrimary),
|
||||
),
|
||||
Wrap(
|
||||
spacing: 8,
|
||||
runSpacing: 4,
|
||||
crossAxisAlignment: WrapCrossAlignment.center,
|
||||
children: [
|
||||
Text(
|
||||
_formatDate(transaction.createdDate, context),
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
color: theme.getColorFor(ThemeCode.textPrimary),
|
||||
),
|
||||
),
|
||||
if (transaction.merchantCity != null &&
|
||||
transaction.merchantCity!.isNotEmpty)
|
||||
Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Icon(Icons.location_on, size: 12,
|
||||
color: theme.getColorFor(ThemeCode.textPrimary),
|
||||
),
|
||||
const SizedBox(width: 2),
|
||||
Text(
|
||||
transaction.merchantCity!,
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
color: theme.getColorFor(ThemeCode.textPrimary),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
if (transaction.maskedPan != null &&
|
||||
transaction.maskedPan!.isNotEmpty)
|
||||
Text(
|
||||
transaction.maskedPan!,
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
color: theme.getColorFor(ThemeCode.textPrimary),
|
||||
),
|
||||
),
|
||||
if (isDeclined)
|
||||
Container(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 6,
|
||||
vertical: 2,
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.red.withAlpha(0x1A),
|
||||
borderRadius: BorderRadius.circular(4),
|
||||
),
|
||||
child: Text(
|
||||
transaction.status,
|
||||
style: const TextStyle(
|
||||
fontSize: 10,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: Colors.red,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
@@ -74,82 +145,51 @@ class TransactionTile extends ConsumerWidget {
|
||||
}
|
||||
|
||||
static IconData _icon(TransactionType type) => switch (type) {
|
||||
TransactionType.payin ||
|
||||
TransactionType.payinAcquiring ||
|
||||
TransactionType.checkPayin => Icons.arrow_downward,
|
||||
TransactionType.payout ||
|
||||
TransactionType.payoutSctInstantEmit => Icons.arrow_upward,
|
||||
TransactionType.payinRefund ||
|
||||
TransactionType.payoutRefund ||
|
||||
TransactionType.payinRefundAcquiring ||
|
||||
TransactionType.checkRefund => Icons.replay,
|
||||
TransactionType.transfer ||
|
||||
TransactionType.sctr ||
|
||||
TransactionType.sctrInst ||
|
||||
TransactionType.creditInternationalTransfer => Icons.swap_horiz,
|
||||
TransactionType.cardTopup => Icons.arrow_downward,
|
||||
TransactionType.cardTransaction => Icons.credit_card,
|
||||
TransactionType.sdde || TransactionType.sddr => Icons.account_balance,
|
||||
TransactionType.creditTransferReturned ||
|
||||
TransactionType.payinSctInstantRecall ||
|
||||
TransactionType.payinSctInstantEmitRecall ||
|
||||
TransactionType.sctrRecall ||
|
||||
TransactionType.sddrReversal => Icons.undo,
|
||||
TransactionType.bankTransfer ||
|
||||
TransactionType.instantBankTransfer => Icons.account_balance,
|
||||
TransactionType.walletTransfer => Icons.swap_horiz,
|
||||
TransactionType.bankDirectDebit => Icons.account_balance_wallet,
|
||||
TransactionType.check => Icons.receipt_long,
|
||||
TransactionType.creditNote => Icons.replay,
|
||||
TransactionType.fees => Icons.monetization_on,
|
||||
TransactionType.unknown => Icons.help_outline,
|
||||
};
|
||||
|
||||
static Color _color(TransactionType type) => switch (type) {
|
||||
TransactionType.payin ||
|
||||
TransactionType.payinAcquiring ||
|
||||
TransactionType.checkPayin => Colors.green,
|
||||
TransactionType.payout ||
|
||||
TransactionType.payoutSctInstantEmit => Colors.red,
|
||||
TransactionType.payinRefund ||
|
||||
TransactionType.payoutRefund ||
|
||||
TransactionType.payinRefundAcquiring ||
|
||||
TransactionType.checkRefund ||
|
||||
TransactionType.creditTransferReturned ||
|
||||
TransactionType.payinSctInstantRecall ||
|
||||
TransactionType.payinSctInstantEmitRecall ||
|
||||
TransactionType.sctrRecall ||
|
||||
TransactionType.sddrReversal => Colors.orange,
|
||||
TransactionType.transfer ||
|
||||
TransactionType.sctr ||
|
||||
TransactionType.sctrInst ||
|
||||
TransactionType.creditInternationalTransfer ||
|
||||
TransactionType.sdde ||
|
||||
TransactionType.sddr => Colors.blue,
|
||||
TransactionType.cardTopup => Colors.green,
|
||||
TransactionType.cardTransaction => Colors.purple,
|
||||
TransactionType.bankTransfer ||
|
||||
TransactionType.instantBankTransfer ||
|
||||
TransactionType.walletTransfer => Colors.blue,
|
||||
TransactionType.bankDirectDebit => Colors.red,
|
||||
TransactionType.check => Colors.teal,
|
||||
TransactionType.creditNote => Colors.orange,
|
||||
TransactionType.fees => Colors.red,
|
||||
TransactionType.unknown => Colors.grey,
|
||||
};
|
||||
|
||||
static String _i18nKey(TransactionType type) => switch (type) {
|
||||
TransactionType.payin => I18n.transactionPayin,
|
||||
TransactionType.payout => I18n.transactionPayout,
|
||||
TransactionType.transfer => I18n.transactionTransfer,
|
||||
TransactionType.payinRefund => I18n.transactionPayinRefund,
|
||||
TransactionType.payoutRefund => I18n.transactionPayoutRefund,
|
||||
TransactionType.bankDirectDebit => I18n.transactionBankDirectDebit,
|
||||
TransactionType.bankTransfer => I18n.transactionBankTransfer,
|
||||
TransactionType.cardTopup => I18n.transactionCardTopup,
|
||||
TransactionType.cardTransaction => I18n.transactionCardPayment,
|
||||
TransactionType.payinAcquiring => I18n.transactionPayinAcquiring,
|
||||
TransactionType.payinRefundAcquiring =>
|
||||
I18n.transactionPayinRefundAcquiring,
|
||||
TransactionType.sctrInst => I18n.transactionSctrInst,
|
||||
TransactionType.payinSctInstantRecall =>
|
||||
I18n.transactionPayinSctInstantRecall,
|
||||
TransactionType.payoutSctInstantEmit =>
|
||||
I18n.transactionPayoutSctInstantEmit,
|
||||
TransactionType.payinSctInstantEmitRecall =>
|
||||
I18n.transactionPayinSctInstantEmitRecall,
|
||||
TransactionType.creditTransferReturned =>
|
||||
I18n.transactionCreditTransferReturned,
|
||||
TransactionType.checkPayin => I18n.transactionCheckPayin,
|
||||
TransactionType.sdde => I18n.transactionSdde,
|
||||
TransactionType.sddr => I18n.transactionSddr,
|
||||
TransactionType.sddrReversal => I18n.transactionSddrReversal,
|
||||
TransactionType.sctrRecall => I18n.transactionSctrRecall,
|
||||
TransactionType.checkRefund => I18n.transactionCheckRefund,
|
||||
TransactionType.sctr => I18n.transactionSctr,
|
||||
TransactionType.creditInternationalTransfer =>
|
||||
I18n.transactionCreditInternationalTransfer,
|
||||
TransactionType.check => I18n.transactionCheck,
|
||||
TransactionType.creditNote => I18n.transactionCreditNote,
|
||||
TransactionType.fees => I18n.transactionFees,
|
||||
TransactionType.instantBankTransfer => I18n.transactionInstantBankTransfer,
|
||||
TransactionType.walletTransfer => I18n.transactionWalletTransfer,
|
||||
TransactionType.unknown => I18n.transactionUnknown,
|
||||
};
|
||||
|
||||
static String _formatDate(String raw, BuildContext context) {
|
||||
try {
|
||||
final date = DateTime.parse(raw).toLocal();
|
||||
final locale = Localizations.localeOf(context).languageCode;
|
||||
return DateFormat('d MMM yyyy · HH:mm', locale).format(date);
|
||||
} catch (_) {
|
||||
return raw;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,3 +7,4 @@ export 'src/features/lock_card/lock_card_builder.dart';
|
||||
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';
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:sf_shared/sf_shared.dart';
|
||||
|
||||
@@ -15,11 +14,12 @@ class ChildDataNotifier extends Notifier<ChildDataState> {
|
||||
final String childId;
|
||||
ChildDataNotifier(this.childId);
|
||||
|
||||
late final TreezorRepository _treezorRepository;
|
||||
late final UserRepository _userRepository;
|
||||
late TreezorRepository _treezorRepository;
|
||||
late UserRepository _userRepository;
|
||||
|
||||
@override
|
||||
ChildDataState build() {
|
||||
ref.watch(walletRefreshProvider);
|
||||
final link = ref.keepAlive();
|
||||
final timer = Timer(const Duration(minutes: 5), link.close);
|
||||
ref.onDispose(timer.cancel);
|
||||
@@ -56,9 +56,7 @@ class ChildDataNotifier extends Notifier<ChildDataState> {
|
||||
device = await _userRepository.getDeviceByIdentificator(
|
||||
identificator: childProfile.deviceIdentificator,
|
||||
);
|
||||
} catch (e) {
|
||||
debugPrint('Error fetching device for child $childId: $e');
|
||||
}
|
||||
} catch (_) {}
|
||||
|
||||
if (!ref.mounted) return;
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ import 'package:flutter/material.dart';
|
||||
import 'package:navigation/navigation.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:sf_localizations/sf_localizations.dart';
|
||||
import 'package:sf_shared/sf_shared.dart';
|
||||
|
||||
import '../../card_colors.dart';
|
||||
import '../../presentation/state/home_view_model.dart';
|
||||
@@ -162,14 +163,60 @@ class _ChildWalletScreenState extends ConsumerState<ChildWalletScreen> {
|
||||
),
|
||||
),
|
||||
_buildGenderAvatar(device?.carrierGenre, 50),
|
||||
Text(
|
||||
childName,
|
||||
style: TextStyle(
|
||||
color: theme.getColorFor(ThemeCode.backgroundPrimary),
|
||||
fontWeight: FontWeight.bold,
|
||||
fontSize: 20,
|
||||
Expanded(
|
||||
child: Text(
|
||||
childName,
|
||||
style: TextStyle(
|
||||
color: theme.getColorFor(
|
||||
ThemeCode.backgroundPrimary,
|
||||
),
|
||||
fontWeight: FontWeight.bold,
|
||||
fontSize: 20,
|
||||
),
|
||||
),
|
||||
),
|
||||
PopupMenuButton<String>(
|
||||
icon: Icon(
|
||||
Icons.more_vert,
|
||||
color: theme.getColorFor(ThemeCode.backgroundPrimary),
|
||||
),
|
||||
onSelected: (value) {
|
||||
if (value == 'edit') {
|
||||
widget.navigation.pushTo(
|
||||
AppRoutes.editChildProfile(widget.childId),
|
||||
);
|
||||
} else if (value == 'delete') {
|
||||
_showDeleteConfirmation();
|
||||
}
|
||||
},
|
||||
itemBuilder: (_) => [
|
||||
PopupMenuItem(
|
||||
value: 'edit',
|
||||
child: Row(
|
||||
spacing: 8,
|
||||
children: [
|
||||
Icon(Icons.edit_outlined),
|
||||
Text(
|
||||
context.translate(I18n.editChildProfile),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
PopupMenuItem(
|
||||
value: 'delete',
|
||||
child: Row(
|
||||
spacing: 8,
|
||||
children: [
|
||||
Icon(Icons.delete_outline, color: Colors.red),
|
||||
Text(
|
||||
context.translate(I18n.deleteDevice),
|
||||
style: TextStyle(color: Colors.red),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
Column(
|
||||
@@ -196,76 +243,37 @@ class _ChildWalletScreenState extends ConsumerState<ChildWalletScreen> {
|
||||
minHeight: 10,
|
||||
borderRadius: BorderRadius.all(Radius.circular(5)),
|
||||
),
|
||||
if (CardStatus.fromString(viewState.cardStatus) ==
|
||||
CardStatus.lost ||
|
||||
CardStatus.fromString(viewState.cardStatus) ==
|
||||
CardStatus.stolen)
|
||||
TextButton(
|
||||
style: ButtonStyle(
|
||||
padding: WidgetStatePropertyAll(EdgeInsets.all(0)),
|
||||
),
|
||||
onPressed: viewState.isUpdatingCard
|
||||
? null
|
||||
: () => _showDeleteConfirmation(context, ref),
|
||||
child: Row(
|
||||
spacing: 10,
|
||||
children: [
|
||||
Icon(
|
||||
Icons.delete_outline,
|
||||
size: 24,
|
||||
color: theme.getColorFor(
|
||||
ThemeCode.textSecondary,
|
||||
),
|
||||
),
|
||||
Text(
|
||||
context.translate(I18n.deleteDevice),
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.w500,
|
||||
fontSize: 16,
|
||||
color: theme.getColorFor(
|
||||
ThemeCode.textSecondary,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
)
|
||||
else
|
||||
TextButton(
|
||||
style: ButtonStyle(
|
||||
padding: WidgetStatePropertyAll(EdgeInsets.all(0)),
|
||||
),
|
||||
onPressed: () =>
|
||||
_showCardStatusSheet(context, ref, theme),
|
||||
child: Row(
|
||||
spacing: 10,
|
||||
children: [
|
||||
Icon(
|
||||
Icons.lock_outline,
|
||||
size: 24,
|
||||
color: theme.getColorFor(
|
||||
ThemeCode.textSecondary,
|
||||
),
|
||||
),
|
||||
Text(
|
||||
locked
|
||||
? context.translate(
|
||||
I18n.childWalletUnlockCard,
|
||||
)
|
||||
: context.translate(
|
||||
I18n.childWalletLockCard,
|
||||
),
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.w500,
|
||||
fontSize: 16,
|
||||
color: theme.getColorFor(
|
||||
ThemeCode.textSecondary,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
TextButton(
|
||||
style: ButtonStyle(
|
||||
padding: WidgetStatePropertyAll(EdgeInsets.all(0)),
|
||||
),
|
||||
onPressed: () =>
|
||||
_showCardStatusSheet(context, ref, theme),
|
||||
child: Row(
|
||||
spacing: 10,
|
||||
children: [
|
||||
Icon(
|
||||
Icons.lock_outline,
|
||||
size: 24,
|
||||
color: theme.getColorFor(ThemeCode.textSecondary),
|
||||
),
|
||||
Text(
|
||||
locked
|
||||
? context.translate(
|
||||
I18n.childWalletUnlockCard,
|
||||
)
|
||||
: context.translate(I18n.childWalletLockCard),
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.w500,
|
||||
fontSize: 16,
|
||||
color: theme.getColorFor(
|
||||
ThemeCode.textSecondary,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
Column(
|
||||
@@ -302,7 +310,7 @@ class _ChildWalletScreenState extends ConsumerState<ChildWalletScreen> {
|
||||
child: AppLoadingIndicator(size: 48),
|
||||
),
|
||||
)
|
||||
else if (viewState.transactions.isEmpty)
|
||||
else if (viewState.transactionPages.isEmpty)
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(24),
|
||||
child: Center(
|
||||
@@ -319,13 +327,34 @@ class _ChildWalletScreenState extends ConsumerState<ChildWalletScreen> {
|
||||
),
|
||||
),
|
||||
)
|
||||
else
|
||||
...viewState.transactions.map(
|
||||
else ...[
|
||||
...viewState.transactionPages[viewState.currentPage].map(
|
||||
(tx) => Padding(
|
||||
padding: const EdgeInsets.only(bottom: 12),
|
||||
child: TransactionTile(transaction: tx),
|
||||
),
|
||||
),
|
||||
PaginationBar(
|
||||
currentPage: viewState.currentPage,
|
||||
totalPages: viewState.transactionPages.length,
|
||||
hasMore: viewState.nextCursor != null,
|
||||
isLoadingMore: viewState.isLoadingMore,
|
||||
onPageChanged: (page) => ref
|
||||
.read(
|
||||
childWalletViewModelProvider(
|
||||
widget.childId,
|
||||
).notifier,
|
||||
)
|
||||
.setPage(page),
|
||||
onLoadMore: () => ref
|
||||
.read(
|
||||
childWalletViewModelProvider(
|
||||
widget.childId,
|
||||
).notifier,
|
||||
)
|
||||
.loadMore(),
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
),
|
||||
@@ -342,17 +371,13 @@ class _ChildWalletScreenState extends ConsumerState<ChildWalletScreen> {
|
||||
|
||||
Widget _buildGenderAvatar(String? carrierGenre, double size) {
|
||||
final IconData icon;
|
||||
final Color color;
|
||||
switch (carrierGenre) {
|
||||
case 'M':
|
||||
icon = Icons.face;
|
||||
color = const Color(0xFF64B5F6);
|
||||
case 'F':
|
||||
icon = Icons.face_3;
|
||||
color = const Color(0xFFF48FB1);
|
||||
default:
|
||||
icon = Icons.face_2;
|
||||
color = const Color(0xFF90A4AE);
|
||||
}
|
||||
return CircleAvatar(
|
||||
radius: size / 2,
|
||||
@@ -376,47 +401,108 @@ class _ChildWalletScreenState extends ConsumerState<ChildWalletScreen> {
|
||||
);
|
||||
}
|
||||
|
||||
void _showDeleteConfirmation(BuildContext context, WidgetRef ref) {
|
||||
Future<void> _showDeleteConfirmation() async {
|
||||
final theme = ref.read(themePortProvider);
|
||||
final userRepo = ref.read(userRepositoryProvider);
|
||||
final navigator = Navigator.of(context, rootNavigator: true);
|
||||
final checkingText = context.translate(I18n.deleteDeviceChecking);
|
||||
final notAllowedTitle = context.translate(I18n.deleteDeviceNotAllowedTitle);
|
||||
final nonZeroText = context.translate(
|
||||
I18n.deleteDeviceWalletNonZeroBalance,
|
||||
);
|
||||
final acceptText = context.translate(I18n.accept);
|
||||
final confirmTitle = context.translate(I18n.deleteDeviceConfirmTitle);
|
||||
final confirmMessage = context.translate(I18n.deleteDeviceConfirmMessage);
|
||||
final cancelText = context.translate(I18n.cancel);
|
||||
final deleteText = context.translate(I18n.deleteDevice);
|
||||
final successText = context.translate(I18n.deleteDeviceSuccess);
|
||||
final bgColor = theme.getColorFor(ThemeCode.backgroundPrimary);
|
||||
final shape = RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
);
|
||||
|
||||
showDialog(
|
||||
context: context,
|
||||
barrierDismissible: false,
|
||||
builder: (_) => AlertDialog(
|
||||
backgroundColor: theme.getColorFor(ThemeCode.backgroundPrimary),
|
||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(16)),
|
||||
title: Text(context.translate(I18n.deleteDeviceConfirmTitle)),
|
||||
content: Text(context.translate(I18n.deleteDeviceConfirmMessage)),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => Navigator.of(context).pop(),
|
||||
child: Text(context.translate(I18n.cancel)),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () async {
|
||||
Navigator.of(context).pop();
|
||||
final viewModel = ref.read(
|
||||
childWalletViewModelProvider(widget.childId).notifier,
|
||||
);
|
||||
final success = await viewModel.deleteDevice();
|
||||
if (success && context.mounted) {
|
||||
ref
|
||||
.read(homeViewModelProvider.notifier)
|
||||
.removeChild(widget.childId);
|
||||
showTopSnackbar(
|
||||
context,
|
||||
message: context.translate(I18n.deleteDeviceSuccess),
|
||||
type: MessageType.success,
|
||||
);
|
||||
widget.navigation.goBack();
|
||||
}
|
||||
},
|
||||
child: Text(
|
||||
context.translate(I18n.deleteDevice),
|
||||
style: TextStyle(color: Colors.red),
|
||||
),
|
||||
),
|
||||
],
|
||||
backgroundColor: bgColor,
|
||||
shape: shape,
|
||||
content: Row(
|
||||
spacing: 16,
|
||||
children: [const AppLoadingIndicator(size: 24), Text(checkingText)],
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
try {
|
||||
final deletability = await userRepo.checkChildProfileDeletability(
|
||||
childProfileId: widget.childId,
|
||||
);
|
||||
if (!mounted) return;
|
||||
navigator.pop();
|
||||
|
||||
if (!deletability.isDeletable) {
|
||||
if (!mounted) return;
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (ctx) => AlertDialog(
|
||||
backgroundColor: bgColor,
|
||||
shape: shape,
|
||||
title: Text(notAllowedTitle),
|
||||
content: Text(nonZeroText),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => Navigator.of(ctx).pop(),
|
||||
child: Text(acceptText),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!mounted) return;
|
||||
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.deleteDevice();
|
||||
if (success && mounted) {
|
||||
ref
|
||||
.read(homeViewModelProvider.notifier)
|
||||
.removeChild(widget.childId);
|
||||
showTopSnackbar(
|
||||
context,
|
||||
message: successText,
|
||||
type: MessageType.success,
|
||||
);
|
||||
widget.navigation.goBack();
|
||||
}
|
||||
},
|
||||
child: Text(deleteText, style: TextStyle(color: Colors.red)),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
} catch (e) {
|
||||
if (!mounted) return;
|
||||
navigator.pop();
|
||||
showTopSnackbar(context, message: e.toString(), type: MessageType.error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -463,13 +549,19 @@ class _CardStatusSheetState extends ConsumerState<_CardStatusSheet> {
|
||||
style: const TextStyle(fontSize: 20, fontWeight: FontWeight.w500),
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
...statuses.map(
|
||||
(status) => RadioListTile<String>(
|
||||
title: Text(context.translate(_labelKey(status))),
|
||||
value: status,
|
||||
groupValue: _selected,
|
||||
activeColor: theme.getColorFor(ThemeCode.buttonPrimary),
|
||||
onChanged: (v) => setState(() => _selected = v!),
|
||||
RadioGroup<String>(
|
||||
groupValue: _selected!,
|
||||
onChanged: (v) => setState(() => _selected = v),
|
||||
child: Column(
|
||||
children: statuses
|
||||
.map(
|
||||
(status) => RadioListTile<String>(
|
||||
title: Text(context.translate(_labelKey(status))),
|
||||
value: status,
|
||||
activeColor: theme.getColorFor(ThemeCode.buttonPrimary),
|
||||
),
|
||||
)
|
||||
.toList(),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
|
||||
@@ -5,7 +5,6 @@ import 'package:get_it/get_it.dart';
|
||||
import 'package:sca_treezor/sca_treezor.dart';
|
||||
import 'package:sf_shared/sf_shared.dart';
|
||||
|
||||
|
||||
import '../../card_colors.dart';
|
||||
import 'child_data_provider.dart';
|
||||
import 'child_wallet_view_state.dart';
|
||||
@@ -19,8 +18,8 @@ class ChildWalletViewModel extends Notifier<ChildWalletViewState> {
|
||||
final String childId;
|
||||
ChildWalletViewModel(this.childId);
|
||||
|
||||
late final TreezorWalletConnectionService _connectionService;
|
||||
late final TreezorWalletSignatureService _signatureService;
|
||||
late TreezorWalletConnectionService _connectionService;
|
||||
late TreezorWalletSignatureService _signatureService;
|
||||
|
||||
@override
|
||||
ChildWalletViewState build() {
|
||||
@@ -43,6 +42,8 @@ class ChildWalletViewModel extends Notifier<ChildWalletViewState> {
|
||||
}
|
||||
});
|
||||
|
||||
ref.watch(walletRefreshProvider);
|
||||
|
||||
final data = ref.read(childDataProvider(childId));
|
||||
final initialState = ChildWalletViewState(
|
||||
isLoading: data.isLoading,
|
||||
@@ -66,19 +67,53 @@ class ChildWalletViewModel extends Notifier<ChildWalletViewState> {
|
||||
state = state.copyWith(isLoadingTransactions: true);
|
||||
try {
|
||||
final query = TransactionsQuery(walletId: walletId);
|
||||
final transactions =
|
||||
await ref.read(walletTransactionsProvider(query).future);
|
||||
final response = await ref.read(
|
||||
walletTransactionsProvider(query).future,
|
||||
);
|
||||
if (!ref.mounted) return;
|
||||
state = state.copyWith(
|
||||
isLoadingTransactions: false,
|
||||
transactions: transactions,
|
||||
transactionPages: [response.items],
|
||||
nextCursor: response.nextCursor,
|
||||
currentPage: 0,
|
||||
);
|
||||
} catch (_) {
|
||||
} catch (e) {
|
||||
if (!ref.mounted) return;
|
||||
state = state.copyWith(isLoadingTransactions: false);
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> loadMore() async {
|
||||
final walletId = state.childProfile?.walletId;
|
||||
if (walletId == null || state.isLoadingMore || state.nextCursor == null) return;
|
||||
|
||||
state = state.copyWith(isLoadingMore: true);
|
||||
|
||||
try {
|
||||
final query = TransactionsQuery(
|
||||
walletId: walletId,
|
||||
cursor: state.nextCursor,
|
||||
);
|
||||
final response = await ref.read(
|
||||
walletTransactionsProvider(query).future,
|
||||
);
|
||||
if (!ref.mounted) return;
|
||||
state = state.copyWith(
|
||||
isLoadingMore: false,
|
||||
transactionPages: [...state.transactionPages, response.items],
|
||||
nextCursor: response.nextCursor,
|
||||
currentPage: state.transactionPages.length,
|
||||
);
|
||||
} catch (_) {
|
||||
if (!ref.mounted) return;
|
||||
state = state.copyWith(isLoadingMore: false);
|
||||
}
|
||||
}
|
||||
|
||||
void setPage(int page) {
|
||||
state = state.copyWith(currentPage: page);
|
||||
}
|
||||
|
||||
Future<void> _loadCard(String walletId) async {
|
||||
try {
|
||||
final card = await ref
|
||||
@@ -181,6 +216,12 @@ class ChildWalletViewModel extends Notifier<ChildWalletViewState> {
|
||||
}
|
||||
}
|
||||
|
||||
Future<ChildProfileDeletabilityEntity> checkDeletability() async {
|
||||
return ref
|
||||
.read(userRepositoryProvider)
|
||||
.checkChildProfileDeletability(childProfileId: childId);
|
||||
}
|
||||
|
||||
Future<bool> deleteDevice() async {
|
||||
final deviceId = state.device?.id;
|
||||
if (deviceId == null || deviceId.isEmpty) return false;
|
||||
@@ -195,7 +236,10 @@ class ChildWalletViewModel extends Notifier<ChildWalletViewState> {
|
||||
return true;
|
||||
} catch (e) {
|
||||
if (!ref.mounted) return false;
|
||||
state = state.copyWith(isUpdatingCard: false, cardStatusError: e.toString());
|
||||
state = state.copyWith(
|
||||
isUpdatingCard: false,
|
||||
cardStatusError: e.toString(),
|
||||
);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,6 +22,9 @@ abstract class ChildWalletViewState with _$ChildWalletViewState {
|
||||
@Default('') String pin,
|
||||
@Default(false) bool isSigning,
|
||||
@Default(false) bool isLoadingTransactions,
|
||||
@Default([]) List<WalletTransactionEntity> transactions,
|
||||
@Default([]) List<List<WalletTransactionEntity>> transactionPages,
|
||||
String? nextCursor,
|
||||
@Default(false) bool isLoadingMore,
|
||||
@Default(0) int currentPage,
|
||||
}) = _ChildWalletViewState;
|
||||
}
|
||||
|
||||
@@ -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<WalletTransactionEntity> get transactions;
|
||||
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;
|
||||
/// 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.transactions, transactions));
|
||||
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));
|
||||
}
|
||||
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,isLoading,childProfile,childWallet,device,cardId,cardStatus,locked,errorMessage,isUpdatingCard,cardStatusError,cardStatusSuccess,showPin,selectedStatus,pin,isSigning,isLoadingTransactions,const DeepCollectionEquality().hash(transactions));
|
||||
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]);
|
||||
|
||||
@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, transactions: $transactions)';
|
||||
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)';
|
||||
}
|
||||
|
||||
|
||||
@@ -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<WalletTransactionEntity> transactions
|
||||
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
|
||||
});
|
||||
|
||||
|
||||
@@ -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? transactions = 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? 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
|
||||
@@ -80,8 +80,11 @@ as bool,selectedStatus: null == selectedStatus ? _self.selectedStatus : selected
|
||||
as String,pin: null == pin ? _self.pin : pin // ignore: cast_nullable_to_non_nullable
|
||||
as String,isSigning: null == isSigning ? _self.isSigning : isSigning // ignore: cast_nullable_to_non_nullable
|
||||
as bool,isLoadingTransactions: null == isLoadingTransactions ? _self.isLoadingTransactions : isLoadingTransactions // ignore: cast_nullable_to_non_nullable
|
||||
as bool,transactions: null == transactions ? _self.transactions : transactions // ignore: cast_nullable_to_non_nullable
|
||||
as List<WalletTransactionEntity>,
|
||||
as bool,transactionPages: null == transactionPages ? _self.transactionPages : transactionPages // ignore: cast_nullable_to_non_nullable
|
||||
as List<List<WalletTransactionEntity>>,nextCursor: freezed == nextCursor ? _self.nextCursor : nextCursor // ignore: cast_nullable_to_non_nullable
|
||||
as String?,isLoadingMore: null == isLoadingMore ? _self.isLoadingMore : isLoadingMore // ignore: cast_nullable_to_non_nullable
|
||||
as bool,currentPage: null == currentPage ? _self.currentPage : currentPage // ignore: cast_nullable_to_non_nullable
|
||||
as int,
|
||||
));
|
||||
}
|
||||
/// Create a copy of ChildWalletViewState
|
||||
@@ -202,10 +205,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<WalletTransactionEntity> transactions)? $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, 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.transactions);case _:
|
||||
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 orElse();
|
||||
|
||||
}
|
||||
@@ -223,10 +226,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<WalletTransactionEntity> transactions) $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, 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.transactions);case _:
|
||||
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 _:
|
||||
throw StateError('Unexpected subclass');
|
||||
|
||||
}
|
||||
@@ -243,10 +246,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<WalletTransactionEntity> transactions)? $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, 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.transactions);case _:
|
||||
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 null;
|
||||
|
||||
}
|
||||
@@ -258,7 +261,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<WalletTransactionEntity> transactions = const []}): _transactions = transactions;
|
||||
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;
|
||||
|
||||
|
||||
@override@JsonKey() final bool isLoading;
|
||||
@@ -277,13 +280,16 @@ class _ChildWalletViewState implements ChildWalletViewState {
|
||||
@override@JsonKey() final String pin;
|
||||
@override@JsonKey() final bool isSigning;
|
||||
@override@JsonKey() final bool isLoadingTransactions;
|
||||
final List<WalletTransactionEntity> _transactions;
|
||||
@override@JsonKey() List<WalletTransactionEntity> get transactions {
|
||||
if (_transactions is EqualUnmodifiableListView) return _transactions;
|
||||
final List<List<WalletTransactionEntity>> _transactionPages;
|
||||
@override@JsonKey() List<List<WalletTransactionEntity>> get transactionPages {
|
||||
if (_transactionPages is EqualUnmodifiableListView) return _transactionPages;
|
||||
// ignore: implicit_dynamic_type
|
||||
return EqualUnmodifiableListView(_transactions);
|
||||
return EqualUnmodifiableListView(_transactionPages);
|
||||
}
|
||||
|
||||
@override final String? nextCursor;
|
||||
@override@JsonKey() final bool isLoadingMore;
|
||||
@override@JsonKey() final int currentPage;
|
||||
|
||||
/// Create a copy of ChildWalletViewState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@@ -295,16 +301,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._transactions, _transactions));
|
||||
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));
|
||||
}
|
||||
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,isLoading,childProfile,childWallet,device,cardId,cardStatus,locked,errorMessage,isUpdatingCard,cardStatusError,cardStatusSuccess,showPin,selectedStatus,pin,isSigning,isLoadingTransactions,const DeepCollectionEquality().hash(_transactions));
|
||||
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]);
|
||||
|
||||
@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, transactions: $transactions)';
|
||||
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)';
|
||||
}
|
||||
|
||||
|
||||
@@ -315,7 +321,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<WalletTransactionEntity> transactions
|
||||
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
|
||||
});
|
||||
|
||||
|
||||
@@ -332,7 +338,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? transactions = 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? 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
|
||||
@@ -350,8 +356,11 @@ as bool,selectedStatus: null == selectedStatus ? _self.selectedStatus : selected
|
||||
as String,pin: null == pin ? _self.pin : pin // ignore: cast_nullable_to_non_nullable
|
||||
as String,isSigning: null == isSigning ? _self.isSigning : isSigning // ignore: cast_nullable_to_non_nullable
|
||||
as bool,isLoadingTransactions: null == isLoadingTransactions ? _self.isLoadingTransactions : isLoadingTransactions // ignore: cast_nullable_to_non_nullable
|
||||
as bool,transactions: null == transactions ? _self._transactions : transactions // ignore: cast_nullable_to_non_nullable
|
||||
as List<WalletTransactionEntity>,
|
||||
as bool,transactionPages: null == transactionPages ? _self._transactionPages : transactionPages // ignore: cast_nullable_to_non_nullable
|
||||
as List<List<WalletTransactionEntity>>,nextCursor: freezed == nextCursor ? _self.nextCursor : nextCursor // ignore: cast_nullable_to_non_nullable
|
||||
as String?,isLoadingMore: null == isLoadingMore ? _self.isLoadingMore : isLoadingMore // ignore: cast_nullable_to_non_nullable
|
||||
as bool,currentPage: null == currentPage ? _self.currentPage : currentPage // ignore: cast_nullable_to_non_nullable
|
||||
as int,
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,6 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:sf_shared/sf_shared.dart';
|
||||
|
||||
import '../../presentation/state/home_view_model.dart';
|
||||
import '../child_wallet/child_data_provider.dart';
|
||||
import 'deposit_view_state.dart';
|
||||
|
||||
@@ -100,8 +99,7 @@ class DepositViewModel extends Notifier<DepositViewState> {
|
||||
);
|
||||
|
||||
if (!ref.mounted) return;
|
||||
ref.read(childDataProvider(childId).notifier).load();
|
||||
ref.read(homeViewModelProvider.notifier).refreshChildWallet(childId);
|
||||
ref.read(walletRefreshProvider.notifier).refresh();
|
||||
await ref.read(parentWalletBalanceProvider.notifier).refresh();
|
||||
if (!ref.mounted) return;
|
||||
state = state.copyWith(isSubmitting: false, success: true);
|
||||
|
||||
@@ -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 'presentation/edit_child_profile_screen.dart';
|
||||
|
||||
class EditChildProfileBuilder {
|
||||
const EditChildProfileBuilder();
|
||||
|
||||
Page<void> buildPage(BuildContext context, GoRouterState state) {
|
||||
final childWalletId = state.pathParameters['childWalletId'] ?? '';
|
||||
final navigationContract = GetIt.I<NavigationContract>();
|
||||
return MaterialPage(
|
||||
key: state.pageKey,
|
||||
child: EditChildProfileScreen(
|
||||
childId: childWalletId,
|
||||
navigation: navigationContract,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,191 @@
|
||||
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 'edit_child_profile_view_model.dart';
|
||||
|
||||
class EditChildProfileScreen extends ConsumerWidget {
|
||||
final String childId;
|
||||
final NavigationContract navigation;
|
||||
|
||||
const EditChildProfileScreen({
|
||||
super.key,
|
||||
required this.childId,
|
||||
required this.navigation,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final theme = ref.watch(themePortProvider);
|
||||
final viewState = ref.watch(editChildProfileViewModelProvider(childId));
|
||||
final viewModel =
|
||||
ref.read(editChildProfileViewModelProvider(childId).notifier);
|
||||
|
||||
ref.listen(editChildProfileViewModelProvider(childId), (prev, next) {
|
||||
if (next.saveSuccess && !(prev?.saveSuccess ?? false)) {
|
||||
showTopSnackbar(
|
||||
context,
|
||||
message: context.translate(I18n.editChildProfileSaveSuccess),
|
||||
type: MessageType.success,
|
||||
);
|
||||
navigation.goBack();
|
||||
}
|
||||
if (next.errorMessage.isNotEmpty &&
|
||||
!next.showPin &&
|
||||
next.errorMessage != (prev?.errorMessage ?? '')) {
|
||||
showTopSnackbar(
|
||||
context,
|
||||
message: next.errorMessage,
|
||||
type: MessageType.error,
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
if (viewState.isLoading) {
|
||||
return Scaffold(
|
||||
backgroundColor: theme.getColorFor(ThemeCode.backgroundSecondary),
|
||||
body: const Center(child: AppLoadingIndicator()),
|
||||
);
|
||||
}
|
||||
|
||||
if (viewState.showPin) {
|
||||
return _buildPinScaffold(context, theme, viewState, viewModel);
|
||||
}
|
||||
|
||||
return _buildFormScaffold(context, theme, viewState, viewModel);
|
||||
}
|
||||
|
||||
Widget _buildPinScaffold(
|
||||
BuildContext context,
|
||||
ThemePort theme,
|
||||
EditChildProfileViewState viewState,
|
||||
EditChildProfileViewModel viewModel,
|
||||
) {
|
||||
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.cancelPin,
|
||||
),
|
||||
),
|
||||
body: SafeArea(
|
||||
child: Column(
|
||||
children: [
|
||||
Expanded(
|
||||
child: SingleChildScrollView(
|
||||
child: ScaPinView(
|
||||
title: context.translate(I18n.scaPinEnter),
|
||||
pin: viewState.pin,
|
||||
isProcessing: viewState.isSigning || viewState.isSaving,
|
||||
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(),
|
||||
),
|
||||
),
|
||||
),
|
||||
if (viewState.errorMessage.isNotEmpty)
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 20),
|
||||
child: Text(
|
||||
viewState.errorMessage,
|
||||
style: const TextStyle(color: Colors.red),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: viewModel.cancelPin,
|
||||
child: Text(context.translate(I18n.cancel)),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildFormScaffold(
|
||||
BuildContext context,
|
||||
ThemePort theme,
|
||||
EditChildProfileViewState viewState,
|
||||
EditChildProfileViewModel viewModel,
|
||||
) {
|
||||
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(),
|
||||
),
|
||||
title: Text(
|
||||
context.translate(I18n.editChildProfileTitle),
|
||||
style: TextStyle(color: theme.getColorFor(ThemeCode.textPrimary)),
|
||||
),
|
||||
),
|
||||
body: Padding(
|
||||
padding: const EdgeInsets.all(20),
|
||||
child: Column(
|
||||
children: [
|
||||
Expanded(
|
||||
child: ListView(
|
||||
children: [
|
||||
TextFormField(
|
||||
initialValue: viewState.firstName,
|
||||
decoration: InputDecoration(
|
||||
labelText: context.translate(I18n.firstNameLabel),
|
||||
border: const OutlineInputBorder(),
|
||||
),
|
||||
onChanged: viewModel.setFirstName,
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
TextFormField(
|
||||
initialValue: viewState.lastName,
|
||||
decoration: InputDecoration(
|
||||
labelText: context.translate(I18n.lastNameLabel),
|
||||
border: const OutlineInputBorder(),
|
||||
),
|
||||
onChanged: viewModel.setLastName,
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
TextFormField(
|
||||
initialValue: viewState.address,
|
||||
decoration: InputDecoration(
|
||||
labelText: context.translate(I18n.streetLabel),
|
||||
border: const OutlineInputBorder(),
|
||||
),
|
||||
onChanged: viewModel.setAddress,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
PrimaryButton(
|
||||
onPressed: () => viewModel.requestPin(),
|
||||
text: context.translate(I18n.profileSettingsSave),
|
||||
color: theme.getColorFor(ThemeCode.buttonPrimary),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () => navigation.goBack(),
|
||||
child: Text(context.translate(I18n.cancel)),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,155 @@
|
||||
import 'dart:convert';
|
||||
|
||||
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';
|
||||
|
||||
export 'edit_child_profile_view_state.dart';
|
||||
import 'edit_child_profile_view_state.dart';
|
||||
|
||||
final editChildProfileViewModelProvider = NotifierProvider.autoDispose
|
||||
.family<EditChildProfileViewModel, EditChildProfileViewState, String>(
|
||||
EditChildProfileViewModel.new,
|
||||
);
|
||||
|
||||
class EditChildProfileViewModel extends Notifier<EditChildProfileViewState> {
|
||||
final String childId;
|
||||
EditChildProfileViewModel(this.childId);
|
||||
|
||||
late TreezorWalletConnectionService _connectionService;
|
||||
late TreezorWalletSignatureService _signatureService;
|
||||
|
||||
@override
|
||||
EditChildProfileViewState build() {
|
||||
_connectionService = GetIt.I<TreezorWalletConnectionService>();
|
||||
_signatureService = GetIt.I<TreezorWalletSignatureService>();
|
||||
|
||||
Future.microtask(() => _loadChildProfile());
|
||||
return const EditChildProfileViewState();
|
||||
}
|
||||
|
||||
Future<void> _loadChildProfile() async {
|
||||
state = state.copyWith(isLoading: true, errorMessage: '');
|
||||
|
||||
try {
|
||||
final childData = ref.read(childDataProvider(childId));
|
||||
var childProfile = childData.childProfile;
|
||||
|
||||
if (childProfile == null) {
|
||||
final profiles =
|
||||
await ref.read(userRepositoryProvider).getChildProfiles();
|
||||
childProfile = profiles.where((p) => p.id == childId).firstOrNull;
|
||||
if (childProfile == null) {
|
||||
state = state.copyWith(
|
||||
isLoading: false,
|
||||
errorMessage: 'Child profile not found',
|
||||
);
|
||||
return;
|
||||
}
|
||||
if (!ref.mounted) return;
|
||||
}
|
||||
|
||||
state = state.copyWith(
|
||||
isLoading: false,
|
||||
firstName: childProfile.firstName,
|
||||
lastName: childProfile.lastName,
|
||||
address: childProfile.address,
|
||||
childProfileId: childProfile.id,
|
||||
treezorUserId: childProfile.treezorUserId,
|
||||
);
|
||||
} catch (e) {
|
||||
if (!ref.mounted) return;
|
||||
state = state.copyWith(isLoading: false, errorMessage: e.toString());
|
||||
}
|
||||
}
|
||||
|
||||
void setFirstName(String value) =>
|
||||
state = state.copyWith(firstName: value, saveSuccess: false);
|
||||
|
||||
void setLastName(String value) =>
|
||||
state = state.copyWith(lastName: value, saveSuccess: false);
|
||||
|
||||
void setAddress(String value) =>
|
||||
state = state.copyWith(address: value, saveSuccess: false);
|
||||
|
||||
void requestPin() {
|
||||
state = state.copyWith(showPin: true, pin: '', errorMessage: '');
|
||||
}
|
||||
|
||||
void cancelPin() {
|
||||
state = state.copyWith(showPin: false, 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 {
|
||||
state = state.copyWith(isSigning: true, errorMessage: '');
|
||||
|
||||
try {
|
||||
await _connectionService.connectWithPin(loginPin: state.pin);
|
||||
if (!ref.mounted) return;
|
||||
|
||||
final scaProof = await _generateScaProof();
|
||||
if (!ref.mounted) return;
|
||||
|
||||
state = state.copyWith(isSigning: false, isSaving: true, pin: '');
|
||||
|
||||
await ref.read(userRepositoryProvider).updateChildProfile(
|
||||
childProfileId: state.childProfileId,
|
||||
scaProof: scaProof,
|
||||
firstName: state.firstName,
|
||||
lastName: state.lastName,
|
||||
address: state.address,
|
||||
);
|
||||
if (!ref.mounted) return;
|
||||
|
||||
ref.read(walletRefreshProvider.notifier).refresh();
|
||||
|
||||
state = state.copyWith(
|
||||
isSaving: false,
|
||||
saveSuccess: true,
|
||||
showPin: false,
|
||||
);
|
||||
} catch (e) {
|
||||
if (!ref.mounted) return;
|
||||
state = state.copyWith(
|
||||
isSigning: false,
|
||||
isSaving: false,
|
||||
pin: '',
|
||||
errorMessage: e.toString(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Future<String> _generateScaProof() async {
|
||||
final url =
|
||||
'https://savefamily.sandbox.treezor.co/v1/users/${state.treezorUserId}';
|
||||
final scaBody = <String, dynamic>{
|
||||
'firstName': state.firstName,
|
||||
'lastName': state.lastName,
|
||||
};
|
||||
|
||||
return _signatureService.generateJwsWithPin(
|
||||
message: '',
|
||||
input: jsonEncode({'url': url, 'body': scaBody}),
|
||||
pin: state.pin,
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
|
||||
part 'edit_child_profile_view_state.freezed.dart';
|
||||
|
||||
@freezed
|
||||
abstract class EditChildProfileViewState with _$EditChildProfileViewState {
|
||||
const factory EditChildProfileViewState({
|
||||
@Default(true) bool isLoading,
|
||||
@Default(false) bool isSaving,
|
||||
@Default(false) bool isSigning,
|
||||
@Default(false) bool showPin,
|
||||
@Default('') String pin,
|
||||
@Default('') String firstName,
|
||||
@Default('') String lastName,
|
||||
@Default('') String address,
|
||||
@Default('') String childProfileId,
|
||||
@Default('') String treezorUserId,
|
||||
@Default('') String errorMessage,
|
||||
@Default(false) bool saveSuccess,
|
||||
}) = _EditChildProfileViewState;
|
||||
}
|
||||
@@ -0,0 +1,304 @@
|
||||
// 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 'edit_child_profile_view_state.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// FreezedGenerator
|
||||
// **************************************************************************
|
||||
|
||||
// dart format off
|
||||
T _$identity<T>(T value) => value;
|
||||
/// @nodoc
|
||||
mixin _$EditChildProfileViewState {
|
||||
|
||||
bool get isLoading; bool get isSaving; bool get isSigning; bool get showPin; String get pin; String get firstName; String get lastName; String get address; String get childProfileId; String get treezorUserId; String get errorMessage; bool get saveSuccess;
|
||||
/// Create a copy of EditChildProfileViewState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@pragma('vm:prefer-inline')
|
||||
$EditChildProfileViewStateCopyWith<EditChildProfileViewState> get copyWith => _$EditChildProfileViewStateCopyWithImpl<EditChildProfileViewState>(this as EditChildProfileViewState, _$identity);
|
||||
|
||||
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is EditChildProfileViewState&&(identical(other.isLoading, isLoading) || other.isLoading == isLoading)&&(identical(other.isSaving, isSaving) || other.isSaving == isSaving)&&(identical(other.isSigning, isSigning) || other.isSigning == isSigning)&&(identical(other.showPin, showPin) || other.showPin == showPin)&&(identical(other.pin, pin) || other.pin == pin)&&(identical(other.firstName, firstName) || other.firstName == firstName)&&(identical(other.lastName, lastName) || other.lastName == lastName)&&(identical(other.address, address) || other.address == address)&&(identical(other.childProfileId, childProfileId) || other.childProfileId == childProfileId)&&(identical(other.treezorUserId, treezorUserId) || other.treezorUserId == treezorUserId)&&(identical(other.errorMessage, errorMessage) || other.errorMessage == errorMessage)&&(identical(other.saveSuccess, saveSuccess) || other.saveSuccess == saveSuccess));
|
||||
}
|
||||
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,isLoading,isSaving,isSigning,showPin,pin,firstName,lastName,address,childProfileId,treezorUserId,errorMessage,saveSuccess);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'EditChildProfileViewState(isLoading: $isLoading, isSaving: $isSaving, isSigning: $isSigning, showPin: $showPin, pin: $pin, firstName: $firstName, lastName: $lastName, address: $address, childProfileId: $childProfileId, treezorUserId: $treezorUserId, errorMessage: $errorMessage, saveSuccess: $saveSuccess)';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract mixin class $EditChildProfileViewStateCopyWith<$Res> {
|
||||
factory $EditChildProfileViewStateCopyWith(EditChildProfileViewState value, $Res Function(EditChildProfileViewState) _then) = _$EditChildProfileViewStateCopyWithImpl;
|
||||
@useResult
|
||||
$Res call({
|
||||
bool isLoading, bool isSaving, bool isSigning, bool showPin, String pin, String firstName, String lastName, String address, String childProfileId, String treezorUserId, String errorMessage, bool saveSuccess
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
/// @nodoc
|
||||
class _$EditChildProfileViewStateCopyWithImpl<$Res>
|
||||
implements $EditChildProfileViewStateCopyWith<$Res> {
|
||||
_$EditChildProfileViewStateCopyWithImpl(this._self, this._then);
|
||||
|
||||
final EditChildProfileViewState _self;
|
||||
final $Res Function(EditChildProfileViewState) _then;
|
||||
|
||||
/// Create a copy of EditChildProfileViewState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline') @override $Res call({Object? isLoading = null,Object? isSaving = null,Object? isSigning = null,Object? showPin = null,Object? pin = null,Object? firstName = null,Object? lastName = null,Object? address = null,Object? childProfileId = null,Object? treezorUserId = null,Object? errorMessage = null,Object? saveSuccess = null,}) {
|
||||
return _then(_self.copyWith(
|
||||
isLoading: null == isLoading ? _self.isLoading : isLoading // ignore: cast_nullable_to_non_nullable
|
||||
as bool,isSaving: null == isSaving ? _self.isSaving : isSaving // ignore: cast_nullable_to_non_nullable
|
||||
as bool,isSigning: null == isSigning ? _self.isSigning : isSigning // ignore: cast_nullable_to_non_nullable
|
||||
as bool,showPin: null == showPin ? _self.showPin : showPin // ignore: cast_nullable_to_non_nullable
|
||||
as bool,pin: null == pin ? _self.pin : pin // ignore: cast_nullable_to_non_nullable
|
||||
as String,firstName: null == firstName ? _self.firstName : firstName // ignore: cast_nullable_to_non_nullable
|
||||
as String,lastName: null == lastName ? _self.lastName : lastName // ignore: cast_nullable_to_non_nullable
|
||||
as String,address: null == address ? _self.address : address // ignore: cast_nullable_to_non_nullable
|
||||
as String,childProfileId: null == childProfileId ? _self.childProfileId : childProfileId // ignore: cast_nullable_to_non_nullable
|
||||
as String,treezorUserId: null == treezorUserId ? _self.treezorUserId : treezorUserId // ignore: cast_nullable_to_non_nullable
|
||||
as String,errorMessage: null == errorMessage ? _self.errorMessage : errorMessage // ignore: cast_nullable_to_non_nullable
|
||||
as String,saveSuccess: null == saveSuccess ? _self.saveSuccess : saveSuccess // ignore: cast_nullable_to_non_nullable
|
||||
as bool,
|
||||
));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// Adds pattern-matching-related methods to [EditChildProfileViewState].
|
||||
extension EditChildProfileViewStatePatterns on EditChildProfileViewState {
|
||||
/// 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( _EditChildProfileViewState value)? $default,{required TResult orElse(),}){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _EditChildProfileViewState() 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( _EditChildProfileViewState value) $default,){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _EditChildProfileViewState():
|
||||
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( _EditChildProfileViewState value)? $default,){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _EditChildProfileViewState() 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, bool isSaving, bool isSigning, bool showPin, String pin, String firstName, String lastName, String address, String childProfileId, String treezorUserId, String errorMessage, bool saveSuccess)? $default,{required TResult orElse(),}) {final _that = this;
|
||||
switch (_that) {
|
||||
case _EditChildProfileViewState() when $default != null:
|
||||
return $default(_that.isLoading,_that.isSaving,_that.isSigning,_that.showPin,_that.pin,_that.firstName,_that.lastName,_that.address,_that.childProfileId,_that.treezorUserId,_that.errorMessage,_that.saveSuccess);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, bool isSaving, bool isSigning, bool showPin, String pin, String firstName, String lastName, String address, String childProfileId, String treezorUserId, String errorMessage, bool saveSuccess) $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _EditChildProfileViewState():
|
||||
return $default(_that.isLoading,_that.isSaving,_that.isSigning,_that.showPin,_that.pin,_that.firstName,_that.lastName,_that.address,_that.childProfileId,_that.treezorUserId,_that.errorMessage,_that.saveSuccess);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, bool isSaving, bool isSigning, bool showPin, String pin, String firstName, String lastName, String address, String childProfileId, String treezorUserId, String errorMessage, bool saveSuccess)? $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _EditChildProfileViewState() when $default != null:
|
||||
return $default(_that.isLoading,_that.isSaving,_that.isSigning,_that.showPin,_that.pin,_that.firstName,_that.lastName,_that.address,_that.childProfileId,_that.treezorUserId,_that.errorMessage,_that.saveSuccess);case _:
|
||||
return null;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
|
||||
|
||||
class _EditChildProfileViewState implements EditChildProfileViewState {
|
||||
const _EditChildProfileViewState({this.isLoading = true, this.isSaving = false, this.isSigning = false, this.showPin = false, this.pin = '', this.firstName = '', this.lastName = '', this.address = '', this.childProfileId = '', this.treezorUserId = '', this.errorMessage = '', this.saveSuccess = false});
|
||||
|
||||
|
||||
@override@JsonKey() final bool isLoading;
|
||||
@override@JsonKey() final bool isSaving;
|
||||
@override@JsonKey() final bool isSigning;
|
||||
@override@JsonKey() final bool showPin;
|
||||
@override@JsonKey() final String pin;
|
||||
@override@JsonKey() final String firstName;
|
||||
@override@JsonKey() final String lastName;
|
||||
@override@JsonKey() final String address;
|
||||
@override@JsonKey() final String childProfileId;
|
||||
@override@JsonKey() final String treezorUserId;
|
||||
@override@JsonKey() final String errorMessage;
|
||||
@override@JsonKey() final bool saveSuccess;
|
||||
|
||||
/// Create a copy of EditChildProfileViewState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override @JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@pragma('vm:prefer-inline')
|
||||
_$EditChildProfileViewStateCopyWith<_EditChildProfileViewState> get copyWith => __$EditChildProfileViewStateCopyWithImpl<_EditChildProfileViewState>(this, _$identity);
|
||||
|
||||
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is _EditChildProfileViewState&&(identical(other.isLoading, isLoading) || other.isLoading == isLoading)&&(identical(other.isSaving, isSaving) || other.isSaving == isSaving)&&(identical(other.isSigning, isSigning) || other.isSigning == isSigning)&&(identical(other.showPin, showPin) || other.showPin == showPin)&&(identical(other.pin, pin) || other.pin == pin)&&(identical(other.firstName, firstName) || other.firstName == firstName)&&(identical(other.lastName, lastName) || other.lastName == lastName)&&(identical(other.address, address) || other.address == address)&&(identical(other.childProfileId, childProfileId) || other.childProfileId == childProfileId)&&(identical(other.treezorUserId, treezorUserId) || other.treezorUserId == treezorUserId)&&(identical(other.errorMessage, errorMessage) || other.errorMessage == errorMessage)&&(identical(other.saveSuccess, saveSuccess) || other.saveSuccess == saveSuccess));
|
||||
}
|
||||
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,isLoading,isSaving,isSigning,showPin,pin,firstName,lastName,address,childProfileId,treezorUserId,errorMessage,saveSuccess);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'EditChildProfileViewState(isLoading: $isLoading, isSaving: $isSaving, isSigning: $isSigning, showPin: $showPin, pin: $pin, firstName: $firstName, lastName: $lastName, address: $address, childProfileId: $childProfileId, treezorUserId: $treezorUserId, errorMessage: $errorMessage, saveSuccess: $saveSuccess)';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract mixin class _$EditChildProfileViewStateCopyWith<$Res> implements $EditChildProfileViewStateCopyWith<$Res> {
|
||||
factory _$EditChildProfileViewStateCopyWith(_EditChildProfileViewState value, $Res Function(_EditChildProfileViewState) _then) = __$EditChildProfileViewStateCopyWithImpl;
|
||||
@override @useResult
|
||||
$Res call({
|
||||
bool isLoading, bool isSaving, bool isSigning, bool showPin, String pin, String firstName, String lastName, String address, String childProfileId, String treezorUserId, String errorMessage, bool saveSuccess
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
/// @nodoc
|
||||
class __$EditChildProfileViewStateCopyWithImpl<$Res>
|
||||
implements _$EditChildProfileViewStateCopyWith<$Res> {
|
||||
__$EditChildProfileViewStateCopyWithImpl(this._self, this._then);
|
||||
|
||||
final _EditChildProfileViewState _self;
|
||||
final $Res Function(_EditChildProfileViewState) _then;
|
||||
|
||||
/// Create a copy of EditChildProfileViewState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override @pragma('vm:prefer-inline') $Res call({Object? isLoading = null,Object? isSaving = null,Object? isSigning = null,Object? showPin = null,Object? pin = null,Object? firstName = null,Object? lastName = null,Object? address = null,Object? childProfileId = null,Object? treezorUserId = null,Object? errorMessage = null,Object? saveSuccess = null,}) {
|
||||
return _then(_EditChildProfileViewState(
|
||||
isLoading: null == isLoading ? _self.isLoading : isLoading // ignore: cast_nullable_to_non_nullable
|
||||
as bool,isSaving: null == isSaving ? _self.isSaving : isSaving // ignore: cast_nullable_to_non_nullable
|
||||
as bool,isSigning: null == isSigning ? _self.isSigning : isSigning // ignore: cast_nullable_to_non_nullable
|
||||
as bool,showPin: null == showPin ? _self.showPin : showPin // ignore: cast_nullable_to_non_nullable
|
||||
as bool,pin: null == pin ? _self.pin : pin // ignore: cast_nullable_to_non_nullable
|
||||
as String,firstName: null == firstName ? _self.firstName : firstName // ignore: cast_nullable_to_non_nullable
|
||||
as String,lastName: null == lastName ? _self.lastName : lastName // ignore: cast_nullable_to_non_nullable
|
||||
as String,address: null == address ? _self.address : address // ignore: cast_nullable_to_non_nullable
|
||||
as String,childProfileId: null == childProfileId ? _self.childProfileId : childProfileId // ignore: cast_nullable_to_non_nullable
|
||||
as String,treezorUserId: null == treezorUserId ? _self.treezorUserId : treezorUserId // ignore: cast_nullable_to_non_nullable
|
||||
as String,errorMessage: null == errorMessage ? _self.errorMessage : errorMessage // ignore: cast_nullable_to_non_nullable
|
||||
as String,saveSuccess: null == saveSuccess ? _self.saveSuccess : saveSuccess // ignore: cast_nullable_to_non_nullable
|
||||
as bool,
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
// dart format on
|
||||
@@ -2,7 +2,6 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:sf_shared/sf_shared.dart';
|
||||
|
||||
import '../../presentation/state/home_view_model.dart';
|
||||
import '../child_wallet/child_data_provider.dart';
|
||||
import 'extract_view_state.dart';
|
||||
|
||||
@@ -92,8 +91,7 @@ class ExtractViewModel extends Notifier<ExtractViewState> {
|
||||
);
|
||||
|
||||
if (!ref.mounted) return;
|
||||
ref.read(childDataProvider(childId).notifier).load();
|
||||
ref.read(homeViewModelProvider.notifier).refreshChildWallet(childId);
|
||||
ref.read(walletRefreshProvider.notifier).refresh();
|
||||
ref.read(parentWalletBalanceProvider.notifier).applyOptimisticPayin(amount);
|
||||
state = state.copyWith(isSubmitting: false, success: true);
|
||||
} catch (e) {
|
||||
|
||||
@@ -37,32 +37,20 @@ class HomeScreen extends ConsumerWidget {
|
||||
margin: EdgeInsets.all(30),
|
||||
child: Column(
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: Text.rich(
|
||||
Align(
|
||||
alignment: Alignment.centerLeft,
|
||||
child: Text.rich(
|
||||
TextSpan(
|
||||
text: context.translate(I18n.homeGreeting),
|
||||
style: TextStyle(fontSize: 25),
|
||||
children: <TextSpan>[
|
||||
TextSpan(
|
||||
text: context.translate(I18n.homeGreeting),
|
||||
style: TextStyle(fontSize: 25),
|
||||
children: <TextSpan>[
|
||||
TextSpan(
|
||||
text: viewState.userName,
|
||||
style: TextStyle(fontWeight: FontWeight.w500),
|
||||
),
|
||||
],
|
||||
text: viewState.userName,
|
||||
style: TextStyle(fontWeight: FontWeight.w500),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
IconButton(
|
||||
onPressed: () =>
|
||||
navigationContract.pushTo(AppRoutes.deviceSetup),
|
||||
icon: Icon(
|
||||
Icons.person_add_outlined,
|
||||
color: theme.getColorFor(ThemeCode.textPrimary),
|
||||
),
|
||||
tooltip: context.translate(I18n.homeAddAnotherKid),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
const ChildWalletsSlider(),
|
||||
Align(
|
||||
|
||||
@@ -77,7 +77,7 @@ class PersonalDataScreen extends ConsumerWidget {
|
||||
child: Column(
|
||||
children: [
|
||||
Text(context.translate(I18n.personalDataMessage)),
|
||||
const SizedBox(height: 14),
|
||||
const SizedBox(height: 4),
|
||||
const _SaveButton(),
|
||||
],
|
||||
),
|
||||
@@ -169,12 +169,33 @@ class _PhoneField extends ConsumerWidget {
|
||||
final hint = ref.watch(
|
||||
personalDataViewModelProvider.select((s) => s.user?.phone ?? ''),
|
||||
);
|
||||
final dialCode = ref.read(
|
||||
personalDataViewModelProvider.select((s)=>s.dialCode)
|
||||
);
|
||||
|
||||
return CustomTextField(
|
||||
controller: vm.phoneController,
|
||||
hint: hint,
|
||||
label: context.translate(I18n.phoneLabel),
|
||||
keyboardType: TextInputType.phone,
|
||||
return Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.end,
|
||||
children: [
|
||||
CountryPrefixPicker(
|
||||
headerText: context.translate(I18n.selectYourCountry),
|
||||
initialSelection: dialCode,
|
||||
onChanged: (country) {
|
||||
vm.updateDialCode(
|
||||
country.dialCode ?? dialCode,
|
||||
);
|
||||
},
|
||||
width: 80,
|
||||
),
|
||||
SizedBox(width: 8),
|
||||
Expanded(
|
||||
child: CustomTextField(
|
||||
controller: vm.phoneController,
|
||||
hint: hint,
|
||||
label: context.translate(I18n.phoneLabel),
|
||||
keyboardType: TextInputType.phone,
|
||||
)
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,12 +39,26 @@ class PersonalDataViewModel extends Notifier<PersonalDataViewState> {
|
||||
state = state.copyWith(user: user, isLoading: false);
|
||||
}
|
||||
|
||||
void updateDialCode(String value) {
|
||||
if (value == state.dialCode) return;
|
||||
|
||||
state = state.copyWith(
|
||||
dialCode: value,
|
||||
errorMessage: '',
|
||||
);
|
||||
}
|
||||
|
||||
bool get _hasChanges =>
|
||||
firstNameController.text.trim().isNotEmpty ||
|
||||
lastNameController.text.trim().isNotEmpty ||
|
||||
phoneController.text.trim().isNotEmpty;
|
||||
|
||||
UpdateUserRequestEntity _toRequest() {
|
||||
final dialCode = state.dialCode;
|
||||
final fullPhone = phoneController.text.trim().isNotEmpty
|
||||
? dialCode+phoneController.text.trim()
|
||||
: null;
|
||||
|
||||
return UpdateUserRequestEntity(
|
||||
firstName: firstNameController.text.trim().isNotEmpty
|
||||
? firstNameController.text.trim()
|
||||
@@ -52,9 +66,7 @@ class PersonalDataViewModel extends Notifier<PersonalDataViewState> {
|
||||
lastName: lastNameController.text.trim().isNotEmpty
|
||||
? lastNameController.text.trim()
|
||||
: null,
|
||||
phone: phoneController.text.trim().isNotEmpty
|
||||
? phoneController.text.trim()
|
||||
: null,
|
||||
phone: fullPhone,
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ abstract class PersonalDataViewState with _$PersonalDataViewState {
|
||||
const factory PersonalDataViewState({
|
||||
@Default(true) bool isLoading,
|
||||
@Default(false) bool isComplete,
|
||||
@Default('+34') String dialCode,
|
||||
UserEntity? user,
|
||||
@Default('') String errorMessage,
|
||||
}) = _PersonalDataViewState;
|
||||
|
||||
@@ -14,7 +14,7 @@ T _$identity<T>(T value) => value;
|
||||
/// @nodoc
|
||||
mixin _$PersonalDataViewState {
|
||||
|
||||
bool get isLoading; bool get isComplete; UserEntity? get user; String get errorMessage;
|
||||
bool get isLoading; bool get isComplete; String get dialCode; UserEntity? get user; String get errorMessage;
|
||||
/// Create a copy of PersonalDataViewState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@@ -25,16 +25,16 @@ $PersonalDataViewStateCopyWith<PersonalDataViewState> get copyWith => _$Personal
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is PersonalDataViewState&&(identical(other.isLoading, isLoading) || other.isLoading == isLoading)&&(identical(other.isComplete, isComplete) || other.isComplete == isComplete)&&(identical(other.user, user) || other.user == user)&&(identical(other.errorMessage, errorMessage) || other.errorMessage == errorMessage));
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is PersonalDataViewState&&(identical(other.isLoading, isLoading) || other.isLoading == isLoading)&&(identical(other.isComplete, isComplete) || other.isComplete == isComplete)&&(identical(other.dialCode, dialCode) || other.dialCode == dialCode)&&(identical(other.user, user) || other.user == user)&&(identical(other.errorMessage, errorMessage) || other.errorMessage == errorMessage));
|
||||
}
|
||||
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,isLoading,isComplete,user,errorMessage);
|
||||
int get hashCode => Object.hash(runtimeType,isLoading,isComplete,dialCode,user,errorMessage);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'PersonalDataViewState(isLoading: $isLoading, isComplete: $isComplete, user: $user, errorMessage: $errorMessage)';
|
||||
return 'PersonalDataViewState(isLoading: $isLoading, isComplete: $isComplete, dialCode: $dialCode, user: $user, errorMessage: $errorMessage)';
|
||||
}
|
||||
|
||||
|
||||
@@ -45,7 +45,7 @@ abstract mixin class $PersonalDataViewStateCopyWith<$Res> {
|
||||
factory $PersonalDataViewStateCopyWith(PersonalDataViewState value, $Res Function(PersonalDataViewState) _then) = _$PersonalDataViewStateCopyWithImpl;
|
||||
@useResult
|
||||
$Res call({
|
||||
bool isLoading, bool isComplete, UserEntity? user, String errorMessage
|
||||
bool isLoading, bool isComplete, String dialCode, UserEntity? user, String errorMessage
|
||||
});
|
||||
|
||||
|
||||
@@ -62,11 +62,12 @@ class _$PersonalDataViewStateCopyWithImpl<$Res>
|
||||
|
||||
/// Create a copy of PersonalDataViewState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline') @override $Res call({Object? isLoading = null,Object? isComplete = null,Object? user = freezed,Object? errorMessage = null,}) {
|
||||
@pragma('vm:prefer-inline') @override $Res call({Object? isLoading = null,Object? isComplete = null,Object? dialCode = null,Object? user = freezed,Object? errorMessage = null,}) {
|
||||
return _then(_self.copyWith(
|
||||
isLoading: null == isLoading ? _self.isLoading : isLoading // ignore: cast_nullable_to_non_nullable
|
||||
as bool,isComplete: null == isComplete ? _self.isComplete : isComplete // ignore: cast_nullable_to_non_nullable
|
||||
as bool,user: freezed == user ? _self.user : user // ignore: cast_nullable_to_non_nullable
|
||||
as bool,dialCode: null == dialCode ? _self.dialCode : dialCode // ignore: cast_nullable_to_non_nullable
|
||||
as String,user: freezed == user ? _self.user : user // ignore: cast_nullable_to_non_nullable
|
||||
as UserEntity?,errorMessage: null == errorMessage ? _self.errorMessage : errorMessage // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
));
|
||||
@@ -165,10 +166,10 @@ return $default(_that);case _:
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( bool isLoading, bool isComplete, UserEntity? user, String errorMessage)? $default,{required TResult orElse(),}) {final _that = this;
|
||||
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( bool isLoading, bool isComplete, String dialCode, UserEntity? user, String errorMessage)? $default,{required TResult orElse(),}) {final _that = this;
|
||||
switch (_that) {
|
||||
case _PersonalDataViewState() when $default != null:
|
||||
return $default(_that.isLoading,_that.isComplete,_that.user,_that.errorMessage);case _:
|
||||
return $default(_that.isLoading,_that.isComplete,_that.dialCode,_that.user,_that.errorMessage);case _:
|
||||
return orElse();
|
||||
|
||||
}
|
||||
@@ -186,10 +187,10 @@ return $default(_that.isLoading,_that.isComplete,_that.user,_that.errorMessage);
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( bool isLoading, bool isComplete, UserEntity? user, String errorMessage) $default,) {final _that = this;
|
||||
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( bool isLoading, bool isComplete, String dialCode, UserEntity? user, String errorMessage) $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _PersonalDataViewState():
|
||||
return $default(_that.isLoading,_that.isComplete,_that.user,_that.errorMessage);case _:
|
||||
return $default(_that.isLoading,_that.isComplete,_that.dialCode,_that.user,_that.errorMessage);case _:
|
||||
throw StateError('Unexpected subclass');
|
||||
|
||||
}
|
||||
@@ -206,10 +207,10 @@ return $default(_that.isLoading,_that.isComplete,_that.user,_that.errorMessage);
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( bool isLoading, bool isComplete, UserEntity? user, String errorMessage)? $default,) {final _that = this;
|
||||
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( bool isLoading, bool isComplete, String dialCode, UserEntity? user, String errorMessage)? $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _PersonalDataViewState() when $default != null:
|
||||
return $default(_that.isLoading,_that.isComplete,_that.user,_that.errorMessage);case _:
|
||||
return $default(_that.isLoading,_that.isComplete,_that.dialCode,_that.user,_that.errorMessage);case _:
|
||||
return null;
|
||||
|
||||
}
|
||||
@@ -221,11 +222,12 @@ return $default(_that.isLoading,_that.isComplete,_that.user,_that.errorMessage);
|
||||
|
||||
|
||||
class _PersonalDataViewState implements PersonalDataViewState {
|
||||
const _PersonalDataViewState({this.isLoading = true, this.isComplete = false, this.user, this.errorMessage = ''});
|
||||
const _PersonalDataViewState({this.isLoading = true, this.isComplete = false, this.dialCode = '+34', this.user, this.errorMessage = ''});
|
||||
|
||||
|
||||
@override@JsonKey() final bool isLoading;
|
||||
@override@JsonKey() final bool isComplete;
|
||||
@override@JsonKey() final String dialCode;
|
||||
@override final UserEntity? user;
|
||||
@override@JsonKey() final String errorMessage;
|
||||
|
||||
@@ -239,16 +241,16 @@ _$PersonalDataViewStateCopyWith<_PersonalDataViewState> get copyWith => __$Perso
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is _PersonalDataViewState&&(identical(other.isLoading, isLoading) || other.isLoading == isLoading)&&(identical(other.isComplete, isComplete) || other.isComplete == isComplete)&&(identical(other.user, user) || other.user == user)&&(identical(other.errorMessage, errorMessage) || other.errorMessage == errorMessage));
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is _PersonalDataViewState&&(identical(other.isLoading, isLoading) || other.isLoading == isLoading)&&(identical(other.isComplete, isComplete) || other.isComplete == isComplete)&&(identical(other.dialCode, dialCode) || other.dialCode == dialCode)&&(identical(other.user, user) || other.user == user)&&(identical(other.errorMessage, errorMessage) || other.errorMessage == errorMessage));
|
||||
}
|
||||
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,isLoading,isComplete,user,errorMessage);
|
||||
int get hashCode => Object.hash(runtimeType,isLoading,isComplete,dialCode,user,errorMessage);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'PersonalDataViewState(isLoading: $isLoading, isComplete: $isComplete, user: $user, errorMessage: $errorMessage)';
|
||||
return 'PersonalDataViewState(isLoading: $isLoading, isComplete: $isComplete, dialCode: $dialCode, user: $user, errorMessage: $errorMessage)';
|
||||
}
|
||||
|
||||
|
||||
@@ -259,7 +261,7 @@ abstract mixin class _$PersonalDataViewStateCopyWith<$Res> implements $PersonalD
|
||||
factory _$PersonalDataViewStateCopyWith(_PersonalDataViewState value, $Res Function(_PersonalDataViewState) _then) = __$PersonalDataViewStateCopyWithImpl;
|
||||
@override @useResult
|
||||
$Res call({
|
||||
bool isLoading, bool isComplete, UserEntity? user, String errorMessage
|
||||
bool isLoading, bool isComplete, String dialCode, UserEntity? user, String errorMessage
|
||||
});
|
||||
|
||||
|
||||
@@ -276,11 +278,12 @@ class __$PersonalDataViewStateCopyWithImpl<$Res>
|
||||
|
||||
/// Create a copy of PersonalDataViewState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override @pragma('vm:prefer-inline') $Res call({Object? isLoading = null,Object? isComplete = null,Object? user = freezed,Object? errorMessage = null,}) {
|
||||
@override @pragma('vm:prefer-inline') $Res call({Object? isLoading = null,Object? isComplete = null,Object? dialCode = null,Object? user = freezed,Object? errorMessage = null,}) {
|
||||
return _then(_PersonalDataViewState(
|
||||
isLoading: null == isLoading ? _self.isLoading : isLoading // ignore: cast_nullable_to_non_nullable
|
||||
as bool,isComplete: null == isComplete ? _self.isComplete : isComplete // ignore: cast_nullable_to_non_nullable
|
||||
as bool,user: freezed == user ? _self.user : user // ignore: cast_nullable_to_non_nullable
|
||||
as bool,dialCode: null == dialCode ? _self.dialCode : dialCode // ignore: cast_nullable_to_non_nullable
|
||||
as String,user: freezed == user ? _self.user : user // ignore: cast_nullable_to_non_nullable
|
||||
as UserEntity?,errorMessage: null == errorMessage ? _self.errorMessage : errorMessage // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
));
|
||||
|
||||
@@ -96,7 +96,7 @@ packages:
|
||||
source: hosted
|
||||
version: "3.0.3"
|
||||
build_runner:
|
||||
dependency: transitive
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: build_runner
|
||||
sha256: b24597fceb695969d47025c958f3837f9f0122e237c6a22cb082a5ac66c3ca30
|
||||
@@ -338,10 +338,10 @@ packages:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: fl_chart
|
||||
sha256: "7ca9a40f4eb85949190e54087be8b4d6ac09dc4c54238d782a34cf1f7c011de9"
|
||||
sha256: b938f77d042cbcd822936a7a359a7235bad8bd72070de1f827efc2cc297ac888
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.1.1"
|
||||
version: "1.2.0"
|
||||
flutter:
|
||||
dependency: "direct main"
|
||||
description: flutter
|
||||
@@ -367,18 +367,18 @@ packages:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: flutter_riverpod
|
||||
sha256: e2026c72738a925a60db30258ff1f29974e40716749f3c9850aabf34ffc1a14c
|
||||
sha256: "4e166be88e1dbbaa34a280bdb744aeae73b7ef25fdf8db7a3bb776760a3648e2"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "3.2.1"
|
||||
version: "3.3.1"
|
||||
flutter_svg:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: flutter_svg
|
||||
sha256: "87fbd7c534435b6c5d9d98b01e1fd527812b82e68ddd8bd35fc45ed0fa8f0a95"
|
||||
sha256: "1ded017b39c8e15c8948ea855070a5ff8ff8b3d5e83f3446e02d6bb12add7ad9"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.2.3"
|
||||
version: "2.2.4"
|
||||
flutter_test:
|
||||
dependency: "direct dev"
|
||||
description: flutter
|
||||
@@ -620,10 +620,10 @@ packages:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: logger
|
||||
sha256: a7967e31b703831a893bbc3c3dd11db08126fe5f369b5c648a36f821979f5be3
|
||||
sha256: "25aee487596a6257655a1e091ec2ae66bc30e7af663592cc3a27e6591e05035c"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.6.2"
|
||||
version: "2.7.0"
|
||||
logging:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -1257,10 +1257,10 @@ packages:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: vector_graphics
|
||||
sha256: a4f059dc26fc8295b5921376600a194c4ec7d55e72f2fe4c7d2831e103d461e6
|
||||
sha256: "7076216a10d5c390315fbe536a30f1254c341e7543e6c4c8a815e591307772b1"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.1.19"
|
||||
version: "1.1.20"
|
||||
vector_graphics_codec:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -1361,10 +1361,10 @@ packages:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: webview_flutter_wkwebview
|
||||
sha256: fc0af89d403e1c053f03d023d97550412fa79f35332e2939514c82e6fe633198
|
||||
sha256: "2df8fd9ada04d699b9db8e79aa783a16e5d89b69e5b74009b87e16b59912cf98"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "3.23.8"
|
||||
version: "3.24.0"
|
||||
wkt_parser:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
||||
@@ -56,6 +56,7 @@ dependencies:
|
||||
uuid: ^4.5.2
|
||||
qr_flutter: ^4.1.0
|
||||
url_launcher: ^6.3.2
|
||||
build_runner: ^2.7.1
|
||||
|
||||
# The following adds the Cupertino Icons font to your application.
|
||||
# Use with the CupertinoIcons class for iOS style icons.
|
||||
|
||||
@@ -13,28 +13,21 @@ import 'package:utils/utils.dart';
|
||||
class ControlPanelScreen extends ConsumerWidget {
|
||||
final NavigationContract navigationContract;
|
||||
|
||||
const ControlPanelScreen({
|
||||
super.key,
|
||||
required this.navigationContract,
|
||||
});
|
||||
const ControlPanelScreen({super.key, required this.navigationContract});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final theme = ref.watch(themePortProvider);
|
||||
final state = ref.watch(controlPanelViewModelProvider);
|
||||
|
||||
ref.listen(
|
||||
controlPanelViewModelProvider.select((s) => s.errorMessage),
|
||||
(previous, next) {
|
||||
if (next.isNotEmpty) {
|
||||
showTopSnackbar(
|
||||
context,
|
||||
message: next,
|
||||
type: MessageType.error,
|
||||
);
|
||||
}
|
||||
},
|
||||
);
|
||||
ref.listen(controlPanelViewModelProvider.select((s) => s.errorMessage), (
|
||||
previous,
|
||||
next,
|
||||
) {
|
||||
if (next.isNotEmpty) {
|
||||
showTopSnackbar(context, message: next, type: MessageType.error);
|
||||
}
|
||||
});
|
||||
|
||||
if (state.isLoading) {
|
||||
return Scaffold(
|
||||
@@ -90,7 +83,9 @@ class _Header extends ConsumerWidget {
|
||||
alignment: Alignment.center,
|
||||
children: [
|
||||
Padding(
|
||||
padding: EdgeInsets.only(top: SizeUtils.getByScreen(small: 14, big: 14)),
|
||||
padding: EdgeInsets.only(
|
||||
top: SizeUtils.getByScreen(small: 14, big: 14),
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
Image.asset(
|
||||
@@ -102,17 +97,13 @@ class _Header extends ConsumerWidget {
|
||||
width: SizeUtils.getByScreen(small: 130, big: 140),
|
||||
height: 32,
|
||||
child: CustomDropdown(
|
||||
items: state.devices
|
||||
.map(
|
||||
(DeviceEntity device) {
|
||||
final name = device.carrierName ?? '';
|
||||
return Text(
|
||||
name.length > 10 ? '${name.substring(0, 10)}...' : name,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
);
|
||||
},
|
||||
)
|
||||
.toList(),
|
||||
items: state.devices.map((DeviceEntity device) {
|
||||
final name = device.carrierName ?? '';
|
||||
return Text(
|
||||
name.length > 10 ? '${name.substring(0, 10)}...' : name,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
);
|
||||
}).toList(),
|
||||
values: state.devices,
|
||||
value: state.selectedDevice,
|
||||
onChanged: (device) {
|
||||
@@ -153,13 +144,13 @@ class _MenuSection extends ConsumerWidget {
|
||||
text: I18n.customerService,
|
||||
),
|
||||
SizedBox(height: SizeUtils.getByScreen(small: 8, big: 7)),
|
||||
_SectionButton(
|
||||
onPressed: () {
|
||||
navigationContract.pushTo(AppRoutes.dashboardHome);
|
||||
},
|
||||
icon: SFIcons.payments,
|
||||
text: I18n.sfPay,
|
||||
),
|
||||
// _SectionButton(
|
||||
// onPressed: () {
|
||||
// navigationContract.pushTo(AppRoutes.dashboardHome);
|
||||
// },
|
||||
// icon: SFIcons.payments,
|
||||
// text: I18n.sfPay,
|
||||
// ),
|
||||
SizedBox(height: SizeUtils.getByScreen(small: 8, big: 7)),
|
||||
_SectionButton(
|
||||
onPressed: () {
|
||||
|
||||
@@ -46,6 +46,8 @@ class _EditContactScreenState extends ConsumerState<EditContactScreen> {
|
||||
Widget build(BuildContext context) {
|
||||
final theme = ref.watch(themePortProvider);
|
||||
|
||||
final state = ref.watch(contactsViewModelProvider);
|
||||
|
||||
return Scaffold(
|
||||
backgroundColor: theme.getColorFor(ThemeCode.backgroundPrimary),
|
||||
body: SafeArea(
|
||||
@@ -101,10 +103,31 @@ class _EditContactScreenState extends ConsumerState<EditContactScreen> {
|
||||
SizedBox(
|
||||
height: SizeUtils.getByScreen(small: 28, big: 26),
|
||||
),
|
||||
CustomTextField(
|
||||
controller: _phoneController,
|
||||
keyboardType: TextInputType.number,
|
||||
label: context.translate(I18n.phoneNumber),
|
||||
Row(
|
||||
children: [
|
||||
CountryPrefixPicker(
|
||||
headerText: context.translate(I18n.selectYourCountry),
|
||||
initialSelection: state.dialCode,
|
||||
onChanged: (country) {
|
||||
final vm =
|
||||
ref.read(contactsViewModelProvider.notifier);
|
||||
vm.updateDialCode(
|
||||
country.dialCode ?? state.dialCode,
|
||||
);
|
||||
},
|
||||
width: 80,
|
||||
),
|
||||
SizedBox(
|
||||
width: SizeUtils.getByScreen(small: 10, big: 10, xl: 6),
|
||||
),
|
||||
Expanded(
|
||||
child: CustomTextField(
|
||||
controller: _phoneController,
|
||||
keyboardType: TextInputType.number,
|
||||
label: context.translate(I18n.phoneNumber),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
@@ -48,6 +48,15 @@ class ContactsViewModel extends Notifier<ContactsViewState> {
|
||||
state = state.copyWith(isEditing: !state.isEditing);
|
||||
}
|
||||
|
||||
void updateDialCode(String value) {
|
||||
if (value == state.dialCode) return;
|
||||
|
||||
state = state.copyWith(
|
||||
dialCode: value,
|
||||
errorMessage: '',
|
||||
);
|
||||
}
|
||||
|
||||
Future<bool> createContact({
|
||||
required String name,
|
||||
required String phone,
|
||||
@@ -64,13 +73,16 @@ class ContactsViewModel extends Notifier<ContactsViewState> {
|
||||
try {
|
||||
state = state.copyWith(isLoading: true, errorMessage: '');
|
||||
|
||||
final dialCode = state.dialCode;
|
||||
final fullPhone = dialCode+phone;
|
||||
|
||||
final user = await ref.read(userInfoProvider.future);
|
||||
if (!ref.mounted) return false;
|
||||
|
||||
final request = CreateContactRequestModel(
|
||||
id: _uuid.v4(),
|
||||
name: name,
|
||||
phone: phone,
|
||||
phone: fullPhone,
|
||||
userId: user.id,
|
||||
);
|
||||
|
||||
@@ -98,10 +110,13 @@ class ContactsViewModel extends Notifier<ContactsViewState> {
|
||||
try {
|
||||
state = state.copyWith(isLoading: true, errorMessage: '');
|
||||
|
||||
final dialCode = state.dialCode;
|
||||
final fullPhone = phone.isEmpty ? contact.phone : dialCode + phone;
|
||||
|
||||
final request = UpdateContactRequestModel(
|
||||
id: contact.id,
|
||||
name: name.isEmpty ? contact.name : name,
|
||||
phone: phone.isEmpty ? contact.phone : phone,
|
||||
phone: fullPhone,
|
||||
);
|
||||
|
||||
await _contactsRepository.updateContact(request: request);
|
||||
|
||||
@@ -8,6 +8,7 @@ part 'contacts_view_state.freezed.dart';
|
||||
abstract class ContactsViewState with _$ContactsViewState {
|
||||
const factory ContactsViewState({
|
||||
@Default([]) List<ContactEntity> contacts,
|
||||
@Default('+34') String dialCode,
|
||||
@Default(true) bool isLoading,
|
||||
@Default(false) bool isEditing,
|
||||
@Default('') String errorMessage,
|
||||
|
||||
@@ -14,7 +14,7 @@ T _$identity<T>(T value) => value;
|
||||
/// @nodoc
|
||||
mixin _$ContactsViewState {
|
||||
|
||||
List<ContactEntity> get contacts; bool get isLoading; bool get isEditing; String get errorMessage;
|
||||
List<ContactEntity> get contacts; String get dialCode; bool get isLoading; bool get isEditing; String get errorMessage;
|
||||
/// Create a copy of ContactsViewState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@@ -25,16 +25,16 @@ $ContactsViewStateCopyWith<ContactsViewState> get copyWith => _$ContactsViewStat
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is ContactsViewState&&const DeepCollectionEquality().equals(other.contacts, contacts)&&(identical(other.isLoading, isLoading) || other.isLoading == isLoading)&&(identical(other.isEditing, isEditing) || other.isEditing == isEditing)&&(identical(other.errorMessage, errorMessage) || other.errorMessage == errorMessage));
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is ContactsViewState&&const DeepCollectionEquality().equals(other.contacts, contacts)&&(identical(other.dialCode, dialCode) || other.dialCode == dialCode)&&(identical(other.isLoading, isLoading) || other.isLoading == isLoading)&&(identical(other.isEditing, isEditing) || other.isEditing == isEditing)&&(identical(other.errorMessage, errorMessage) || other.errorMessage == errorMessage));
|
||||
}
|
||||
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,const DeepCollectionEquality().hash(contacts),isLoading,isEditing,errorMessage);
|
||||
int get hashCode => Object.hash(runtimeType,const DeepCollectionEquality().hash(contacts),dialCode,isLoading,isEditing,errorMessage);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'ContactsViewState(contacts: $contacts, isLoading: $isLoading, isEditing: $isEditing, errorMessage: $errorMessage)';
|
||||
return 'ContactsViewState(contacts: $contacts, dialCode: $dialCode, isLoading: $isLoading, isEditing: $isEditing, errorMessage: $errorMessage)';
|
||||
}
|
||||
|
||||
|
||||
@@ -45,7 +45,7 @@ abstract mixin class $ContactsViewStateCopyWith<$Res> {
|
||||
factory $ContactsViewStateCopyWith(ContactsViewState value, $Res Function(ContactsViewState) _then) = _$ContactsViewStateCopyWithImpl;
|
||||
@useResult
|
||||
$Res call({
|
||||
List<ContactEntity> contacts, bool isLoading, bool isEditing, String errorMessage
|
||||
List<ContactEntity> contacts, String dialCode, bool isLoading, bool isEditing, String errorMessage
|
||||
});
|
||||
|
||||
|
||||
@@ -62,10 +62,11 @@ class _$ContactsViewStateCopyWithImpl<$Res>
|
||||
|
||||
/// Create a copy of ContactsViewState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline') @override $Res call({Object? contacts = null,Object? isLoading = null,Object? isEditing = null,Object? errorMessage = null,}) {
|
||||
@pragma('vm:prefer-inline') @override $Res call({Object? contacts = null,Object? dialCode = null,Object? isLoading = null,Object? isEditing = null,Object? errorMessage = null,}) {
|
||||
return _then(_self.copyWith(
|
||||
contacts: null == contacts ? _self.contacts : contacts // ignore: cast_nullable_to_non_nullable
|
||||
as List<ContactEntity>,isLoading: null == isLoading ? _self.isLoading : isLoading // ignore: cast_nullable_to_non_nullable
|
||||
as List<ContactEntity>,dialCode: null == dialCode ? _self.dialCode : dialCode // ignore: cast_nullable_to_non_nullable
|
||||
as String,isLoading: null == isLoading ? _self.isLoading : isLoading // ignore: cast_nullable_to_non_nullable
|
||||
as bool,isEditing: null == isEditing ? _self.isEditing : isEditing // ignore: cast_nullable_to_non_nullable
|
||||
as bool,errorMessage: null == errorMessage ? _self.errorMessage : errorMessage // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
@@ -153,10 +154,10 @@ return $default(_that);case _:
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( List<ContactEntity> contacts, bool isLoading, bool isEditing, String errorMessage)? $default,{required TResult orElse(),}) {final _that = this;
|
||||
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( List<ContactEntity> contacts, String dialCode, bool isLoading, bool isEditing, String errorMessage)? $default,{required TResult orElse(),}) {final _that = this;
|
||||
switch (_that) {
|
||||
case _ContactsViewState() when $default != null:
|
||||
return $default(_that.contacts,_that.isLoading,_that.isEditing,_that.errorMessage);case _:
|
||||
return $default(_that.contacts,_that.dialCode,_that.isLoading,_that.isEditing,_that.errorMessage);case _:
|
||||
return orElse();
|
||||
|
||||
}
|
||||
@@ -174,10 +175,10 @@ return $default(_that.contacts,_that.isLoading,_that.isEditing,_that.errorMessag
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( List<ContactEntity> contacts, bool isLoading, bool isEditing, String errorMessage) $default,) {final _that = this;
|
||||
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( List<ContactEntity> contacts, String dialCode, bool isLoading, bool isEditing, String errorMessage) $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _ContactsViewState():
|
||||
return $default(_that.contacts,_that.isLoading,_that.isEditing,_that.errorMessage);case _:
|
||||
return $default(_that.contacts,_that.dialCode,_that.isLoading,_that.isEditing,_that.errorMessage);case _:
|
||||
throw StateError('Unexpected subclass');
|
||||
|
||||
}
|
||||
@@ -194,10 +195,10 @@ return $default(_that.contacts,_that.isLoading,_that.isEditing,_that.errorMessag
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( List<ContactEntity> contacts, bool isLoading, bool isEditing, String errorMessage)? $default,) {final _that = this;
|
||||
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( List<ContactEntity> contacts, String dialCode, bool isLoading, bool isEditing, String errorMessage)? $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _ContactsViewState() when $default != null:
|
||||
return $default(_that.contacts,_that.isLoading,_that.isEditing,_that.errorMessage);case _:
|
||||
return $default(_that.contacts,_that.dialCode,_that.isLoading,_that.isEditing,_that.errorMessage);case _:
|
||||
return null;
|
||||
|
||||
}
|
||||
@@ -209,7 +210,7 @@ return $default(_that.contacts,_that.isLoading,_that.isEditing,_that.errorMessag
|
||||
|
||||
|
||||
class _ContactsViewState implements ContactsViewState {
|
||||
const _ContactsViewState({final List<ContactEntity> contacts = const [], this.isLoading = true, this.isEditing = false, this.errorMessage = ''}): _contacts = contacts;
|
||||
const _ContactsViewState({final List<ContactEntity> contacts = const [], this.dialCode = '+34', this.isLoading = true, this.isEditing = false, this.errorMessage = ''}): _contacts = contacts;
|
||||
|
||||
|
||||
final List<ContactEntity> _contacts;
|
||||
@@ -219,6 +220,7 @@ class _ContactsViewState implements ContactsViewState {
|
||||
return EqualUnmodifiableListView(_contacts);
|
||||
}
|
||||
|
||||
@override@JsonKey() final String dialCode;
|
||||
@override@JsonKey() final bool isLoading;
|
||||
@override@JsonKey() final bool isEditing;
|
||||
@override@JsonKey() final String errorMessage;
|
||||
@@ -233,16 +235,16 @@ _$ContactsViewStateCopyWith<_ContactsViewState> get copyWith => __$ContactsViewS
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is _ContactsViewState&&const DeepCollectionEquality().equals(other._contacts, _contacts)&&(identical(other.isLoading, isLoading) || other.isLoading == isLoading)&&(identical(other.isEditing, isEditing) || other.isEditing == isEditing)&&(identical(other.errorMessage, errorMessage) || other.errorMessage == errorMessage));
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is _ContactsViewState&&const DeepCollectionEquality().equals(other._contacts, _contacts)&&(identical(other.dialCode, dialCode) || other.dialCode == dialCode)&&(identical(other.isLoading, isLoading) || other.isLoading == isLoading)&&(identical(other.isEditing, isEditing) || other.isEditing == isEditing)&&(identical(other.errorMessage, errorMessage) || other.errorMessage == errorMessage));
|
||||
}
|
||||
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,const DeepCollectionEquality().hash(_contacts),isLoading,isEditing,errorMessage);
|
||||
int get hashCode => Object.hash(runtimeType,const DeepCollectionEquality().hash(_contacts),dialCode,isLoading,isEditing,errorMessage);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'ContactsViewState(contacts: $contacts, isLoading: $isLoading, isEditing: $isEditing, errorMessage: $errorMessage)';
|
||||
return 'ContactsViewState(contacts: $contacts, dialCode: $dialCode, isLoading: $isLoading, isEditing: $isEditing, errorMessage: $errorMessage)';
|
||||
}
|
||||
|
||||
|
||||
@@ -253,7 +255,7 @@ abstract mixin class _$ContactsViewStateCopyWith<$Res> implements $ContactsViewS
|
||||
factory _$ContactsViewStateCopyWith(_ContactsViewState value, $Res Function(_ContactsViewState) _then) = __$ContactsViewStateCopyWithImpl;
|
||||
@override @useResult
|
||||
$Res call({
|
||||
List<ContactEntity> contacts, bool isLoading, bool isEditing, String errorMessage
|
||||
List<ContactEntity> contacts, String dialCode, bool isLoading, bool isEditing, String errorMessage
|
||||
});
|
||||
|
||||
|
||||
@@ -270,10 +272,11 @@ class __$ContactsViewStateCopyWithImpl<$Res>
|
||||
|
||||
/// Create a copy of ContactsViewState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override @pragma('vm:prefer-inline') $Res call({Object? contacts = null,Object? isLoading = null,Object? isEditing = null,Object? errorMessage = null,}) {
|
||||
@override @pragma('vm:prefer-inline') $Res call({Object? contacts = null,Object? dialCode = null,Object? isLoading = null,Object? isEditing = null,Object? errorMessage = null,}) {
|
||||
return _then(_ContactsViewState(
|
||||
contacts: null == contacts ? _self._contacts : contacts // ignore: cast_nullable_to_non_nullable
|
||||
as List<ContactEntity>,isLoading: null == isLoading ? _self.isLoading : isLoading // ignore: cast_nullable_to_non_nullable
|
||||
as List<ContactEntity>,dialCode: null == dialCode ? _self.dialCode : dialCode // ignore: cast_nullable_to_non_nullable
|
||||
as String,isLoading: null == isLoading ? _self.isLoading : isLoading // ignore: cast_nullable_to_non_nullable
|
||||
as bool,isEditing: null == isEditing ? _self.isEditing : isEditing // ignore: cast_nullable_to_non_nullable
|
||||
as bool,errorMessage: null == errorMessage ? _self.errorMessage : errorMessage // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
|
||||
@@ -25,7 +25,7 @@ class ContactCard extends ConsumerWidget {
|
||||
return Container(
|
||||
padding: EdgeInsets.symmetric(
|
||||
horizontal: SizeUtils.getByScreen(small: 22, big: 21),
|
||||
vertical: SizeUtils.getByScreen(small: 10, big: 8),
|
||||
vertical: SizeUtils.getByScreen(small: 12, big: 8),
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.all(
|
||||
@@ -41,7 +41,7 @@ class ContactCard extends ConsumerWidget {
|
||||
color: theme.getColorFor(ThemeCode.backgroundPrimary),
|
||||
),
|
||||
padding:
|
||||
EdgeInsets.all(SizeUtils.getByScreen(small: 4, big: 12)),
|
||||
EdgeInsets.all(SizeUtils.getByScreen(small: 10, big: 12)),
|
||||
child: Icon(
|
||||
SFIcons.account,
|
||||
size: SizeUtils.getByScreen(small: 40, big: 44),
|
||||
|
||||
@@ -29,6 +29,10 @@ class _NewContactDialogState extends ConsumerState<NewContactDialog> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final theme = ref.watch(themePortProvider);
|
||||
|
||||
final dialCode = ref.read(
|
||||
contactsViewModelProvider.select((s)=>s.dialCode)
|
||||
);
|
||||
|
||||
return Container(
|
||||
padding: EdgeInsets.symmetric(
|
||||
@@ -82,12 +86,23 @@ class _NewContactDialogState extends ConsumerState<NewContactDialog> {
|
||||
Row(
|
||||
spacing: SizeUtils.getByScreen(small: 10, big: 8),
|
||||
children: [
|
||||
|
||||
CountryPrefixPicker(
|
||||
headerText: context.translate(I18n.selectYourCountry),
|
||||
initialSelection: dialCode,
|
||||
onChanged: (country) {
|
||||
final vm = ref.read(contactsViewModelProvider.notifier);
|
||||
vm.updateDialCode(
|
||||
country.dialCode ?? dialCode,
|
||||
);
|
||||
},
|
||||
width: 80,
|
||||
),
|
||||
Expanded(
|
||||
child: CustomTextField(
|
||||
controller: _phoneController,
|
||||
hint: context.translate(I18n.phoneNumber),
|
||||
keyboardType: TextInputType.phone,
|
||||
readOnly: true,
|
||||
),
|
||||
),
|
||||
DecoratedBox(
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
export 'src/presentation/profile_screen.dart';
|
||||
export 'src/profile_builder.dart';
|
||||
export 'src/features/profile_settings/presentation/profile_settings_builder.dart';
|
||||
export 'src/features/edit_personal_data/presentation/edit_personal_data_builder.dart';
|
||||
export 'src/features/payment_methods/presentation/payment_methods_builder.dart';
|
||||
export 'src/features/payout/presentation/payout_builder.dart';
|
||||
|
||||
@@ -0,0 +1,59 @@
|
||||
import 'package:country_code_picker/country_code_picker.dart';
|
||||
import 'package:flutter/widgets.dart';
|
||||
import 'package:sealed_countries/sealed_countries.dart';
|
||||
|
||||
final List<String> _sortedDialCodes = List.unmodifiable(
|
||||
codes
|
||||
.map((c) => c['dial_code'] ?? '')
|
||||
.where((d) => d.isNotEmpty)
|
||||
.toSet()
|
||||
.toList()
|
||||
..sort((a, b) => b.length.compareTo(a.length)),
|
||||
);
|
||||
|
||||
String extractDialCode(String phone) {
|
||||
if (phone.isEmpty || !phone.startsWith('+')) return '';
|
||||
for (final dc in _sortedDialCodes) {
|
||||
if (phone.startsWith(dc)) return dc;
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
String alpha2ToCountryName(String code) {
|
||||
if (code.isEmpty) return '';
|
||||
try {
|
||||
return WorldCountry.list
|
||||
.firstWhere((c) => c.codeShort.toUpperCase() == code.toUpperCase())
|
||||
.name
|
||||
.common;
|
||||
} catch (_) {
|
||||
return code;
|
||||
}
|
||||
}
|
||||
|
||||
String countryNameToAlpha2(String name) {
|
||||
if (name.isEmpty) return '';
|
||||
if (name.length == 2) return name.toUpperCase();
|
||||
try {
|
||||
return WorldCountry.list
|
||||
.firstWhere((c) => c.name.common.toLowerCase() == name.toLowerCase())
|
||||
.codeShort;
|
||||
} catch (_) {
|
||||
return name;
|
||||
}
|
||||
}
|
||||
|
||||
String resolveAlpha2({required String country, required String countryCode}) {
|
||||
if (countryCode.length == 2) return countryCode.toUpperCase();
|
||||
if (country.length == 2) return country.toUpperCase();
|
||||
return countryNameToAlpha2(country);
|
||||
}
|
||||
|
||||
String localizedCountryName(BuildContext context, String alpha2) {
|
||||
if (alpha2.isEmpty) return '';
|
||||
try {
|
||||
return CountryCode.fromCountryCode(alpha2).localize(context).name ?? alpha2;
|
||||
} catch (_) {
|
||||
return alpha2;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
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 'edit_personal_data_screen.dart';
|
||||
|
||||
class EditPersonalDataBuilder {
|
||||
const EditPersonalDataBuilder();
|
||||
|
||||
Page<void> buildPage(BuildContext context, GoRouterState state) {
|
||||
final navigationContract = GetIt.I<NavigationContract>();
|
||||
return MaterialPage(
|
||||
key: state.pageKey,
|
||||
child: EditPersonalDataScreen(navigationContract: navigationContract),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,341 @@
|
||||
import 'package:auth/auth.dart';
|
||||
import 'package:country_code_picker/country_code_picker.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 '../country_utils.dart';
|
||||
import 'edit_personal_data_view_model.dart';
|
||||
|
||||
class EditPersonalDataScreen extends ConsumerWidget {
|
||||
final NavigationContract navigationContract;
|
||||
|
||||
const EditPersonalDataScreen({super.key, required this.navigationContract});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final theme = ref.watch(themePortProvider);
|
||||
final viewState = ref.watch(editPersonalDataViewModelProvider);
|
||||
final viewModel = ref.read(editPersonalDataViewModelProvider.notifier);
|
||||
|
||||
ref.listen(editPersonalDataViewModelProvider, (prev, next) {
|
||||
if (next.saveSuccess && !(prev?.saveSuccess ?? false)) {
|
||||
showTopSnackbar(
|
||||
context,
|
||||
message: context.translate(I18n.profileSettingsSaveSuccess),
|
||||
type: MessageType.success,
|
||||
);
|
||||
navigationContract.goBack();
|
||||
}
|
||||
if (next.errorMessage.isNotEmpty &&
|
||||
!next.showPin &&
|
||||
next.errorMessage != (prev?.errorMessage ?? '')) {
|
||||
showTopSnackbar(
|
||||
context,
|
||||
message: next.errorMessage,
|
||||
type: MessageType.error,
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
if (viewState.isLoading) {
|
||||
return Scaffold(
|
||||
backgroundColor: theme.getColorFor(ThemeCode.backgroundSecondary),
|
||||
body: const Center(child: AppLoadingIndicator()),
|
||||
);
|
||||
}
|
||||
|
||||
if (viewState.showPin) {
|
||||
return _buildPinScaffold(context, theme, viewState, viewModel);
|
||||
}
|
||||
|
||||
return _buildFormScaffold(context, theme, viewState, viewModel);
|
||||
}
|
||||
|
||||
Widget _buildPinScaffold(
|
||||
BuildContext context,
|
||||
ThemePort theme,
|
||||
EditPersonalDataViewState viewState,
|
||||
EditPersonalDataViewModel viewModel,
|
||||
) {
|
||||
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.cancelPin,
|
||||
),
|
||||
),
|
||||
body: SafeArea(
|
||||
child: Column(
|
||||
children: [
|
||||
Expanded(
|
||||
child: SingleChildScrollView(
|
||||
child: ScaPinView(
|
||||
title: context.translate(I18n.scaPinEnter),
|
||||
pin: viewState.pin,
|
||||
isProcessing: viewState.isSigning || viewState.isSaving,
|
||||
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(),
|
||||
),
|
||||
),
|
||||
),
|
||||
if (viewState.errorMessage.isNotEmpty)
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 20),
|
||||
child: Text(
|
||||
viewState.errorMessage,
|
||||
style: const TextStyle(color: Colors.red),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: viewModel.cancelPin,
|
||||
child: Text(context.translate(I18n.cancel)),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildFormScaffold(
|
||||
BuildContext context,
|
||||
ThemePort theme,
|
||||
EditPersonalDataViewState viewState,
|
||||
EditPersonalDataViewModel viewModel,
|
||||
) {
|
||||
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: () => navigationContract.goBack(),
|
||||
),
|
||||
title: Text(
|
||||
context.translate(I18n.profileSettingsEdit),
|
||||
style: TextStyle(color: theme.getColorFor(ThemeCode.textPrimary)),
|
||||
),
|
||||
),
|
||||
body: Padding(
|
||||
padding: const EdgeInsets.all(20),
|
||||
child: Column(
|
||||
children: [
|
||||
Expanded(
|
||||
child: ListView(
|
||||
children: [
|
||||
..._personalDataSection(context, viewState, viewModel),
|
||||
const SizedBox(height: 32),
|
||||
..._addressSection(context, viewState, viewModel),
|
||||
],
|
||||
),
|
||||
),
|
||||
PrimaryButton(
|
||||
onPressed: () => viewModel.requestPin(),
|
||||
text: context.translate(I18n.profileSettingsSave),
|
||||
color: theme.getColorFor(ThemeCode.buttonPrimary),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () => navigationContract.goBack(),
|
||||
child: Text(context.translate(I18n.cancel)),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
List<Widget> _personalDataSection(
|
||||
BuildContext context,
|
||||
EditPersonalDataViewState viewState,
|
||||
EditPersonalDataViewModel viewModel,
|
||||
) {
|
||||
return [
|
||||
_sectionTitle(context.translate(I18n.profileSettingsPersonalData)),
|
||||
const SizedBox(height: 12),
|
||||
_textField(
|
||||
label: context.translate(I18n.profileSettingsName),
|
||||
initialValue: viewState.firstName,
|
||||
onChanged: viewModel.setFirstName,
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
_textField(
|
||||
label: context.translate(I18n.profileSettingsLastName),
|
||||
initialValue: viewState.lastName,
|
||||
onChanged: viewModel.setLastName,
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
_labeledField(
|
||||
label: context.translate(I18n.profileSettingsPhone),
|
||||
child: Row(
|
||||
spacing: 10,
|
||||
children: [
|
||||
CountryPrefixPicker(
|
||||
headerText: context.translate(I18n.selectYourCountry),
|
||||
initialSelection: viewState.dialCode,
|
||||
onChanged: (CountryCode value) {
|
||||
viewModel.setDialCode(value.dialCode ?? '');
|
||||
},
|
||||
),
|
||||
Expanded(
|
||||
child: TextFormField(
|
||||
initialValue: viewState.phoneNumber,
|
||||
decoration: const InputDecoration(border: OutlineInputBorder()),
|
||||
keyboardType: TextInputType.phone,
|
||||
onChanged: viewModel.setPhoneNumber,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
_countryPickerField(
|
||||
context: context,
|
||||
label: context.translate(I18n.profileSettingsNationality),
|
||||
displayName: localizedCountryName(context, viewState.nationality),
|
||||
initialSelection: viewState.nationality.isNotEmpty
|
||||
? viewState.nationality
|
||||
: 'ES',
|
||||
onChanged: (CountryCode value) {
|
||||
viewModel.setNationality(value.code ?? '');
|
||||
},
|
||||
),
|
||||
];
|
||||
}
|
||||
|
||||
List<Widget> _addressSection(
|
||||
BuildContext context,
|
||||
EditPersonalDataViewState viewState,
|
||||
EditPersonalDataViewModel viewModel,
|
||||
) {
|
||||
return [
|
||||
_sectionTitle(context.translate(I18n.profileSettingsAddress)),
|
||||
const SizedBox(height: 12),
|
||||
_textField(
|
||||
label: context.translate(I18n.profileSettingsStreet),
|
||||
initialValue: viewState.address.street,
|
||||
onChanged: viewModel.setStreet,
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
_textField(
|
||||
label: context.translate(I18n.profileSettingsCity),
|
||||
initialValue: viewState.address.city,
|
||||
onChanged: viewModel.setCity,
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
_textField(
|
||||
label: context.translate(I18n.profileSettingsPostCode),
|
||||
initialValue: viewState.address.postCode == 0
|
||||
? ''
|
||||
: viewState.address.postCode.toString(),
|
||||
onChanged: viewModel.setPostCode,
|
||||
keyboardType: TextInputType.number,
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
_countryPickerField(
|
||||
context: context,
|
||||
label: context.translate(I18n.profileSettingsCountry),
|
||||
displayName: localizedCountryName(
|
||||
context,
|
||||
viewState.address.countryCode,
|
||||
),
|
||||
initialSelection: viewState.address.countryCode.isNotEmpty
|
||||
? viewState.address.countryCode
|
||||
: 'ES',
|
||||
onChanged: (CountryCode value) {
|
||||
viewModel.setCountry(name: value.name ?? '', code: value.code ?? '');
|
||||
},
|
||||
),
|
||||
];
|
||||
}
|
||||
|
||||
Widget _sectionTitle(String title) {
|
||||
return Text(
|
||||
title,
|
||||
style: const TextStyle(fontWeight: FontWeight.bold, fontSize: 20),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _textField({
|
||||
required String label,
|
||||
required String initialValue,
|
||||
required ValueChanged<String> onChanged,
|
||||
TextInputType keyboardType = TextInputType.text,
|
||||
}) {
|
||||
return TextFormField(
|
||||
initialValue: initialValue,
|
||||
decoration: InputDecoration(
|
||||
labelText: label,
|
||||
border: const OutlineInputBorder(),
|
||||
),
|
||||
keyboardType: keyboardType,
|
||||
onChanged: onChanged,
|
||||
);
|
||||
}
|
||||
|
||||
Widget _labeledField({required String label, required Widget child}) {
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(label, style: const TextStyle(fontSize: 14)),
|
||||
const SizedBox(height: 8),
|
||||
child,
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget _countryPickerField({
|
||||
required BuildContext context,
|
||||
required String label,
|
||||
required String displayName,
|
||||
required String initialSelection,
|
||||
required ValueChanged<CountryCode> onChanged,
|
||||
}) {
|
||||
return _labeledField(
|
||||
label: label,
|
||||
child: Row(
|
||||
spacing: 10,
|
||||
children: [
|
||||
CountryPrefixPicker(
|
||||
headerText: context.translate(I18n.selectYourCountry),
|
||||
initialSelection: initialSelection,
|
||||
onChanged: onChanged,
|
||||
),
|
||||
Expanded(
|
||||
child: InputDecorator(
|
||||
decoration: InputDecoration(
|
||||
border: const OutlineInputBorder(),
|
||||
contentPadding: const EdgeInsets.symmetric(
|
||||
horizontal: 12,
|
||||
vertical: 14,
|
||||
),
|
||||
),
|
||||
child: Text(
|
||||
displayName.isNotEmpty ? displayName : label,
|
||||
style: TextStyle(
|
||||
color: displayName.isNotEmpty ? null : Colors.grey,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,239 @@
|
||||
import 'dart:convert';
|
||||
|
||||
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 '../country_utils.dart';
|
||||
|
||||
export 'edit_personal_data_view_state.dart';
|
||||
import 'edit_personal_data_view_state.dart';
|
||||
|
||||
final editPersonalDataViewModelProvider =
|
||||
NotifierProvider.autoDispose<
|
||||
EditPersonalDataViewModel,
|
||||
EditPersonalDataViewState
|
||||
>(EditPersonalDataViewModel.new);
|
||||
|
||||
class EditPersonalDataViewModel extends Notifier<EditPersonalDataViewState> {
|
||||
late GetUserInfoUseCase _getUserInfoUseCase;
|
||||
late GetPaymentProfileUseCase _getPaymentProfileUseCase;
|
||||
late TreezorWalletConnectionService _connectionService;
|
||||
late TreezorWalletSignatureService _signatureService;
|
||||
|
||||
@override
|
||||
EditPersonalDataViewState build() {
|
||||
_getUserInfoUseCase = ref.read(getUserInfoUseCaseProvider);
|
||||
_getPaymentProfileUseCase = ref.read(getPaymentProfileUseCaseProvider);
|
||||
_connectionService = GetIt.I<TreezorWalletConnectionService>();
|
||||
_signatureService = GetIt.I<TreezorWalletSignatureService>();
|
||||
|
||||
Future.microtask(() => load());
|
||||
return const EditPersonalDataViewState();
|
||||
}
|
||||
|
||||
Future<void> load() async {
|
||||
state = state.copyWith(isLoading: true, errorMessage: '');
|
||||
|
||||
try {
|
||||
final user = await _getUserInfoUseCase.getUserInfo();
|
||||
if (!ref.mounted) return;
|
||||
|
||||
final profile = await _getPaymentProfileUseCase.getPaymentProfile(
|
||||
userId: user.id,
|
||||
);
|
||||
if (!ref.mounted) return;
|
||||
|
||||
final profileAddress = profile.addresses.isNotEmpty
|
||||
? profile.addresses.first
|
||||
: null;
|
||||
|
||||
final phone = profile.phone;
|
||||
final dialCode = extractDialCode(phone);
|
||||
final phoneNumber = dialCode.isNotEmpty
|
||||
? phone.substring(dialCode.length)
|
||||
: phone;
|
||||
|
||||
final rawCountry = profileAddress?.country ?? '';
|
||||
|
||||
state = state.copyWith(
|
||||
isLoading: false,
|
||||
firstName: user.firstName,
|
||||
lastName: user.lastName,
|
||||
dialCode: dialCode,
|
||||
phoneNumber: phoneNumber,
|
||||
nationality: profile.nationality,
|
||||
address: AddressViewState(
|
||||
street: profileAddress?.street ?? '',
|
||||
city: profileAddress?.city ?? '',
|
||||
province: profileAddress?.province ?? '',
|
||||
state: profileAddress?.state ?? '',
|
||||
country: rawCountry,
|
||||
countryCode: countryNameToAlpha2(rawCountry),
|
||||
postCode: profileAddress?.postCode ?? 0,
|
||||
),
|
||||
paymentProfileId: profile.paymentProfileId,
|
||||
);
|
||||
} catch (e) {
|
||||
if (!ref.mounted) return;
|
||||
state = state.copyWith(isLoading: false, errorMessage: e.toString());
|
||||
}
|
||||
}
|
||||
|
||||
void setFirstName(String value) =>
|
||||
state = state.copyWith(firstName: value, saveSuccess: false);
|
||||
|
||||
void setLastName(String value) =>
|
||||
state = state.copyWith(lastName: value, saveSuccess: false);
|
||||
|
||||
void setDialCode(String value) =>
|
||||
state = state.copyWith(dialCode: value, saveSuccess: false);
|
||||
|
||||
void setPhoneNumber(String value) =>
|
||||
state = state.copyWith(phoneNumber: value, saveSuccess: false);
|
||||
|
||||
void setNationality(String code) =>
|
||||
state = state.copyWith(nationality: code, saveSuccess: false);
|
||||
|
||||
void setStreet(String value) => state = state.copyWith(
|
||||
address: state.address.copyWith(street: value),
|
||||
saveSuccess: false,
|
||||
);
|
||||
|
||||
void setCity(String value) => state = state.copyWith(
|
||||
address: state.address.copyWith(city: value),
|
||||
saveSuccess: false,
|
||||
);
|
||||
|
||||
void setCountry({required String name, required String code}) =>
|
||||
state = state.copyWith(
|
||||
address: state.address.copyWith(country: name, countryCode: code),
|
||||
saveSuccess: false,
|
||||
);
|
||||
|
||||
void setPostCode(String value) => state = state.copyWith(
|
||||
address: state.address.copyWith(postCode: int.tryParse(value) ?? 0),
|
||||
saveSuccess: false,
|
||||
);
|
||||
|
||||
void requestPin() {
|
||||
state = state.copyWith(showPin: true, pin: '', errorMessage: '');
|
||||
}
|
||||
|
||||
void cancelPin() {
|
||||
state = state.copyWith(showPin: false, 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 {
|
||||
state = state.copyWith(isSigning: true, errorMessage: '');
|
||||
|
||||
try {
|
||||
await _connectionService.connectWithPin(loginPin: state.pin);
|
||||
if (!ref.mounted) return;
|
||||
|
||||
final scaProof = await _generateScaProof();
|
||||
if (!ref.mounted) return;
|
||||
|
||||
state = state.copyWith(isSigning: false, isSaving: true, pin: '');
|
||||
|
||||
await _saveProfile(scaProof);
|
||||
if (!ref.mounted) return;
|
||||
|
||||
ref.read(walletRefreshProvider.notifier).refresh();
|
||||
|
||||
state = state.copyWith(
|
||||
isSaving: false,
|
||||
saveSuccess: true,
|
||||
showPin: false,
|
||||
);
|
||||
} catch (e) {
|
||||
if (!ref.mounted) return;
|
||||
state = state.copyWith(
|
||||
isSigning: false,
|
||||
isSaving: false,
|
||||
pin: '',
|
||||
errorMessage: e.toString(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
String get _fullPhone => '${state.dialCode}${state.phoneNumber}'.trim();
|
||||
|
||||
String get _addressCountryName => alpha2ToCountryName(
|
||||
resolveAlpha2(
|
||||
country: state.address.country,
|
||||
countryCode: state.address.countryCode,
|
||||
),
|
||||
);
|
||||
|
||||
Future<String> _generateScaProof() async {
|
||||
final url =
|
||||
'https://savefamily.sandbox.treezor.co/v1/users/${state.paymentProfileId}';
|
||||
final scaBody = <String, dynamic>{
|
||||
'firstName': state.firstName,
|
||||
'lastName': state.lastName,
|
||||
'phone': _fullPhone,
|
||||
'nationality': state.nationality,
|
||||
'address1': state.address.street,
|
||||
'postcode': state.address.postCode,
|
||||
'city': state.address.city,
|
||||
'country': resolveAlpha2(
|
||||
country: state.address.country,
|
||||
countryCode: state.address.countryCode,
|
||||
),
|
||||
};
|
||||
|
||||
final scaInput = jsonEncode({'url': url, 'body': scaBody});
|
||||
|
||||
return _signatureService.generateJwsWithPin(
|
||||
message: '',
|
||||
input: scaInput,
|
||||
pin: state.pin,
|
||||
);
|
||||
}
|
||||
|
||||
PaymentProfileAddressEntity _buildAddressEntity() {
|
||||
return PaymentProfileAddressEntity(
|
||||
street: state.address.street,
|
||||
city: state.address.city,
|
||||
province: state.address.province,
|
||||
state: state.address.state,
|
||||
country: _addressCountryName,
|
||||
postCode: state.address.postCode,
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> _saveProfile(String scaProof) async {
|
||||
final address = _buildAddressEntity();
|
||||
|
||||
await ref
|
||||
.read(treezorRepositoryProvider)
|
||||
.updatePaymentProfile(
|
||||
paymentProfileId: state.paymentProfileId,
|
||||
scaProof: scaProof,
|
||||
firstName: state.firstName,
|
||||
lastName: state.lastName,
|
||||
phone: _fullPhone,
|
||||
nationality: state.nationality,
|
||||
addresses: [address],
|
||||
taxResidences: [address],
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
|
||||
part 'edit_personal_data_view_state.freezed.dart';
|
||||
|
||||
@freezed
|
||||
abstract class AddressViewState with _$AddressViewState {
|
||||
const factory AddressViewState({
|
||||
@Default('') String street,
|
||||
@Default('') String city,
|
||||
@Default('') String province,
|
||||
@Default('') String state,
|
||||
@Default('') String country,
|
||||
@Default('') String countryCode,
|
||||
@Default(0) int postCode,
|
||||
}) = _AddressViewState;
|
||||
}
|
||||
|
||||
@freezed
|
||||
abstract class EditPersonalDataViewState with _$EditPersonalDataViewState {
|
||||
const factory EditPersonalDataViewState({
|
||||
@Default(true) bool isLoading,
|
||||
@Default(false) bool isSaving,
|
||||
@Default(false) bool isSigning,
|
||||
@Default(false) bool showPin,
|
||||
@Default('') String pin,
|
||||
@Default('') String firstName,
|
||||
@Default('') String lastName,
|
||||
@Default('') String dialCode,
|
||||
@Default('') String phoneNumber,
|
||||
@Default('') String nationality,
|
||||
@Default(AddressViewState()) AddressViewState address,
|
||||
@Default('') String paymentProfileId,
|
||||
@Default('') String errorMessage,
|
||||
@Default(false) bool saveSuccess,
|
||||
}) = _EditPersonalDataViewState;
|
||||
}
|
||||
@@ -0,0 +1,603 @@
|
||||
// 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 'edit_personal_data_view_state.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// FreezedGenerator
|
||||
// **************************************************************************
|
||||
|
||||
// dart format off
|
||||
T _$identity<T>(T value) => value;
|
||||
/// @nodoc
|
||||
mixin _$AddressViewState {
|
||||
|
||||
String get street; String get city; String get province; String get state; String get country; String get countryCode; int get postCode;
|
||||
/// Create a copy of AddressViewState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@pragma('vm:prefer-inline')
|
||||
$AddressViewStateCopyWith<AddressViewState> get copyWith => _$AddressViewStateCopyWithImpl<AddressViewState>(this as AddressViewState, _$identity);
|
||||
|
||||
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is AddressViewState&&(identical(other.street, street) || other.street == street)&&(identical(other.city, city) || other.city == city)&&(identical(other.province, province) || other.province == province)&&(identical(other.state, state) || other.state == state)&&(identical(other.country, country) || other.country == country)&&(identical(other.countryCode, countryCode) || other.countryCode == countryCode)&&(identical(other.postCode, postCode) || other.postCode == postCode));
|
||||
}
|
||||
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,street,city,province,state,country,countryCode,postCode);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'AddressViewState(street: $street, city: $city, province: $province, state: $state, country: $country, countryCode: $countryCode, postCode: $postCode)';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract mixin class $AddressViewStateCopyWith<$Res> {
|
||||
factory $AddressViewStateCopyWith(AddressViewState value, $Res Function(AddressViewState) _then) = _$AddressViewStateCopyWithImpl;
|
||||
@useResult
|
||||
$Res call({
|
||||
String street, String city, String province, String state, String country, String countryCode, int postCode
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
/// @nodoc
|
||||
class _$AddressViewStateCopyWithImpl<$Res>
|
||||
implements $AddressViewStateCopyWith<$Res> {
|
||||
_$AddressViewStateCopyWithImpl(this._self, this._then);
|
||||
|
||||
final AddressViewState _self;
|
||||
final $Res Function(AddressViewState) _then;
|
||||
|
||||
/// Create a copy of AddressViewState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline') @override $Res call({Object? street = null,Object? city = null,Object? province = null,Object? state = null,Object? country = null,Object? countryCode = null,Object? postCode = null,}) {
|
||||
return _then(_self.copyWith(
|
||||
street: null == street ? _self.street : street // ignore: cast_nullable_to_non_nullable
|
||||
as String,city: null == city ? _self.city : city // ignore: cast_nullable_to_non_nullable
|
||||
as String,province: null == province ? _self.province : province // ignore: cast_nullable_to_non_nullable
|
||||
as String,state: null == state ? _self.state : state // ignore: cast_nullable_to_non_nullable
|
||||
as String,country: null == country ? _self.country : country // ignore: cast_nullable_to_non_nullable
|
||||
as String,countryCode: null == countryCode ? _self.countryCode : countryCode // ignore: cast_nullable_to_non_nullable
|
||||
as String,postCode: null == postCode ? _self.postCode : postCode // ignore: cast_nullable_to_non_nullable
|
||||
as int,
|
||||
));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// Adds pattern-matching-related methods to [AddressViewState].
|
||||
extension AddressViewStatePatterns on AddressViewState {
|
||||
/// 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( _AddressViewState value)? $default,{required TResult orElse(),}){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _AddressViewState() 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( _AddressViewState value) $default,){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _AddressViewState():
|
||||
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( _AddressViewState value)? $default,){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _AddressViewState() 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( String street, String city, String province, String state, String country, String countryCode, int postCode)? $default,{required TResult orElse(),}) {final _that = this;
|
||||
switch (_that) {
|
||||
case _AddressViewState() when $default != null:
|
||||
return $default(_that.street,_that.city,_that.province,_that.state,_that.country,_that.countryCode,_that.postCode);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( String street, String city, String province, String state, String country, String countryCode, int postCode) $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _AddressViewState():
|
||||
return $default(_that.street,_that.city,_that.province,_that.state,_that.country,_that.countryCode,_that.postCode);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( String street, String city, String province, String state, String country, String countryCode, int postCode)? $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _AddressViewState() when $default != null:
|
||||
return $default(_that.street,_that.city,_that.province,_that.state,_that.country,_that.countryCode,_that.postCode);case _:
|
||||
return null;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
|
||||
|
||||
class _AddressViewState implements AddressViewState {
|
||||
const _AddressViewState({this.street = '', this.city = '', this.province = '', this.state = '', this.country = '', this.countryCode = '', this.postCode = 0});
|
||||
|
||||
|
||||
@override@JsonKey() final String street;
|
||||
@override@JsonKey() final String city;
|
||||
@override@JsonKey() final String province;
|
||||
@override@JsonKey() final String state;
|
||||
@override@JsonKey() final String country;
|
||||
@override@JsonKey() final String countryCode;
|
||||
@override@JsonKey() final int postCode;
|
||||
|
||||
/// Create a copy of AddressViewState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override @JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@pragma('vm:prefer-inline')
|
||||
_$AddressViewStateCopyWith<_AddressViewState> get copyWith => __$AddressViewStateCopyWithImpl<_AddressViewState>(this, _$identity);
|
||||
|
||||
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is _AddressViewState&&(identical(other.street, street) || other.street == street)&&(identical(other.city, city) || other.city == city)&&(identical(other.province, province) || other.province == province)&&(identical(other.state, state) || other.state == state)&&(identical(other.country, country) || other.country == country)&&(identical(other.countryCode, countryCode) || other.countryCode == countryCode)&&(identical(other.postCode, postCode) || other.postCode == postCode));
|
||||
}
|
||||
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,street,city,province,state,country,countryCode,postCode);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'AddressViewState(street: $street, city: $city, province: $province, state: $state, country: $country, countryCode: $countryCode, postCode: $postCode)';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract mixin class _$AddressViewStateCopyWith<$Res> implements $AddressViewStateCopyWith<$Res> {
|
||||
factory _$AddressViewStateCopyWith(_AddressViewState value, $Res Function(_AddressViewState) _then) = __$AddressViewStateCopyWithImpl;
|
||||
@override @useResult
|
||||
$Res call({
|
||||
String street, String city, String province, String state, String country, String countryCode, int postCode
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
/// @nodoc
|
||||
class __$AddressViewStateCopyWithImpl<$Res>
|
||||
implements _$AddressViewStateCopyWith<$Res> {
|
||||
__$AddressViewStateCopyWithImpl(this._self, this._then);
|
||||
|
||||
final _AddressViewState _self;
|
||||
final $Res Function(_AddressViewState) _then;
|
||||
|
||||
/// Create a copy of AddressViewState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override @pragma('vm:prefer-inline') $Res call({Object? street = null,Object? city = null,Object? province = null,Object? state = null,Object? country = null,Object? countryCode = null,Object? postCode = null,}) {
|
||||
return _then(_AddressViewState(
|
||||
street: null == street ? _self.street : street // ignore: cast_nullable_to_non_nullable
|
||||
as String,city: null == city ? _self.city : city // ignore: cast_nullable_to_non_nullable
|
||||
as String,province: null == province ? _self.province : province // ignore: cast_nullable_to_non_nullable
|
||||
as String,state: null == state ? _self.state : state // ignore: cast_nullable_to_non_nullable
|
||||
as String,country: null == country ? _self.country : country // ignore: cast_nullable_to_non_nullable
|
||||
as String,countryCode: null == countryCode ? _self.countryCode : countryCode // ignore: cast_nullable_to_non_nullable
|
||||
as String,postCode: null == postCode ? _self.postCode : postCode // ignore: cast_nullable_to_non_nullable
|
||||
as int,
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
mixin _$EditPersonalDataViewState {
|
||||
|
||||
bool get isLoading; bool get isSaving; bool get isSigning; bool get showPin; String get pin; String get firstName; String get lastName; String get dialCode; String get phoneNumber; String get nationality; AddressViewState get address; String get paymentProfileId; String get errorMessage; bool get saveSuccess;
|
||||
/// Create a copy of EditPersonalDataViewState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@pragma('vm:prefer-inline')
|
||||
$EditPersonalDataViewStateCopyWith<EditPersonalDataViewState> get copyWith => _$EditPersonalDataViewStateCopyWithImpl<EditPersonalDataViewState>(this as EditPersonalDataViewState, _$identity);
|
||||
|
||||
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is EditPersonalDataViewState&&(identical(other.isLoading, isLoading) || other.isLoading == isLoading)&&(identical(other.isSaving, isSaving) || other.isSaving == isSaving)&&(identical(other.isSigning, isSigning) || other.isSigning == isSigning)&&(identical(other.showPin, showPin) || other.showPin == showPin)&&(identical(other.pin, pin) || other.pin == pin)&&(identical(other.firstName, firstName) || other.firstName == firstName)&&(identical(other.lastName, lastName) || other.lastName == lastName)&&(identical(other.dialCode, dialCode) || other.dialCode == dialCode)&&(identical(other.phoneNumber, phoneNumber) || other.phoneNumber == phoneNumber)&&(identical(other.nationality, nationality) || other.nationality == nationality)&&(identical(other.address, address) || other.address == address)&&(identical(other.paymentProfileId, paymentProfileId) || other.paymentProfileId == paymentProfileId)&&(identical(other.errorMessage, errorMessage) || other.errorMessage == errorMessage)&&(identical(other.saveSuccess, saveSuccess) || other.saveSuccess == saveSuccess));
|
||||
}
|
||||
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,isLoading,isSaving,isSigning,showPin,pin,firstName,lastName,dialCode,phoneNumber,nationality,address,paymentProfileId,errorMessage,saveSuccess);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'EditPersonalDataViewState(isLoading: $isLoading, isSaving: $isSaving, isSigning: $isSigning, showPin: $showPin, pin: $pin, firstName: $firstName, lastName: $lastName, dialCode: $dialCode, phoneNumber: $phoneNumber, nationality: $nationality, address: $address, paymentProfileId: $paymentProfileId, errorMessage: $errorMessage, saveSuccess: $saveSuccess)';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract mixin class $EditPersonalDataViewStateCopyWith<$Res> {
|
||||
factory $EditPersonalDataViewStateCopyWith(EditPersonalDataViewState value, $Res Function(EditPersonalDataViewState) _then) = _$EditPersonalDataViewStateCopyWithImpl;
|
||||
@useResult
|
||||
$Res call({
|
||||
bool isLoading, bool isSaving, bool isSigning, bool showPin, String pin, String firstName, String lastName, String dialCode, String phoneNumber, String nationality, AddressViewState address, String paymentProfileId, String errorMessage, bool saveSuccess
|
||||
});
|
||||
|
||||
|
||||
$AddressViewStateCopyWith<$Res> get address;
|
||||
|
||||
}
|
||||
/// @nodoc
|
||||
class _$EditPersonalDataViewStateCopyWithImpl<$Res>
|
||||
implements $EditPersonalDataViewStateCopyWith<$Res> {
|
||||
_$EditPersonalDataViewStateCopyWithImpl(this._self, this._then);
|
||||
|
||||
final EditPersonalDataViewState _self;
|
||||
final $Res Function(EditPersonalDataViewState) _then;
|
||||
|
||||
/// Create a copy of EditPersonalDataViewState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline') @override $Res call({Object? isLoading = null,Object? isSaving = null,Object? isSigning = null,Object? showPin = null,Object? pin = null,Object? firstName = null,Object? lastName = null,Object? dialCode = null,Object? phoneNumber = null,Object? nationality = null,Object? address = null,Object? paymentProfileId = null,Object? errorMessage = null,Object? saveSuccess = null,}) {
|
||||
return _then(_self.copyWith(
|
||||
isLoading: null == isLoading ? _self.isLoading : isLoading // ignore: cast_nullable_to_non_nullable
|
||||
as bool,isSaving: null == isSaving ? _self.isSaving : isSaving // ignore: cast_nullable_to_non_nullable
|
||||
as bool,isSigning: null == isSigning ? _self.isSigning : isSigning // ignore: cast_nullable_to_non_nullable
|
||||
as bool,showPin: null == showPin ? _self.showPin : showPin // ignore: cast_nullable_to_non_nullable
|
||||
as bool,pin: null == pin ? _self.pin : pin // ignore: cast_nullable_to_non_nullable
|
||||
as String,firstName: null == firstName ? _self.firstName : firstName // ignore: cast_nullable_to_non_nullable
|
||||
as String,lastName: null == lastName ? _self.lastName : lastName // ignore: cast_nullable_to_non_nullable
|
||||
as String,dialCode: null == dialCode ? _self.dialCode : dialCode // ignore: cast_nullable_to_non_nullable
|
||||
as String,phoneNumber: null == phoneNumber ? _self.phoneNumber : phoneNumber // ignore: cast_nullable_to_non_nullable
|
||||
as String,nationality: null == nationality ? _self.nationality : nationality // ignore: cast_nullable_to_non_nullable
|
||||
as String,address: null == address ? _self.address : address // ignore: cast_nullable_to_non_nullable
|
||||
as AddressViewState,paymentProfileId: null == paymentProfileId ? _self.paymentProfileId : paymentProfileId // ignore: cast_nullable_to_non_nullable
|
||||
as String,errorMessage: null == errorMessage ? _self.errorMessage : errorMessage // ignore: cast_nullable_to_non_nullable
|
||||
as String,saveSuccess: null == saveSuccess ? _self.saveSuccess : saveSuccess // ignore: cast_nullable_to_non_nullable
|
||||
as bool,
|
||||
));
|
||||
}
|
||||
/// Create a copy of EditPersonalDataViewState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
$AddressViewStateCopyWith<$Res> get address {
|
||||
|
||||
return $AddressViewStateCopyWith<$Res>(_self.address, (value) {
|
||||
return _then(_self.copyWith(address: value));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// Adds pattern-matching-related methods to [EditPersonalDataViewState].
|
||||
extension EditPersonalDataViewStatePatterns on EditPersonalDataViewState {
|
||||
/// 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( _EditPersonalDataViewState value)? $default,{required TResult orElse(),}){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _EditPersonalDataViewState() 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( _EditPersonalDataViewState value) $default,){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _EditPersonalDataViewState():
|
||||
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( _EditPersonalDataViewState value)? $default,){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _EditPersonalDataViewState() 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, bool isSaving, bool isSigning, bool showPin, String pin, String firstName, String lastName, String dialCode, String phoneNumber, String nationality, AddressViewState address, String paymentProfileId, String errorMessage, bool saveSuccess)? $default,{required TResult orElse(),}) {final _that = this;
|
||||
switch (_that) {
|
||||
case _EditPersonalDataViewState() when $default != null:
|
||||
return $default(_that.isLoading,_that.isSaving,_that.isSigning,_that.showPin,_that.pin,_that.firstName,_that.lastName,_that.dialCode,_that.phoneNumber,_that.nationality,_that.address,_that.paymentProfileId,_that.errorMessage,_that.saveSuccess);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, bool isSaving, bool isSigning, bool showPin, String pin, String firstName, String lastName, String dialCode, String phoneNumber, String nationality, AddressViewState address, String paymentProfileId, String errorMessage, bool saveSuccess) $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _EditPersonalDataViewState():
|
||||
return $default(_that.isLoading,_that.isSaving,_that.isSigning,_that.showPin,_that.pin,_that.firstName,_that.lastName,_that.dialCode,_that.phoneNumber,_that.nationality,_that.address,_that.paymentProfileId,_that.errorMessage,_that.saveSuccess);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, bool isSaving, bool isSigning, bool showPin, String pin, String firstName, String lastName, String dialCode, String phoneNumber, String nationality, AddressViewState address, String paymentProfileId, String errorMessage, bool saveSuccess)? $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _EditPersonalDataViewState() when $default != null:
|
||||
return $default(_that.isLoading,_that.isSaving,_that.isSigning,_that.showPin,_that.pin,_that.firstName,_that.lastName,_that.dialCode,_that.phoneNumber,_that.nationality,_that.address,_that.paymentProfileId,_that.errorMessage,_that.saveSuccess);case _:
|
||||
return null;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
|
||||
|
||||
class _EditPersonalDataViewState implements EditPersonalDataViewState {
|
||||
const _EditPersonalDataViewState({this.isLoading = true, this.isSaving = false, this.isSigning = false, this.showPin = false, this.pin = '', this.firstName = '', this.lastName = '', this.dialCode = '', this.phoneNumber = '', this.nationality = '', this.address = const AddressViewState(), this.paymentProfileId = '', this.errorMessage = '', this.saveSuccess = false});
|
||||
|
||||
|
||||
@override@JsonKey() final bool isLoading;
|
||||
@override@JsonKey() final bool isSaving;
|
||||
@override@JsonKey() final bool isSigning;
|
||||
@override@JsonKey() final bool showPin;
|
||||
@override@JsonKey() final String pin;
|
||||
@override@JsonKey() final String firstName;
|
||||
@override@JsonKey() final String lastName;
|
||||
@override@JsonKey() final String dialCode;
|
||||
@override@JsonKey() final String phoneNumber;
|
||||
@override@JsonKey() final String nationality;
|
||||
@override@JsonKey() final AddressViewState address;
|
||||
@override@JsonKey() final String paymentProfileId;
|
||||
@override@JsonKey() final String errorMessage;
|
||||
@override@JsonKey() final bool saveSuccess;
|
||||
|
||||
/// Create a copy of EditPersonalDataViewState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override @JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@pragma('vm:prefer-inline')
|
||||
_$EditPersonalDataViewStateCopyWith<_EditPersonalDataViewState> get copyWith => __$EditPersonalDataViewStateCopyWithImpl<_EditPersonalDataViewState>(this, _$identity);
|
||||
|
||||
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is _EditPersonalDataViewState&&(identical(other.isLoading, isLoading) || other.isLoading == isLoading)&&(identical(other.isSaving, isSaving) || other.isSaving == isSaving)&&(identical(other.isSigning, isSigning) || other.isSigning == isSigning)&&(identical(other.showPin, showPin) || other.showPin == showPin)&&(identical(other.pin, pin) || other.pin == pin)&&(identical(other.firstName, firstName) || other.firstName == firstName)&&(identical(other.lastName, lastName) || other.lastName == lastName)&&(identical(other.dialCode, dialCode) || other.dialCode == dialCode)&&(identical(other.phoneNumber, phoneNumber) || other.phoneNumber == phoneNumber)&&(identical(other.nationality, nationality) || other.nationality == nationality)&&(identical(other.address, address) || other.address == address)&&(identical(other.paymentProfileId, paymentProfileId) || other.paymentProfileId == paymentProfileId)&&(identical(other.errorMessage, errorMessage) || other.errorMessage == errorMessage)&&(identical(other.saveSuccess, saveSuccess) || other.saveSuccess == saveSuccess));
|
||||
}
|
||||
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,isLoading,isSaving,isSigning,showPin,pin,firstName,lastName,dialCode,phoneNumber,nationality,address,paymentProfileId,errorMessage,saveSuccess);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'EditPersonalDataViewState(isLoading: $isLoading, isSaving: $isSaving, isSigning: $isSigning, showPin: $showPin, pin: $pin, firstName: $firstName, lastName: $lastName, dialCode: $dialCode, phoneNumber: $phoneNumber, nationality: $nationality, address: $address, paymentProfileId: $paymentProfileId, errorMessage: $errorMessage, saveSuccess: $saveSuccess)';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract mixin class _$EditPersonalDataViewStateCopyWith<$Res> implements $EditPersonalDataViewStateCopyWith<$Res> {
|
||||
factory _$EditPersonalDataViewStateCopyWith(_EditPersonalDataViewState value, $Res Function(_EditPersonalDataViewState) _then) = __$EditPersonalDataViewStateCopyWithImpl;
|
||||
@override @useResult
|
||||
$Res call({
|
||||
bool isLoading, bool isSaving, bool isSigning, bool showPin, String pin, String firstName, String lastName, String dialCode, String phoneNumber, String nationality, AddressViewState address, String paymentProfileId, String errorMessage, bool saveSuccess
|
||||
});
|
||||
|
||||
|
||||
@override $AddressViewStateCopyWith<$Res> get address;
|
||||
|
||||
}
|
||||
/// @nodoc
|
||||
class __$EditPersonalDataViewStateCopyWithImpl<$Res>
|
||||
implements _$EditPersonalDataViewStateCopyWith<$Res> {
|
||||
__$EditPersonalDataViewStateCopyWithImpl(this._self, this._then);
|
||||
|
||||
final _EditPersonalDataViewState _self;
|
||||
final $Res Function(_EditPersonalDataViewState) _then;
|
||||
|
||||
/// Create a copy of EditPersonalDataViewState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override @pragma('vm:prefer-inline') $Res call({Object? isLoading = null,Object? isSaving = null,Object? isSigning = null,Object? showPin = null,Object? pin = null,Object? firstName = null,Object? lastName = null,Object? dialCode = null,Object? phoneNumber = null,Object? nationality = null,Object? address = null,Object? paymentProfileId = null,Object? errorMessage = null,Object? saveSuccess = null,}) {
|
||||
return _then(_EditPersonalDataViewState(
|
||||
isLoading: null == isLoading ? _self.isLoading : isLoading // ignore: cast_nullable_to_non_nullable
|
||||
as bool,isSaving: null == isSaving ? _self.isSaving : isSaving // ignore: cast_nullable_to_non_nullable
|
||||
as bool,isSigning: null == isSigning ? _self.isSigning : isSigning // ignore: cast_nullable_to_non_nullable
|
||||
as bool,showPin: null == showPin ? _self.showPin : showPin // ignore: cast_nullable_to_non_nullable
|
||||
as bool,pin: null == pin ? _self.pin : pin // ignore: cast_nullable_to_non_nullable
|
||||
as String,firstName: null == firstName ? _self.firstName : firstName // ignore: cast_nullable_to_non_nullable
|
||||
as String,lastName: null == lastName ? _self.lastName : lastName // ignore: cast_nullable_to_non_nullable
|
||||
as String,dialCode: null == dialCode ? _self.dialCode : dialCode // ignore: cast_nullable_to_non_nullable
|
||||
as String,phoneNumber: null == phoneNumber ? _self.phoneNumber : phoneNumber // ignore: cast_nullable_to_non_nullable
|
||||
as String,nationality: null == nationality ? _self.nationality : nationality // ignore: cast_nullable_to_non_nullable
|
||||
as String,address: null == address ? _self.address : address // ignore: cast_nullable_to_non_nullable
|
||||
as AddressViewState,paymentProfileId: null == paymentProfileId ? _self.paymentProfileId : paymentProfileId // ignore: cast_nullable_to_non_nullable
|
||||
as String,errorMessage: null == errorMessage ? _self.errorMessage : errorMessage // ignore: cast_nullable_to_non_nullable
|
||||
as String,saveSuccess: null == saveSuccess ? _self.saveSuccess : saveSuccess // ignore: cast_nullable_to_non_nullable
|
||||
as bool,
|
||||
));
|
||||
}
|
||||
|
||||
/// Create a copy of EditPersonalDataViewState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
$AddressViewStateCopyWith<$Res> get address {
|
||||
|
||||
return $AddressViewStateCopyWith<$Res>(_self.address, (value) {
|
||||
return _then(_self.copyWith(address: value));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// dart format on
|
||||
@@ -221,7 +221,9 @@ class PayoutScreen extends ConsumerWidget {
|
||||
),
|
||||
),
|
||||
subtitle: Text(
|
||||
maskedIban,
|
||||
beneficiary.bic.isNotEmpty
|
||||
? '$maskedIban · ${beneficiary.bic}'
|
||||
: maskedIban,
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
color: theme
|
||||
@@ -279,6 +281,12 @@ class PayoutScreen extends ConsumerWidget {
|
||||
label: context.translate(I18n.payoutHolderNameLabel),
|
||||
hint: context.translate(I18n.payoutHolderNameHint),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
CustomTextField(
|
||||
controller: viewModel.bicController,
|
||||
label: 'BIC / SWIFT',
|
||||
hint: 'XXXXXXXX',
|
||||
),
|
||||
const SizedBox(height: 24),
|
||||
if (viewState.isSubmitting)
|
||||
const Center(child: AppLoadingIndicator(size: 48))
|
||||
|
||||
@@ -16,13 +16,14 @@ final payoutViewModelProvider =
|
||||
);
|
||||
|
||||
class PayoutViewModel extends Notifier<PayoutViewState> {
|
||||
late final TreezorWalletSignatureService _signatureService;
|
||||
late final GetPaymentProfileUseCase _getPaymentProfileUseCase;
|
||||
late final GetUserInfoUseCase _getUserInfoUseCase;
|
||||
late TreezorWalletSignatureService _signatureService;
|
||||
late GetPaymentProfileUseCase _getPaymentProfileUseCase;
|
||||
late GetUserInfoUseCase _getUserInfoUseCase;
|
||||
|
||||
late final TextEditingController amountController;
|
||||
late final TextEditingController ibanController;
|
||||
late final TextEditingController holderNameController;
|
||||
late TextEditingController amountController;
|
||||
late TextEditingController ibanController;
|
||||
late TextEditingController holderNameController;
|
||||
late TextEditingController bicController;
|
||||
|
||||
@override
|
||||
PayoutViewState build() {
|
||||
@@ -33,10 +34,12 @@ class PayoutViewModel extends Notifier<PayoutViewState> {
|
||||
amountController = TextEditingController();
|
||||
ibanController = TextEditingController();
|
||||
holderNameController = TextEditingController();
|
||||
bicController = TextEditingController();
|
||||
|
||||
amountController.addListener(_onAmountChanged);
|
||||
ibanController.addListener(_onIbanChanged);
|
||||
holderNameController.addListener(_onHolderNameChanged);
|
||||
bicController.addListener(_onBicChanged);
|
||||
|
||||
ref.onDispose(disposeControllers);
|
||||
|
||||
@@ -49,9 +52,11 @@ class PayoutViewModel extends Notifier<PayoutViewState> {
|
||||
amountController.removeListener(_onAmountChanged);
|
||||
ibanController.removeListener(_onIbanChanged);
|
||||
holderNameController.removeListener(_onHolderNameChanged);
|
||||
bicController.removeListener(_onBicChanged);
|
||||
amountController.dispose();
|
||||
ibanController.dispose();
|
||||
holderNameController.dispose();
|
||||
bicController.dispose();
|
||||
}
|
||||
|
||||
void _onAmountChanged() {
|
||||
@@ -66,6 +71,10 @@ class PayoutViewModel extends Notifier<PayoutViewState> {
|
||||
state = state.copyWith(holderName: holderNameController.text);
|
||||
}
|
||||
|
||||
void _onBicChanged() {
|
||||
state = state.copyWith(bic: bicController.text);
|
||||
}
|
||||
|
||||
Future<void> _load() async {
|
||||
try {
|
||||
final user = await _getUserInfoUseCase.getUserInfo();
|
||||
@@ -117,10 +126,12 @@ class PayoutViewModel extends Notifier<PayoutViewState> {
|
||||
void showAddBeneficiaryForm() {
|
||||
ibanController.clear();
|
||||
holderNameController.clear();
|
||||
bicController.clear();
|
||||
state = state.copyWith(
|
||||
step: PayoutStep.addBeneficiary,
|
||||
iban: '',
|
||||
holderName: '',
|
||||
bic: '',
|
||||
errorMessage: '',
|
||||
);
|
||||
}
|
||||
@@ -224,16 +235,22 @@ class PayoutViewModel extends Notifier<PayoutViewState> {
|
||||
|
||||
try {
|
||||
final url = 'https://savefamily.sandbox.treezor.co/v1/beneficiaries';
|
||||
final scaBody = <String, dynamic>{
|
||||
'name': state.holderName.trim(),
|
||||
'userId': state.paymentProfileId,
|
||||
'iban': state.iban.replaceAll(' ', ''),
|
||||
'usableForSct': true,
|
||||
};
|
||||
if (state.bic.trim().isNotEmpty) {
|
||||
scaBody['bic'] = state.bic.trim();
|
||||
}
|
||||
final scaInput = {
|
||||
'url': url,
|
||||
'body': scaBody,
|
||||
};
|
||||
final scaProof = await _signatureService.generateJwsWithPin(
|
||||
message: '',
|
||||
input: jsonEncode({
|
||||
'url': url,
|
||||
'body': {
|
||||
'name': state.holderName.trim(),
|
||||
'userId': state.paymentProfileId,
|
||||
'iban': state.iban.trim(),
|
||||
},
|
||||
}),
|
||||
input: jsonEncode(scaInput),
|
||||
pin: state.pin,
|
||||
);
|
||||
|
||||
@@ -243,7 +260,8 @@ class PayoutViewModel extends Notifier<PayoutViewState> {
|
||||
final treezorRepo = ref.read(treezorRepositoryProvider);
|
||||
await treezorRepo.createTransactionBeneficiary(
|
||||
name: state.holderName.trim(),
|
||||
iban: state.iban.trim(),
|
||||
iban: state.iban.replaceAll(' ', ''),
|
||||
bic: state.bic.trim().isNotEmpty ? state.bic.trim() : null,
|
||||
scaProof: scaProof,
|
||||
);
|
||||
|
||||
@@ -296,7 +314,6 @@ class PayoutViewModel extends Notifier<PayoutViewState> {
|
||||
'beneficiaryValidationId': beneficiaryValidationId,
|
||||
},
|
||||
};
|
||||
debugPrint('[Payout] SCA input: ${jsonEncode(scaInput)}');
|
||||
final scaProof = await _signatureService.generateJwsWithPin(
|
||||
message: '',
|
||||
input: jsonEncode(scaInput),
|
||||
@@ -307,7 +324,6 @@ class PayoutViewModel extends Notifier<PayoutViewState> {
|
||||
state = state.copyWith(isSigning: false, isSubmitting: true);
|
||||
|
||||
await treezorRepo.walletTransfer(
|
||||
walletId: state.walletId,
|
||||
beneficiaryId: beneficiary.id,
|
||||
beneficiaryValidationId: beneficiaryValidationId,
|
||||
amount: amount,
|
||||
|
||||
@@ -20,6 +20,7 @@ abstract class PayoutViewState with _$PayoutViewState {
|
||||
PayoutBeneficiaryEntity? selectedBeneficiary,
|
||||
@Default('') String iban,
|
||||
@Default('') String holderName,
|
||||
@Default('') String bic,
|
||||
@Default('') String amount,
|
||||
@Default('') String pin,
|
||||
}) = _PayoutViewState;
|
||||
|
||||
@@ -14,7 +14,7 @@ T _$identity<T>(T value) => value;
|
||||
/// @nodoc
|
||||
mixin _$PayoutViewState {
|
||||
|
||||
PayoutStep get step; bool get isLoading; bool get isSubmitting; bool get isSigning; String get errorMessage; String get walletId; String get paymentProfileId; double get availableBalance; List<PayoutBeneficiaryEntity> get beneficiaries; PayoutBeneficiaryEntity? get selectedBeneficiary; String get iban; String get holderName; String get amount; String get pin;
|
||||
PayoutStep get step; bool get isLoading; bool get isSubmitting; bool get isSigning; String get errorMessage; String get walletId; String get paymentProfileId; double get availableBalance; List<PayoutBeneficiaryEntity> get beneficiaries; PayoutBeneficiaryEntity? get selectedBeneficiary; String get iban; String get holderName; String get bic; String get amount; String get pin;
|
||||
/// Create a copy of PayoutViewState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@@ -25,16 +25,16 @@ $PayoutViewStateCopyWith<PayoutViewState> get copyWith => _$PayoutViewStateCopyW
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is PayoutViewState&&(identical(other.step, step) || other.step == step)&&(identical(other.isLoading, isLoading) || other.isLoading == isLoading)&&(identical(other.isSubmitting, isSubmitting) || other.isSubmitting == isSubmitting)&&(identical(other.isSigning, isSigning) || other.isSigning == isSigning)&&(identical(other.errorMessage, errorMessage) || other.errorMessage == errorMessage)&&(identical(other.walletId, walletId) || other.walletId == walletId)&&(identical(other.paymentProfileId, paymentProfileId) || other.paymentProfileId == paymentProfileId)&&(identical(other.availableBalance, availableBalance) || other.availableBalance == availableBalance)&&const DeepCollectionEquality().equals(other.beneficiaries, beneficiaries)&&(identical(other.selectedBeneficiary, selectedBeneficiary) || other.selectedBeneficiary == selectedBeneficiary)&&(identical(other.iban, iban) || other.iban == iban)&&(identical(other.holderName, holderName) || other.holderName == holderName)&&(identical(other.amount, amount) || other.amount == amount)&&(identical(other.pin, pin) || other.pin == pin));
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is PayoutViewState&&(identical(other.step, step) || other.step == step)&&(identical(other.isLoading, isLoading) || other.isLoading == isLoading)&&(identical(other.isSubmitting, isSubmitting) || other.isSubmitting == isSubmitting)&&(identical(other.isSigning, isSigning) || other.isSigning == isSigning)&&(identical(other.errorMessage, errorMessage) || other.errorMessage == errorMessage)&&(identical(other.walletId, walletId) || other.walletId == walletId)&&(identical(other.paymentProfileId, paymentProfileId) || other.paymentProfileId == paymentProfileId)&&(identical(other.availableBalance, availableBalance) || other.availableBalance == availableBalance)&&const DeepCollectionEquality().equals(other.beneficiaries, beneficiaries)&&(identical(other.selectedBeneficiary, selectedBeneficiary) || other.selectedBeneficiary == selectedBeneficiary)&&(identical(other.iban, iban) || other.iban == iban)&&(identical(other.holderName, holderName) || other.holderName == holderName)&&(identical(other.bic, bic) || other.bic == bic)&&(identical(other.amount, amount) || other.amount == amount)&&(identical(other.pin, pin) || other.pin == pin));
|
||||
}
|
||||
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,step,isLoading,isSubmitting,isSigning,errorMessage,walletId,paymentProfileId,availableBalance,const DeepCollectionEquality().hash(beneficiaries),selectedBeneficiary,iban,holderName,amount,pin);
|
||||
int get hashCode => Object.hash(runtimeType,step,isLoading,isSubmitting,isSigning,errorMessage,walletId,paymentProfileId,availableBalance,const DeepCollectionEquality().hash(beneficiaries),selectedBeneficiary,iban,holderName,bic,amount,pin);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'PayoutViewState(step: $step, isLoading: $isLoading, isSubmitting: $isSubmitting, isSigning: $isSigning, errorMessage: $errorMessage, walletId: $walletId, paymentProfileId: $paymentProfileId, availableBalance: $availableBalance, beneficiaries: $beneficiaries, selectedBeneficiary: $selectedBeneficiary, iban: $iban, holderName: $holderName, amount: $amount, pin: $pin)';
|
||||
return 'PayoutViewState(step: $step, isLoading: $isLoading, isSubmitting: $isSubmitting, isSigning: $isSigning, errorMessage: $errorMessage, walletId: $walletId, paymentProfileId: $paymentProfileId, availableBalance: $availableBalance, beneficiaries: $beneficiaries, selectedBeneficiary: $selectedBeneficiary, iban: $iban, holderName: $holderName, bic: $bic, amount: $amount, pin: $pin)';
|
||||
}
|
||||
|
||||
|
||||
@@ -45,7 +45,7 @@ abstract mixin class $PayoutViewStateCopyWith<$Res> {
|
||||
factory $PayoutViewStateCopyWith(PayoutViewState value, $Res Function(PayoutViewState) _then) = _$PayoutViewStateCopyWithImpl;
|
||||
@useResult
|
||||
$Res call({
|
||||
PayoutStep step, bool isLoading, bool isSubmitting, bool isSigning, String errorMessage, String walletId, String paymentProfileId, double availableBalance, List<PayoutBeneficiaryEntity> beneficiaries, PayoutBeneficiaryEntity? selectedBeneficiary, String iban, String holderName, String amount, String pin
|
||||
PayoutStep step, bool isLoading, bool isSubmitting, bool isSigning, String errorMessage, String walletId, String paymentProfileId, double availableBalance, List<PayoutBeneficiaryEntity> beneficiaries, PayoutBeneficiaryEntity? selectedBeneficiary, String iban, String holderName, String bic, String amount, String pin
|
||||
});
|
||||
|
||||
|
||||
@@ -62,7 +62,7 @@ class _$PayoutViewStateCopyWithImpl<$Res>
|
||||
|
||||
/// Create a copy of PayoutViewState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline') @override $Res call({Object? step = null,Object? isLoading = null,Object? isSubmitting = null,Object? isSigning = null,Object? errorMessage = null,Object? walletId = null,Object? paymentProfileId = null,Object? availableBalance = null,Object? beneficiaries = null,Object? selectedBeneficiary = freezed,Object? iban = null,Object? holderName = null,Object? amount = null,Object? pin = null,}) {
|
||||
@pragma('vm:prefer-inline') @override $Res call({Object? step = null,Object? isLoading = null,Object? isSubmitting = null,Object? isSigning = null,Object? errorMessage = null,Object? walletId = null,Object? paymentProfileId = null,Object? availableBalance = null,Object? beneficiaries = null,Object? selectedBeneficiary = freezed,Object? iban = null,Object? holderName = null,Object? bic = null,Object? amount = null,Object? pin = null,}) {
|
||||
return _then(_self.copyWith(
|
||||
step: null == step ? _self.step : step // ignore: cast_nullable_to_non_nullable
|
||||
as PayoutStep,isLoading: null == isLoading ? _self.isLoading : isLoading // ignore: cast_nullable_to_non_nullable
|
||||
@@ -76,6 +76,7 @@ as double,beneficiaries: null == beneficiaries ? _self.beneficiaries : beneficia
|
||||
as List<PayoutBeneficiaryEntity>,selectedBeneficiary: freezed == selectedBeneficiary ? _self.selectedBeneficiary : selectedBeneficiary // ignore: cast_nullable_to_non_nullable
|
||||
as PayoutBeneficiaryEntity?,iban: null == iban ? _self.iban : iban // ignore: cast_nullable_to_non_nullable
|
||||
as String,holderName: null == holderName ? _self.holderName : holderName // ignore: cast_nullable_to_non_nullable
|
||||
as String,bic: null == bic ? _self.bic : bic // ignore: cast_nullable_to_non_nullable
|
||||
as String,amount: null == amount ? _self.amount : amount // ignore: cast_nullable_to_non_nullable
|
||||
as String,pin: null == pin ? _self.pin : pin // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
@@ -175,10 +176,10 @@ return $default(_that);case _:
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( PayoutStep step, bool isLoading, bool isSubmitting, bool isSigning, String errorMessage, String walletId, String paymentProfileId, double availableBalance, List<PayoutBeneficiaryEntity> beneficiaries, PayoutBeneficiaryEntity? selectedBeneficiary, String iban, String holderName, String amount, String pin)? $default,{required TResult orElse(),}) {final _that = this;
|
||||
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( PayoutStep step, bool isLoading, bool isSubmitting, bool isSigning, String errorMessage, String walletId, String paymentProfileId, double availableBalance, List<PayoutBeneficiaryEntity> beneficiaries, PayoutBeneficiaryEntity? selectedBeneficiary, String iban, String holderName, String bic, String amount, String pin)? $default,{required TResult orElse(),}) {final _that = this;
|
||||
switch (_that) {
|
||||
case _PayoutViewState() when $default != null:
|
||||
return $default(_that.step,_that.isLoading,_that.isSubmitting,_that.isSigning,_that.errorMessage,_that.walletId,_that.paymentProfileId,_that.availableBalance,_that.beneficiaries,_that.selectedBeneficiary,_that.iban,_that.holderName,_that.amount,_that.pin);case _:
|
||||
return $default(_that.step,_that.isLoading,_that.isSubmitting,_that.isSigning,_that.errorMessage,_that.walletId,_that.paymentProfileId,_that.availableBalance,_that.beneficiaries,_that.selectedBeneficiary,_that.iban,_that.holderName,_that.bic,_that.amount,_that.pin);case _:
|
||||
return orElse();
|
||||
|
||||
}
|
||||
@@ -196,10 +197,10 @@ return $default(_that.step,_that.isLoading,_that.isSubmitting,_that.isSigning,_t
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( PayoutStep step, bool isLoading, bool isSubmitting, bool isSigning, String errorMessage, String walletId, String paymentProfileId, double availableBalance, List<PayoutBeneficiaryEntity> beneficiaries, PayoutBeneficiaryEntity? selectedBeneficiary, String iban, String holderName, String amount, String pin) $default,) {final _that = this;
|
||||
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( PayoutStep step, bool isLoading, bool isSubmitting, bool isSigning, String errorMessage, String walletId, String paymentProfileId, double availableBalance, List<PayoutBeneficiaryEntity> beneficiaries, PayoutBeneficiaryEntity? selectedBeneficiary, String iban, String holderName, String bic, String amount, String pin) $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _PayoutViewState():
|
||||
return $default(_that.step,_that.isLoading,_that.isSubmitting,_that.isSigning,_that.errorMessage,_that.walletId,_that.paymentProfileId,_that.availableBalance,_that.beneficiaries,_that.selectedBeneficiary,_that.iban,_that.holderName,_that.amount,_that.pin);case _:
|
||||
return $default(_that.step,_that.isLoading,_that.isSubmitting,_that.isSigning,_that.errorMessage,_that.walletId,_that.paymentProfileId,_that.availableBalance,_that.beneficiaries,_that.selectedBeneficiary,_that.iban,_that.holderName,_that.bic,_that.amount,_that.pin);case _:
|
||||
throw StateError('Unexpected subclass');
|
||||
|
||||
}
|
||||
@@ -216,10 +217,10 @@ return $default(_that.step,_that.isLoading,_that.isSubmitting,_that.isSigning,_t
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( PayoutStep step, bool isLoading, bool isSubmitting, bool isSigning, String errorMessage, String walletId, String paymentProfileId, double availableBalance, List<PayoutBeneficiaryEntity> beneficiaries, PayoutBeneficiaryEntity? selectedBeneficiary, String iban, String holderName, String amount, String pin)? $default,) {final _that = this;
|
||||
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( PayoutStep step, bool isLoading, bool isSubmitting, bool isSigning, String errorMessage, String walletId, String paymentProfileId, double availableBalance, List<PayoutBeneficiaryEntity> beneficiaries, PayoutBeneficiaryEntity? selectedBeneficiary, String iban, String holderName, String bic, String amount, String pin)? $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _PayoutViewState() when $default != null:
|
||||
return $default(_that.step,_that.isLoading,_that.isSubmitting,_that.isSigning,_that.errorMessage,_that.walletId,_that.paymentProfileId,_that.availableBalance,_that.beneficiaries,_that.selectedBeneficiary,_that.iban,_that.holderName,_that.amount,_that.pin);case _:
|
||||
return $default(_that.step,_that.isLoading,_that.isSubmitting,_that.isSigning,_that.errorMessage,_that.walletId,_that.paymentProfileId,_that.availableBalance,_that.beneficiaries,_that.selectedBeneficiary,_that.iban,_that.holderName,_that.bic,_that.amount,_that.pin);case _:
|
||||
return null;
|
||||
|
||||
}
|
||||
@@ -231,7 +232,7 @@ return $default(_that.step,_that.isLoading,_that.isSubmitting,_that.isSigning,_t
|
||||
|
||||
|
||||
class _PayoutViewState implements PayoutViewState {
|
||||
const _PayoutViewState({this.step = PayoutStep.loading, this.isLoading = false, this.isSubmitting = false, this.isSigning = false, this.errorMessage = '', this.walletId = '', this.paymentProfileId = '', this.availableBalance = 0, final List<PayoutBeneficiaryEntity> beneficiaries = const [], this.selectedBeneficiary, this.iban = '', this.holderName = '', this.amount = '', this.pin = ''}): _beneficiaries = beneficiaries;
|
||||
const _PayoutViewState({this.step = PayoutStep.loading, this.isLoading = false, this.isSubmitting = false, this.isSigning = false, this.errorMessage = '', this.walletId = '', this.paymentProfileId = '', this.availableBalance = 0, final List<PayoutBeneficiaryEntity> beneficiaries = const [], this.selectedBeneficiary, this.iban = '', this.holderName = '', this.bic = '', this.amount = '', this.pin = ''}): _beneficiaries = beneficiaries;
|
||||
|
||||
|
||||
@override@JsonKey() final PayoutStep step;
|
||||
@@ -252,6 +253,7 @@ class _PayoutViewState implements PayoutViewState {
|
||||
@override final PayoutBeneficiaryEntity? selectedBeneficiary;
|
||||
@override@JsonKey() final String iban;
|
||||
@override@JsonKey() final String holderName;
|
||||
@override@JsonKey() final String bic;
|
||||
@override@JsonKey() final String amount;
|
||||
@override@JsonKey() final String pin;
|
||||
|
||||
@@ -265,16 +267,16 @@ _$PayoutViewStateCopyWith<_PayoutViewState> get copyWith => __$PayoutViewStateCo
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is _PayoutViewState&&(identical(other.step, step) || other.step == step)&&(identical(other.isLoading, isLoading) || other.isLoading == isLoading)&&(identical(other.isSubmitting, isSubmitting) || other.isSubmitting == isSubmitting)&&(identical(other.isSigning, isSigning) || other.isSigning == isSigning)&&(identical(other.errorMessage, errorMessage) || other.errorMessage == errorMessage)&&(identical(other.walletId, walletId) || other.walletId == walletId)&&(identical(other.paymentProfileId, paymentProfileId) || other.paymentProfileId == paymentProfileId)&&(identical(other.availableBalance, availableBalance) || other.availableBalance == availableBalance)&&const DeepCollectionEquality().equals(other._beneficiaries, _beneficiaries)&&(identical(other.selectedBeneficiary, selectedBeneficiary) || other.selectedBeneficiary == selectedBeneficiary)&&(identical(other.iban, iban) || other.iban == iban)&&(identical(other.holderName, holderName) || other.holderName == holderName)&&(identical(other.amount, amount) || other.amount == amount)&&(identical(other.pin, pin) || other.pin == pin));
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is _PayoutViewState&&(identical(other.step, step) || other.step == step)&&(identical(other.isLoading, isLoading) || other.isLoading == isLoading)&&(identical(other.isSubmitting, isSubmitting) || other.isSubmitting == isSubmitting)&&(identical(other.isSigning, isSigning) || other.isSigning == isSigning)&&(identical(other.errorMessage, errorMessage) || other.errorMessage == errorMessage)&&(identical(other.walletId, walletId) || other.walletId == walletId)&&(identical(other.paymentProfileId, paymentProfileId) || other.paymentProfileId == paymentProfileId)&&(identical(other.availableBalance, availableBalance) || other.availableBalance == availableBalance)&&const DeepCollectionEquality().equals(other._beneficiaries, _beneficiaries)&&(identical(other.selectedBeneficiary, selectedBeneficiary) || other.selectedBeneficiary == selectedBeneficiary)&&(identical(other.iban, iban) || other.iban == iban)&&(identical(other.holderName, holderName) || other.holderName == holderName)&&(identical(other.bic, bic) || other.bic == bic)&&(identical(other.amount, amount) || other.amount == amount)&&(identical(other.pin, pin) || other.pin == pin));
|
||||
}
|
||||
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,step,isLoading,isSubmitting,isSigning,errorMessage,walletId,paymentProfileId,availableBalance,const DeepCollectionEquality().hash(_beneficiaries),selectedBeneficiary,iban,holderName,amount,pin);
|
||||
int get hashCode => Object.hash(runtimeType,step,isLoading,isSubmitting,isSigning,errorMessage,walletId,paymentProfileId,availableBalance,const DeepCollectionEquality().hash(_beneficiaries),selectedBeneficiary,iban,holderName,bic,amount,pin);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'PayoutViewState(step: $step, isLoading: $isLoading, isSubmitting: $isSubmitting, isSigning: $isSigning, errorMessage: $errorMessage, walletId: $walletId, paymentProfileId: $paymentProfileId, availableBalance: $availableBalance, beneficiaries: $beneficiaries, selectedBeneficiary: $selectedBeneficiary, iban: $iban, holderName: $holderName, amount: $amount, pin: $pin)';
|
||||
return 'PayoutViewState(step: $step, isLoading: $isLoading, isSubmitting: $isSubmitting, isSigning: $isSigning, errorMessage: $errorMessage, walletId: $walletId, paymentProfileId: $paymentProfileId, availableBalance: $availableBalance, beneficiaries: $beneficiaries, selectedBeneficiary: $selectedBeneficiary, iban: $iban, holderName: $holderName, bic: $bic, amount: $amount, pin: $pin)';
|
||||
}
|
||||
|
||||
|
||||
@@ -285,7 +287,7 @@ abstract mixin class _$PayoutViewStateCopyWith<$Res> implements $PayoutViewState
|
||||
factory _$PayoutViewStateCopyWith(_PayoutViewState value, $Res Function(_PayoutViewState) _then) = __$PayoutViewStateCopyWithImpl;
|
||||
@override @useResult
|
||||
$Res call({
|
||||
PayoutStep step, bool isLoading, bool isSubmitting, bool isSigning, String errorMessage, String walletId, String paymentProfileId, double availableBalance, List<PayoutBeneficiaryEntity> beneficiaries, PayoutBeneficiaryEntity? selectedBeneficiary, String iban, String holderName, String amount, String pin
|
||||
PayoutStep step, bool isLoading, bool isSubmitting, bool isSigning, String errorMessage, String walletId, String paymentProfileId, double availableBalance, List<PayoutBeneficiaryEntity> beneficiaries, PayoutBeneficiaryEntity? selectedBeneficiary, String iban, String holderName, String bic, String amount, String pin
|
||||
});
|
||||
|
||||
|
||||
@@ -302,7 +304,7 @@ class __$PayoutViewStateCopyWithImpl<$Res>
|
||||
|
||||
/// Create a copy of PayoutViewState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override @pragma('vm:prefer-inline') $Res call({Object? step = null,Object? isLoading = null,Object? isSubmitting = null,Object? isSigning = null,Object? errorMessage = null,Object? walletId = null,Object? paymentProfileId = null,Object? availableBalance = null,Object? beneficiaries = null,Object? selectedBeneficiary = freezed,Object? iban = null,Object? holderName = null,Object? amount = null,Object? pin = null,}) {
|
||||
@override @pragma('vm:prefer-inline') $Res call({Object? step = null,Object? isLoading = null,Object? isSubmitting = null,Object? isSigning = null,Object? errorMessage = null,Object? walletId = null,Object? paymentProfileId = null,Object? availableBalance = null,Object? beneficiaries = null,Object? selectedBeneficiary = freezed,Object? iban = null,Object? holderName = null,Object? bic = null,Object? amount = null,Object? pin = null,}) {
|
||||
return _then(_PayoutViewState(
|
||||
step: null == step ? _self.step : step // ignore: cast_nullable_to_non_nullable
|
||||
as PayoutStep,isLoading: null == isLoading ? _self.isLoading : isLoading // ignore: cast_nullable_to_non_nullable
|
||||
@@ -316,6 +318,7 @@ as double,beneficiaries: null == beneficiaries ? _self._beneficiaries : benefici
|
||||
as List<PayoutBeneficiaryEntity>,selectedBeneficiary: freezed == selectedBeneficiary ? _self.selectedBeneficiary : selectedBeneficiary // ignore: cast_nullable_to_non_nullable
|
||||
as PayoutBeneficiaryEntity?,iban: null == iban ? _self.iban : iban // ignore: cast_nullable_to_non_nullable
|
||||
as String,holderName: null == holderName ? _self.holderName : holderName // ignore: cast_nullable_to_non_nullable
|
||||
as String,bic: null == bic ? _self.bic : bic // ignore: cast_nullable_to_non_nullable
|
||||
as String,amount: null == amount ? _self.amount : amount // ignore: cast_nullable_to_non_nullable
|
||||
as String,pin: null == pin ? _self.pin : pin // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
|
||||
@@ -155,6 +155,12 @@ class ProfileSettingsScreen extends ConsumerWidget {
|
||||
),
|
||||
),
|
||||
const Spacer(),
|
||||
TextButton(
|
||||
onPressed: () => navigationContract.pushTo(
|
||||
AppRoutes.dashboardProfileEditPersonalData,
|
||||
),
|
||||
child: Text(context.translate(I18n.profileSettingsEdit)),
|
||||
),
|
||||
],
|
||||
),
|
||||
_labelValue(context.translate(I18n.profileSettingsName), fullName),
|
||||
|
||||
@@ -5,17 +5,19 @@ import 'package:url_launcher/url_launcher.dart';
|
||||
export 'profile_settings_view_state.dart';
|
||||
import 'profile_settings_view_state.dart';
|
||||
|
||||
final profileSettingsViewModelProvider = NotifierProvider.autoDispose<
|
||||
ProfileSettingsViewModel, ProfileSettingsViewState>(
|
||||
ProfileSettingsViewModel.new,
|
||||
);
|
||||
final profileSettingsViewModelProvider =
|
||||
NotifierProvider.autoDispose<
|
||||
ProfileSettingsViewModel,
|
||||
ProfileSettingsViewState
|
||||
>(ProfileSettingsViewModel.new);
|
||||
|
||||
class ProfileSettingsViewModel extends Notifier<ProfileSettingsViewState> {
|
||||
late final GetUserInfoUseCase _getUserInfoUseCase;
|
||||
late final GetPaymentProfileUseCase _getPaymentProfileUseCase;
|
||||
late GetUserInfoUseCase _getUserInfoUseCase;
|
||||
late GetPaymentProfileUseCase _getPaymentProfileUseCase;
|
||||
|
||||
@override
|
||||
ProfileSettingsViewState build() {
|
||||
ref.watch(walletRefreshProvider);
|
||||
_getUserInfoUseCase = ref.read(getUserInfoUseCaseProvider);
|
||||
_getPaymentProfileUseCase = ref.read(getPaymentProfileUseCaseProvider);
|
||||
|
||||
@@ -38,8 +40,9 @@ class ProfileSettingsViewModel extends Notifier<ProfileSettingsViewState> {
|
||||
final user = await _getUserInfoUseCase.getUserInfo();
|
||||
if (!ref.mounted) return;
|
||||
|
||||
final paymentProfile =
|
||||
await _getPaymentProfileUseCase.getPaymentProfile(userId: user.id);
|
||||
final paymentProfile = await _getPaymentProfileUseCase.getPaymentProfile(
|
||||
userId: user.id,
|
||||
);
|
||||
if (!ref.mounted) return;
|
||||
|
||||
state = state.copyWith(
|
||||
@@ -78,11 +81,7 @@ class ProfileSettingsViewModel extends Notifier<ProfileSettingsViewState> {
|
||||
try {
|
||||
final link = await ref
|
||||
.read(treezorRepositoryProvider)
|
||||
.getAccountStatement(
|
||||
walletId: walletId,
|
||||
year: year,
|
||||
month: month,
|
||||
);
|
||||
.getAccountStatement(walletId: walletId, year: year, month: month);
|
||||
await launchUrl(Uri.parse(link), mode: LaunchMode.externalApplication);
|
||||
return null;
|
||||
} catch (e) {
|
||||
|
||||
@@ -131,12 +131,47 @@ class _ProfileScreenState extends ConsumerState<ProfileScreen> {
|
||||
),
|
||||
];
|
||||
|
||||
final transactions = viewState.transactions;
|
||||
final hasTransactions = transactions.isNotEmpty;
|
||||
final hasPages = viewState.transactionPages.isNotEmpty;
|
||||
final currentTransactions = hasPages
|
||||
? viewState.transactionPages[viewState.currentPage]
|
||||
: <WalletTransactionEntity>[];
|
||||
|
||||
final itemCount = header.length
|
||||
+ 1 // transactions title or empty message
|
||||
+ (hasTransactions ? transactions.length : 0);
|
||||
final content = [
|
||||
...header,
|
||||
if (!hasPages)
|
||||
Center(
|
||||
child: Text(
|
||||
context.translate(I18n.profileNoRecentTransactions),
|
||||
style: TextStyle(
|
||||
fontSize: 14,
|
||||
color: theme.getColorFor(ThemeCode.textPrimary),
|
||||
),
|
||||
),
|
||||
)
|
||||
else ...[
|
||||
Text(
|
||||
context.translate(I18n.profileRecentTransactions),
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.w500,
|
||||
fontSize: 18,
|
||||
color: theme.getColorFor(ThemeCode.textPrimary),
|
||||
),
|
||||
),
|
||||
...currentTransactions.map(
|
||||
(tx) => TransactionTile(transaction: tx),
|
||||
),
|
||||
PaginationBar(
|
||||
currentPage: viewState.currentPage,
|
||||
totalPages: viewState.transactionPages.length,
|
||||
hasMore: viewState.nextCursor != null,
|
||||
isLoadingMore: viewState.isLoadingMore,
|
||||
onPageChanged: (page) =>
|
||||
ref.read(profileViewModelProvider.notifier).setPage(page),
|
||||
onLoadMore: () =>
|
||||
ref.read(profileViewModelProvider.notifier).loadMore(),
|
||||
),
|
||||
],
|
||||
];
|
||||
|
||||
return Stack(
|
||||
children: [
|
||||
@@ -160,43 +195,10 @@ class _ProfileScreenState extends ConsumerState<ProfileScreen> {
|
||||
ref.read(profileViewModelProvider.notifier).load(),
|
||||
child: ListView.separated(
|
||||
physics: const AlwaysScrollableScrollPhysics(),
|
||||
itemCount: itemCount,
|
||||
itemCount: content.length,
|
||||
separatorBuilder: (_, __) =>
|
||||
const Divider(color: Colors.transparent, height: 20),
|
||||
itemBuilder: (context, index) {
|
||||
// Header items
|
||||
if (index < header.length) {
|
||||
return header[index];
|
||||
}
|
||||
|
||||
final offset = index - header.length;
|
||||
|
||||
// Transactions title or empty message
|
||||
if (offset == 0) {
|
||||
if (!hasTransactions) {
|
||||
return Center(
|
||||
child: Text(
|
||||
context.translate(I18n.profileNoRecentTransactions),
|
||||
style: TextStyle(
|
||||
fontSize: 14,
|
||||
color: theme.getColorFor(ThemeCode.textPrimary),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
return Text(
|
||||
context.translate(I18n.profileRecentTransactions),
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.w500,
|
||||
fontSize: 18,
|
||||
color: theme.getColorFor(ThemeCode.textPrimary),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
final txIndex = offset - 1;
|
||||
return TransactionTile(transaction: transactions[txIndex]);
|
||||
},
|
||||
itemBuilder: (_, index) => content[index],
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
@@ -43,7 +43,7 @@ class ProfileViewModel extends Notifier<ProfileViewState> {
|
||||
dateFilter: DateFilter.lastWeek,
|
||||
);
|
||||
|
||||
final transactions = await ref
|
||||
final response = await ref
|
||||
.read(walletTransactionsProvider(query).future);
|
||||
|
||||
if (!ref.mounted) return;
|
||||
@@ -52,7 +52,8 @@ class ProfileViewModel extends Notifier<ProfileViewState> {
|
||||
isLoading: false,
|
||||
userName: name,
|
||||
walletId: walletId,
|
||||
transactions: transactions,
|
||||
transactionPages: [response.items],
|
||||
nextCursor: response.nextCursor,
|
||||
);
|
||||
} catch (e) {
|
||||
if (!ref.mounted) return;
|
||||
@@ -60,6 +61,36 @@ class ProfileViewModel extends Notifier<ProfileViewState> {
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> loadMore() async {
|
||||
if (state.isLoadingMore || state.nextCursor == null || state.walletId.isEmpty) return;
|
||||
|
||||
state = state.copyWith(isLoadingMore: true);
|
||||
|
||||
try {
|
||||
final query = TransactionsQuery(
|
||||
walletId: state.walletId,
|
||||
dateFilter: DateFilter.lastWeek,
|
||||
cursor: state.nextCursor,
|
||||
);
|
||||
final response = await ref.read(walletTransactionsProvider(query).future);
|
||||
|
||||
if (!ref.mounted) return;
|
||||
state = state.copyWith(
|
||||
isLoadingMore: false,
|
||||
transactionPages: [...state.transactionPages, response.items],
|
||||
nextCursor: response.nextCursor,
|
||||
currentPage: state.transactionPages.length,
|
||||
);
|
||||
} catch (e) {
|
||||
if (!ref.mounted) return;
|
||||
state = state.copyWith(isLoadingMore: false);
|
||||
}
|
||||
}
|
||||
|
||||
void setPage(int page) {
|
||||
state = state.copyWith(currentPage: page);
|
||||
}
|
||||
|
||||
Future<void> retry() async {
|
||||
await load();
|
||||
}
|
||||
|
||||
@@ -9,7 +9,10 @@ abstract class ProfileViewState with _$ProfileViewState {
|
||||
@Default(false) bool isLoading,
|
||||
@Default('') String userName,
|
||||
@Default('') String walletId,
|
||||
@Default([]) List<WalletTransactionEntity> transactions,
|
||||
@Default([]) List<List<WalletTransactionEntity>> transactionPages,
|
||||
String? nextCursor,
|
||||
@Default(false) bool isLoadingMore,
|
||||
@Default(0) int currentPage,
|
||||
@Default('') String errorMessage,
|
||||
}) = _ProfileViewState;
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ T _$identity<T>(T value) => value;
|
||||
/// @nodoc
|
||||
mixin _$ProfileViewState {
|
||||
|
||||
bool get isLoading; String get userName; String get walletId; List<WalletTransactionEntity> get transactions; String get errorMessage;
|
||||
bool get isLoading; String get userName; String get walletId; List<List<WalletTransactionEntity>> get transactionPages; String? get nextCursor; bool get isLoadingMore; int get currentPage; String get errorMessage;
|
||||
/// Create a copy of ProfileViewState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@@ -25,16 +25,16 @@ $ProfileViewStateCopyWith<ProfileViewState> get copyWith => _$ProfileViewStateCo
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is ProfileViewState&&(identical(other.isLoading, isLoading) || other.isLoading == isLoading)&&(identical(other.userName, userName) || other.userName == userName)&&(identical(other.walletId, walletId) || other.walletId == walletId)&&const DeepCollectionEquality().equals(other.transactions, transactions)&&(identical(other.errorMessage, errorMessage) || other.errorMessage == errorMessage));
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is ProfileViewState&&(identical(other.isLoading, isLoading) || other.isLoading == isLoading)&&(identical(other.userName, userName) || other.userName == userName)&&(identical(other.walletId, walletId) || other.walletId == walletId)&&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)&&(identical(other.errorMessage, errorMessage) || other.errorMessage == errorMessage));
|
||||
}
|
||||
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,isLoading,userName,walletId,const DeepCollectionEquality().hash(transactions),errorMessage);
|
||||
int get hashCode => Object.hash(runtimeType,isLoading,userName,walletId,const DeepCollectionEquality().hash(transactionPages),nextCursor,isLoadingMore,currentPage,errorMessage);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'ProfileViewState(isLoading: $isLoading, userName: $userName, walletId: $walletId, transactions: $transactions, errorMessage: $errorMessage)';
|
||||
return 'ProfileViewState(isLoading: $isLoading, userName: $userName, walletId: $walletId, transactionPages: $transactionPages, nextCursor: $nextCursor, isLoadingMore: $isLoadingMore, currentPage: $currentPage, errorMessage: $errorMessage)';
|
||||
}
|
||||
|
||||
|
||||
@@ -45,7 +45,7 @@ abstract mixin class $ProfileViewStateCopyWith<$Res> {
|
||||
factory $ProfileViewStateCopyWith(ProfileViewState value, $Res Function(ProfileViewState) _then) = _$ProfileViewStateCopyWithImpl;
|
||||
@useResult
|
||||
$Res call({
|
||||
bool isLoading, String userName, String walletId, List<WalletTransactionEntity> transactions, String errorMessage
|
||||
bool isLoading, String userName, String walletId, List<List<WalletTransactionEntity>> transactionPages, String? nextCursor, bool isLoadingMore, int currentPage, String errorMessage
|
||||
});
|
||||
|
||||
|
||||
@@ -62,13 +62,16 @@ class _$ProfileViewStateCopyWithImpl<$Res>
|
||||
|
||||
/// Create a copy of ProfileViewState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline') @override $Res call({Object? isLoading = null,Object? userName = null,Object? walletId = null,Object? transactions = null,Object? errorMessage = null,}) {
|
||||
@pragma('vm:prefer-inline') @override $Res call({Object? isLoading = null,Object? userName = null,Object? walletId = null,Object? transactionPages = null,Object? nextCursor = freezed,Object? isLoadingMore = null,Object? currentPage = null,Object? errorMessage = null,}) {
|
||||
return _then(_self.copyWith(
|
||||
isLoading: null == isLoading ? _self.isLoading : isLoading // ignore: cast_nullable_to_non_nullable
|
||||
as bool,userName: null == userName ? _self.userName : userName // ignore: cast_nullable_to_non_nullable
|
||||
as String,walletId: null == walletId ? _self.walletId : walletId // ignore: cast_nullable_to_non_nullable
|
||||
as String,transactions: null == transactions ? _self.transactions : transactions // ignore: cast_nullable_to_non_nullable
|
||||
as List<WalletTransactionEntity>,errorMessage: null == errorMessage ? _self.errorMessage : errorMessage // ignore: cast_nullable_to_non_nullable
|
||||
as String,transactionPages: null == transactionPages ? _self.transactionPages : transactionPages // ignore: cast_nullable_to_non_nullable
|
||||
as List<List<WalletTransactionEntity>>,nextCursor: freezed == nextCursor ? _self.nextCursor : nextCursor // ignore: cast_nullable_to_non_nullable
|
||||
as String?,isLoadingMore: null == isLoadingMore ? _self.isLoadingMore : isLoadingMore // ignore: cast_nullable_to_non_nullable
|
||||
as bool,currentPage: null == currentPage ? _self.currentPage : currentPage // ignore: cast_nullable_to_non_nullable
|
||||
as int,errorMessage: null == errorMessage ? _self.errorMessage : errorMessage // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
));
|
||||
}
|
||||
@@ -154,10 +157,10 @@ return $default(_that);case _:
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( bool isLoading, String userName, String walletId, List<WalletTransactionEntity> transactions, String errorMessage)? $default,{required TResult orElse(),}) {final _that = this;
|
||||
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( bool isLoading, String userName, String walletId, List<List<WalletTransactionEntity>> transactionPages, String? nextCursor, bool isLoadingMore, int currentPage, String errorMessage)? $default,{required TResult orElse(),}) {final _that = this;
|
||||
switch (_that) {
|
||||
case _ProfileViewState() when $default != null:
|
||||
return $default(_that.isLoading,_that.userName,_that.walletId,_that.transactions,_that.errorMessage);case _:
|
||||
return $default(_that.isLoading,_that.userName,_that.walletId,_that.transactionPages,_that.nextCursor,_that.isLoadingMore,_that.currentPage,_that.errorMessage);case _:
|
||||
return orElse();
|
||||
|
||||
}
|
||||
@@ -175,10 +178,10 @@ return $default(_that.isLoading,_that.userName,_that.walletId,_that.transactions
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( bool isLoading, String userName, String walletId, List<WalletTransactionEntity> transactions, String errorMessage) $default,) {final _that = this;
|
||||
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( bool isLoading, String userName, String walletId, List<List<WalletTransactionEntity>> transactionPages, String? nextCursor, bool isLoadingMore, int currentPage, String errorMessage) $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _ProfileViewState():
|
||||
return $default(_that.isLoading,_that.userName,_that.walletId,_that.transactions,_that.errorMessage);case _:
|
||||
return $default(_that.isLoading,_that.userName,_that.walletId,_that.transactionPages,_that.nextCursor,_that.isLoadingMore,_that.currentPage,_that.errorMessage);case _:
|
||||
throw StateError('Unexpected subclass');
|
||||
|
||||
}
|
||||
@@ -195,10 +198,10 @@ return $default(_that.isLoading,_that.userName,_that.walletId,_that.transactions
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( bool isLoading, String userName, String walletId, List<WalletTransactionEntity> transactions, String errorMessage)? $default,) {final _that = this;
|
||||
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( bool isLoading, String userName, String walletId, List<List<WalletTransactionEntity>> transactionPages, String? nextCursor, bool isLoadingMore, int currentPage, String errorMessage)? $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _ProfileViewState() when $default != null:
|
||||
return $default(_that.isLoading,_that.userName,_that.walletId,_that.transactions,_that.errorMessage);case _:
|
||||
return $default(_that.isLoading,_that.userName,_that.walletId,_that.transactionPages,_that.nextCursor,_that.isLoadingMore,_that.currentPage,_that.errorMessage);case _:
|
||||
return null;
|
||||
|
||||
}
|
||||
@@ -210,19 +213,22 @@ return $default(_that.isLoading,_that.userName,_that.walletId,_that.transactions
|
||||
|
||||
|
||||
class _ProfileViewState implements ProfileViewState {
|
||||
const _ProfileViewState({this.isLoading = false, this.userName = '', this.walletId = '', final List<WalletTransactionEntity> transactions = const [], this.errorMessage = ''}): _transactions = transactions;
|
||||
const _ProfileViewState({this.isLoading = false, this.userName = '', this.walletId = '', final List<List<WalletTransactionEntity>> transactionPages = const [], this.nextCursor, this.isLoadingMore = false, this.currentPage = 0, this.errorMessage = ''}): _transactionPages = transactionPages;
|
||||
|
||||
|
||||
@override@JsonKey() final bool isLoading;
|
||||
@override@JsonKey() final String userName;
|
||||
@override@JsonKey() final String walletId;
|
||||
final List<WalletTransactionEntity> _transactions;
|
||||
@override@JsonKey() List<WalletTransactionEntity> get transactions {
|
||||
if (_transactions is EqualUnmodifiableListView) return _transactions;
|
||||
final List<List<WalletTransactionEntity>> _transactionPages;
|
||||
@override@JsonKey() List<List<WalletTransactionEntity>> get transactionPages {
|
||||
if (_transactionPages is EqualUnmodifiableListView) return _transactionPages;
|
||||
// ignore: implicit_dynamic_type
|
||||
return EqualUnmodifiableListView(_transactions);
|
||||
return EqualUnmodifiableListView(_transactionPages);
|
||||
}
|
||||
|
||||
@override final String? nextCursor;
|
||||
@override@JsonKey() final bool isLoadingMore;
|
||||
@override@JsonKey() final int currentPage;
|
||||
@override@JsonKey() final String errorMessage;
|
||||
|
||||
/// Create a copy of ProfileViewState
|
||||
@@ -235,16 +241,16 @@ _$ProfileViewStateCopyWith<_ProfileViewState> get copyWith => __$ProfileViewStat
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is _ProfileViewState&&(identical(other.isLoading, isLoading) || other.isLoading == isLoading)&&(identical(other.userName, userName) || other.userName == userName)&&(identical(other.walletId, walletId) || other.walletId == walletId)&&const DeepCollectionEquality().equals(other._transactions, _transactions)&&(identical(other.errorMessage, errorMessage) || other.errorMessage == errorMessage));
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is _ProfileViewState&&(identical(other.isLoading, isLoading) || other.isLoading == isLoading)&&(identical(other.userName, userName) || other.userName == userName)&&(identical(other.walletId, walletId) || other.walletId == walletId)&&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)&&(identical(other.errorMessage, errorMessage) || other.errorMessage == errorMessage));
|
||||
}
|
||||
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,isLoading,userName,walletId,const DeepCollectionEquality().hash(_transactions),errorMessage);
|
||||
int get hashCode => Object.hash(runtimeType,isLoading,userName,walletId,const DeepCollectionEquality().hash(_transactionPages),nextCursor,isLoadingMore,currentPage,errorMessage);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'ProfileViewState(isLoading: $isLoading, userName: $userName, walletId: $walletId, transactions: $transactions, errorMessage: $errorMessage)';
|
||||
return 'ProfileViewState(isLoading: $isLoading, userName: $userName, walletId: $walletId, transactionPages: $transactionPages, nextCursor: $nextCursor, isLoadingMore: $isLoadingMore, currentPage: $currentPage, errorMessage: $errorMessage)';
|
||||
}
|
||||
|
||||
|
||||
@@ -255,7 +261,7 @@ abstract mixin class _$ProfileViewStateCopyWith<$Res> implements $ProfileViewSta
|
||||
factory _$ProfileViewStateCopyWith(_ProfileViewState value, $Res Function(_ProfileViewState) _then) = __$ProfileViewStateCopyWithImpl;
|
||||
@override @useResult
|
||||
$Res call({
|
||||
bool isLoading, String userName, String walletId, List<WalletTransactionEntity> transactions, String errorMessage
|
||||
bool isLoading, String userName, String walletId, List<List<WalletTransactionEntity>> transactionPages, String? nextCursor, bool isLoadingMore, int currentPage, String errorMessage
|
||||
});
|
||||
|
||||
|
||||
@@ -272,13 +278,16 @@ class __$ProfileViewStateCopyWithImpl<$Res>
|
||||
|
||||
/// Create a copy of ProfileViewState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override @pragma('vm:prefer-inline') $Res call({Object? isLoading = null,Object? userName = null,Object? walletId = null,Object? transactions = null,Object? errorMessage = null,}) {
|
||||
@override @pragma('vm:prefer-inline') $Res call({Object? isLoading = null,Object? userName = null,Object? walletId = null,Object? transactionPages = null,Object? nextCursor = freezed,Object? isLoadingMore = null,Object? currentPage = null,Object? errorMessage = null,}) {
|
||||
return _then(_ProfileViewState(
|
||||
isLoading: null == isLoading ? _self.isLoading : isLoading // ignore: cast_nullable_to_non_nullable
|
||||
as bool,userName: null == userName ? _self.userName : userName // ignore: cast_nullable_to_non_nullable
|
||||
as String,walletId: null == walletId ? _self.walletId : walletId // ignore: cast_nullable_to_non_nullable
|
||||
as String,transactions: null == transactions ? _self._transactions : transactions // ignore: cast_nullable_to_non_nullable
|
||||
as List<WalletTransactionEntity>,errorMessage: null == errorMessage ? _self.errorMessage : errorMessage // ignore: cast_nullable_to_non_nullable
|
||||
as String,transactionPages: null == transactionPages ? _self._transactionPages : transactionPages // ignore: cast_nullable_to_non_nullable
|
||||
as List<List<WalletTransactionEntity>>,nextCursor: freezed == nextCursor ? _self.nextCursor : nextCursor // ignore: cast_nullable_to_non_nullable
|
||||
as String?,isLoadingMore: null == isLoadingMore ? _self.isLoadingMore : isLoadingMore // ignore: cast_nullable_to_non_nullable
|
||||
as bool,currentPage: null == currentPage ? _self.currentPage : currentPage // ignore: cast_nullable_to_non_nullable
|
||||
as int,errorMessage: null == errorMessage ? _self.errorMessage : errorMessage // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
));
|
||||
}
|
||||
|
||||
@@ -35,6 +35,7 @@ dependencies:
|
||||
|
||||
dio: ^5.9.0
|
||||
#dependencies go here
|
||||
country_code_picker: ^3.4.1
|
||||
sealed_countries: ^2.8.0
|
||||
freezed_annotation: ^3.0.0
|
||||
flutter_riverpod: ^3.0.3
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:sf_shared/sf_shared.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
|
||||
import 'check_session_use_case.dart';
|
||||
import 'initial_route.dart';
|
||||
@@ -7,10 +8,22 @@ import 'initial_route.dart';
|
||||
class CheckSessionUseCaseImpl implements CheckSessionUseCase {
|
||||
CheckSessionUseCaseImpl(this._userRepository);
|
||||
|
||||
static const _onboardingSeenKey = 'onboarding_seen';
|
||||
|
||||
final UserRepository _userRepository;
|
||||
|
||||
@override
|
||||
Future<InitialRoute> execute() async {
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
final onboardingSeen = prefs.getBool(_onboardingSeenKey) ?? false;
|
||||
debugPrint('[CheckSession] onboardingSeen=$onboardingSeen');
|
||||
|
||||
if (!onboardingSeen) {
|
||||
await prefs.setBool(_onboardingSeenKey, true);
|
||||
debugPrint('[CheckSession] → onboarding');
|
||||
return InitialRoute.onboarding;
|
||||
}
|
||||
|
||||
try {
|
||||
await _userRepository.getUserInfo();
|
||||
return InitialRoute.home;
|
||||
|
||||
@@ -1 +1 @@
|
||||
enum InitialRoute { login, home }
|
||||
enum InitialRoute { login, home, onboarding }
|
||||
|
||||
@@ -53,6 +53,7 @@ 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,
|
||||
};
|
||||
|
||||
@@ -29,11 +29,15 @@ class AppRoutes {
|
||||
'${childWallet(childWalletId)}/goals';
|
||||
static String extract(String childWalletId) =>
|
||||
'${childWallet(childWalletId)}/extract';
|
||||
static String editChildProfile(String childWalletId) =>
|
||||
'${childWallet(childWalletId)}/edit';
|
||||
static const dashboardActivity = '$dashboard/activity';
|
||||
static const dashboardNotifications = '$dashboard/notifications';
|
||||
static const dashboardProfile = '$dashboard/profile';
|
||||
static const dashboardProfileSettings = '$dashboardProfile/settings';
|
||||
static const dashboardProfilePayout = '$dashboardProfile/payout';
|
||||
static const dashboardProfileEditPersonalData =
|
||||
'$dashboardProfileSettings/edit-personal-data';
|
||||
static const dashboardProfilePaymentMethods =
|
||||
'$dashboardProfileSettings/payment-methods';
|
||||
|
||||
|
||||
@@ -21,18 +21,17 @@ class TreezorTokenInterceptor extends Interceptor {
|
||||
_handling = true;
|
||||
_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);
|
||||
} else if (err.response?.statusCode == 401) {
|
||||
_handling = true;
|
||||
_onUnauthorized();
|
||||
Future.delayed(const Duration(seconds: 2), () => _handling = false);
|
||||
}
|
||||
// else if (err.response?.statusCode == 401) {
|
||||
// _handling = true;
|
||||
// _onUnauthorized();
|
||||
// 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);
|
||||
// }
|
||||
}
|
||||
|
||||
handler.next(err);
|
||||
}
|
||||
|
||||
|
||||
@@ -273,8 +273,17 @@
|
||||
"transactionCheckRefund": "Scheckerstattung",
|
||||
"transactionSctr": "Banküberweisung",
|
||||
"transactionCreditInternationalTransfer": "Auslandsüberweisung",
|
||||
"transactionBankDirectDebit": "Lastschrift",
|
||||
"transactionBankTransfer": "Banküberweisung",
|
||||
"transactionCardTopup": "Kartenaufladung",
|
||||
"transactionCheck": "Scheck",
|
||||
"transactionCreditNote": "Gutschrift",
|
||||
"transactionFees": "Gebühren",
|
||||
"transactionInstantBankTransfer": "Sofortüberweisung",
|
||||
"transactionWalletTransfer": "Kontotransfer",
|
||||
"transactionUnknown": "Bewegung",
|
||||
"loadMore": "Mehr laden",
|
||||
"transactionsShown": "Bewegungen",
|
||||
|
||||
"profileAccountSettings": "Kontoeinstellungen",
|
||||
"profileWithdrawMoney": "Geld vom Wallet abheben",
|
||||
@@ -382,6 +391,9 @@
|
||||
"deleteDeviceConfirmTitle": "Gerät löschen?",
|
||||
"deleteDeviceConfirmMessage": "Diese Aktion kann nicht rückgängig gemacht werden. Bist du sicher, dass du dieses Gerät löschen möchtest?",
|
||||
"deleteDeviceSuccess": "Gerät erfolgreich gelöscht",
|
||||
"deleteDeviceNotAllowedTitle": "Löschen nicht möglich",
|
||||
"deleteDeviceChecking": "Überprüfung...",
|
||||
"deleteDeviceWalletNonZeroBalance": "Das Profil kann nicht gelöscht werden, da das Wallet ein verfügbares Guthaben hat",
|
||||
|
||||
"limitsSave": "Limits speichern",
|
||||
"limitsSpendingTitle": "Ausgabenlimits setzen",
|
||||
@@ -473,6 +485,13 @@
|
||||
"profileSettingsLogoutConfirm": "Sind Sie sicher, dass Sie sich abmelden möchten?",
|
||||
"profileSettingsLogoutError": "Fehler beim Abmelden",
|
||||
"profileSettingsSave": "Änderungen speichern",
|
||||
"profileSettingsSaveSuccess": "Änderungen erfolgreich gespeichert",
|
||||
"profileSettingsLastName": "Nachname",
|
||||
"profileSettingsStreet": "Straße",
|
||||
"profileSettingsCity": "Stadt",
|
||||
"profileSettingsProvince": "Provinz",
|
||||
"profileSettingsState": "Bundesland",
|
||||
"profileSettingsPostCode": "Postleitzahl",
|
||||
|
||||
"dashboardTabHome": "Startseite",
|
||||
"dashboardTabActivity": "Aktivität",
|
||||
@@ -501,7 +520,7 @@
|
||||
"scheduledActivityStartTime": "Beginn",
|
||||
"scheduledActivityEndTime": "Ende",
|
||||
"scheduledActivityStartBeforeEnd": "Die Startzeit muss vor der Endzeit liegen",
|
||||
"scheduledActivityOverlap": "Überschneidung mit „{name}" ({time})",
|
||||
"scheduledActivityOverlap": "Überschneidung mit „{name}\" ({time})",
|
||||
"scheduledActivityNewTitle": "Neue Aktivität",
|
||||
"scheduledActivityEditTitle": "Aktivität bearbeiten",
|
||||
"scheduledActivityDeleteTitle": "Aktivität löschen",
|
||||
@@ -574,5 +593,8 @@
|
||||
"wifiSsid": "Netzwerkname (SSID)",
|
||||
"wifiBssid": "MAC-Adresse (BSSID)",
|
||||
"wifiSsidHint": "z.B. MeinHeimWLAN",
|
||||
"wifiBssidHint": "z.B. 0c:80:63:e4:cb:e1"
|
||||
"wifiBssidHint": "z.B. 0c:80:63:e4:cb:e1",
|
||||
"editChildProfile": "Profil bearbeiten",
|
||||
"editChildProfileTitle": "Kinderprofil bearbeiten",
|
||||
"editChildProfileSaveSuccess": "Kinderprofil erfolgreich aktualisiert"
|
||||
}
|
||||
@@ -266,8 +266,17 @@
|
||||
"transactionCheckRefund": "Check refund",
|
||||
"transactionSctr": "Credit transfer",
|
||||
"transactionCreditInternationalTransfer": "International transfer",
|
||||
"transactionBankDirectDebit": "Direct debit",
|
||||
"transactionBankTransfer": "Bank transfer",
|
||||
"transactionCardTopup": "Card top-up",
|
||||
"transactionCheck": "Check",
|
||||
"transactionCreditNote": "Credit note",
|
||||
"transactionFees": "Fees",
|
||||
"transactionInstantBankTransfer": "Instant transfer",
|
||||
"transactionWalletTransfer": "Wallet transfer",
|
||||
"transactionUnknown": "Transaction",
|
||||
"loadMore": "Load more",
|
||||
"transactionsShown": "transactions",
|
||||
"profileAccountSettings": "Account settings",
|
||||
"profileWithdrawMoney": "Withdraw money from wallet",
|
||||
"profileNoRecentTransactions": "No recent transactions",
|
||||
@@ -364,6 +373,9 @@
|
||||
"deleteDeviceConfirmTitle": "Delete device?",
|
||||
"deleteDeviceConfirmMessage": "This action cannot be undone. Are you sure you want to delete this device?",
|
||||
"deleteDeviceSuccess": "Device deleted successfully",
|
||||
"deleteDeviceNotAllowedTitle": "Cannot delete",
|
||||
"deleteDeviceChecking": "Checking...",
|
||||
"deleteDeviceWalletNonZeroBalance": "Cannot delete the profile because the wallet has a non-zero balance",
|
||||
"limitsSave": "Save limits",
|
||||
"limitsSpendingTitle": "Set spending limits",
|
||||
"limitsSpendingSubtitle": "Freedom for them, peace of mind for you",
|
||||
@@ -452,6 +464,13 @@
|
||||
"profileSettingsLogoutConfirm": "Are you sure you want to log out?",
|
||||
"profileSettingsLogoutError": "Error logging out",
|
||||
"profileSettingsSave": "Save changes",
|
||||
"profileSettingsSaveSuccess": "Changes saved successfully",
|
||||
"profileSettingsLastName": "Last name",
|
||||
"profileSettingsStreet": "Street",
|
||||
"profileSettingsCity": "City",
|
||||
"profileSettingsProvince": "Province",
|
||||
"profileSettingsState": "State",
|
||||
"profileSettingsPostCode": "Post code",
|
||||
"dashboardTabHome": "Home",
|
||||
"dashboardTabActivity": "Activity",
|
||||
"dashboardTabNotifications": "Notifications",
|
||||
@@ -683,5 +702,8 @@
|
||||
"wifiSsid": "Network name (SSID)",
|
||||
"wifiBssid": "MAC address (BSSID)",
|
||||
"wifiSsidHint": "e.g. MyHomeWiFi",
|
||||
"wifiBssidHint": "e.g. 0c:80:63:e4:cb:e1"
|
||||
"wifiBssidHint": "e.g. 0c:80:63:e4:cb:e1",
|
||||
"editChildProfile": "Edit profile",
|
||||
"editChildProfileSaveSuccess": "Child profile updated successfully",
|
||||
"editChildProfileTitle": "Edit child profile"
|
||||
}
|
||||
@@ -266,8 +266,17 @@
|
||||
"transactionCheckRefund": "Reembolso de cheque",
|
||||
"transactionSctr": "Transferencia bancaria",
|
||||
"transactionCreditInternationalTransfer": "Transferencia internacional",
|
||||
"transactionBankDirectDebit": "Domiciliación bancaria",
|
||||
"transactionBankTransfer": "Transferencia bancaria",
|
||||
"transactionCardTopup": "Recarga con tarjeta",
|
||||
"transactionCheck": "Cheque",
|
||||
"transactionCreditNote": "Nota de crédito",
|
||||
"transactionFees": "Comisiones",
|
||||
"transactionInstantBankTransfer": "Transferencia instantánea",
|
||||
"transactionWalletTransfer": "Transferencia entre cuentas",
|
||||
"transactionUnknown": "Movimiento",
|
||||
"loadMore": "Cargar más",
|
||||
"transactionsShown": "movimientos",
|
||||
"profileAccountSettings": "Ajustes de la cuenta",
|
||||
"profileWithdrawMoney": "Retirar dinero del wallet",
|
||||
"profileNoRecentTransactions": "No hay movimientos recientes",
|
||||
@@ -363,6 +372,9 @@
|
||||
"deleteDeviceConfirmTitle": "¿Eliminar dispositivo?",
|
||||
"deleteDeviceConfirmMessage": "Esta acción no se puede deshacer. ¿Estás seguro de que quieres eliminar este dispositivo?",
|
||||
"deleteDeviceSuccess": "Dispositivo eliminado correctamente",
|
||||
"deleteDeviceNotAllowedTitle": "No se puede eliminar",
|
||||
"deleteDeviceChecking": "Comprobando...",
|
||||
"deleteDeviceWalletNonZeroBalance": "No se puede eliminar el perfil porque la cartera tiene saldo disponible",
|
||||
"limitsSave": "Guardar límites",
|
||||
"limitsSpendingTitle": "Pon límite de gastos",
|
||||
"limitsSpendingSubtitle": "Libertad para ellos, tranquilidad para ti",
|
||||
@@ -451,6 +463,13 @@
|
||||
"profileSettingsLogoutConfirm": "¿Estás seguro de que deseas cerrar sesión?",
|
||||
"profileSettingsLogoutError": "Error al cerrar sesión",
|
||||
"profileSettingsSave": "Guardar cambios",
|
||||
"profileSettingsSaveSuccess": "Cambios guardados correctamente",
|
||||
"profileSettingsLastName": "Apellido",
|
||||
"profileSettingsStreet": "Calle",
|
||||
"profileSettingsCity": "Ciudad",
|
||||
"profileSettingsProvince": "Provincia",
|
||||
"profileSettingsState": "Estado",
|
||||
"profileSettingsPostCode": "Código postal",
|
||||
"dashboardTabHome": "Inicio",
|
||||
"dashboardTabActivity": "Actividad",
|
||||
"dashboardTabNotifications": "Notificaciones",
|
||||
@@ -681,5 +700,8 @@
|
||||
"wifiSsid": "Nombre de red (SSID)",
|
||||
"wifiBssid": "Dirección MAC (BSSID)",
|
||||
"wifiSsidHint": "ej. MiWiFiCasa",
|
||||
"wifiBssidHint": "ej. 0c:80:63:e4:cb:e1"
|
||||
"wifiBssidHint": "ej. 0c:80:63:e4:cb:e1",
|
||||
"editChildProfile": "Editar perfil",
|
||||
"editChildProfileTitle": "Editar perfil del niño",
|
||||
"editChildProfileSaveSuccess": "Perfil del niño actualizado correctamente"
|
||||
}
|
||||
@@ -273,8 +273,17 @@
|
||||
"transactionCheckRefund": "Remboursement de chèque",
|
||||
"transactionSctr": "Virement bancaire",
|
||||
"transactionCreditInternationalTransfer": "Virement international",
|
||||
"transactionBankDirectDebit": "Prélèvement bancaire",
|
||||
"transactionBankTransfer": "Virement bancaire",
|
||||
"transactionCardTopup": "Rechargement par carte",
|
||||
"transactionCheck": "Chèque",
|
||||
"transactionCreditNote": "Avoir",
|
||||
"transactionFees": "Frais",
|
||||
"transactionInstantBankTransfer": "Virement instantané",
|
||||
"transactionWalletTransfer": "Transfert entre comptes",
|
||||
"transactionUnknown": "Mouvement",
|
||||
"loadMore": "Charger plus",
|
||||
"transactionsShown": "mouvements",
|
||||
|
||||
"profileAccountSettings": "Paramètres du compte",
|
||||
"profileWithdrawMoney": "Retirer de l'argent du portefeuille",
|
||||
@@ -382,6 +391,9 @@
|
||||
"deleteDeviceConfirmTitle": "Supprimer l'appareil ?",
|
||||
"deleteDeviceConfirmMessage": "Cette action est irréversible. Êtes-vous sûr de vouloir supprimer cet appareil ?",
|
||||
"deleteDeviceSuccess": "Appareil supprimé avec succès",
|
||||
"deleteDeviceNotAllowedTitle": "Suppression impossible",
|
||||
"deleteDeviceChecking": "Vérification...",
|
||||
"deleteDeviceWalletNonZeroBalance": "Impossible de supprimer le profil car le portefeuille a un solde disponible",
|
||||
|
||||
"limitsSave": "Enregistrer les limites",
|
||||
"limitsSpendingTitle": "Fixe des limites de dépenses",
|
||||
@@ -473,6 +485,13 @@
|
||||
"profileSettingsLogoutConfirm": "Êtes-vous sûr de vouloir vous déconnecter ?",
|
||||
"profileSettingsLogoutError": "Erreur lors de la déconnexion",
|
||||
"profileSettingsSave": "Enregistrer les modifications",
|
||||
"profileSettingsSaveSuccess": "Modifications enregistrées avec succès",
|
||||
"profileSettingsLastName": "Nom de famille",
|
||||
"profileSettingsStreet": "Rue",
|
||||
"profileSettingsCity": "Ville",
|
||||
"profileSettingsProvince": "Province",
|
||||
"profileSettingsState": "État",
|
||||
"profileSettingsPostCode": "Code postal",
|
||||
|
||||
"dashboardTabHome": "Accueil",
|
||||
"dashboardTabActivity": "Activité",
|
||||
@@ -574,5 +593,8 @@
|
||||
"wifiSsid": "Nom du réseau (SSID)",
|
||||
"wifiBssid": "Adresse MAC (BSSID)",
|
||||
"wifiSsidHint": "ex. MonWiFiMaison",
|
||||
"wifiBssidHint": "ex. 0c:80:63:e4:cb:e1"
|
||||
"wifiBssidHint": "ex. 0c:80:63:e4:cb:e1",
|
||||
"editChildProfile": "Modifier le profil",
|
||||
"editChildProfileTitle": "Modifier le profil de l'enfant",
|
||||
"editChildProfileSaveSuccess": "Profil de l'enfant mis à jour avec succès"
|
||||
}
|
||||
@@ -273,8 +273,17 @@
|
||||
"transactionCheckRefund": "Rimborso assegno",
|
||||
"transactionSctr": "Bonifico bancario",
|
||||
"transactionCreditInternationalTransfer": "Bonifico internazionale",
|
||||
"transactionBankDirectDebit": "Addebito diretto",
|
||||
"transactionBankTransfer": "Bonifico bancario",
|
||||
"transactionCardTopup": "Ricarica con carta",
|
||||
"transactionCheck": "Assegno",
|
||||
"transactionCreditNote": "Nota di credito",
|
||||
"transactionFees": "Commissioni",
|
||||
"transactionInstantBankTransfer": "Bonifico istantaneo",
|
||||
"transactionWalletTransfer": "Trasferimento tra conti",
|
||||
"transactionUnknown": "Movimento",
|
||||
"loadMore": "Carica altro",
|
||||
"transactionsShown": "movimenti",
|
||||
|
||||
"profileAccountSettings": "Impostazioni account",
|
||||
"profileWithdrawMoney": "Preleva denaro dal portafoglio",
|
||||
@@ -382,6 +391,9 @@
|
||||
"deleteDeviceConfirmTitle": "Eliminare il dispositivo?",
|
||||
"deleteDeviceConfirmMessage": "Questa azione non può essere annullata. Sei sicuro di voler eliminare questo dispositivo?",
|
||||
"deleteDeviceSuccess": "Dispositivo eliminato con successo",
|
||||
"deleteDeviceNotAllowedTitle": "Impossibile eliminare",
|
||||
"deleteDeviceChecking": "Verifica in corso...",
|
||||
"deleteDeviceWalletNonZeroBalance": "Impossibile eliminare il profilo perché il portafoglio ha un saldo disponibile",
|
||||
|
||||
"limitsSave": "Salva limiti",
|
||||
"limitsSpendingTitle": "Imposta limiti di spesa",
|
||||
@@ -473,6 +485,13 @@
|
||||
"profileSettingsLogoutConfirm": "Sei sicuro di voler uscire?",
|
||||
"profileSettingsLogoutError": "Errore durante la disconnessione",
|
||||
"profileSettingsSave": "Salva modifiche",
|
||||
"profileSettingsSaveSuccess": "Modifiche salvate con successo",
|
||||
"profileSettingsLastName": "Cognome",
|
||||
"profileSettingsStreet": "Via",
|
||||
"profileSettingsCity": "Città",
|
||||
"profileSettingsProvince": "Provincia",
|
||||
"profileSettingsState": "Stato",
|
||||
"profileSettingsPostCode": "Codice postale",
|
||||
|
||||
"dashboardTabHome": "Home",
|
||||
"dashboardTabActivity": "Attività",
|
||||
@@ -574,5 +593,8 @@
|
||||
"wifiSsid": "Nome rete (SSID)",
|
||||
"wifiBssid": "Indirizzo MAC (BSSID)",
|
||||
"wifiSsidHint": "es. MiaReteCasa",
|
||||
"wifiBssidHint": "es. 0c:80:63:e4:cb:e1"
|
||||
"wifiBssidHint": "es. 0c:80:63:e4:cb:e1",
|
||||
"editChildProfile": "Modifica profilo",
|
||||
"editChildProfileTitle": "Modifica profilo del bambino",
|
||||
"editChildProfileSaveSuccess": "Profilo del bambino aggiornato con successo"
|
||||
}
|
||||
@@ -273,8 +273,17 @@
|
||||
"transactionCheckRefund": "Reembolso de cheque",
|
||||
"transactionSctr": "Transferência bancária",
|
||||
"transactionCreditInternationalTransfer": "Transferência internacional",
|
||||
"transactionBankDirectDebit": "Débito direto",
|
||||
"transactionBankTransfer": "Transferência bancária",
|
||||
"transactionCardTopup": "Carregamento com cartão",
|
||||
"transactionCheck": "Cheque",
|
||||
"transactionCreditNote": "Nota de crédito",
|
||||
"transactionFees": "Taxas",
|
||||
"transactionInstantBankTransfer": "Transferência instantânea",
|
||||
"transactionWalletTransfer": "Transferência entre contas",
|
||||
"transactionUnknown": "Movimento",
|
||||
"loadMore": "Carregar mais",
|
||||
"transactionsShown": "movimentos",
|
||||
|
||||
"profileAccountSettings": "Definições da conta",
|
||||
"profileWithdrawMoney": "Levantar dinheiro da carteira",
|
||||
@@ -382,6 +391,9 @@
|
||||
"deleteDeviceConfirmTitle": "Eliminar dispositivo?",
|
||||
"deleteDeviceConfirmMessage": "Esta ação não pode ser desfeita. Tens a certeza de que queres eliminar este dispositivo?",
|
||||
"deleteDeviceSuccess": "Dispositivo eliminado com sucesso",
|
||||
"deleteDeviceNotAllowedTitle": "Não é possível eliminar",
|
||||
"deleteDeviceChecking": "A verificar...",
|
||||
"deleteDeviceWalletNonZeroBalance": "Não é possível eliminar o perfil porque a carteira tem saldo disponível",
|
||||
|
||||
"limitsSave": "Guardar limites",
|
||||
"limitsSpendingTitle": "Define limite de gastos",
|
||||
@@ -473,6 +485,13 @@
|
||||
"profileSettingsLogoutConfirm": "Tem a certeza de que deseja terminar sessão?",
|
||||
"profileSettingsLogoutError": "Erro ao terminar sessão",
|
||||
"profileSettingsSave": "Guardar alterações",
|
||||
"profileSettingsSaveSuccess": "Alterações guardadas com sucesso",
|
||||
"profileSettingsLastName": "Apelido",
|
||||
"profileSettingsStreet": "Rua",
|
||||
"profileSettingsCity": "Cidade",
|
||||
"profileSettingsProvince": "Província",
|
||||
"profileSettingsState": "Estado",
|
||||
"profileSettingsPostCode": "Código postal",
|
||||
|
||||
"dashboardTabHome": "Início",
|
||||
"dashboardTabActivity": "Atividade",
|
||||
@@ -574,5 +593,8 @@
|
||||
"wifiSsid": "Nome da rede (SSID)",
|
||||
"wifiBssid": "Endereço MAC (BSSID)",
|
||||
"wifiSsidHint": "ex. MinhaRedeWiFi",
|
||||
"wifiBssidHint": "ex. 0c:80:63:e4:cb:e1"
|
||||
"wifiBssidHint": "ex. 0c:80:63:e4:cb:e1",
|
||||
"editChildProfile": "Editar perfil",
|
||||
"editChildProfileTitle": "Editar perfil da criança",
|
||||
"editChildProfileSaveSuccess": "Perfil da criança atualizado com sucesso"
|
||||
}
|
||||
@@ -327,8 +327,17 @@ class I18n {
|
||||
static const String transactionSctr = 'transactionSctr';
|
||||
static const String transactionCreditInternationalTransfer =
|
||||
'transactionCreditInternationalTransfer';
|
||||
static const String transactionBankDirectDebit = 'transactionBankDirectDebit';
|
||||
static const String transactionBankTransfer = 'transactionBankTransfer';
|
||||
static const String transactionCardTopup = 'transactionCardTopup';
|
||||
static const String transactionCheck = 'transactionCheck';
|
||||
static const String transactionCreditNote = 'transactionCreditNote';
|
||||
static const String transactionFees = 'transactionFees';
|
||||
static const String transactionInstantBankTransfer = 'transactionInstantBankTransfer';
|
||||
static const String transactionWalletTransfer = 'transactionWalletTransfer';
|
||||
static const String transactionUnknown = 'transactionUnknown';
|
||||
static const String loadMore = 'loadMore';
|
||||
static const String transactionsShown = 'transactionsShown';
|
||||
static const String profileAccountSettings = 'profileAccountSettings';
|
||||
static const String profileWithdrawMoney = 'profileWithdrawMoney';
|
||||
static const String profileNoRecentTransactions =
|
||||
@@ -451,6 +460,9 @@ class I18n {
|
||||
static const String deleteDeviceConfirmTitle = 'deleteDeviceConfirmTitle';
|
||||
static const String deleteDeviceConfirmMessage = 'deleteDeviceConfirmMessage';
|
||||
static const String deleteDeviceSuccess = 'deleteDeviceSuccess';
|
||||
static const String deleteDeviceNotAllowedTitle = 'deleteDeviceNotAllowedTitle';
|
||||
static const String deleteDeviceChecking = 'deleteDeviceChecking';
|
||||
static const String deleteDeviceWalletNonZeroBalance = 'deleteDeviceWalletNonZeroBalance';
|
||||
|
||||
// Limits
|
||||
static const String limitsSave = 'limitsSave';
|
||||
@@ -542,6 +554,13 @@ class I18n {
|
||||
'profileSettingsLogoutConfirm';
|
||||
static const String profileSettingsLogoutError = 'profileSettingsLogoutError';
|
||||
static const String profileSettingsSave = 'profileSettingsSave';
|
||||
static const String profileSettingsSaveSuccess = 'profileSettingsSaveSuccess';
|
||||
static const String profileSettingsLastName = 'profileSettingsLastName';
|
||||
static const String profileSettingsStreet = 'profileSettingsStreet';
|
||||
static const String profileSettingsCity = 'profileSettingsCity';
|
||||
static const String profileSettingsProvince = 'profileSettingsProvince';
|
||||
static const String profileSettingsState = 'profileSettingsState';
|
||||
static const String profileSettingsPostCode = 'profileSettingsPostCode';
|
||||
|
||||
// Account Documents
|
||||
static const String accountDetails = 'accountDetails';
|
||||
@@ -807,4 +826,7 @@ class I18n {
|
||||
static const String wifiBssid = 'wifiBssid';
|
||||
static const String wifiSsidHint = 'wifiSsidHint';
|
||||
static const String wifiBssidHint = 'wifiBssidHint';
|
||||
static const String editChildProfile = 'editChildProfile';
|
||||
static const String editChildProfileTitle = 'editChildProfileTitle';
|
||||
static const String editChildProfileSaveSuccess = 'editChildProfileSaveSuccess';
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@ export 'src/domain/entities/payment_profile_entity.dart';
|
||||
export 'src/domain/use_cases/get_payment_profile_use_case.dart';
|
||||
export 'src/providers/get_payment_profile_use_case_provider.dart';
|
||||
export 'src/domain/entities/child_profile_entity.dart';
|
||||
export 'src/domain/entities/child_profile_deletability_entity.dart';
|
||||
export 'src/domain/entities/wallet_balance_entity.dart';
|
||||
export 'src/domain/entities/wallet_transaction_entity.dart';
|
||||
export 'src/domain/entities/user_entity.dart';
|
||||
|
||||
@@ -7,7 +7,7 @@ import 'package:sf_shared/src/data/models/transaction_beneficiary_model.dart';
|
||||
import 'package:sf_shared/src/data/models/wallet_balance_model.dart';
|
||||
import 'package:sf_shared/src/data/models/wallet_card_model.dart';
|
||||
import 'package:sf_shared/src/data/models/wallet_limits_model.dart';
|
||||
import 'package:sf_shared/src/data/models/wallet_transaction_model.dart';
|
||||
import 'package:sf_shared/src/data/models/wallet_operation_model.dart';
|
||||
|
||||
abstract class TreezorRemoteDatasource {
|
||||
Future<ScaWalletsResponseModel> scaWallets();
|
||||
@@ -20,7 +20,12 @@ abstract class TreezorRemoteDatasource {
|
||||
required String userId,
|
||||
});
|
||||
|
||||
Future<WalletTransactionsResponseModel> getWalletTransactions({
|
||||
Future<PaymentProfileResponseModel> updatePaymentProfile({
|
||||
required String paymentProfileId,
|
||||
required Map<String, dynamic> body,
|
||||
});
|
||||
|
||||
Future<WalletOperationsResponseModel> getWalletOperations({
|
||||
required String walletId,
|
||||
Map<String, dynamic>? queryParameters,
|
||||
});
|
||||
@@ -32,13 +37,13 @@ abstract class TreezorRemoteDatasource {
|
||||
Future<TransactionBeneficiaryModel> createTransactionBeneficiary({
|
||||
required String name,
|
||||
required String iban,
|
||||
String? bic,
|
||||
required String scaProof,
|
||||
});
|
||||
|
||||
Future<String> validateTransactionBeneficiary({required int beneficiaryId});
|
||||
|
||||
Future<void> walletTransfer({
|
||||
required String walletId,
|
||||
required int beneficiaryId,
|
||||
required String beneficiaryValidationId,
|
||||
required double amount,
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:sf_infrastructure/sf_infrastructure.dart';
|
||||
import 'package:sf_shared/src/data/models/child_wallet_model.dart';
|
||||
@@ -12,7 +11,7 @@ import 'package:sf_shared/src/data/models/transaction_beneficiary_model.dart';
|
||||
import 'package:sf_shared/src/data/models/wallet_balance_model.dart';
|
||||
import 'package:sf_shared/src/data/models/wallet_card_model.dart';
|
||||
import 'package:sf_shared/src/data/models/wallet_limits_model.dart';
|
||||
import 'package:sf_shared/src/data/models/wallet_transaction_model.dart';
|
||||
import 'package:sf_shared/src/data/models/wallet_operation_model.dart';
|
||||
|
||||
import 'treezor_remote_data_source.dart';
|
||||
|
||||
@@ -120,26 +119,53 @@ class TreezorRemoteDatasourceImpl implements TreezorRemoteDatasource {
|
||||
}
|
||||
|
||||
@override
|
||||
Future<WalletTransactionsResponseModel> getWalletTransactions({
|
||||
Future<PaymentProfileResponseModel> updatePaymentProfile({
|
||||
required String paymentProfileId,
|
||||
required Map<String, dynamic> body,
|
||||
}) async {
|
||||
try {
|
||||
final response = await _repository.put<Map<String, dynamic>>(
|
||||
'/payment-profiles',
|
||||
body: body,
|
||||
);
|
||||
|
||||
final data = response.data;
|
||||
if (data == null || data.isEmpty) {
|
||||
throw Exception(
|
||||
'Empty response from PUT /payment-profiles/$paymentProfileId',
|
||||
);
|
||||
}
|
||||
|
||||
return PaymentProfileResponseModel.fromJson(data);
|
||||
} on DioException catch (error) {
|
||||
throw _mapDioError(
|
||||
error,
|
||||
defaultMessage: 'Error in PUT /payment-profiles/$paymentProfileId',
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Future<WalletOperationsResponseModel> getWalletOperations({
|
||||
required String walletId,
|
||||
Map<String, dynamic>? queryParameters,
|
||||
}) async {
|
||||
try {
|
||||
final response = await _repository.get<Map<String, dynamic>>(
|
||||
'/wallets/$walletId/transactions',
|
||||
'/wallets/$walletId/operations',
|
||||
queryParameters: queryParameters,
|
||||
);
|
||||
|
||||
final data = response.data;
|
||||
if (data == null || data.isEmpty) {
|
||||
throw Exception('Empty response from /wallets/$walletId/transactions');
|
||||
throw Exception('Empty response from /wallets/$walletId/operations');
|
||||
}
|
||||
|
||||
return WalletTransactionsResponseModel.fromJson(data);
|
||||
return WalletOperationsResponseModel.fromJson(data);
|
||||
} on DioException catch (error) {
|
||||
throw _mapDioError(
|
||||
error,
|
||||
defaultMessage: 'Error in /wallets/$walletId/transactions',
|
||||
defaultMessage: 'Error in /wallets/$walletId/operations',
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -183,16 +209,19 @@ class TreezorRemoteDatasourceImpl implements TreezorRemoteDatasource {
|
||||
Future<TransactionBeneficiaryModel> createTransactionBeneficiary({
|
||||
required String name,
|
||||
required String iban,
|
||||
String? bic,
|
||||
required String scaProof,
|
||||
}) async {
|
||||
try {
|
||||
final body = <String, dynamic>{
|
||||
'name': name,
|
||||
'iban': iban,
|
||||
if (bic != null && bic.isNotEmpty) 'bic': bic,
|
||||
'scaProof': scaProof,
|
||||
};
|
||||
final response = await _repository.post<Map<String, dynamic>>(
|
||||
'/transaction-beneficiaries',
|
||||
body: <String, dynamic>{
|
||||
'name': name,
|
||||
'iban': iban,
|
||||
'scaProof': scaProof,
|
||||
},
|
||||
body: body,
|
||||
);
|
||||
|
||||
final data = response.data;
|
||||
@@ -236,7 +265,6 @@ class TreezorRemoteDatasourceImpl implements TreezorRemoteDatasource {
|
||||
|
||||
@override
|
||||
Future<void> walletTransfer({
|
||||
required String walletId,
|
||||
required int beneficiaryId,
|
||||
required String beneficiaryValidationId,
|
||||
required double amount,
|
||||
@@ -244,13 +272,11 @@ class TreezorRemoteDatasourceImpl implements TreezorRemoteDatasource {
|
||||
}) async {
|
||||
try {
|
||||
final body = <String, dynamic>{
|
||||
'walletId': walletId,
|
||||
'target': beneficiaryId,
|
||||
'beneficiaryValidationId': beneficiaryValidationId,
|
||||
'amount': amount.toStringAsFixed(2),
|
||||
'scaProof': scaProof,
|
||||
};
|
||||
debugPrint('[Payout] POST /wallets/transfer body: $body');
|
||||
await _repository.post<void>('/wallets/transfer', body: body);
|
||||
} on DioException catch (error) {
|
||||
throw _mapDioError(error, defaultMessage: 'Error in /wallets/transfer');
|
||||
@@ -512,7 +538,6 @@ class TreezorRemoteDatasourceImpl implements TreezorRemoteDatasource {
|
||||
}) async {
|
||||
try {
|
||||
final body = limits.toJson()..removeWhere((_, v) => v == null);
|
||||
debugPrint('setWalletLimits body: $body');
|
||||
await _repository.post<void>('/wallets/$walletId/limits', body: body);
|
||||
} on DioException catch (error) {
|
||||
throw _mapDioError(
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import 'package:sf_shared/src/data/models/child_profile_deletability_model.dart';
|
||||
import 'package:sf_shared/src/data/models/child_profile_response_model.dart';
|
||||
import 'package:sf_shared/src/data/models/device_model.dart';
|
||||
import 'package:sf_shared/src/data/models/user_response_model.dart';
|
||||
@@ -5,6 +6,13 @@ import 'package:sf_shared/src/data/models/user_response_model.dart';
|
||||
abstract class UserRemoteDatasource {
|
||||
Future<UserModel> getUserInfo();
|
||||
Future<ChildProfileResponseModel> getChildProfiles();
|
||||
Future<ChildProfileDeletabilityModel> checkChildProfileDeletability({
|
||||
required String childProfileId,
|
||||
});
|
||||
Future<DeviceModel> getDeviceByIdentificator({required String identificator});
|
||||
Future<String> deleteDevice({required String deviceId});
|
||||
Future<void> updateChildProfile({
|
||||
required String childProfileId,
|
||||
required Map<String, dynamic> body,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:sf_infrastructure/sf_infrastructure.dart';
|
||||
import 'package:sf_shared/src/data/models/child_profile_deletability_model.dart';
|
||||
import 'package:sf_shared/src/data/models/child_profile_response_model.dart';
|
||||
import 'package:sf_shared/src/data/models/device_model.dart';
|
||||
import 'package:sf_shared/src/data/models/user_response_model.dart';
|
||||
@@ -45,6 +45,31 @@ class UserRemoteDatasourceImpl implements UserRemoteDatasource {
|
||||
return ChildProfileResponseModel.fromJson(data);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<ChildProfileDeletabilityModel> checkChildProfileDeletability({
|
||||
required String childProfileId,
|
||||
}) async {
|
||||
try {
|
||||
final response = await _repository.get<Map<String, dynamic>>(
|
||||
'/child-profiles/$childProfileId/deletability',
|
||||
);
|
||||
final data = response.data;
|
||||
if (data == null || data.isEmpty) {
|
||||
throw Exception(
|
||||
'Empty response from /child-profiles/$childProfileId/deletability',
|
||||
);
|
||||
}
|
||||
final inner = data['item'] as Map<String, dynamic>? ?? data;
|
||||
return ChildProfileDeletabilityModel.fromJson(inner);
|
||||
} on DioException catch (error) {
|
||||
final apiMsg = error.response?.data;
|
||||
final msg = apiMsg is String
|
||||
? apiMsg
|
||||
: (error.message ?? 'Error checking child profile deletability');
|
||||
throw Exception(msg);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Future<DeviceModel> getDeviceByIdentificator({
|
||||
required String identificator,
|
||||
@@ -54,7 +79,6 @@ class UserRemoteDatasourceImpl implements UserRemoteDatasource {
|
||||
'/devices/identificator/$identificator',
|
||||
);
|
||||
final data = response.data;
|
||||
debugPrint('Response from /devices/identificator/$identificator: $data');
|
||||
if (data == null || data.isEmpty) {
|
||||
throw Exception(
|
||||
'Empty response from /devices/identificator/$identificator',
|
||||
@@ -73,6 +97,25 @@ class UserRemoteDatasourceImpl implements UserRemoteDatasource {
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> updateChildProfile({
|
||||
required String childProfileId,
|
||||
required Map<String, dynamic> body,
|
||||
}) async {
|
||||
try {
|
||||
await _repository.put<Map<String, dynamic>>(
|
||||
'/child-profiles/$childProfileId',
|
||||
body: body,
|
||||
);
|
||||
} on DioException catch (error) {
|
||||
final apiMsg = error.response?.data;
|
||||
final msg = apiMsg is String
|
||||
? apiMsg
|
||||
: (error.message ?? 'Error updating child profile');
|
||||
throw Exception(msg);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Future<String> deleteDevice({required String deviceId}) async {
|
||||
try {
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
import 'package:sf_shared/src/domain/entities/child_profile_deletability_entity.dart';
|
||||
|
||||
part 'child_profile_deletability_model.freezed.dart';
|
||||
part 'child_profile_deletability_model.g.dart';
|
||||
|
||||
@freezed
|
||||
abstract class ChildProfileDeletabilityModel
|
||||
with _$ChildProfileDeletabilityModel {
|
||||
const factory ChildProfileDeletabilityModel({
|
||||
required bool deletable,
|
||||
@Default('') String reason,
|
||||
}) = _ChildProfileDeletabilityModel;
|
||||
|
||||
factory ChildProfileDeletabilityModel.fromJson(Map<String, dynamic> json) =>
|
||||
_$ChildProfileDeletabilityModelFromJson(json);
|
||||
}
|
||||
|
||||
extension ChildProfileDeletabilityModelMapper
|
||||
on ChildProfileDeletabilityModel {
|
||||
ChildProfileDeletabilityEntity toEntity() {
|
||||
return ChildProfileDeletabilityEntity(
|
||||
isDeletable: deletable,
|
||||
reason: reason,
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,280 @@
|
||||
// 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 'child_profile_deletability_model.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// FreezedGenerator
|
||||
// **************************************************************************
|
||||
|
||||
// dart format off
|
||||
T _$identity<T>(T value) => value;
|
||||
|
||||
/// @nodoc
|
||||
mixin _$ChildProfileDeletabilityModel {
|
||||
|
||||
bool get deletable; String get reason;
|
||||
/// Create a copy of ChildProfileDeletabilityModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@pragma('vm:prefer-inline')
|
||||
$ChildProfileDeletabilityModelCopyWith<ChildProfileDeletabilityModel> get copyWith => _$ChildProfileDeletabilityModelCopyWithImpl<ChildProfileDeletabilityModel>(this as ChildProfileDeletabilityModel, _$identity);
|
||||
|
||||
/// Serializes this ChildProfileDeletabilityModel to a JSON map.
|
||||
Map<String, dynamic> toJson();
|
||||
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is ChildProfileDeletabilityModel&&(identical(other.deletable, deletable) || other.deletable == deletable)&&(identical(other.reason, reason) || other.reason == reason));
|
||||
}
|
||||
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,deletable,reason);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'ChildProfileDeletabilityModel(deletable: $deletable, reason: $reason)';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract mixin class $ChildProfileDeletabilityModelCopyWith<$Res> {
|
||||
factory $ChildProfileDeletabilityModelCopyWith(ChildProfileDeletabilityModel value, $Res Function(ChildProfileDeletabilityModel) _then) = _$ChildProfileDeletabilityModelCopyWithImpl;
|
||||
@useResult
|
||||
$Res call({
|
||||
bool deletable, String reason
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
/// @nodoc
|
||||
class _$ChildProfileDeletabilityModelCopyWithImpl<$Res>
|
||||
implements $ChildProfileDeletabilityModelCopyWith<$Res> {
|
||||
_$ChildProfileDeletabilityModelCopyWithImpl(this._self, this._then);
|
||||
|
||||
final ChildProfileDeletabilityModel _self;
|
||||
final $Res Function(ChildProfileDeletabilityModel) _then;
|
||||
|
||||
/// Create a copy of ChildProfileDeletabilityModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline') @override $Res call({Object? deletable = null,Object? reason = null,}) {
|
||||
return _then(_self.copyWith(
|
||||
deletable: null == deletable ? _self.deletable : deletable // ignore: cast_nullable_to_non_nullable
|
||||
as bool,reason: null == reason ? _self.reason : reason // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// Adds pattern-matching-related methods to [ChildProfileDeletabilityModel].
|
||||
extension ChildProfileDeletabilityModelPatterns on ChildProfileDeletabilityModel {
|
||||
/// 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( _ChildProfileDeletabilityModel value)? $default,{required TResult orElse(),}){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _ChildProfileDeletabilityModel() 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( _ChildProfileDeletabilityModel value) $default,){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _ChildProfileDeletabilityModel():
|
||||
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( _ChildProfileDeletabilityModel value)? $default,){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _ChildProfileDeletabilityModel() 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 deletable, String reason)? $default,{required TResult orElse(),}) {final _that = this;
|
||||
switch (_that) {
|
||||
case _ChildProfileDeletabilityModel() when $default != null:
|
||||
return $default(_that.deletable,_that.reason);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 deletable, String reason) $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _ChildProfileDeletabilityModel():
|
||||
return $default(_that.deletable,_that.reason);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 deletable, String reason)? $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _ChildProfileDeletabilityModel() when $default != null:
|
||||
return $default(_that.deletable,_that.reason);case _:
|
||||
return null;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
@JsonSerializable()
|
||||
|
||||
class _ChildProfileDeletabilityModel implements ChildProfileDeletabilityModel {
|
||||
const _ChildProfileDeletabilityModel({required this.deletable, this.reason = ''});
|
||||
factory _ChildProfileDeletabilityModel.fromJson(Map<String, dynamic> json) => _$ChildProfileDeletabilityModelFromJson(json);
|
||||
|
||||
@override final bool deletable;
|
||||
@override@JsonKey() final String reason;
|
||||
|
||||
/// Create a copy of ChildProfileDeletabilityModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override @JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@pragma('vm:prefer-inline')
|
||||
_$ChildProfileDeletabilityModelCopyWith<_ChildProfileDeletabilityModel> get copyWith => __$ChildProfileDeletabilityModelCopyWithImpl<_ChildProfileDeletabilityModel>(this, _$identity);
|
||||
|
||||
@override
|
||||
Map<String, dynamic> toJson() {
|
||||
return _$ChildProfileDeletabilityModelToJson(this, );
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is _ChildProfileDeletabilityModel&&(identical(other.deletable, deletable) || other.deletable == deletable)&&(identical(other.reason, reason) || other.reason == reason));
|
||||
}
|
||||
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,deletable,reason);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'ChildProfileDeletabilityModel(deletable: $deletable, reason: $reason)';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract mixin class _$ChildProfileDeletabilityModelCopyWith<$Res> implements $ChildProfileDeletabilityModelCopyWith<$Res> {
|
||||
factory _$ChildProfileDeletabilityModelCopyWith(_ChildProfileDeletabilityModel value, $Res Function(_ChildProfileDeletabilityModel) _then) = __$ChildProfileDeletabilityModelCopyWithImpl;
|
||||
@override @useResult
|
||||
$Res call({
|
||||
bool deletable, String reason
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
/// @nodoc
|
||||
class __$ChildProfileDeletabilityModelCopyWithImpl<$Res>
|
||||
implements _$ChildProfileDeletabilityModelCopyWith<$Res> {
|
||||
__$ChildProfileDeletabilityModelCopyWithImpl(this._self, this._then);
|
||||
|
||||
final _ChildProfileDeletabilityModel _self;
|
||||
final $Res Function(_ChildProfileDeletabilityModel) _then;
|
||||
|
||||
/// Create a copy of ChildProfileDeletabilityModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override @pragma('vm:prefer-inline') $Res call({Object? deletable = null,Object? reason = null,}) {
|
||||
return _then(_ChildProfileDeletabilityModel(
|
||||
deletable: null == deletable ? _self.deletable : deletable // ignore: cast_nullable_to_non_nullable
|
||||
as bool,reason: null == reason ? _self.reason : reason // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
// dart format on
|
||||
@@ -0,0 +1,21 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'child_profile_deletability_model.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
_ChildProfileDeletabilityModel _$ChildProfileDeletabilityModelFromJson(
|
||||
Map<String, dynamic> json,
|
||||
) => _ChildProfileDeletabilityModel(
|
||||
deletable: json['deletable'] as bool,
|
||||
reason: json['reason'] as String? ?? '',
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$ChildProfileDeletabilityModelToJson(
|
||||
_ChildProfileDeletabilityModel instance,
|
||||
) => <String, dynamic>{
|
||||
'deletable': instance.deletable,
|
||||
'reason': instance.reason,
|
||||
};
|
||||
@@ -0,0 +1,163 @@
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
import 'package:sf_shared/src/domain/entities/wallet_transaction_entity.dart';
|
||||
|
||||
part 'wallet_operation_model.freezed.dart';
|
||||
part 'wallet_operation_model.g.dart';
|
||||
|
||||
@freezed
|
||||
abstract class WalletOperationsResponseModel
|
||||
with _$WalletOperationsResponseModel {
|
||||
const factory WalletOperationsResponseModel({
|
||||
OperationCursorModel? cursor,
|
||||
@Default([]) List<WalletOperationModel> data,
|
||||
}) = _WalletOperationsResponseModel;
|
||||
|
||||
factory WalletOperationsResponseModel.fromJson(Map<String, dynamic> json) =>
|
||||
_$WalletOperationsResponseModelFromJson(json);
|
||||
}
|
||||
|
||||
@freezed
|
||||
abstract class OperationCursorModel with _$OperationCursorModel {
|
||||
const factory OperationCursorModel({
|
||||
String? prev,
|
||||
String? current,
|
||||
String? next,
|
||||
}) = _OperationCursorModel;
|
||||
|
||||
factory OperationCursorModel.fromJson(Map<String, dynamic> json) =>
|
||||
_$OperationCursorModelFromJson(json);
|
||||
}
|
||||
|
||||
@freezed
|
||||
abstract class WalletOperationModel with _$WalletOperationModel {
|
||||
const factory WalletOperationModel({
|
||||
@Default('') String operationType,
|
||||
@Default('') String initialFlow,
|
||||
OperationAmountModel? amount,
|
||||
@Default(0) int walletId,
|
||||
@Default('') String direction,
|
||||
@Default('') String objectId,
|
||||
@Default('') String label,
|
||||
@Default('') String status,
|
||||
OperationDateModel? date,
|
||||
OperationMetadataModel? metadata,
|
||||
}) = _WalletOperationModel;
|
||||
|
||||
factory WalletOperationModel.fromJson(Map<String, dynamic> json) =>
|
||||
_$WalletOperationModelFromJson(json);
|
||||
}
|
||||
|
||||
@freezed
|
||||
abstract class OperationAmountModel with _$OperationAmountModel {
|
||||
const factory OperationAmountModel({
|
||||
@Default(0.0) double amount,
|
||||
@Default('EUR') String currency,
|
||||
}) = _OperationAmountModel;
|
||||
|
||||
factory OperationAmountModel.fromJson(Map<String, dynamic> json) =>
|
||||
_$OperationAmountModelFromJson(json);
|
||||
}
|
||||
|
||||
@freezed
|
||||
abstract class OperationDateModel with _$OperationDateModel {
|
||||
const factory OperationDateModel({
|
||||
String? creation,
|
||||
String? settlement,
|
||||
}) = _OperationDateModel;
|
||||
|
||||
factory OperationDateModel.fromJson(Map<String, dynamic> json) =>
|
||||
_$OperationDateModelFromJson(json);
|
||||
}
|
||||
|
||||
@freezed
|
||||
abstract class OperationMetadataModel with _$OperationMetadataModel {
|
||||
const factory OperationMetadataModel({
|
||||
String? maskedPan,
|
||||
String? cardId,
|
||||
OperationMccModel? mcc,
|
||||
OperationMidModel? mid,
|
||||
OperationAmountModel? localAmount,
|
||||
String? is3DS,
|
||||
String? optimizedMerchantName,
|
||||
String? merchantLogo,
|
||||
String? merchantCategory,
|
||||
String? merchantCategoryGroup,
|
||||
String? paymentCountry,
|
||||
String? authorizationNote,
|
||||
String? messageToUser,
|
||||
OperationAuthResponseModel? authorisationResponseCode,
|
||||
}) = _OperationMetadataModel;
|
||||
|
||||
factory OperationMetadataModel.fromJson(Map<String, dynamic> json) =>
|
||||
_$OperationMetadataModelFromJson(json);
|
||||
}
|
||||
|
||||
@freezed
|
||||
abstract class OperationMccModel with _$OperationMccModel {
|
||||
const factory OperationMccModel({
|
||||
@Default(0) int code,
|
||||
}) = _OperationMccModel;
|
||||
|
||||
factory OperationMccModel.fromJson(Map<String, dynamic> json) =>
|
||||
_$OperationMccModelFromJson(json);
|
||||
}
|
||||
|
||||
@freezed
|
||||
abstract class OperationMidModel with _$OperationMidModel {
|
||||
const factory OperationMidModel({
|
||||
String? value,
|
||||
String? name,
|
||||
String? city,
|
||||
String? country,
|
||||
String? address,
|
||||
}) = _OperationMidModel;
|
||||
|
||||
factory OperationMidModel.fromJson(Map<String, dynamic> json) =>
|
||||
_$OperationMidModelFromJson(json);
|
||||
}
|
||||
|
||||
@freezed
|
||||
abstract class OperationAuthResponseModel with _$OperationAuthResponseModel {
|
||||
const factory OperationAuthResponseModel({
|
||||
String? action,
|
||||
String? description,
|
||||
int? value,
|
||||
}) = _OperationAuthResponseModel;
|
||||
|
||||
factory OperationAuthResponseModel.fromJson(Map<String, dynamic> json) =>
|
||||
_$OperationAuthResponseModelFromJson(json);
|
||||
}
|
||||
|
||||
extension WalletOperationsResponseModelMapper
|
||||
on WalletOperationsResponseModel {
|
||||
WalletTransactionsResponseEntity toEntity() {
|
||||
return WalletTransactionsResponseEntity(
|
||||
items: data.map((op) => op.toEntity()).toList(),
|
||||
nextCursor: cursor?.next,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
extension WalletOperationModelMapper on WalletOperationModel {
|
||||
WalletTransactionEntity toEntity() {
|
||||
return WalletTransactionEntity(
|
||||
operationType: TransactionType.fromString(operationType),
|
||||
direction: direction,
|
||||
objectId: objectId,
|
||||
label: label,
|
||||
status: status,
|
||||
amount: (amount?.amount ?? 0.0) / 100,
|
||||
currency: amount?.currency ?? 'EUR',
|
||||
createdDate: date?.creation ?? '',
|
||||
settlementDate: date?.settlement,
|
||||
merchantName: metadata?.optimizedMerchantName ?? metadata?.mid?.name,
|
||||
merchantLogo: metadata?.merchantLogo,
|
||||
merchantCategory: metadata?.merchantCategory,
|
||||
merchantCategoryGroup: metadata?.merchantCategoryGroup,
|
||||
merchantCity: metadata?.mid?.city,
|
||||
merchantCountry: metadata?.mid?.country,
|
||||
maskedPan: metadata?.maskedPan,
|
||||
messageToUser: metadata?.messageToUser,
|
||||
);
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,194 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'wallet_operation_model.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
_WalletOperationsResponseModel _$WalletOperationsResponseModelFromJson(
|
||||
Map<String, dynamic> json,
|
||||
) => _WalletOperationsResponseModel(
|
||||
cursor: json['cursor'] == null
|
||||
? null
|
||||
: OperationCursorModel.fromJson(json['cursor'] as Map<String, dynamic>),
|
||||
data:
|
||||
(json['data'] as List<dynamic>?)
|
||||
?.map((e) => WalletOperationModel.fromJson(e as Map<String, dynamic>))
|
||||
.toList() ??
|
||||
const [],
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$WalletOperationsResponseModelToJson(
|
||||
_WalletOperationsResponseModel instance,
|
||||
) => <String, dynamic>{'cursor': instance.cursor, 'data': instance.data};
|
||||
|
||||
_OperationCursorModel _$OperationCursorModelFromJson(
|
||||
Map<String, dynamic> json,
|
||||
) => _OperationCursorModel(
|
||||
prev: json['prev'] as String?,
|
||||
current: json['current'] as String?,
|
||||
next: json['next'] as String?,
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$OperationCursorModelToJson(
|
||||
_OperationCursorModel instance,
|
||||
) => <String, dynamic>{
|
||||
'prev': instance.prev,
|
||||
'current': instance.current,
|
||||
'next': instance.next,
|
||||
};
|
||||
|
||||
_WalletOperationModel _$WalletOperationModelFromJson(
|
||||
Map<String, dynamic> json,
|
||||
) => _WalletOperationModel(
|
||||
operationType: json['operationType'] as String? ?? '',
|
||||
initialFlow: json['initialFlow'] as String? ?? '',
|
||||
amount: json['amount'] == null
|
||||
? null
|
||||
: OperationAmountModel.fromJson(json['amount'] as Map<String, dynamic>),
|
||||
walletId: (json['walletId'] as num?)?.toInt() ?? 0,
|
||||
direction: json['direction'] as String? ?? '',
|
||||
objectId: json['objectId'] as String? ?? '',
|
||||
label: json['label'] as String? ?? '',
|
||||
status: json['status'] as String? ?? '',
|
||||
date: json['date'] == null
|
||||
? null
|
||||
: OperationDateModel.fromJson(json['date'] as Map<String, dynamic>),
|
||||
metadata: json['metadata'] == null
|
||||
? null
|
||||
: OperationMetadataModel.fromJson(
|
||||
json['metadata'] as Map<String, dynamic>,
|
||||
),
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$WalletOperationModelToJson(
|
||||
_WalletOperationModel instance,
|
||||
) => <String, dynamic>{
|
||||
'operationType': instance.operationType,
|
||||
'initialFlow': instance.initialFlow,
|
||||
'amount': instance.amount,
|
||||
'walletId': instance.walletId,
|
||||
'direction': instance.direction,
|
||||
'objectId': instance.objectId,
|
||||
'label': instance.label,
|
||||
'status': instance.status,
|
||||
'date': instance.date,
|
||||
'metadata': instance.metadata,
|
||||
};
|
||||
|
||||
_OperationAmountModel _$OperationAmountModelFromJson(
|
||||
Map<String, dynamic> json,
|
||||
) => _OperationAmountModel(
|
||||
amount: (json['amount'] as num?)?.toDouble() ?? 0.0,
|
||||
currency: json['currency'] as String? ?? 'EUR',
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$OperationAmountModelToJson(
|
||||
_OperationAmountModel instance,
|
||||
) => <String, dynamic>{
|
||||
'amount': instance.amount,
|
||||
'currency': instance.currency,
|
||||
};
|
||||
|
||||
_OperationDateModel _$OperationDateModelFromJson(Map<String, dynamic> json) =>
|
||||
_OperationDateModel(
|
||||
creation: json['creation'] as String?,
|
||||
settlement: json['settlement'] as String?,
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$OperationDateModelToJson(_OperationDateModel instance) =>
|
||||
<String, dynamic>{
|
||||
'creation': instance.creation,
|
||||
'settlement': instance.settlement,
|
||||
};
|
||||
|
||||
_OperationMetadataModel _$OperationMetadataModelFromJson(
|
||||
Map<String, dynamic> json,
|
||||
) => _OperationMetadataModel(
|
||||
maskedPan: json['maskedPan'] as String?,
|
||||
cardId: json['cardId'] as String?,
|
||||
mcc: json['mcc'] == null
|
||||
? null
|
||||
: OperationMccModel.fromJson(json['mcc'] as Map<String, dynamic>),
|
||||
mid: json['mid'] == null
|
||||
? null
|
||||
: OperationMidModel.fromJson(json['mid'] as Map<String, dynamic>),
|
||||
localAmount: json['localAmount'] == null
|
||||
? null
|
||||
: OperationAmountModel.fromJson(
|
||||
json['localAmount'] as Map<String, dynamic>,
|
||||
),
|
||||
is3DS: json['is3DS'] as String?,
|
||||
optimizedMerchantName: json['optimizedMerchantName'] as String?,
|
||||
merchantLogo: json['merchantLogo'] as String?,
|
||||
merchantCategory: json['merchantCategory'] as String?,
|
||||
merchantCategoryGroup: json['merchantCategoryGroup'] as String?,
|
||||
paymentCountry: json['paymentCountry'] as String?,
|
||||
authorizationNote: json['authorizationNote'] as String?,
|
||||
messageToUser: json['messageToUser'] as String?,
|
||||
authorisationResponseCode: json['authorisationResponseCode'] == null
|
||||
? null
|
||||
: OperationAuthResponseModel.fromJson(
|
||||
json['authorisationResponseCode'] as Map<String, dynamic>,
|
||||
),
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$OperationMetadataModelToJson(
|
||||
_OperationMetadataModel instance,
|
||||
) => <String, dynamic>{
|
||||
'maskedPan': instance.maskedPan,
|
||||
'cardId': instance.cardId,
|
||||
'mcc': instance.mcc,
|
||||
'mid': instance.mid,
|
||||
'localAmount': instance.localAmount,
|
||||
'is3DS': instance.is3DS,
|
||||
'optimizedMerchantName': instance.optimizedMerchantName,
|
||||
'merchantLogo': instance.merchantLogo,
|
||||
'merchantCategory': instance.merchantCategory,
|
||||
'merchantCategoryGroup': instance.merchantCategoryGroup,
|
||||
'paymentCountry': instance.paymentCountry,
|
||||
'authorizationNote': instance.authorizationNote,
|
||||
'messageToUser': instance.messageToUser,
|
||||
'authorisationResponseCode': instance.authorisationResponseCode,
|
||||
};
|
||||
|
||||
_OperationMccModel _$OperationMccModelFromJson(Map<String, dynamic> json) =>
|
||||
_OperationMccModel(code: (json['code'] as num?)?.toInt() ?? 0);
|
||||
|
||||
Map<String, dynamic> _$OperationMccModelToJson(_OperationMccModel instance) =>
|
||||
<String, dynamic>{'code': instance.code};
|
||||
|
||||
_OperationMidModel _$OperationMidModelFromJson(Map<String, dynamic> json) =>
|
||||
_OperationMidModel(
|
||||
value: json['value'] as String?,
|
||||
name: json['name'] as String?,
|
||||
city: json['city'] as String?,
|
||||
country: json['country'] as String?,
|
||||
address: json['address'] as String?,
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$OperationMidModelToJson(_OperationMidModel instance) =>
|
||||
<String, dynamic>{
|
||||
'value': instance.value,
|
||||
'name': instance.name,
|
||||
'city': instance.city,
|
||||
'country': instance.country,
|
||||
'address': instance.address,
|
||||
};
|
||||
|
||||
_OperationAuthResponseModel _$OperationAuthResponseModelFromJson(
|
||||
Map<String, dynamic> json,
|
||||
) => _OperationAuthResponseModel(
|
||||
action: json['action'] as String?,
|
||||
description: json['description'] as String?,
|
||||
value: (json['value'] as num?)?.toInt(),
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$OperationAuthResponseModelToJson(
|
||||
_OperationAuthResponseModel instance,
|
||||
) => <String, dynamic>{
|
||||
'action': instance.action,
|
||||
'description': instance.description,
|
||||
'value': instance.value,
|
||||
};
|
||||
@@ -1,78 +0,0 @@
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
import 'package:sf_shared/src/domain/entities/wallet_transaction_entity.dart';
|
||||
|
||||
part 'wallet_transaction_model.freezed.dart';
|
||||
part 'wallet_transaction_model.g.dart';
|
||||
|
||||
@freezed
|
||||
abstract class WalletTransactionsResponseModel
|
||||
with _$WalletTransactionsResponseModel {
|
||||
const factory WalletTransactionsResponseModel({
|
||||
required int total,
|
||||
required int page,
|
||||
required int pages,
|
||||
required List<WalletTransactionModel> items,
|
||||
}) = _WalletTransactionsResponseModel;
|
||||
|
||||
factory WalletTransactionsResponseModel.fromJson(
|
||||
Map<String, dynamic> json,
|
||||
) => _$WalletTransactionsResponseModelFromJson(json);
|
||||
}
|
||||
|
||||
@freezed
|
||||
abstract class WalletTransactionModel with _$WalletTransactionModel {
|
||||
const factory WalletTransactionModel({
|
||||
required int transactionId,
|
||||
required int walletDebitId,
|
||||
required int walletCreditId,
|
||||
required String transactionType,
|
||||
required String foreignId,
|
||||
required String name,
|
||||
required String description,
|
||||
required String valueDate,
|
||||
required String executionDate,
|
||||
required String amount,
|
||||
required String walletDebitBalance,
|
||||
required String walletCreditBalance,
|
||||
required String currency,
|
||||
required String createdDate,
|
||||
required String totalRows,
|
||||
}) = _WalletTransactionModel;
|
||||
|
||||
factory WalletTransactionModel.fromJson(Map<String, dynamic> json) =>
|
||||
_$WalletTransactionModelFromJson(json);
|
||||
}
|
||||
|
||||
extension WalletTransactionsResponseModelMapper
|
||||
on WalletTransactionsResponseModel {
|
||||
WalletTransactionsResponseEntity toEntity() {
|
||||
return WalletTransactionsResponseEntity(
|
||||
total: total,
|
||||
page: page,
|
||||
pages: pages,
|
||||
items: items.map((item) => item.toEntity()).toList(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
extension WalletTransactionModelMapper on WalletTransactionModel {
|
||||
WalletTransactionEntity toEntity() {
|
||||
return WalletTransactionEntity(
|
||||
transactionId: transactionId,
|
||||
walletDebitId: walletDebitId,
|
||||
walletCreditId: walletCreditId,
|
||||
transactionType: TransactionType.fromString(transactionType),
|
||||
foreignId: foreignId,
|
||||
name: name,
|
||||
description: description,
|
||||
valueDate: valueDate,
|
||||
executionDate: executionDate,
|
||||
amount: amount,
|
||||
walletDebitBalance: walletDebitBalance,
|
||||
walletCreditBalance: walletCreditBalance,
|
||||
currency: currency,
|
||||
createdDate: createdDate,
|
||||
totalRows: totalRows,
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,597 +0,0 @@
|
||||
// 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 'wallet_transaction_model.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// FreezedGenerator
|
||||
// **************************************************************************
|
||||
|
||||
// dart format off
|
||||
T _$identity<T>(T value) => value;
|
||||
|
||||
/// @nodoc
|
||||
mixin _$WalletTransactionsResponseModel {
|
||||
|
||||
int get total; int get page; int get pages; List<WalletTransactionModel> get items;
|
||||
/// Create a copy of WalletTransactionsResponseModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@pragma('vm:prefer-inline')
|
||||
$WalletTransactionsResponseModelCopyWith<WalletTransactionsResponseModel> get copyWith => _$WalletTransactionsResponseModelCopyWithImpl<WalletTransactionsResponseModel>(this as WalletTransactionsResponseModel, _$identity);
|
||||
|
||||
/// Serializes this WalletTransactionsResponseModel to a JSON map.
|
||||
Map<String, dynamic> toJson();
|
||||
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is WalletTransactionsResponseModel&&(identical(other.total, total) || other.total == total)&&(identical(other.page, page) || other.page == page)&&(identical(other.pages, pages) || other.pages == pages)&&const DeepCollectionEquality().equals(other.items, items));
|
||||
}
|
||||
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,total,page,pages,const DeepCollectionEquality().hash(items));
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'WalletTransactionsResponseModel(total: $total, page: $page, pages: $pages, items: $items)';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract mixin class $WalletTransactionsResponseModelCopyWith<$Res> {
|
||||
factory $WalletTransactionsResponseModelCopyWith(WalletTransactionsResponseModel value, $Res Function(WalletTransactionsResponseModel) _then) = _$WalletTransactionsResponseModelCopyWithImpl;
|
||||
@useResult
|
||||
$Res call({
|
||||
int total, int page, int pages, List<WalletTransactionModel> items
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
/// @nodoc
|
||||
class _$WalletTransactionsResponseModelCopyWithImpl<$Res>
|
||||
implements $WalletTransactionsResponseModelCopyWith<$Res> {
|
||||
_$WalletTransactionsResponseModelCopyWithImpl(this._self, this._then);
|
||||
|
||||
final WalletTransactionsResponseModel _self;
|
||||
final $Res Function(WalletTransactionsResponseModel) _then;
|
||||
|
||||
/// Create a copy of WalletTransactionsResponseModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline') @override $Res call({Object? total = null,Object? page = null,Object? pages = null,Object? items = null,}) {
|
||||
return _then(_self.copyWith(
|
||||
total: null == total ? _self.total : total // ignore: cast_nullable_to_non_nullable
|
||||
as int,page: null == page ? _self.page : page // ignore: cast_nullable_to_non_nullable
|
||||
as int,pages: null == pages ? _self.pages : pages // ignore: cast_nullable_to_non_nullable
|
||||
as int,items: null == items ? _self.items : items // ignore: cast_nullable_to_non_nullable
|
||||
as List<WalletTransactionModel>,
|
||||
));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// Adds pattern-matching-related methods to [WalletTransactionsResponseModel].
|
||||
extension WalletTransactionsResponseModelPatterns on WalletTransactionsResponseModel {
|
||||
/// 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( _WalletTransactionsResponseModel value)? $default,{required TResult orElse(),}){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _WalletTransactionsResponseModel() 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( _WalletTransactionsResponseModel value) $default,){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _WalletTransactionsResponseModel():
|
||||
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( _WalletTransactionsResponseModel value)? $default,){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _WalletTransactionsResponseModel() 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( int total, int page, int pages, List<WalletTransactionModel> items)? $default,{required TResult orElse(),}) {final _that = this;
|
||||
switch (_that) {
|
||||
case _WalletTransactionsResponseModel() when $default != null:
|
||||
return $default(_that.total,_that.page,_that.pages,_that.items);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( int total, int page, int pages, List<WalletTransactionModel> items) $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _WalletTransactionsResponseModel():
|
||||
return $default(_that.total,_that.page,_that.pages,_that.items);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( int total, int page, int pages, List<WalletTransactionModel> items)? $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _WalletTransactionsResponseModel() when $default != null:
|
||||
return $default(_that.total,_that.page,_that.pages,_that.items);case _:
|
||||
return null;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
@JsonSerializable()
|
||||
|
||||
class _WalletTransactionsResponseModel implements WalletTransactionsResponseModel {
|
||||
const _WalletTransactionsResponseModel({required this.total, required this.page, required this.pages, required final List<WalletTransactionModel> items}): _items = items;
|
||||
factory _WalletTransactionsResponseModel.fromJson(Map<String, dynamic> json) => _$WalletTransactionsResponseModelFromJson(json);
|
||||
|
||||
@override final int total;
|
||||
@override final int page;
|
||||
@override final int pages;
|
||||
final List<WalletTransactionModel> _items;
|
||||
@override List<WalletTransactionModel> get items {
|
||||
if (_items is EqualUnmodifiableListView) return _items;
|
||||
// ignore: implicit_dynamic_type
|
||||
return EqualUnmodifiableListView(_items);
|
||||
}
|
||||
|
||||
|
||||
/// Create a copy of WalletTransactionsResponseModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override @JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@pragma('vm:prefer-inline')
|
||||
_$WalletTransactionsResponseModelCopyWith<_WalletTransactionsResponseModel> get copyWith => __$WalletTransactionsResponseModelCopyWithImpl<_WalletTransactionsResponseModel>(this, _$identity);
|
||||
|
||||
@override
|
||||
Map<String, dynamic> toJson() {
|
||||
return _$WalletTransactionsResponseModelToJson(this, );
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is _WalletTransactionsResponseModel&&(identical(other.total, total) || other.total == total)&&(identical(other.page, page) || other.page == page)&&(identical(other.pages, pages) || other.pages == pages)&&const DeepCollectionEquality().equals(other._items, _items));
|
||||
}
|
||||
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,total,page,pages,const DeepCollectionEquality().hash(_items));
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'WalletTransactionsResponseModel(total: $total, page: $page, pages: $pages, items: $items)';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract mixin class _$WalletTransactionsResponseModelCopyWith<$Res> implements $WalletTransactionsResponseModelCopyWith<$Res> {
|
||||
factory _$WalletTransactionsResponseModelCopyWith(_WalletTransactionsResponseModel value, $Res Function(_WalletTransactionsResponseModel) _then) = __$WalletTransactionsResponseModelCopyWithImpl;
|
||||
@override @useResult
|
||||
$Res call({
|
||||
int total, int page, int pages, List<WalletTransactionModel> items
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
/// @nodoc
|
||||
class __$WalletTransactionsResponseModelCopyWithImpl<$Res>
|
||||
implements _$WalletTransactionsResponseModelCopyWith<$Res> {
|
||||
__$WalletTransactionsResponseModelCopyWithImpl(this._self, this._then);
|
||||
|
||||
final _WalletTransactionsResponseModel _self;
|
||||
final $Res Function(_WalletTransactionsResponseModel) _then;
|
||||
|
||||
/// Create a copy of WalletTransactionsResponseModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override @pragma('vm:prefer-inline') $Res call({Object? total = null,Object? page = null,Object? pages = null,Object? items = null,}) {
|
||||
return _then(_WalletTransactionsResponseModel(
|
||||
total: null == total ? _self.total : total // ignore: cast_nullable_to_non_nullable
|
||||
as int,page: null == page ? _self.page : page // ignore: cast_nullable_to_non_nullable
|
||||
as int,pages: null == pages ? _self.pages : pages // ignore: cast_nullable_to_non_nullable
|
||||
as int,items: null == items ? _self._items : items // ignore: cast_nullable_to_non_nullable
|
||||
as List<WalletTransactionModel>,
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// @nodoc
|
||||
mixin _$WalletTransactionModel {
|
||||
|
||||
int get transactionId; int get walletDebitId; int get walletCreditId; String get transactionType; String get foreignId; String get name; String get description; String get valueDate; String get executionDate; String get amount; String get walletDebitBalance; String get walletCreditBalance; String get currency; String get createdDate; String get totalRows;
|
||||
/// Create a copy of WalletTransactionModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@pragma('vm:prefer-inline')
|
||||
$WalletTransactionModelCopyWith<WalletTransactionModel> get copyWith => _$WalletTransactionModelCopyWithImpl<WalletTransactionModel>(this as WalletTransactionModel, _$identity);
|
||||
|
||||
/// Serializes this WalletTransactionModel to a JSON map.
|
||||
Map<String, dynamic> toJson();
|
||||
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is WalletTransactionModel&&(identical(other.transactionId, transactionId) || other.transactionId == transactionId)&&(identical(other.walletDebitId, walletDebitId) || other.walletDebitId == walletDebitId)&&(identical(other.walletCreditId, walletCreditId) || other.walletCreditId == walletCreditId)&&(identical(other.transactionType, transactionType) || other.transactionType == transactionType)&&(identical(other.foreignId, foreignId) || other.foreignId == foreignId)&&(identical(other.name, name) || other.name == name)&&(identical(other.description, description) || other.description == description)&&(identical(other.valueDate, valueDate) || other.valueDate == valueDate)&&(identical(other.executionDate, executionDate) || other.executionDate == executionDate)&&(identical(other.amount, amount) || other.amount == amount)&&(identical(other.walletDebitBalance, walletDebitBalance) || other.walletDebitBalance == walletDebitBalance)&&(identical(other.walletCreditBalance, walletCreditBalance) || other.walletCreditBalance == walletCreditBalance)&&(identical(other.currency, currency) || other.currency == currency)&&(identical(other.createdDate, createdDate) || other.createdDate == createdDate)&&(identical(other.totalRows, totalRows) || other.totalRows == totalRows));
|
||||
}
|
||||
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,transactionId,walletDebitId,walletCreditId,transactionType,foreignId,name,description,valueDate,executionDate,amount,walletDebitBalance,walletCreditBalance,currency,createdDate,totalRows);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'WalletTransactionModel(transactionId: $transactionId, walletDebitId: $walletDebitId, walletCreditId: $walletCreditId, transactionType: $transactionType, foreignId: $foreignId, name: $name, description: $description, valueDate: $valueDate, executionDate: $executionDate, amount: $amount, walletDebitBalance: $walletDebitBalance, walletCreditBalance: $walletCreditBalance, currency: $currency, createdDate: $createdDate, totalRows: $totalRows)';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract mixin class $WalletTransactionModelCopyWith<$Res> {
|
||||
factory $WalletTransactionModelCopyWith(WalletTransactionModel value, $Res Function(WalletTransactionModel) _then) = _$WalletTransactionModelCopyWithImpl;
|
||||
@useResult
|
||||
$Res call({
|
||||
int transactionId, int walletDebitId, int walletCreditId, String transactionType, String foreignId, String name, String description, String valueDate, String executionDate, String amount, String walletDebitBalance, String walletCreditBalance, String currency, String createdDate, String totalRows
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
/// @nodoc
|
||||
class _$WalletTransactionModelCopyWithImpl<$Res>
|
||||
implements $WalletTransactionModelCopyWith<$Res> {
|
||||
_$WalletTransactionModelCopyWithImpl(this._self, this._then);
|
||||
|
||||
final WalletTransactionModel _self;
|
||||
final $Res Function(WalletTransactionModel) _then;
|
||||
|
||||
/// Create a copy of WalletTransactionModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline') @override $Res call({Object? transactionId = null,Object? walletDebitId = null,Object? walletCreditId = null,Object? transactionType = null,Object? foreignId = null,Object? name = null,Object? description = null,Object? valueDate = null,Object? executionDate = null,Object? amount = null,Object? walletDebitBalance = null,Object? walletCreditBalance = null,Object? currency = null,Object? createdDate = null,Object? totalRows = null,}) {
|
||||
return _then(_self.copyWith(
|
||||
transactionId: null == transactionId ? _self.transactionId : transactionId // ignore: cast_nullable_to_non_nullable
|
||||
as int,walletDebitId: null == walletDebitId ? _self.walletDebitId : walletDebitId // ignore: cast_nullable_to_non_nullable
|
||||
as int,walletCreditId: null == walletCreditId ? _self.walletCreditId : walletCreditId // ignore: cast_nullable_to_non_nullable
|
||||
as int,transactionType: null == transactionType ? _self.transactionType : transactionType // ignore: cast_nullable_to_non_nullable
|
||||
as String,foreignId: null == foreignId ? _self.foreignId : foreignId // ignore: cast_nullable_to_non_nullable
|
||||
as String,name: null == name ? _self.name : name // ignore: cast_nullable_to_non_nullable
|
||||
as String,description: null == description ? _self.description : description // ignore: cast_nullable_to_non_nullable
|
||||
as String,valueDate: null == valueDate ? _self.valueDate : valueDate // ignore: cast_nullable_to_non_nullable
|
||||
as String,executionDate: null == executionDate ? _self.executionDate : executionDate // ignore: cast_nullable_to_non_nullable
|
||||
as String,amount: null == amount ? _self.amount : amount // ignore: cast_nullable_to_non_nullable
|
||||
as String,walletDebitBalance: null == walletDebitBalance ? _self.walletDebitBalance : walletDebitBalance // ignore: cast_nullable_to_non_nullable
|
||||
as String,walletCreditBalance: null == walletCreditBalance ? _self.walletCreditBalance : walletCreditBalance // ignore: cast_nullable_to_non_nullable
|
||||
as String,currency: null == currency ? _self.currency : currency // ignore: cast_nullable_to_non_nullable
|
||||
as String,createdDate: null == createdDate ? _self.createdDate : createdDate // ignore: cast_nullable_to_non_nullable
|
||||
as String,totalRows: null == totalRows ? _self.totalRows : totalRows // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// Adds pattern-matching-related methods to [WalletTransactionModel].
|
||||
extension WalletTransactionModelPatterns on WalletTransactionModel {
|
||||
/// 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( _WalletTransactionModel value)? $default,{required TResult orElse(),}){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _WalletTransactionModel() 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( _WalletTransactionModel value) $default,){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _WalletTransactionModel():
|
||||
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( _WalletTransactionModel value)? $default,){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _WalletTransactionModel() 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( int transactionId, int walletDebitId, int walletCreditId, String transactionType, String foreignId, String name, String description, String valueDate, String executionDate, String amount, String walletDebitBalance, String walletCreditBalance, String currency, String createdDate, String totalRows)? $default,{required TResult orElse(),}) {final _that = this;
|
||||
switch (_that) {
|
||||
case _WalletTransactionModel() when $default != null:
|
||||
return $default(_that.transactionId,_that.walletDebitId,_that.walletCreditId,_that.transactionType,_that.foreignId,_that.name,_that.description,_that.valueDate,_that.executionDate,_that.amount,_that.walletDebitBalance,_that.walletCreditBalance,_that.currency,_that.createdDate,_that.totalRows);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( int transactionId, int walletDebitId, int walletCreditId, String transactionType, String foreignId, String name, String description, String valueDate, String executionDate, String amount, String walletDebitBalance, String walletCreditBalance, String currency, String createdDate, String totalRows) $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _WalletTransactionModel():
|
||||
return $default(_that.transactionId,_that.walletDebitId,_that.walletCreditId,_that.transactionType,_that.foreignId,_that.name,_that.description,_that.valueDate,_that.executionDate,_that.amount,_that.walletDebitBalance,_that.walletCreditBalance,_that.currency,_that.createdDate,_that.totalRows);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( int transactionId, int walletDebitId, int walletCreditId, String transactionType, String foreignId, String name, String description, String valueDate, String executionDate, String amount, String walletDebitBalance, String walletCreditBalance, String currency, String createdDate, String totalRows)? $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _WalletTransactionModel() when $default != null:
|
||||
return $default(_that.transactionId,_that.walletDebitId,_that.walletCreditId,_that.transactionType,_that.foreignId,_that.name,_that.description,_that.valueDate,_that.executionDate,_that.amount,_that.walletDebitBalance,_that.walletCreditBalance,_that.currency,_that.createdDate,_that.totalRows);case _:
|
||||
return null;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
@JsonSerializable()
|
||||
|
||||
class _WalletTransactionModel implements WalletTransactionModel {
|
||||
const _WalletTransactionModel({required this.transactionId, required this.walletDebitId, required this.walletCreditId, required this.transactionType, required this.foreignId, required this.name, required this.description, required this.valueDate, required this.executionDate, required this.amount, required this.walletDebitBalance, required this.walletCreditBalance, required this.currency, required this.createdDate, required this.totalRows});
|
||||
factory _WalletTransactionModel.fromJson(Map<String, dynamic> json) => _$WalletTransactionModelFromJson(json);
|
||||
|
||||
@override final int transactionId;
|
||||
@override final int walletDebitId;
|
||||
@override final int walletCreditId;
|
||||
@override final String transactionType;
|
||||
@override final String foreignId;
|
||||
@override final String name;
|
||||
@override final String description;
|
||||
@override final String valueDate;
|
||||
@override final String executionDate;
|
||||
@override final String amount;
|
||||
@override final String walletDebitBalance;
|
||||
@override final String walletCreditBalance;
|
||||
@override final String currency;
|
||||
@override final String createdDate;
|
||||
@override final String totalRows;
|
||||
|
||||
/// Create a copy of WalletTransactionModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override @JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@pragma('vm:prefer-inline')
|
||||
_$WalletTransactionModelCopyWith<_WalletTransactionModel> get copyWith => __$WalletTransactionModelCopyWithImpl<_WalletTransactionModel>(this, _$identity);
|
||||
|
||||
@override
|
||||
Map<String, dynamic> toJson() {
|
||||
return _$WalletTransactionModelToJson(this, );
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is _WalletTransactionModel&&(identical(other.transactionId, transactionId) || other.transactionId == transactionId)&&(identical(other.walletDebitId, walletDebitId) || other.walletDebitId == walletDebitId)&&(identical(other.walletCreditId, walletCreditId) || other.walletCreditId == walletCreditId)&&(identical(other.transactionType, transactionType) || other.transactionType == transactionType)&&(identical(other.foreignId, foreignId) || other.foreignId == foreignId)&&(identical(other.name, name) || other.name == name)&&(identical(other.description, description) || other.description == description)&&(identical(other.valueDate, valueDate) || other.valueDate == valueDate)&&(identical(other.executionDate, executionDate) || other.executionDate == executionDate)&&(identical(other.amount, amount) || other.amount == amount)&&(identical(other.walletDebitBalance, walletDebitBalance) || other.walletDebitBalance == walletDebitBalance)&&(identical(other.walletCreditBalance, walletCreditBalance) || other.walletCreditBalance == walletCreditBalance)&&(identical(other.currency, currency) || other.currency == currency)&&(identical(other.createdDate, createdDate) || other.createdDate == createdDate)&&(identical(other.totalRows, totalRows) || other.totalRows == totalRows));
|
||||
}
|
||||
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,transactionId,walletDebitId,walletCreditId,transactionType,foreignId,name,description,valueDate,executionDate,amount,walletDebitBalance,walletCreditBalance,currency,createdDate,totalRows);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'WalletTransactionModel(transactionId: $transactionId, walletDebitId: $walletDebitId, walletCreditId: $walletCreditId, transactionType: $transactionType, foreignId: $foreignId, name: $name, description: $description, valueDate: $valueDate, executionDate: $executionDate, amount: $amount, walletDebitBalance: $walletDebitBalance, walletCreditBalance: $walletCreditBalance, currency: $currency, createdDate: $createdDate, totalRows: $totalRows)';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract mixin class _$WalletTransactionModelCopyWith<$Res> implements $WalletTransactionModelCopyWith<$Res> {
|
||||
factory _$WalletTransactionModelCopyWith(_WalletTransactionModel value, $Res Function(_WalletTransactionModel) _then) = __$WalletTransactionModelCopyWithImpl;
|
||||
@override @useResult
|
||||
$Res call({
|
||||
int transactionId, int walletDebitId, int walletCreditId, String transactionType, String foreignId, String name, String description, String valueDate, String executionDate, String amount, String walletDebitBalance, String walletCreditBalance, String currency, String createdDate, String totalRows
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
/// @nodoc
|
||||
class __$WalletTransactionModelCopyWithImpl<$Res>
|
||||
implements _$WalletTransactionModelCopyWith<$Res> {
|
||||
__$WalletTransactionModelCopyWithImpl(this._self, this._then);
|
||||
|
||||
final _WalletTransactionModel _self;
|
||||
final $Res Function(_WalletTransactionModel) _then;
|
||||
|
||||
/// Create a copy of WalletTransactionModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override @pragma('vm:prefer-inline') $Res call({Object? transactionId = null,Object? walletDebitId = null,Object? walletCreditId = null,Object? transactionType = null,Object? foreignId = null,Object? name = null,Object? description = null,Object? valueDate = null,Object? executionDate = null,Object? amount = null,Object? walletDebitBalance = null,Object? walletCreditBalance = null,Object? currency = null,Object? createdDate = null,Object? totalRows = null,}) {
|
||||
return _then(_WalletTransactionModel(
|
||||
transactionId: null == transactionId ? _self.transactionId : transactionId // ignore: cast_nullable_to_non_nullable
|
||||
as int,walletDebitId: null == walletDebitId ? _self.walletDebitId : walletDebitId // ignore: cast_nullable_to_non_nullable
|
||||
as int,walletCreditId: null == walletCreditId ? _self.walletCreditId : walletCreditId // ignore: cast_nullable_to_non_nullable
|
||||
as int,transactionType: null == transactionType ? _self.transactionType : transactionType // ignore: cast_nullable_to_non_nullable
|
||||
as String,foreignId: null == foreignId ? _self.foreignId : foreignId // ignore: cast_nullable_to_non_nullable
|
||||
as String,name: null == name ? _self.name : name // ignore: cast_nullable_to_non_nullable
|
||||
as String,description: null == description ? _self.description : description // ignore: cast_nullable_to_non_nullable
|
||||
as String,valueDate: null == valueDate ? _self.valueDate : valueDate // ignore: cast_nullable_to_non_nullable
|
||||
as String,executionDate: null == executionDate ? _self.executionDate : executionDate // ignore: cast_nullable_to_non_nullable
|
||||
as String,amount: null == amount ? _self.amount : amount // ignore: cast_nullable_to_non_nullable
|
||||
as String,walletDebitBalance: null == walletDebitBalance ? _self.walletDebitBalance : walletDebitBalance // ignore: cast_nullable_to_non_nullable
|
||||
as String,walletCreditBalance: null == walletCreditBalance ? _self.walletCreditBalance : walletCreditBalance // ignore: cast_nullable_to_non_nullable
|
||||
as String,currency: null == currency ? _self.currency : currency // ignore: cast_nullable_to_non_nullable
|
||||
as String,createdDate: null == createdDate ? _self.createdDate : createdDate // ignore: cast_nullable_to_non_nullable
|
||||
as String,totalRows: null == totalRows ? _self.totalRows : totalRows // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
// dart format on
|
||||
@@ -1,67 +0,0 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'wallet_transaction_model.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
_WalletTransactionsResponseModel _$WalletTransactionsResponseModelFromJson(
|
||||
Map<String, dynamic> json,
|
||||
) => _WalletTransactionsResponseModel(
|
||||
total: (json['total'] as num).toInt(),
|
||||
page: (json['page'] as num).toInt(),
|
||||
pages: (json['pages'] as num).toInt(),
|
||||
items: (json['items'] as List<dynamic>)
|
||||
.map((e) => WalletTransactionModel.fromJson(e as Map<String, dynamic>))
|
||||
.toList(),
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$WalletTransactionsResponseModelToJson(
|
||||
_WalletTransactionsResponseModel instance,
|
||||
) => <String, dynamic>{
|
||||
'total': instance.total,
|
||||
'page': instance.page,
|
||||
'pages': instance.pages,
|
||||
'items': instance.items,
|
||||
};
|
||||
|
||||
_WalletTransactionModel _$WalletTransactionModelFromJson(
|
||||
Map<String, dynamic> json,
|
||||
) => _WalletTransactionModel(
|
||||
transactionId: (json['transactionId'] as num).toInt(),
|
||||
walletDebitId: (json['walletDebitId'] as num).toInt(),
|
||||
walletCreditId: (json['walletCreditId'] as num).toInt(),
|
||||
transactionType: json['transactionType'] as String,
|
||||
foreignId: json['foreignId'] as String,
|
||||
name: json['name'] as String,
|
||||
description: json['description'] as String,
|
||||
valueDate: json['valueDate'] as String,
|
||||
executionDate: json['executionDate'] as String,
|
||||
amount: json['amount'] as String,
|
||||
walletDebitBalance: json['walletDebitBalance'] as String,
|
||||
walletCreditBalance: json['walletCreditBalance'] as String,
|
||||
currency: json['currency'] as String,
|
||||
createdDate: json['createdDate'] as String,
|
||||
totalRows: json['totalRows'] as String,
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$WalletTransactionModelToJson(
|
||||
_WalletTransactionModel instance,
|
||||
) => <String, dynamic>{
|
||||
'transactionId': instance.transactionId,
|
||||
'walletDebitId': instance.walletDebitId,
|
||||
'walletCreditId': instance.walletCreditId,
|
||||
'transactionType': instance.transactionType,
|
||||
'foreignId': instance.foreignId,
|
||||
'name': instance.name,
|
||||
'description': instance.description,
|
||||
'valueDate': instance.valueDate,
|
||||
'executionDate': instance.executionDate,
|
||||
'amount': instance.amount,
|
||||
'walletDebitBalance': instance.walletDebitBalance,
|
||||
'walletCreditBalance': instance.walletCreditBalance,
|
||||
'currency': instance.currency,
|
||||
'createdDate': instance.createdDate,
|
||||
'totalRows': instance.totalRows,
|
||||
};
|
||||
@@ -6,7 +6,7 @@ import 'package:sf_shared/src/data/models/sca_wallet_model.dart';
|
||||
import 'package:sf_shared/src/data/models/wallet_balance_model.dart';
|
||||
import 'package:sf_shared/src/data/models/wallet_card_model.dart';
|
||||
import 'package:sf_shared/src/data/models/wallet_limits_model.dart';
|
||||
import 'package:sf_shared/src/data/models/wallet_transaction_model.dart';
|
||||
import 'package:sf_shared/src/data/models/wallet_operation_model.dart';
|
||||
import 'package:sf_shared/src/domain/entities/mcc_group_entity.dart';
|
||||
import 'package:sf_shared/src/domain/entities/wallet_card_entity.dart';
|
||||
import 'package:sf_shared/src/domain/entities/wallet_limits_entity.dart';
|
||||
@@ -94,11 +94,59 @@ class TreezorRepositoryImpl implements TreezorRepository {
|
||||
}
|
||||
|
||||
@override
|
||||
Future<WalletTransactionsResponseEntity> getWalletTransactions({
|
||||
Future<PaymentProfileEntity> updatePaymentProfile({
|
||||
required String paymentProfileId,
|
||||
required String scaProof,
|
||||
String? firstName,
|
||||
String? lastName,
|
||||
String? phone,
|
||||
List<PaymentProfileAddressEntity>? addresses,
|
||||
List<PaymentProfileAddressEntity>? taxResidences,
|
||||
String? nationality,
|
||||
}) async {
|
||||
final body = <String, dynamic>{
|
||||
'scaProof': scaProof,
|
||||
if (firstName != null) 'firstName': firstName,
|
||||
if (lastName != null) 'lastName': lastName,
|
||||
if (phone != null) 'phone': phone,
|
||||
if (addresses != null)
|
||||
'addresses': addresses
|
||||
.map((a) => {
|
||||
'street': a.street,
|
||||
'city': a.city,
|
||||
'province': a.province,
|
||||
'state': a.state,
|
||||
'country': a.country,
|
||||
'postCode': a.postCode,
|
||||
})
|
||||
.toList(),
|
||||
if (taxResidences != null)
|
||||
'taxResidences': taxResidences
|
||||
.map((a) => {
|
||||
'street': a.street,
|
||||
'city': a.city,
|
||||
'province': a.province,
|
||||
'state': a.state,
|
||||
'country': a.country,
|
||||
'postCode': a.postCode,
|
||||
})
|
||||
.toList(),
|
||||
if (nationality != null) 'nationality': nationality,
|
||||
};
|
||||
|
||||
final model = await _remote.updatePaymentProfile(
|
||||
paymentProfileId: paymentProfileId,
|
||||
body: body,
|
||||
);
|
||||
return model.toEntity();
|
||||
}
|
||||
|
||||
@override
|
||||
Future<WalletTransactionsResponseEntity> getWalletOperations({
|
||||
required String walletId,
|
||||
Map<String, dynamic>? queryParameters,
|
||||
}) async {
|
||||
final model = await _remote.getWalletTransactions(
|
||||
final model = await _remote.getWalletOperations(
|
||||
walletId: walletId,
|
||||
queryParameters: queryParameters,
|
||||
);
|
||||
@@ -124,11 +172,13 @@ class TreezorRepositoryImpl implements TreezorRepository {
|
||||
Future<TransactionBeneficiaryEntity> createTransactionBeneficiary({
|
||||
required String name,
|
||||
required String iban,
|
||||
String? bic,
|
||||
required String scaProof,
|
||||
}) async {
|
||||
final model = await _remote.createTransactionBeneficiary(
|
||||
name: name,
|
||||
iban: iban,
|
||||
bic: bic,
|
||||
scaProof: scaProof,
|
||||
);
|
||||
return model.toEntity();
|
||||
@@ -145,14 +195,12 @@ class TreezorRepositoryImpl implements TreezorRepository {
|
||||
|
||||
@override
|
||||
Future<void> walletTransfer({
|
||||
required String walletId,
|
||||
required int beneficiaryId,
|
||||
required String beneficiaryValidationId,
|
||||
required double amount,
|
||||
required String scaProof,
|
||||
}) async {
|
||||
await _remote.walletTransfer(
|
||||
walletId: walletId,
|
||||
beneficiaryId: beneficiaryId,
|
||||
beneficiaryValidationId: beneficiaryValidationId,
|
||||
amount: amount,
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
import 'package:sf_shared/src/data/models/child_profile_deletability_model.dart';
|
||||
import 'package:sf_shared/src/data/models/child_profile_response_model.dart';
|
||||
import 'package:sf_shared/src/data/models/device_model.dart';
|
||||
import 'package:sf_shared/src/data/models/user_response_model.dart';
|
||||
import 'package:sf_shared/src/domain/entities/child_profile_deletability_entity.dart';
|
||||
import 'package:sf_shared/src/domain/entities/child_profile_entity.dart';
|
||||
import 'package:sf_shared/src/domain/entities/device_entity.dart';
|
||||
import 'package:sf_shared/src/domain/entities/user_entity.dart';
|
||||
@@ -25,6 +27,16 @@ class UserRepositoryImpl implements UserRepository {
|
||||
return model.items.map((item) => item.toEntity()).toList();
|
||||
}
|
||||
|
||||
@override
|
||||
Future<ChildProfileDeletabilityEntity> checkChildProfileDeletability({
|
||||
required String childProfileId,
|
||||
}) async {
|
||||
final model = await _remote.checkChildProfileDeletability(
|
||||
childProfileId: childProfileId,
|
||||
);
|
||||
return model.toEntity();
|
||||
}
|
||||
|
||||
@override
|
||||
Future<DeviceEntity> getDeviceByIdentificator({
|
||||
required String identificator,
|
||||
@@ -39,4 +51,26 @@ class UserRepositoryImpl implements UserRepository {
|
||||
Future<String> deleteDevice({required String deviceId}) {
|
||||
return _remote.deleteDevice(deviceId: deviceId);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> updateChildProfile({
|
||||
required String childProfileId,
|
||||
required String scaProof,
|
||||
String? firstName,
|
||||
String? lastName,
|
||||
int? bornAt,
|
||||
String? address,
|
||||
}) {
|
||||
final body = <String, dynamic>{
|
||||
'scaProof': scaProof,
|
||||
if (firstName != null) 'firstName': firstName,
|
||||
if (lastName != null) 'lastName': lastName,
|
||||
if (bornAt != null) 'bornAt': bornAt,
|
||||
if (address != null) 'address': address,
|
||||
};
|
||||
return _remote.updateChildProfile(
|
||||
childProfileId: childProfileId,
|
||||
body: body,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
|
||||
part 'child_profile_deletability_entity.freezed.dart';
|
||||
|
||||
@freezed
|
||||
abstract class ChildProfileDeletabilityEntity
|
||||
with _$ChildProfileDeletabilityEntity {
|
||||
const factory ChildProfileDeletabilityEntity({
|
||||
required bool isDeletable,
|
||||
@Default('') String reason,
|
||||
}) = _ChildProfileDeletabilityEntity;
|
||||
}
|
||||
@@ -0,0 +1,274 @@
|
||||
// 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 'child_profile_deletability_entity.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// FreezedGenerator
|
||||
// **************************************************************************
|
||||
|
||||
// dart format off
|
||||
T _$identity<T>(T value) => value;
|
||||
/// @nodoc
|
||||
mixin _$ChildProfileDeletabilityEntity {
|
||||
|
||||
bool get isDeletable; String get reason;
|
||||
/// Create a copy of ChildProfileDeletabilityEntity
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@pragma('vm:prefer-inline')
|
||||
$ChildProfileDeletabilityEntityCopyWith<ChildProfileDeletabilityEntity> get copyWith => _$ChildProfileDeletabilityEntityCopyWithImpl<ChildProfileDeletabilityEntity>(this as ChildProfileDeletabilityEntity, _$identity);
|
||||
|
||||
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is ChildProfileDeletabilityEntity&&(identical(other.isDeletable, isDeletable) || other.isDeletable == isDeletable)&&(identical(other.reason, reason) || other.reason == reason));
|
||||
}
|
||||
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,isDeletable,reason);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'ChildProfileDeletabilityEntity(isDeletable: $isDeletable, reason: $reason)';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract mixin class $ChildProfileDeletabilityEntityCopyWith<$Res> {
|
||||
factory $ChildProfileDeletabilityEntityCopyWith(ChildProfileDeletabilityEntity value, $Res Function(ChildProfileDeletabilityEntity) _then) = _$ChildProfileDeletabilityEntityCopyWithImpl;
|
||||
@useResult
|
||||
$Res call({
|
||||
bool isDeletable, String reason
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
/// @nodoc
|
||||
class _$ChildProfileDeletabilityEntityCopyWithImpl<$Res>
|
||||
implements $ChildProfileDeletabilityEntityCopyWith<$Res> {
|
||||
_$ChildProfileDeletabilityEntityCopyWithImpl(this._self, this._then);
|
||||
|
||||
final ChildProfileDeletabilityEntity _self;
|
||||
final $Res Function(ChildProfileDeletabilityEntity) _then;
|
||||
|
||||
/// Create a copy of ChildProfileDeletabilityEntity
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline') @override $Res call({Object? isDeletable = null,Object? reason = null,}) {
|
||||
return _then(_self.copyWith(
|
||||
isDeletable: null == isDeletable ? _self.isDeletable : isDeletable // ignore: cast_nullable_to_non_nullable
|
||||
as bool,reason: null == reason ? _self.reason : reason // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// Adds pattern-matching-related methods to [ChildProfileDeletabilityEntity].
|
||||
extension ChildProfileDeletabilityEntityPatterns on ChildProfileDeletabilityEntity {
|
||||
/// 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( _ChildProfileDeletabilityEntity value)? $default,{required TResult orElse(),}){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _ChildProfileDeletabilityEntity() 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( _ChildProfileDeletabilityEntity value) $default,){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _ChildProfileDeletabilityEntity():
|
||||
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( _ChildProfileDeletabilityEntity value)? $default,){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _ChildProfileDeletabilityEntity() 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 isDeletable, String reason)? $default,{required TResult orElse(),}) {final _that = this;
|
||||
switch (_that) {
|
||||
case _ChildProfileDeletabilityEntity() when $default != null:
|
||||
return $default(_that.isDeletable,_that.reason);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 isDeletable, String reason) $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _ChildProfileDeletabilityEntity():
|
||||
return $default(_that.isDeletable,_that.reason);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 isDeletable, String reason)? $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _ChildProfileDeletabilityEntity() when $default != null:
|
||||
return $default(_that.isDeletable,_that.reason);case _:
|
||||
return null;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
|
||||
|
||||
class _ChildProfileDeletabilityEntity implements ChildProfileDeletabilityEntity {
|
||||
const _ChildProfileDeletabilityEntity({required this.isDeletable, this.reason = ''});
|
||||
|
||||
|
||||
@override final bool isDeletable;
|
||||
@override@JsonKey() final String reason;
|
||||
|
||||
/// Create a copy of ChildProfileDeletabilityEntity
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override @JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@pragma('vm:prefer-inline')
|
||||
_$ChildProfileDeletabilityEntityCopyWith<_ChildProfileDeletabilityEntity> get copyWith => __$ChildProfileDeletabilityEntityCopyWithImpl<_ChildProfileDeletabilityEntity>(this, _$identity);
|
||||
|
||||
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is _ChildProfileDeletabilityEntity&&(identical(other.isDeletable, isDeletable) || other.isDeletable == isDeletable)&&(identical(other.reason, reason) || other.reason == reason));
|
||||
}
|
||||
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,isDeletable,reason);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'ChildProfileDeletabilityEntity(isDeletable: $isDeletable, reason: $reason)';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract mixin class _$ChildProfileDeletabilityEntityCopyWith<$Res> implements $ChildProfileDeletabilityEntityCopyWith<$Res> {
|
||||
factory _$ChildProfileDeletabilityEntityCopyWith(_ChildProfileDeletabilityEntity value, $Res Function(_ChildProfileDeletabilityEntity) _then) = __$ChildProfileDeletabilityEntityCopyWithImpl;
|
||||
@override @useResult
|
||||
$Res call({
|
||||
bool isDeletable, String reason
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
/// @nodoc
|
||||
class __$ChildProfileDeletabilityEntityCopyWithImpl<$Res>
|
||||
implements _$ChildProfileDeletabilityEntityCopyWith<$Res> {
|
||||
__$ChildProfileDeletabilityEntityCopyWithImpl(this._self, this._then);
|
||||
|
||||
final _ChildProfileDeletabilityEntity _self;
|
||||
final $Res Function(_ChildProfileDeletabilityEntity) _then;
|
||||
|
||||
/// Create a copy of ChildProfileDeletabilityEntity
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override @pragma('vm:prefer-inline') $Res call({Object? isDeletable = null,Object? reason = null,}) {
|
||||
return _then(_ChildProfileDeletabilityEntity(
|
||||
isDeletable: null == isDeletable ? _self.isDeletable : isDeletable // ignore: cast_nullable_to_non_nullable
|
||||
as bool,reason: null == reason ? _self.reason : reason // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
// dart format on
|
||||
@@ -33,10 +33,12 @@ enum DateFilter {
|
||||
class TransactionsQuery {
|
||||
final String walletId;
|
||||
final DateFilter? dateFilter;
|
||||
final String? cursor;
|
||||
|
||||
const TransactionsQuery({
|
||||
required this.walletId,
|
||||
this.dateFilter,
|
||||
this.cursor,
|
||||
});
|
||||
|
||||
@override
|
||||
@@ -44,8 +46,9 @@ class TransactionsQuery {
|
||||
identical(this, other) ||
|
||||
other is TransactionsQuery &&
|
||||
walletId == other.walletId &&
|
||||
dateFilter == other.dateFilter;
|
||||
dateFilter == other.dateFilter &&
|
||||
cursor == other.cursor;
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(walletId, dateFilter);
|
||||
int get hashCode => Object.hash(walletId, dateFilter, cursor);
|
||||
}
|
||||
|
||||
@@ -3,27 +3,15 @@ import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
part 'wallet_transaction_entity.freezed.dart';
|
||||
|
||||
enum TransactionType {
|
||||
payin,
|
||||
payout,
|
||||
transfer,
|
||||
payinRefund,
|
||||
payoutRefund,
|
||||
bankDirectDebit,
|
||||
bankTransfer,
|
||||
cardTopup,
|
||||
cardTransaction,
|
||||
payinAcquiring,
|
||||
payinRefundAcquiring,
|
||||
sctrInst,
|
||||
payinSctInstantRecall,
|
||||
payoutSctInstantEmit,
|
||||
payinSctInstantEmitRecall,
|
||||
creditTransferReturned,
|
||||
checkPayin,
|
||||
sdde,
|
||||
sddr,
|
||||
sddrReversal,
|
||||
sctrRecall,
|
||||
checkRefund,
|
||||
sctr,
|
||||
creditInternationalTransfer,
|
||||
check,
|
||||
creditNote,
|
||||
fees,
|
||||
instantBankTransfer,
|
||||
walletTransfer,
|
||||
unknown;
|
||||
|
||||
static TransactionType fromString(String value) {
|
||||
@@ -39,30 +27,30 @@ enum TransactionType {
|
||||
abstract class WalletTransactionsResponseEntity
|
||||
with _$WalletTransactionsResponseEntity {
|
||||
const factory WalletTransactionsResponseEntity({
|
||||
required int total,
|
||||
required int page,
|
||||
required int pages,
|
||||
required List<WalletTransactionEntity> items,
|
||||
String? nextCursor,
|
||||
}) = _WalletTransactionsResponseEntity;
|
||||
}
|
||||
|
||||
@freezed
|
||||
abstract class WalletTransactionEntity with _$WalletTransactionEntity {
|
||||
const factory WalletTransactionEntity({
|
||||
required int transactionId,
|
||||
required int walletDebitId,
|
||||
required int walletCreditId,
|
||||
required TransactionType transactionType,
|
||||
required String foreignId,
|
||||
required String name,
|
||||
required String description,
|
||||
required String valueDate,
|
||||
required String executionDate,
|
||||
required String amount,
|
||||
required String walletDebitBalance,
|
||||
required String walletCreditBalance,
|
||||
required String currency,
|
||||
required String createdDate,
|
||||
required String totalRows,
|
||||
required TransactionType operationType,
|
||||
@Default('') String direction,
|
||||
@Default('') String objectId,
|
||||
@Default('') String label,
|
||||
@Default('') String status,
|
||||
@Default(0.0) double amount,
|
||||
@Default('EUR') String currency,
|
||||
@Default('') String createdDate,
|
||||
String? settlementDate,
|
||||
String? merchantName,
|
||||
String? merchantLogo,
|
||||
String? merchantCategory,
|
||||
String? merchantCategoryGroup,
|
||||
String? merchantCity,
|
||||
String? merchantCountry,
|
||||
String? maskedPan,
|
||||
String? messageToUser,
|
||||
}) = _WalletTransactionEntity;
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ T _$identity<T>(T value) => value;
|
||||
/// @nodoc
|
||||
mixin _$WalletTransactionsResponseEntity {
|
||||
|
||||
int get total; int get page; int get pages; List<WalletTransactionEntity> get items;
|
||||
List<WalletTransactionEntity> get items; String? get nextCursor;
|
||||
/// Create a copy of WalletTransactionsResponseEntity
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@@ -25,16 +25,16 @@ $WalletTransactionsResponseEntityCopyWith<WalletTransactionsResponseEntity> get
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is WalletTransactionsResponseEntity&&(identical(other.total, total) || other.total == total)&&(identical(other.page, page) || other.page == page)&&(identical(other.pages, pages) || other.pages == pages)&&const DeepCollectionEquality().equals(other.items, items));
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is WalletTransactionsResponseEntity&&const DeepCollectionEquality().equals(other.items, items)&&(identical(other.nextCursor, nextCursor) || other.nextCursor == nextCursor));
|
||||
}
|
||||
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,total,page,pages,const DeepCollectionEquality().hash(items));
|
||||
int get hashCode => Object.hash(runtimeType,const DeepCollectionEquality().hash(items),nextCursor);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'WalletTransactionsResponseEntity(total: $total, page: $page, pages: $pages, items: $items)';
|
||||
return 'WalletTransactionsResponseEntity(items: $items, nextCursor: $nextCursor)';
|
||||
}
|
||||
|
||||
|
||||
@@ -45,7 +45,7 @@ abstract mixin class $WalletTransactionsResponseEntityCopyWith<$Res> {
|
||||
factory $WalletTransactionsResponseEntityCopyWith(WalletTransactionsResponseEntity value, $Res Function(WalletTransactionsResponseEntity) _then) = _$WalletTransactionsResponseEntityCopyWithImpl;
|
||||
@useResult
|
||||
$Res call({
|
||||
int total, int page, int pages, List<WalletTransactionEntity> items
|
||||
List<WalletTransactionEntity> items, String? nextCursor
|
||||
});
|
||||
|
||||
|
||||
@@ -62,13 +62,11 @@ class _$WalletTransactionsResponseEntityCopyWithImpl<$Res>
|
||||
|
||||
/// Create a copy of WalletTransactionsResponseEntity
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline') @override $Res call({Object? total = null,Object? page = null,Object? pages = null,Object? items = null,}) {
|
||||
@pragma('vm:prefer-inline') @override $Res call({Object? items = null,Object? nextCursor = freezed,}) {
|
||||
return _then(_self.copyWith(
|
||||
total: null == total ? _self.total : total // ignore: cast_nullable_to_non_nullable
|
||||
as int,page: null == page ? _self.page : page // ignore: cast_nullable_to_non_nullable
|
||||
as int,pages: null == pages ? _self.pages : pages // ignore: cast_nullable_to_non_nullable
|
||||
as int,items: null == items ? _self.items : items // ignore: cast_nullable_to_non_nullable
|
||||
as List<WalletTransactionEntity>,
|
||||
items: null == items ? _self.items : items // ignore: cast_nullable_to_non_nullable
|
||||
as List<WalletTransactionEntity>,nextCursor: freezed == nextCursor ? _self.nextCursor : nextCursor // ignore: cast_nullable_to_non_nullable
|
||||
as String?,
|
||||
));
|
||||
}
|
||||
|
||||
@@ -153,10 +151,10 @@ return $default(_that);case _:
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( int total, int page, int pages, List<WalletTransactionEntity> items)? $default,{required TResult orElse(),}) {final _that = this;
|
||||
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( List<WalletTransactionEntity> items, String? nextCursor)? $default,{required TResult orElse(),}) {final _that = this;
|
||||
switch (_that) {
|
||||
case _WalletTransactionsResponseEntity() when $default != null:
|
||||
return $default(_that.total,_that.page,_that.pages,_that.items);case _:
|
||||
return $default(_that.items,_that.nextCursor);case _:
|
||||
return orElse();
|
||||
|
||||
}
|
||||
@@ -174,10 +172,10 @@ return $default(_that.total,_that.page,_that.pages,_that.items);case _:
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( int total, int page, int pages, List<WalletTransactionEntity> items) $default,) {final _that = this;
|
||||
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( List<WalletTransactionEntity> items, String? nextCursor) $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _WalletTransactionsResponseEntity():
|
||||
return $default(_that.total,_that.page,_that.pages,_that.items);case _:
|
||||
return $default(_that.items,_that.nextCursor);case _:
|
||||
throw StateError('Unexpected subclass');
|
||||
|
||||
}
|
||||
@@ -194,10 +192,10 @@ return $default(_that.total,_that.page,_that.pages,_that.items);case _:
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( int total, int page, int pages, List<WalletTransactionEntity> items)? $default,) {final _that = this;
|
||||
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( List<WalletTransactionEntity> items, String? nextCursor)? $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _WalletTransactionsResponseEntity() when $default != null:
|
||||
return $default(_that.total,_that.page,_that.pages,_that.items);case _:
|
||||
return $default(_that.items,_that.nextCursor);case _:
|
||||
return null;
|
||||
|
||||
}
|
||||
@@ -209,12 +207,9 @@ return $default(_that.total,_that.page,_that.pages,_that.items);case _:
|
||||
|
||||
|
||||
class _WalletTransactionsResponseEntity implements WalletTransactionsResponseEntity {
|
||||
const _WalletTransactionsResponseEntity({required this.total, required this.page, required this.pages, required final List<WalletTransactionEntity> items}): _items = items;
|
||||
const _WalletTransactionsResponseEntity({required final List<WalletTransactionEntity> items, this.nextCursor}): _items = items;
|
||||
|
||||
|
||||
@override final int total;
|
||||
@override final int page;
|
||||
@override final int pages;
|
||||
final List<WalletTransactionEntity> _items;
|
||||
@override List<WalletTransactionEntity> get items {
|
||||
if (_items is EqualUnmodifiableListView) return _items;
|
||||
@@ -222,6 +217,7 @@ class _WalletTransactionsResponseEntity implements WalletTransactionsResponseEnt
|
||||
return EqualUnmodifiableListView(_items);
|
||||
}
|
||||
|
||||
@override final String? nextCursor;
|
||||
|
||||
/// Create a copy of WalletTransactionsResponseEntity
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@@ -233,16 +229,16 @@ _$WalletTransactionsResponseEntityCopyWith<_WalletTransactionsResponseEntity> ge
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is _WalletTransactionsResponseEntity&&(identical(other.total, total) || other.total == total)&&(identical(other.page, page) || other.page == page)&&(identical(other.pages, pages) || other.pages == pages)&&const DeepCollectionEquality().equals(other._items, _items));
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is _WalletTransactionsResponseEntity&&const DeepCollectionEquality().equals(other._items, _items)&&(identical(other.nextCursor, nextCursor) || other.nextCursor == nextCursor));
|
||||
}
|
||||
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,total,page,pages,const DeepCollectionEquality().hash(_items));
|
||||
int get hashCode => Object.hash(runtimeType,const DeepCollectionEquality().hash(_items),nextCursor);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'WalletTransactionsResponseEntity(total: $total, page: $page, pages: $pages, items: $items)';
|
||||
return 'WalletTransactionsResponseEntity(items: $items, nextCursor: $nextCursor)';
|
||||
}
|
||||
|
||||
|
||||
@@ -253,7 +249,7 @@ abstract mixin class _$WalletTransactionsResponseEntityCopyWith<$Res> implements
|
||||
factory _$WalletTransactionsResponseEntityCopyWith(_WalletTransactionsResponseEntity value, $Res Function(_WalletTransactionsResponseEntity) _then) = __$WalletTransactionsResponseEntityCopyWithImpl;
|
||||
@override @useResult
|
||||
$Res call({
|
||||
int total, int page, int pages, List<WalletTransactionEntity> items
|
||||
List<WalletTransactionEntity> items, String? nextCursor
|
||||
});
|
||||
|
||||
|
||||
@@ -270,13 +266,11 @@ class __$WalletTransactionsResponseEntityCopyWithImpl<$Res>
|
||||
|
||||
/// Create a copy of WalletTransactionsResponseEntity
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override @pragma('vm:prefer-inline') $Res call({Object? total = null,Object? page = null,Object? pages = null,Object? items = null,}) {
|
||||
@override @pragma('vm:prefer-inline') $Res call({Object? items = null,Object? nextCursor = freezed,}) {
|
||||
return _then(_WalletTransactionsResponseEntity(
|
||||
total: null == total ? _self.total : total // ignore: cast_nullable_to_non_nullable
|
||||
as int,page: null == page ? _self.page : page // ignore: cast_nullable_to_non_nullable
|
||||
as int,pages: null == pages ? _self.pages : pages // ignore: cast_nullable_to_non_nullable
|
||||
as int,items: null == items ? _self._items : items // ignore: cast_nullable_to_non_nullable
|
||||
as List<WalletTransactionEntity>,
|
||||
items: null == items ? _self._items : items // ignore: cast_nullable_to_non_nullable
|
||||
as List<WalletTransactionEntity>,nextCursor: freezed == nextCursor ? _self.nextCursor : nextCursor // ignore: cast_nullable_to_non_nullable
|
||||
as String?,
|
||||
));
|
||||
}
|
||||
|
||||
@@ -286,7 +280,7 @@ as List<WalletTransactionEntity>,
|
||||
/// @nodoc
|
||||
mixin _$WalletTransactionEntity {
|
||||
|
||||
int get transactionId; int get walletDebitId; int get walletCreditId; TransactionType get transactionType; String get foreignId; String get name; String get description; String get valueDate; String get executionDate; String get amount; String get walletDebitBalance; String get walletCreditBalance; String get currency; String get createdDate; String get totalRows;
|
||||
TransactionType get operationType; String get direction; String get objectId; String get label; String get status; double get amount; String get currency; String get createdDate; String? get settlementDate; String? get merchantName; String? get merchantLogo; String? get merchantCategory; String? get merchantCategoryGroup; String? get merchantCity; String? get merchantCountry; String? get maskedPan; String? get messageToUser;
|
||||
/// Create a copy of WalletTransactionEntity
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@@ -297,16 +291,16 @@ $WalletTransactionEntityCopyWith<WalletTransactionEntity> get copyWith => _$Wall
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is WalletTransactionEntity&&(identical(other.transactionId, transactionId) || other.transactionId == transactionId)&&(identical(other.walletDebitId, walletDebitId) || other.walletDebitId == walletDebitId)&&(identical(other.walletCreditId, walletCreditId) || other.walletCreditId == walletCreditId)&&(identical(other.transactionType, transactionType) || other.transactionType == transactionType)&&(identical(other.foreignId, foreignId) || other.foreignId == foreignId)&&(identical(other.name, name) || other.name == name)&&(identical(other.description, description) || other.description == description)&&(identical(other.valueDate, valueDate) || other.valueDate == valueDate)&&(identical(other.executionDate, executionDate) || other.executionDate == executionDate)&&(identical(other.amount, amount) || other.amount == amount)&&(identical(other.walletDebitBalance, walletDebitBalance) || other.walletDebitBalance == walletDebitBalance)&&(identical(other.walletCreditBalance, walletCreditBalance) || other.walletCreditBalance == walletCreditBalance)&&(identical(other.currency, currency) || other.currency == currency)&&(identical(other.createdDate, createdDate) || other.createdDate == createdDate)&&(identical(other.totalRows, totalRows) || other.totalRows == totalRows));
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is WalletTransactionEntity&&(identical(other.operationType, operationType) || other.operationType == operationType)&&(identical(other.direction, direction) || other.direction == direction)&&(identical(other.objectId, objectId) || other.objectId == objectId)&&(identical(other.label, label) || other.label == label)&&(identical(other.status, status) || other.status == status)&&(identical(other.amount, amount) || other.amount == amount)&&(identical(other.currency, currency) || other.currency == currency)&&(identical(other.createdDate, createdDate) || other.createdDate == createdDate)&&(identical(other.settlementDate, settlementDate) || other.settlementDate == settlementDate)&&(identical(other.merchantName, merchantName) || other.merchantName == merchantName)&&(identical(other.merchantLogo, merchantLogo) || other.merchantLogo == merchantLogo)&&(identical(other.merchantCategory, merchantCategory) || other.merchantCategory == merchantCategory)&&(identical(other.merchantCategoryGroup, merchantCategoryGroup) || other.merchantCategoryGroup == merchantCategoryGroup)&&(identical(other.merchantCity, merchantCity) || other.merchantCity == merchantCity)&&(identical(other.merchantCountry, merchantCountry) || other.merchantCountry == merchantCountry)&&(identical(other.maskedPan, maskedPan) || other.maskedPan == maskedPan)&&(identical(other.messageToUser, messageToUser) || other.messageToUser == messageToUser));
|
||||
}
|
||||
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,transactionId,walletDebitId,walletCreditId,transactionType,foreignId,name,description,valueDate,executionDate,amount,walletDebitBalance,walletCreditBalance,currency,createdDate,totalRows);
|
||||
int get hashCode => Object.hash(runtimeType,operationType,direction,objectId,label,status,amount,currency,createdDate,settlementDate,merchantName,merchantLogo,merchantCategory,merchantCategoryGroup,merchantCity,merchantCountry,maskedPan,messageToUser);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'WalletTransactionEntity(transactionId: $transactionId, walletDebitId: $walletDebitId, walletCreditId: $walletCreditId, transactionType: $transactionType, foreignId: $foreignId, name: $name, description: $description, valueDate: $valueDate, executionDate: $executionDate, amount: $amount, walletDebitBalance: $walletDebitBalance, walletCreditBalance: $walletCreditBalance, currency: $currency, createdDate: $createdDate, totalRows: $totalRows)';
|
||||
return 'WalletTransactionEntity(operationType: $operationType, direction: $direction, objectId: $objectId, label: $label, status: $status, amount: $amount, currency: $currency, createdDate: $createdDate, settlementDate: $settlementDate, merchantName: $merchantName, merchantLogo: $merchantLogo, merchantCategory: $merchantCategory, merchantCategoryGroup: $merchantCategoryGroup, merchantCity: $merchantCity, merchantCountry: $merchantCountry, maskedPan: $maskedPan, messageToUser: $messageToUser)';
|
||||
}
|
||||
|
||||
|
||||
@@ -317,7 +311,7 @@ abstract mixin class $WalletTransactionEntityCopyWith<$Res> {
|
||||
factory $WalletTransactionEntityCopyWith(WalletTransactionEntity value, $Res Function(WalletTransactionEntity) _then) = _$WalletTransactionEntityCopyWithImpl;
|
||||
@useResult
|
||||
$Res call({
|
||||
int transactionId, int walletDebitId, int walletCreditId, TransactionType transactionType, String foreignId, String name, String description, String valueDate, String executionDate, String amount, String walletDebitBalance, String walletCreditBalance, String currency, String createdDate, String totalRows
|
||||
TransactionType operationType, String direction, String objectId, String label, String status, double amount, String currency, String createdDate, String? settlementDate, String? merchantName, String? merchantLogo, String? merchantCategory, String? merchantCategoryGroup, String? merchantCity, String? merchantCountry, String? maskedPan, String? messageToUser
|
||||
});
|
||||
|
||||
|
||||
@@ -334,24 +328,26 @@ class _$WalletTransactionEntityCopyWithImpl<$Res>
|
||||
|
||||
/// Create a copy of WalletTransactionEntity
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline') @override $Res call({Object? transactionId = null,Object? walletDebitId = null,Object? walletCreditId = null,Object? transactionType = null,Object? foreignId = null,Object? name = null,Object? description = null,Object? valueDate = null,Object? executionDate = null,Object? amount = null,Object? walletDebitBalance = null,Object? walletCreditBalance = null,Object? currency = null,Object? createdDate = null,Object? totalRows = null,}) {
|
||||
@pragma('vm:prefer-inline') @override $Res call({Object? operationType = null,Object? direction = null,Object? objectId = null,Object? label = null,Object? status = null,Object? amount = null,Object? currency = null,Object? createdDate = null,Object? settlementDate = freezed,Object? merchantName = freezed,Object? merchantLogo = freezed,Object? merchantCategory = freezed,Object? merchantCategoryGroup = freezed,Object? merchantCity = freezed,Object? merchantCountry = freezed,Object? maskedPan = freezed,Object? messageToUser = freezed,}) {
|
||||
return _then(_self.copyWith(
|
||||
transactionId: null == transactionId ? _self.transactionId : transactionId // ignore: cast_nullable_to_non_nullable
|
||||
as int,walletDebitId: null == walletDebitId ? _self.walletDebitId : walletDebitId // ignore: cast_nullable_to_non_nullable
|
||||
as int,walletCreditId: null == walletCreditId ? _self.walletCreditId : walletCreditId // ignore: cast_nullable_to_non_nullable
|
||||
as int,transactionType: null == transactionType ? _self.transactionType : transactionType // ignore: cast_nullable_to_non_nullable
|
||||
as TransactionType,foreignId: null == foreignId ? _self.foreignId : foreignId // ignore: cast_nullable_to_non_nullable
|
||||
as String,name: null == name ? _self.name : name // ignore: cast_nullable_to_non_nullable
|
||||
as String,description: null == description ? _self.description : description // ignore: cast_nullable_to_non_nullable
|
||||
as String,valueDate: null == valueDate ? _self.valueDate : valueDate // ignore: cast_nullable_to_non_nullable
|
||||
as String,executionDate: null == executionDate ? _self.executionDate : executionDate // ignore: cast_nullable_to_non_nullable
|
||||
operationType: null == operationType ? _self.operationType : operationType // ignore: cast_nullable_to_non_nullable
|
||||
as TransactionType,direction: null == direction ? _self.direction : direction // ignore: cast_nullable_to_non_nullable
|
||||
as String,objectId: null == objectId ? _self.objectId : objectId // ignore: cast_nullable_to_non_nullable
|
||||
as String,label: null == label ? _self.label : label // ignore: cast_nullable_to_non_nullable
|
||||
as String,status: null == status ? _self.status : status // ignore: cast_nullable_to_non_nullable
|
||||
as String,amount: null == amount ? _self.amount : amount // ignore: cast_nullable_to_non_nullable
|
||||
as String,walletDebitBalance: null == walletDebitBalance ? _self.walletDebitBalance : walletDebitBalance // ignore: cast_nullable_to_non_nullable
|
||||
as String,walletCreditBalance: null == walletCreditBalance ? _self.walletCreditBalance : walletCreditBalance // ignore: cast_nullable_to_non_nullable
|
||||
as String,currency: null == currency ? _self.currency : currency // ignore: cast_nullable_to_non_nullable
|
||||
as double,currency: null == currency ? _self.currency : currency // ignore: cast_nullable_to_non_nullable
|
||||
as String,createdDate: null == createdDate ? _self.createdDate : createdDate // ignore: cast_nullable_to_non_nullable
|
||||
as String,totalRows: null == totalRows ? _self.totalRows : totalRows // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
as String,settlementDate: freezed == settlementDate ? _self.settlementDate : settlementDate // ignore: cast_nullable_to_non_nullable
|
||||
as String?,merchantName: freezed == merchantName ? _self.merchantName : merchantName // ignore: cast_nullable_to_non_nullable
|
||||
as String?,merchantLogo: freezed == merchantLogo ? _self.merchantLogo : merchantLogo // ignore: cast_nullable_to_non_nullable
|
||||
as String?,merchantCategory: freezed == merchantCategory ? _self.merchantCategory : merchantCategory // ignore: cast_nullable_to_non_nullable
|
||||
as String?,merchantCategoryGroup: freezed == merchantCategoryGroup ? _self.merchantCategoryGroup : merchantCategoryGroup // ignore: cast_nullable_to_non_nullable
|
||||
as String?,merchantCity: freezed == merchantCity ? _self.merchantCity : merchantCity // ignore: cast_nullable_to_non_nullable
|
||||
as String?,merchantCountry: freezed == merchantCountry ? _self.merchantCountry : merchantCountry // ignore: cast_nullable_to_non_nullable
|
||||
as String?,maskedPan: freezed == maskedPan ? _self.maskedPan : maskedPan // ignore: cast_nullable_to_non_nullable
|
||||
as String?,messageToUser: freezed == messageToUser ? _self.messageToUser : messageToUser // ignore: cast_nullable_to_non_nullable
|
||||
as String?,
|
||||
));
|
||||
}
|
||||
|
||||
@@ -436,10 +432,10 @@ return $default(_that);case _:
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( int transactionId, int walletDebitId, int walletCreditId, TransactionType transactionType, String foreignId, String name, String description, String valueDate, String executionDate, String amount, String walletDebitBalance, String walletCreditBalance, String currency, String createdDate, String totalRows)? $default,{required TResult orElse(),}) {final _that = this;
|
||||
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( TransactionType operationType, String direction, String objectId, String label, String status, double amount, String currency, String createdDate, String? settlementDate, String? merchantName, String? merchantLogo, String? merchantCategory, String? merchantCategoryGroup, String? merchantCity, String? merchantCountry, String? maskedPan, String? messageToUser)? $default,{required TResult orElse(),}) {final _that = this;
|
||||
switch (_that) {
|
||||
case _WalletTransactionEntity() when $default != null:
|
||||
return $default(_that.transactionId,_that.walletDebitId,_that.walletCreditId,_that.transactionType,_that.foreignId,_that.name,_that.description,_that.valueDate,_that.executionDate,_that.amount,_that.walletDebitBalance,_that.walletCreditBalance,_that.currency,_that.createdDate,_that.totalRows);case _:
|
||||
return $default(_that.operationType,_that.direction,_that.objectId,_that.label,_that.status,_that.amount,_that.currency,_that.createdDate,_that.settlementDate,_that.merchantName,_that.merchantLogo,_that.merchantCategory,_that.merchantCategoryGroup,_that.merchantCity,_that.merchantCountry,_that.maskedPan,_that.messageToUser);case _:
|
||||
return orElse();
|
||||
|
||||
}
|
||||
@@ -457,10 +453,10 @@ return $default(_that.transactionId,_that.walletDebitId,_that.walletCreditId,_th
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( int transactionId, int walletDebitId, int walletCreditId, TransactionType transactionType, String foreignId, String name, String description, String valueDate, String executionDate, String amount, String walletDebitBalance, String walletCreditBalance, String currency, String createdDate, String totalRows) $default,) {final _that = this;
|
||||
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( TransactionType operationType, String direction, String objectId, String label, String status, double amount, String currency, String createdDate, String? settlementDate, String? merchantName, String? merchantLogo, String? merchantCategory, String? merchantCategoryGroup, String? merchantCity, String? merchantCountry, String? maskedPan, String? messageToUser) $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _WalletTransactionEntity():
|
||||
return $default(_that.transactionId,_that.walletDebitId,_that.walletCreditId,_that.transactionType,_that.foreignId,_that.name,_that.description,_that.valueDate,_that.executionDate,_that.amount,_that.walletDebitBalance,_that.walletCreditBalance,_that.currency,_that.createdDate,_that.totalRows);case _:
|
||||
return $default(_that.operationType,_that.direction,_that.objectId,_that.label,_that.status,_that.amount,_that.currency,_that.createdDate,_that.settlementDate,_that.merchantName,_that.merchantLogo,_that.merchantCategory,_that.merchantCategoryGroup,_that.merchantCity,_that.merchantCountry,_that.maskedPan,_that.messageToUser);case _:
|
||||
throw StateError('Unexpected subclass');
|
||||
|
||||
}
|
||||
@@ -477,10 +473,10 @@ return $default(_that.transactionId,_that.walletDebitId,_that.walletCreditId,_th
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( int transactionId, int walletDebitId, int walletCreditId, TransactionType transactionType, String foreignId, String name, String description, String valueDate, String executionDate, String amount, String walletDebitBalance, String walletCreditBalance, String currency, String createdDate, String totalRows)? $default,) {final _that = this;
|
||||
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( TransactionType operationType, String direction, String objectId, String label, String status, double amount, String currency, String createdDate, String? settlementDate, String? merchantName, String? merchantLogo, String? merchantCategory, String? merchantCategoryGroup, String? merchantCity, String? merchantCountry, String? maskedPan, String? messageToUser)? $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _WalletTransactionEntity() when $default != null:
|
||||
return $default(_that.transactionId,_that.walletDebitId,_that.walletCreditId,_that.transactionType,_that.foreignId,_that.name,_that.description,_that.valueDate,_that.executionDate,_that.amount,_that.walletDebitBalance,_that.walletCreditBalance,_that.currency,_that.createdDate,_that.totalRows);case _:
|
||||
return $default(_that.operationType,_that.direction,_that.objectId,_that.label,_that.status,_that.amount,_that.currency,_that.createdDate,_that.settlementDate,_that.merchantName,_that.merchantLogo,_that.merchantCategory,_that.merchantCategoryGroup,_that.merchantCity,_that.merchantCountry,_that.maskedPan,_that.messageToUser);case _:
|
||||
return null;
|
||||
|
||||
}
|
||||
@@ -492,24 +488,26 @@ return $default(_that.transactionId,_that.walletDebitId,_that.walletCreditId,_th
|
||||
|
||||
|
||||
class _WalletTransactionEntity implements WalletTransactionEntity {
|
||||
const _WalletTransactionEntity({required this.transactionId, required this.walletDebitId, required this.walletCreditId, required this.transactionType, required this.foreignId, required this.name, required this.description, required this.valueDate, required this.executionDate, required this.amount, required this.walletDebitBalance, required this.walletCreditBalance, required this.currency, required this.createdDate, required this.totalRows});
|
||||
const _WalletTransactionEntity({required this.operationType, this.direction = '', this.objectId = '', this.label = '', this.status = '', this.amount = 0.0, this.currency = 'EUR', this.createdDate = '', this.settlementDate, this.merchantName, this.merchantLogo, this.merchantCategory, this.merchantCategoryGroup, this.merchantCity, this.merchantCountry, this.maskedPan, this.messageToUser});
|
||||
|
||||
|
||||
@override final int transactionId;
|
||||
@override final int walletDebitId;
|
||||
@override final int walletCreditId;
|
||||
@override final TransactionType transactionType;
|
||||
@override final String foreignId;
|
||||
@override final String name;
|
||||
@override final String description;
|
||||
@override final String valueDate;
|
||||
@override final String executionDate;
|
||||
@override final String amount;
|
||||
@override final String walletDebitBalance;
|
||||
@override final String walletCreditBalance;
|
||||
@override final String currency;
|
||||
@override final String createdDate;
|
||||
@override final String totalRows;
|
||||
@override final TransactionType operationType;
|
||||
@override@JsonKey() final String direction;
|
||||
@override@JsonKey() final String objectId;
|
||||
@override@JsonKey() final String label;
|
||||
@override@JsonKey() final String status;
|
||||
@override@JsonKey() final double amount;
|
||||
@override@JsonKey() final String currency;
|
||||
@override@JsonKey() final String createdDate;
|
||||
@override final String? settlementDate;
|
||||
@override final String? merchantName;
|
||||
@override final String? merchantLogo;
|
||||
@override final String? merchantCategory;
|
||||
@override final String? merchantCategoryGroup;
|
||||
@override final String? merchantCity;
|
||||
@override final String? merchantCountry;
|
||||
@override final String? maskedPan;
|
||||
@override final String? messageToUser;
|
||||
|
||||
/// Create a copy of WalletTransactionEntity
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@@ -521,16 +519,16 @@ _$WalletTransactionEntityCopyWith<_WalletTransactionEntity> get copyWith => __$W
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is _WalletTransactionEntity&&(identical(other.transactionId, transactionId) || other.transactionId == transactionId)&&(identical(other.walletDebitId, walletDebitId) || other.walletDebitId == walletDebitId)&&(identical(other.walletCreditId, walletCreditId) || other.walletCreditId == walletCreditId)&&(identical(other.transactionType, transactionType) || other.transactionType == transactionType)&&(identical(other.foreignId, foreignId) || other.foreignId == foreignId)&&(identical(other.name, name) || other.name == name)&&(identical(other.description, description) || other.description == description)&&(identical(other.valueDate, valueDate) || other.valueDate == valueDate)&&(identical(other.executionDate, executionDate) || other.executionDate == executionDate)&&(identical(other.amount, amount) || other.amount == amount)&&(identical(other.walletDebitBalance, walletDebitBalance) || other.walletDebitBalance == walletDebitBalance)&&(identical(other.walletCreditBalance, walletCreditBalance) || other.walletCreditBalance == walletCreditBalance)&&(identical(other.currency, currency) || other.currency == currency)&&(identical(other.createdDate, createdDate) || other.createdDate == createdDate)&&(identical(other.totalRows, totalRows) || other.totalRows == totalRows));
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is _WalletTransactionEntity&&(identical(other.operationType, operationType) || other.operationType == operationType)&&(identical(other.direction, direction) || other.direction == direction)&&(identical(other.objectId, objectId) || other.objectId == objectId)&&(identical(other.label, label) || other.label == label)&&(identical(other.status, status) || other.status == status)&&(identical(other.amount, amount) || other.amount == amount)&&(identical(other.currency, currency) || other.currency == currency)&&(identical(other.createdDate, createdDate) || other.createdDate == createdDate)&&(identical(other.settlementDate, settlementDate) || other.settlementDate == settlementDate)&&(identical(other.merchantName, merchantName) || other.merchantName == merchantName)&&(identical(other.merchantLogo, merchantLogo) || other.merchantLogo == merchantLogo)&&(identical(other.merchantCategory, merchantCategory) || other.merchantCategory == merchantCategory)&&(identical(other.merchantCategoryGroup, merchantCategoryGroup) || other.merchantCategoryGroup == merchantCategoryGroup)&&(identical(other.merchantCity, merchantCity) || other.merchantCity == merchantCity)&&(identical(other.merchantCountry, merchantCountry) || other.merchantCountry == merchantCountry)&&(identical(other.maskedPan, maskedPan) || other.maskedPan == maskedPan)&&(identical(other.messageToUser, messageToUser) || other.messageToUser == messageToUser));
|
||||
}
|
||||
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,transactionId,walletDebitId,walletCreditId,transactionType,foreignId,name,description,valueDate,executionDate,amount,walletDebitBalance,walletCreditBalance,currency,createdDate,totalRows);
|
||||
int get hashCode => Object.hash(runtimeType,operationType,direction,objectId,label,status,amount,currency,createdDate,settlementDate,merchantName,merchantLogo,merchantCategory,merchantCategoryGroup,merchantCity,merchantCountry,maskedPan,messageToUser);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'WalletTransactionEntity(transactionId: $transactionId, walletDebitId: $walletDebitId, walletCreditId: $walletCreditId, transactionType: $transactionType, foreignId: $foreignId, name: $name, description: $description, valueDate: $valueDate, executionDate: $executionDate, amount: $amount, walletDebitBalance: $walletDebitBalance, walletCreditBalance: $walletCreditBalance, currency: $currency, createdDate: $createdDate, totalRows: $totalRows)';
|
||||
return 'WalletTransactionEntity(operationType: $operationType, direction: $direction, objectId: $objectId, label: $label, status: $status, amount: $amount, currency: $currency, createdDate: $createdDate, settlementDate: $settlementDate, merchantName: $merchantName, merchantLogo: $merchantLogo, merchantCategory: $merchantCategory, merchantCategoryGroup: $merchantCategoryGroup, merchantCity: $merchantCity, merchantCountry: $merchantCountry, maskedPan: $maskedPan, messageToUser: $messageToUser)';
|
||||
}
|
||||
|
||||
|
||||
@@ -541,7 +539,7 @@ abstract mixin class _$WalletTransactionEntityCopyWith<$Res> implements $WalletT
|
||||
factory _$WalletTransactionEntityCopyWith(_WalletTransactionEntity value, $Res Function(_WalletTransactionEntity) _then) = __$WalletTransactionEntityCopyWithImpl;
|
||||
@override @useResult
|
||||
$Res call({
|
||||
int transactionId, int walletDebitId, int walletCreditId, TransactionType transactionType, String foreignId, String name, String description, String valueDate, String executionDate, String amount, String walletDebitBalance, String walletCreditBalance, String currency, String createdDate, String totalRows
|
||||
TransactionType operationType, String direction, String objectId, String label, String status, double amount, String currency, String createdDate, String? settlementDate, String? merchantName, String? merchantLogo, String? merchantCategory, String? merchantCategoryGroup, String? merchantCity, String? merchantCountry, String? maskedPan, String? messageToUser
|
||||
});
|
||||
|
||||
|
||||
@@ -558,24 +556,26 @@ class __$WalletTransactionEntityCopyWithImpl<$Res>
|
||||
|
||||
/// Create a copy of WalletTransactionEntity
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override @pragma('vm:prefer-inline') $Res call({Object? transactionId = null,Object? walletDebitId = null,Object? walletCreditId = null,Object? transactionType = null,Object? foreignId = null,Object? name = null,Object? description = null,Object? valueDate = null,Object? executionDate = null,Object? amount = null,Object? walletDebitBalance = null,Object? walletCreditBalance = null,Object? currency = null,Object? createdDate = null,Object? totalRows = null,}) {
|
||||
@override @pragma('vm:prefer-inline') $Res call({Object? operationType = null,Object? direction = null,Object? objectId = null,Object? label = null,Object? status = null,Object? amount = null,Object? currency = null,Object? createdDate = null,Object? settlementDate = freezed,Object? merchantName = freezed,Object? merchantLogo = freezed,Object? merchantCategory = freezed,Object? merchantCategoryGroup = freezed,Object? merchantCity = freezed,Object? merchantCountry = freezed,Object? maskedPan = freezed,Object? messageToUser = freezed,}) {
|
||||
return _then(_WalletTransactionEntity(
|
||||
transactionId: null == transactionId ? _self.transactionId : transactionId // ignore: cast_nullable_to_non_nullable
|
||||
as int,walletDebitId: null == walletDebitId ? _self.walletDebitId : walletDebitId // ignore: cast_nullable_to_non_nullable
|
||||
as int,walletCreditId: null == walletCreditId ? _self.walletCreditId : walletCreditId // ignore: cast_nullable_to_non_nullable
|
||||
as int,transactionType: null == transactionType ? _self.transactionType : transactionType // ignore: cast_nullable_to_non_nullable
|
||||
as TransactionType,foreignId: null == foreignId ? _self.foreignId : foreignId // ignore: cast_nullable_to_non_nullable
|
||||
as String,name: null == name ? _self.name : name // ignore: cast_nullable_to_non_nullable
|
||||
as String,description: null == description ? _self.description : description // ignore: cast_nullable_to_non_nullable
|
||||
as String,valueDate: null == valueDate ? _self.valueDate : valueDate // ignore: cast_nullable_to_non_nullable
|
||||
as String,executionDate: null == executionDate ? _self.executionDate : executionDate // ignore: cast_nullable_to_non_nullable
|
||||
operationType: null == operationType ? _self.operationType : operationType // ignore: cast_nullable_to_non_nullable
|
||||
as TransactionType,direction: null == direction ? _self.direction : direction // ignore: cast_nullable_to_non_nullable
|
||||
as String,objectId: null == objectId ? _self.objectId : objectId // ignore: cast_nullable_to_non_nullable
|
||||
as String,label: null == label ? _self.label : label // ignore: cast_nullable_to_non_nullable
|
||||
as String,status: null == status ? _self.status : status // ignore: cast_nullable_to_non_nullable
|
||||
as String,amount: null == amount ? _self.amount : amount // ignore: cast_nullable_to_non_nullable
|
||||
as String,walletDebitBalance: null == walletDebitBalance ? _self.walletDebitBalance : walletDebitBalance // ignore: cast_nullable_to_non_nullable
|
||||
as String,walletCreditBalance: null == walletCreditBalance ? _self.walletCreditBalance : walletCreditBalance // ignore: cast_nullable_to_non_nullable
|
||||
as String,currency: null == currency ? _self.currency : currency // ignore: cast_nullable_to_non_nullable
|
||||
as double,currency: null == currency ? _self.currency : currency // ignore: cast_nullable_to_non_nullable
|
||||
as String,createdDate: null == createdDate ? _self.createdDate : createdDate // ignore: cast_nullable_to_non_nullable
|
||||
as String,totalRows: null == totalRows ? _self.totalRows : totalRows // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
as String,settlementDate: freezed == settlementDate ? _self.settlementDate : settlementDate // ignore: cast_nullable_to_non_nullable
|
||||
as String?,merchantName: freezed == merchantName ? _self.merchantName : merchantName // ignore: cast_nullable_to_non_nullable
|
||||
as String?,merchantLogo: freezed == merchantLogo ? _self.merchantLogo : merchantLogo // ignore: cast_nullable_to_non_nullable
|
||||
as String?,merchantCategory: freezed == merchantCategory ? _self.merchantCategory : merchantCategory // ignore: cast_nullable_to_non_nullable
|
||||
as String?,merchantCategoryGroup: freezed == merchantCategoryGroup ? _self.merchantCategoryGroup : merchantCategoryGroup // ignore: cast_nullable_to_non_nullable
|
||||
as String?,merchantCity: freezed == merchantCity ? _self.merchantCity : merchantCity // ignore: cast_nullable_to_non_nullable
|
||||
as String?,merchantCountry: freezed == merchantCountry ? _self.merchantCountry : merchantCountry // ignore: cast_nullable_to_non_nullable
|
||||
as String?,maskedPan: freezed == maskedPan ? _self.maskedPan : maskedPan // ignore: cast_nullable_to_non_nullable
|
||||
as String?,messageToUser: freezed == messageToUser ? _self.messageToUser : messageToUser // ignore: cast_nullable_to_non_nullable
|
||||
as String?,
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
@@ -20,7 +20,18 @@ abstract class TreezorRepository {
|
||||
|
||||
Future<PaymentProfileEntity> getPaymentProfile({required String userId});
|
||||
|
||||
Future<WalletTransactionsResponseEntity> getWalletTransactions({
|
||||
Future<PaymentProfileEntity> updatePaymentProfile({
|
||||
required String paymentProfileId,
|
||||
required String scaProof,
|
||||
String? firstName,
|
||||
String? lastName,
|
||||
String? phone,
|
||||
List<PaymentProfileAddressEntity>? addresses,
|
||||
List<PaymentProfileAddressEntity>? taxResidences,
|
||||
String? nationality,
|
||||
});
|
||||
|
||||
Future<WalletTransactionsResponseEntity> getWalletOperations({
|
||||
required String walletId,
|
||||
Map<String, dynamic>? queryParameters,
|
||||
});
|
||||
@@ -32,13 +43,13 @@ abstract class TreezorRepository {
|
||||
Future<TransactionBeneficiaryEntity> createTransactionBeneficiary({
|
||||
required String name,
|
||||
required String iban,
|
||||
String? bic,
|
||||
required String scaProof,
|
||||
});
|
||||
|
||||
Future<String> validateTransactionBeneficiary({required int beneficiaryId});
|
||||
|
||||
Future<void> walletTransfer({
|
||||
required String walletId,
|
||||
required int beneficiaryId,
|
||||
required String beneficiaryValidationId,
|
||||
required double amount,
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import '../entities/child_profile_deletability_entity.dart';
|
||||
import '../entities/child_profile_entity.dart';
|
||||
import '../entities/device_entity.dart';
|
||||
import '../entities/user_entity.dart';
|
||||
@@ -5,6 +6,17 @@ import '../entities/user_entity.dart';
|
||||
abstract class UserRepository {
|
||||
Future<UserEntity> getUserInfo();
|
||||
Future<List<ChildProfileEntity>> getChildProfiles();
|
||||
Future<ChildProfileDeletabilityEntity> checkChildProfileDeletability({
|
||||
required String childProfileId,
|
||||
});
|
||||
Future<DeviceEntity> getDeviceByIdentificator({required String identificator});
|
||||
Future<String> deleteDevice({required String deviceId});
|
||||
Future<void> updateChildProfile({
|
||||
required String childProfileId,
|
||||
required String scaProof,
|
||||
String? firstName,
|
||||
String? lastName,
|
||||
int? bornAt,
|
||||
String? address,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
|
||||
import 'package:sf_shared/src/domain/entities/date_filter.dart';
|
||||
@@ -8,22 +6,26 @@ import 'package:sf_shared/src/providers/treezor_repository_provider.dart';
|
||||
import 'package:sf_shared/src/providers/wallet_refresh_provider.dart';
|
||||
|
||||
final walletTransactionsProvider = FutureProvider.autoDispose
|
||||
.family<List<WalletTransactionEntity>, TransactionsQuery>(
|
||||
.family<WalletTransactionsResponseEntity, TransactionsQuery>(
|
||||
(ref, query) async {
|
||||
ref.watch(walletRefreshProvider);
|
||||
final repository = ref.read(treezorRepositoryProvider);
|
||||
|
||||
Map<String, dynamic>? queryParameters;
|
||||
if (query.dateFilter != null) {
|
||||
final filtersJson = jsonEncode({
|
||||
'createdDate': {'gte': query.dateFilter!.startDate.toIso8601String()},
|
||||
});
|
||||
queryParameters = {'filters': base64Encode(utf8.encode(filtersJson))};
|
||||
}
|
||||
final now = DateTime.now().toUtc();
|
||||
final dateFrom = (query.dateFilter?.startDate ??
|
||||
DateTime(now.year, now.month - 1, now.day)).toUtc();
|
||||
final dateTo = now;
|
||||
|
||||
final response = await repository.getWalletTransactions(
|
||||
final queryParameters = <String, dynamic>{
|
||||
'dateFrom': dateFrom.millisecondsSinceEpoch,
|
||||
'dateTo': dateTo.millisecondsSinceEpoch,
|
||||
'pageSize': 3,
|
||||
if (query.cursor != null) 'cursor': query.cursor,
|
||||
};
|
||||
|
||||
final response = await repository.getWalletOperations(
|
||||
walletId: query.walletId,
|
||||
queryParameters: queryParameters,
|
||||
);
|
||||
return response.items;
|
||||
return response;
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user