mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2024-12-26 21:39:21 +00:00
275 lines
10 KiB
Dart
275 lines
10 KiB
Dart
import 'package:flutter/cupertino.dart';
|
|
import 'package:flutter/widgets.dart';
|
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
|
import 'pages/add_wallet_views/frost_ms/new/steps/frost_create_step_1a.dart';
|
|
import 'pages/add_wallet_views/frost_ms/new/steps/frost_create_step_1b.dart';
|
|
import 'pages/add_wallet_views/frost_ms/new/steps/frost_create_step_2.dart';
|
|
import 'pages/add_wallet_views/frost_ms/new/steps/frost_create_step_3.dart';
|
|
import 'pages/add_wallet_views/frost_ms/new/steps/frost_create_step_4.dart';
|
|
import 'pages/add_wallet_views/frost_ms/new/steps/frost_create_step_5.dart';
|
|
import 'pages/add_wallet_views/frost_ms/reshare/frost_reshare_step_1a.dart';
|
|
import 'pages/add_wallet_views/frost_ms/reshare/frost_reshare_step_1b.dart';
|
|
import 'pages/add_wallet_views/frost_ms/reshare/frost_reshare_step_1c.dart';
|
|
import 'pages/add_wallet_views/frost_ms/reshare/frost_reshare_step_2abd.dart';
|
|
import 'pages/add_wallet_views/frost_ms/reshare/frost_reshare_step_2c.dart';
|
|
import 'pages/add_wallet_views/frost_ms/reshare/frost_reshare_step_3abd.dart';
|
|
import 'pages/add_wallet_views/frost_ms/reshare/frost_reshare_step_3c.dart';
|
|
import 'pages/add_wallet_views/frost_ms/reshare/frost_reshare_step_4.dart';
|
|
import 'pages/add_wallet_views/frost_ms/reshare/frost_reshare_step_5.dart';
|
|
import 'pages/send_view/frost_ms/send_steps/frost_send_step_1a.dart';
|
|
import 'pages/send_view/frost_ms/send_steps/frost_send_step_1b.dart';
|
|
import 'pages/send_view/frost_ms/send_steps/frost_send_step_2.dart';
|
|
import 'pages/send_view/frost_ms/send_steps/frost_send_step_3.dart';
|
|
import 'pages/send_view/frost_ms/send_steps/frost_send_step_4.dart';
|
|
import 'route_generator.dart';
|
|
import 'wallets/crypto_currency/intermediate/frost_currency.dart';
|
|
|
|
typedef FrostStepRoute = ({String routeName, String title});
|
|
|
|
enum FrostInterruptionDialogType {
|
|
walletCreation,
|
|
resharing,
|
|
transactionCreation;
|
|
}
|
|
|
|
final pFrostCreateCurrentStep = StateProvider.autoDispose((ref) => 1);
|
|
final pFrostScaffoldCanPopDesktop = StateProvider.autoDispose((_) => false);
|
|
final pFrostScaffoldArgs = StateProvider<
|
|
({
|
|
({String walletName, FrostCurrency frostCurrency}) info,
|
|
String? walletId,
|
|
List<FrostStepRoute> stepRoutes,
|
|
FrostInterruptionDialogType frostInterruptionDialogType,
|
|
NavigatorState parentNav,
|
|
String callerRouteName,
|
|
})?>((ref) => null);
|
|
|
|
abstract class FrostRouteGenerator {
|
|
static const bool useMaterialPageRoute = true;
|
|
|
|
static const List<FrostStepRoute> createNewConfigStepRoutes = [
|
|
(routeName: FrostCreateStep1a.routeName, title: FrostCreateStep1a.title),
|
|
(routeName: FrostCreateStep2.routeName, title: FrostCreateStep2.title),
|
|
(routeName: FrostCreateStep3.routeName, title: FrostCreateStep3.title),
|
|
(routeName: FrostCreateStep4.routeName, title: FrostCreateStep4.title),
|
|
(routeName: FrostCreateStep5.routeName, title: FrostCreateStep5.title),
|
|
];
|
|
|
|
static const List<FrostStepRoute> importNewConfigStepRoutes = [
|
|
(routeName: FrostCreateStep1b.routeName, title: FrostCreateStep1b.title),
|
|
(routeName: FrostCreateStep2.routeName, title: FrostCreateStep2.title),
|
|
(routeName: FrostCreateStep3.routeName, title: FrostCreateStep3.title),
|
|
(routeName: FrostCreateStep4.routeName, title: FrostCreateStep4.title),
|
|
(routeName: FrostCreateStep5.routeName, title: FrostCreateStep5.title),
|
|
];
|
|
|
|
static const List<FrostStepRoute> initiateReshareStepRoutes = [
|
|
(routeName: FrostReshareStep1a.routeName, title: FrostReshareStep1a.title),
|
|
(
|
|
routeName: FrostReshareStep2abd.routeName,
|
|
title: FrostReshareStep2abd.title
|
|
),
|
|
(
|
|
routeName: FrostReshareStep3abd.routeName,
|
|
title: FrostReshareStep3abd.title
|
|
),
|
|
(routeName: FrostReshareStep4.routeName, title: FrostReshareStep4.title),
|
|
(routeName: FrostReshareStep5.routeName, title: FrostReshareStep5.title),
|
|
];
|
|
|
|
static const List<FrostStepRoute> importReshareStepRoutes = [
|
|
(routeName: FrostReshareStep1b.routeName, title: FrostReshareStep1b.title),
|
|
(
|
|
routeName: FrostReshareStep2abd.routeName,
|
|
title: FrostReshareStep2abd.title
|
|
),
|
|
(
|
|
routeName: FrostReshareStep3abd.routeName,
|
|
title: FrostReshareStep3abd.title
|
|
),
|
|
(routeName: FrostReshareStep4.routeName, title: FrostReshareStep4.title),
|
|
(routeName: FrostReshareStep5.routeName, title: FrostReshareStep5.title),
|
|
];
|
|
|
|
static const List<FrostStepRoute> joinReshareStepRoutes = [
|
|
(routeName: FrostReshareStep1c.routeName, title: FrostReshareStep1c.title),
|
|
(routeName: FrostReshareStep2c.routeName, title: FrostReshareStep2c.title),
|
|
(routeName: FrostReshareStep3c.routeName, title: FrostReshareStep3c.title),
|
|
(routeName: FrostReshareStep4.routeName, title: FrostReshareStep4.title),
|
|
(routeName: FrostReshareStep5.routeName, title: FrostReshareStep5.title),
|
|
];
|
|
|
|
static const List<FrostStepRoute> sendFrostTxStepRoutes = [
|
|
(routeName: FrostSendStep1a.routeName, title: FrostSendStep1a.title),
|
|
(routeName: FrostSendStep2.routeName, title: FrostSendStep2.title),
|
|
(routeName: FrostSendStep3.routeName, title: FrostSendStep3.title),
|
|
(routeName: FrostSendStep4.routeName, title: FrostSendStep4.title),
|
|
];
|
|
|
|
static const List<FrostStepRoute> signFrostTxStepRoutes = [
|
|
(routeName: FrostSendStep1b.routeName, title: FrostSendStep1b.title),
|
|
(routeName: FrostSendStep2.routeName, title: FrostSendStep2.title),
|
|
(routeName: FrostSendStep3.routeName, title: FrostSendStep3.title),
|
|
(routeName: FrostSendStep4.routeName, title: FrostSendStep4.title),
|
|
];
|
|
|
|
static Route<dynamic> generateRoute(RouteSettings settings) {
|
|
final args = settings.arguments;
|
|
|
|
switch (settings.name) {
|
|
case FrostCreateStep1a.routeName:
|
|
return RouteGenerator.getRoute(
|
|
shouldUseMaterialRoute: useMaterialPageRoute,
|
|
builder: (_) => const FrostCreateStep1a(),
|
|
settings: settings,
|
|
);
|
|
|
|
case FrostCreateStep1b.routeName:
|
|
return RouteGenerator.getRoute(
|
|
shouldUseMaterialRoute: useMaterialPageRoute,
|
|
builder: (_) => const FrostCreateStep1b(),
|
|
settings: settings,
|
|
);
|
|
|
|
case FrostCreateStep2.routeName:
|
|
return RouteGenerator.getRoute(
|
|
shouldUseMaterialRoute: useMaterialPageRoute,
|
|
builder: (_) => const FrostCreateStep2(),
|
|
settings: settings,
|
|
);
|
|
|
|
case FrostCreateStep3.routeName:
|
|
return RouteGenerator.getRoute(
|
|
shouldUseMaterialRoute: useMaterialPageRoute,
|
|
builder: (_) => const FrostCreateStep3(),
|
|
settings: settings,
|
|
);
|
|
|
|
case FrostCreateStep4.routeName:
|
|
return RouteGenerator.getRoute(
|
|
shouldUseMaterialRoute: useMaterialPageRoute,
|
|
builder: (_) => const FrostCreateStep4(),
|
|
settings: settings,
|
|
);
|
|
|
|
case FrostCreateStep5.routeName:
|
|
return RouteGenerator.getRoute(
|
|
shouldUseMaterialRoute: useMaterialPageRoute,
|
|
builder: (_) => const FrostCreateStep5(),
|
|
settings: settings,
|
|
);
|
|
|
|
case FrostReshareStep1a.routeName:
|
|
return RouteGenerator.getRoute(
|
|
shouldUseMaterialRoute: useMaterialPageRoute,
|
|
builder: (_) => const FrostReshareStep1a(),
|
|
settings: settings,
|
|
);
|
|
|
|
case FrostReshareStep1b.routeName:
|
|
return RouteGenerator.getRoute(
|
|
shouldUseMaterialRoute: useMaterialPageRoute,
|
|
builder: (_) => const FrostReshareStep1b(),
|
|
settings: settings,
|
|
);
|
|
|
|
case FrostReshareStep1c.routeName:
|
|
return RouteGenerator.getRoute(
|
|
shouldUseMaterialRoute: useMaterialPageRoute,
|
|
builder: (_) => const FrostReshareStep1c(),
|
|
settings: settings,
|
|
);
|
|
|
|
case FrostReshareStep2abd.routeName:
|
|
return RouteGenerator.getRoute(
|
|
shouldUseMaterialRoute: useMaterialPageRoute,
|
|
builder: (_) => const FrostReshareStep2abd(),
|
|
settings: settings,
|
|
);
|
|
|
|
case FrostReshareStep2c.routeName:
|
|
return RouteGenerator.getRoute(
|
|
shouldUseMaterialRoute: useMaterialPageRoute,
|
|
builder: (_) => const FrostReshareStep2c(),
|
|
settings: settings,
|
|
);
|
|
|
|
case FrostReshareStep3abd.routeName:
|
|
return RouteGenerator.getRoute(
|
|
shouldUseMaterialRoute: useMaterialPageRoute,
|
|
builder: (_) => const FrostReshareStep3abd(),
|
|
settings: settings,
|
|
);
|
|
|
|
case FrostReshareStep3c.routeName:
|
|
return RouteGenerator.getRoute(
|
|
shouldUseMaterialRoute: useMaterialPageRoute,
|
|
builder: (_) => const FrostReshareStep3c(),
|
|
settings: settings,
|
|
);
|
|
|
|
case FrostReshareStep4.routeName:
|
|
return RouteGenerator.getRoute(
|
|
shouldUseMaterialRoute: useMaterialPageRoute,
|
|
builder: (_) => const FrostReshareStep4(),
|
|
settings: settings,
|
|
);
|
|
|
|
case FrostReshareStep5.routeName:
|
|
return RouteGenerator.getRoute(
|
|
shouldUseMaterialRoute: useMaterialPageRoute,
|
|
builder: (_) => const FrostReshareStep5(),
|
|
settings: settings,
|
|
);
|
|
|
|
case FrostSendStep1a.routeName:
|
|
return RouteGenerator.getRoute(
|
|
shouldUseMaterialRoute: useMaterialPageRoute,
|
|
builder: (_) => const FrostSendStep1a(),
|
|
settings: settings,
|
|
);
|
|
|
|
case FrostSendStep1b.routeName:
|
|
return RouteGenerator.getRoute(
|
|
shouldUseMaterialRoute: useMaterialPageRoute,
|
|
builder: (_) => const FrostSendStep1b(),
|
|
settings: settings,
|
|
);
|
|
|
|
case FrostSendStep2.routeName:
|
|
return RouteGenerator.getRoute(
|
|
shouldUseMaterialRoute: useMaterialPageRoute,
|
|
builder: (_) => const FrostSendStep2(),
|
|
settings: settings,
|
|
);
|
|
|
|
case FrostSendStep3.routeName:
|
|
return RouteGenerator.getRoute(
|
|
shouldUseMaterialRoute: useMaterialPageRoute,
|
|
builder: (_) => const FrostSendStep3(),
|
|
settings: settings,
|
|
);
|
|
|
|
case FrostSendStep4.routeName:
|
|
return RouteGenerator.getRoute(
|
|
shouldUseMaterialRoute: useMaterialPageRoute,
|
|
builder: (_) => const FrostSendStep4(),
|
|
settings: settings,
|
|
);
|
|
|
|
default:
|
|
return _routeError("");
|
|
}
|
|
}
|
|
|
|
static Route<dynamic> _routeError(String message) {
|
|
return RouteGenerator.getRoute(
|
|
shouldUseMaterialRoute: useMaterialPageRoute,
|
|
builder: (_) => Placeholder(
|
|
child: Center(
|
|
child: Text(message),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|