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
@@ -0,0 +1,134 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'package:go_router/go_router.dart';
|
||||
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
import 'package:sxchnge_wallet/sxchnge_wallet.dart';
|
||||
|
||||
import '../auth/brand_panel.dart';
|
||||
import '../providers/locale.dart';
|
||||
|
||||
import '../generated/i18n/app_localizations.dart';
|
||||
|
||||
class WorkspaceShell extends StatefulWidget {
|
||||
const WorkspaceShell({super.key, required this.child, required this.path});
|
||||
final Widget child;
|
||||
final String path;
|
||||
@override
|
||||
State<WorkspaceShell> createState() => _WorkspaceShellState();
|
||||
}
|
||||
|
||||
class _WorkspaceShellState extends State<WorkspaceShell> {
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
if (!mounted) return;
|
||||
final wallet = context.read<WalletProvider>();
|
||||
if (wallet.data == null) wallet.refresh();
|
||||
context.read<LocaleProvider>().loadAccount(wallet);
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final l = AppLocalizations.of(context)!;
|
||||
final t = Theme.of(context);
|
||||
final c = t.colorScheme;
|
||||
final paths = ['/accounts', '/activity', '/limits', '/settings'];
|
||||
final labels = [l.wAccounts, l.wActivity, l.wLimits, l.wSettings];
|
||||
final icons = [
|
||||
Icons.account_balance_wallet_outlined,
|
||||
Icons.receipt_long_outlined,
|
||||
Icons.speed_outlined,
|
||||
Icons.tune_rounded,
|
||||
];
|
||||
final index = widget.path.startsWith('/activity')
|
||||
? 1
|
||||
: widget.path.startsWith('/limits') ||
|
||||
widget.path.startsWith('/identity')
|
||||
? 2
|
||||
: widget.path.startsWith('/settings')
|
||||
? 3
|
||||
: 0;
|
||||
void navigate(int i) {
|
||||
if (['/top-up', '/exchange', '/payout'].contains(widget.path) && i >= 2) {
|
||||
context.push(paths[i]);
|
||||
} else {
|
||||
context.go(paths[i]);
|
||||
}
|
||||
}
|
||||
|
||||
final wide = MediaQuery.sizeOf(context).width >= 900;
|
||||
final content = Column(
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 24, vertical: 12),
|
||||
child: Column(
|
||||
crossAxisAlignment: wide
|
||||
? CrossAxisAlignment.end
|
||||
: CrossAxisAlignment.start,
|
||||
children: [
|
||||
if (!wide) ...[const BrandWordmark(), const SizedBox(height: 8)],
|
||||
Text(l.wDemo, style: t.textTheme.bodySmall),
|
||||
],
|
||||
),
|
||||
),
|
||||
Expanded(child: widget.child),
|
||||
],
|
||||
);
|
||||
return Scaffold(
|
||||
body: SafeArea(
|
||||
child: Row(
|
||||
children: [
|
||||
if (wide)
|
||||
Container(
|
||||
width: 220,
|
||||
padding: const EdgeInsets.all(20),
|
||||
decoration: BoxDecoration(
|
||||
color: c.surfaceContainerLow,
|
||||
border: Border(right: BorderSide(color: c.outlineVariant)),
|
||||
),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
const Padding(
|
||||
padding: EdgeInsets.symmetric(vertical: 24),
|
||||
child: BrandWordmark(),
|
||||
),
|
||||
const SizedBox(height: 48),
|
||||
for (var i = 0; i < 4; i++)
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(bottom: 12),
|
||||
child: ListTile(
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(18),
|
||||
),
|
||||
selected: i == index,
|
||||
selectedTileColor: c.primaryContainer,
|
||||
leading: Icon(icons[i]),
|
||||
title: Text(labels[i]),
|
||||
onTap: () => navigate(i),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
Expanded(child: content),
|
||||
],
|
||||
),
|
||||
),
|
||||
bottomNavigationBar: wide
|
||||
? null
|
||||
: NavigationBar(
|
||||
selectedIndex: index,
|
||||
onDestinationSelected: navigate,
|
||||
destinations: [
|
||||
for (var i = 0; i < 4; i++)
|
||||
NavigationDestination(icon: Icon(icons[i]), label: labels[i]),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user