Build exchange workspace and shared transaction services (#28)
This commit is contained in:
1 parent
52b7135eda
commit
c496da8a55
48 files changed
+4757
-120
No files matched your search
@@ -4,23 +4,101 @@ import 'package:flutter/widgets.dart';
|
||||
|
||||
import 'package:go_router/go_router.dart';
|
||||
|
||||
import 'package:sxchnge_wallet/sxchnge_wallet.dart';
|
||||
|
||||
import '../auth/page.dart';
|
||||
import '../kyc/page.dart';
|
||||
import '../verification/page.dart';
|
||||
import '../workspace/accounts.dart';
|
||||
import '../workspace/activity.dart';
|
||||
import '../workspace/limits.dart';
|
||||
import '../workspace/operation.dart';
|
||||
import '../workspace/settings.dart';
|
||||
import '../workspace/shell.dart';
|
||||
import '../workspace/transfer.dart';
|
||||
import 'routes.dart';
|
||||
|
||||
GoRouter createAppRouter() {
|
||||
final topUpKey = GlobalKey<TransferPageState>();
|
||||
final exchangeKey = GlobalKey<TransferPageState>();
|
||||
final payoutKey = GlobalKey<TransferPageState>();
|
||||
final identityKey = GlobalKey<IdentityPageState>();
|
||||
return GoRouter(
|
||||
// Signup email is an in-memory navigation extra, never browser-history data.
|
||||
extraCodec: const _TransientExtras(),
|
||||
routes: [
|
||||
GoRoute(
|
||||
path: '/identity',
|
||||
name: AppRoutes.identity,
|
||||
builder: (context, state) => IdentityPage(key: identityKey),
|
||||
onExit: (context, state) async =>
|
||||
await identityKey.currentState?.allowExit() ?? true,
|
||||
ShellRoute(
|
||||
builder: (context, state, child) =>
|
||||
WorkspaceShell(path: state.uri.path, child: child),
|
||||
routes: [
|
||||
GoRoute(
|
||||
path: '/accounts',
|
||||
builder: (context, state) => const AccountsPage(),
|
||||
routes: [
|
||||
GoRoute(
|
||||
path: ':accountId',
|
||||
builder: (context, state) =>
|
||||
AccountsPage(accountId: state.pathParameters['accountId']),
|
||||
),
|
||||
],
|
||||
),
|
||||
GoRoute(
|
||||
path: '/activity',
|
||||
builder: (context, state) => const ActivityPage(),
|
||||
routes: [
|
||||
GoRoute(
|
||||
path: ':operationId',
|
||||
builder: (context, state) =>
|
||||
OperationPage(id: state.pathParameters['operationId']!),
|
||||
),
|
||||
],
|
||||
),
|
||||
GoRoute(
|
||||
path: '/limits',
|
||||
builder: (context, state) => const LimitsPage(),
|
||||
),
|
||||
GoRoute(
|
||||
path: '/settings',
|
||||
builder: (context, state) => const SettingsPage(),
|
||||
),
|
||||
GoRoute(
|
||||
path: '/top-up',
|
||||
builder: (context, state) => TransferPage(
|
||||
key: topUpKey,
|
||||
kind: TransferKind.topUp,
|
||||
source: state.extra is String ? state.extra as String : null,
|
||||
),
|
||||
onExit: (context, state) async =>
|
||||
await topUpKey.currentState?.allowExit() ?? true,
|
||||
),
|
||||
GoRoute(
|
||||
path: '/exchange',
|
||||
builder: (context, state) => TransferPage(
|
||||
key: exchangeKey,
|
||||
kind: TransferKind.exchange,
|
||||
source: state.extra is String ? state.extra as String : null,
|
||||
),
|
||||
onExit: (context, state) async =>
|
||||
await exchangeKey.currentState?.allowExit() ?? true,
|
||||
),
|
||||
GoRoute(
|
||||
path: '/payout',
|
||||
builder: (context, state) => TransferPage(
|
||||
key: payoutKey,
|
||||
kind: TransferKind.payout,
|
||||
source: state.extra is String ? state.extra as String : null,
|
||||
),
|
||||
onExit: (context, state) async =>
|
||||
await payoutKey.currentState?.allowExit() ?? true,
|
||||
),
|
||||
GoRoute(
|
||||
path: '/identity',
|
||||
name: AppRoutes.identity,
|
||||
builder: (context, state) => IdentityPage(key: identityKey),
|
||||
onExit: (context, state) async =>
|
||||
await identityKey.currentState?.allowExit() ?? true,
|
||||
),
|
||||
],
|
||||
),
|
||||
GoRoute(
|
||||
path: '/',
|
||||
|
||||
Reference in new issue
Block a user