mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2024-12-23 03:49:22 +00:00
fusion group details
This commit is contained in:
parent
f290743d31
commit
4c6404cfb2
4 changed files with 280 additions and 23 deletions
|
@ -0,0 +1,234 @@
|
|||
/*
|
||||
* This file is part of Stack Wallet.
|
||||
*
|
||||
* Copyright (c) 2023 Cypher Stack
|
||||
* All Rights Reserved.
|
||||
* The code is distributed under GPLv3 license, see LICENSE file for details.
|
||||
* Generated by Cypher Stack on 2023-05-26
|
||||
*
|
||||
*/
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:stackwallet/models/isar/models/blockchain_data/v2/transaction_v2.dart';
|
||||
import 'package:stackwallet/pages/wallet_view/transaction_views/tx_v2/transaction_v2_list_item.dart';
|
||||
import 'package:stackwallet/pages/wallet_view/wallet_view.dart';
|
||||
import 'package:stackwallet/themes/stack_colors.dart';
|
||||
import 'package:stackwallet/utilities/constants.dart';
|
||||
import 'package:stackwallet/utilities/enums/coin_enum.dart';
|
||||
import 'package:stackwallet/utilities/text_styles.dart';
|
||||
import 'package:stackwallet/utilities/util.dart';
|
||||
import 'package:stackwallet/widgets/background.dart';
|
||||
import 'package:stackwallet/widgets/conditional_parent.dart';
|
||||
import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart';
|
||||
import 'package:stackwallet/widgets/desktop/desktop_dialog_close_button.dart';
|
||||
import 'package:stackwallet/widgets/rounded_white_container.dart';
|
||||
|
||||
class FusionGroupDetailsView extends ConsumerStatefulWidget {
|
||||
const FusionGroupDetailsView({
|
||||
Key? key,
|
||||
required this.transactions,
|
||||
required this.walletId,
|
||||
required this.coin,
|
||||
}) : super(key: key);
|
||||
|
||||
static const String routeName = "/fusionGroupDetailsView";
|
||||
|
||||
final List<TransactionV2> transactions;
|
||||
final String walletId;
|
||||
final Coin coin;
|
||||
|
||||
@override
|
||||
ConsumerState<FusionGroupDetailsView> createState() =>
|
||||
_FusionGroupDetailsViewState();
|
||||
}
|
||||
|
||||
class _FusionGroupDetailsViewState
|
||||
extends ConsumerState<FusionGroupDetailsView> {
|
||||
late final bool isDesktop;
|
||||
late final String walletId;
|
||||
|
||||
BorderRadius get _borderRadiusFirst {
|
||||
return BorderRadius.only(
|
||||
topLeft: Radius.circular(
|
||||
Constants.size.circularBorderRadius,
|
||||
),
|
||||
topRight: Radius.circular(
|
||||
Constants.size.circularBorderRadius,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
BorderRadius get _borderRadiusLast {
|
||||
return BorderRadius.only(
|
||||
bottomLeft: Radius.circular(
|
||||
Constants.size.circularBorderRadius,
|
||||
),
|
||||
bottomRight: Radius.circular(
|
||||
Constants.size.circularBorderRadius,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
isDesktop = Util.isDesktop;
|
||||
walletId = widget.walletId;
|
||||
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ConditionalParent(
|
||||
condition: !isDesktop,
|
||||
builder: (child) => Background(
|
||||
child: child,
|
||||
),
|
||||
child: Scaffold(
|
||||
backgroundColor: isDesktop
|
||||
? Colors.transparent
|
||||
: Theme.of(context).extension<StackColors>()!.background,
|
||||
appBar: isDesktop
|
||||
? null
|
||||
: AppBar(
|
||||
backgroundColor:
|
||||
Theme.of(context).extension<StackColors>()!.background,
|
||||
leading: AppBarBackButton(
|
||||
onPressed: () async {
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
),
|
||||
title: Text(
|
||||
"Fusion transactions",
|
||||
style: STextStyles.navBarTitle(context),
|
||||
),
|
||||
),
|
||||
body: Padding(
|
||||
padding: isDesktop
|
||||
? const EdgeInsets.only(left: 32)
|
||||
: const EdgeInsets.all(12),
|
||||
child: Column(
|
||||
children: [
|
||||
if (isDesktop)
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
"Fusion transactions",
|
||||
style: STextStyles.desktopH3(context),
|
||||
),
|
||||
const DesktopDialogCloseButton(),
|
||||
],
|
||||
),
|
||||
Flexible(
|
||||
child: Padding(
|
||||
padding: isDesktop
|
||||
? const EdgeInsets.only(
|
||||
right: 32,
|
||||
bottom: 32,
|
||||
)
|
||||
: const EdgeInsets.all(0),
|
||||
child: ConditionalParent(
|
||||
condition: isDesktop,
|
||||
builder: (child) {
|
||||
return RoundedWhiteContainer(
|
||||
borderColor: isDesktop
|
||||
? Theme.of(context)
|
||||
.extension<StackColors>()!
|
||||
.backgroundAppBar
|
||||
: null,
|
||||
padding: const EdgeInsets.all(0),
|
||||
child: child,
|
||||
);
|
||||
},
|
||||
child: SingleChildScrollView(
|
||||
primary: isDesktop ? false : null,
|
||||
child: Padding(
|
||||
padding: isDesktop
|
||||
? const EdgeInsets.all(0)
|
||||
: const EdgeInsets.all(4),
|
||||
child: Util.isDesktop
|
||||
? ListView.separated(
|
||||
shrinkWrap: true,
|
||||
itemBuilder: (context, index) {
|
||||
BorderRadius? radius;
|
||||
if (widget.transactions.length == 1) {
|
||||
radius = BorderRadius.circular(
|
||||
Constants.size.circularBorderRadius,
|
||||
);
|
||||
} else if (index ==
|
||||
widget.transactions.length - 1) {
|
||||
radius = _borderRadiusLast;
|
||||
} else if (index == 0) {
|
||||
radius = _borderRadiusFirst;
|
||||
}
|
||||
final tx = widget.transactions[index];
|
||||
return TxListItem(
|
||||
tx: tx,
|
||||
coin: widget.coin,
|
||||
radius: radius,
|
||||
);
|
||||
},
|
||||
separatorBuilder: (context, index) {
|
||||
return Container(
|
||||
width: double.infinity,
|
||||
height: 1.2,
|
||||
color: Theme.of(context)
|
||||
.extension<StackColors>()!
|
||||
.background,
|
||||
);
|
||||
},
|
||||
itemCount: widget.transactions.length,
|
||||
)
|
||||
: ListView.builder(
|
||||
itemCount: widget.transactions.length,
|
||||
itemBuilder: (context, index) {
|
||||
BorderRadius? radius;
|
||||
bool shouldWrap = false;
|
||||
if (widget.transactions.length == 1) {
|
||||
radius = BorderRadius.circular(
|
||||
Constants.size.circularBorderRadius,
|
||||
);
|
||||
} else if (index ==
|
||||
widget.transactions.length - 1) {
|
||||
radius = _borderRadiusLast;
|
||||
shouldWrap = true;
|
||||
} else if (index == 0) {
|
||||
radius = _borderRadiusFirst;
|
||||
}
|
||||
final tx = widget.transactions[index];
|
||||
if (shouldWrap) {
|
||||
return Column(
|
||||
children: [
|
||||
TxListItem(
|
||||
tx: tx,
|
||||
coin: widget.coin,
|
||||
radius: radius,
|
||||
),
|
||||
const SizedBox(
|
||||
height: WalletView.navBarHeight + 14,
|
||||
),
|
||||
],
|
||||
);
|
||||
} else {
|
||||
return TxListItem(
|
||||
tx: tx,
|
||||
coin: widget.coin,
|
||||
radius: radius,
|
||||
);
|
||||
}
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
|
@ -1,13 +1,17 @@
|
|||
import 'dart:async';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:stackwallet/models/isar/models/blockchain_data/v2/transaction_v2.dart';
|
||||
import 'package:stackwallet/pages/wallet_view/sub_widgets/tx_icon.dart';
|
||||
import 'package:stackwallet/pages/wallet_view/transaction_views/tx_v2/fusion_group_details_view.dart';
|
||||
import 'package:stackwallet/providers/providers.dart';
|
||||
import 'package:stackwallet/themes/stack_colors.dart';
|
||||
import 'package:stackwallet/utilities/constants.dart';
|
||||
import 'package:stackwallet/utilities/format.dart';
|
||||
import 'package:stackwallet/utilities/text_styles.dart';
|
||||
import 'package:stackwallet/utilities/util.dart';
|
||||
import 'package:stackwallet/widgets/desktop/desktop_dialog.dart';
|
||||
|
||||
class FusionTxGroup {
|
||||
final List<TransactionV2> transactions;
|
||||
|
@ -46,29 +50,28 @@ class FusionTxGroupCard extends ConsumerWidget {
|
|||
),
|
||||
onPressed: () async {
|
||||
if (Util.isDesktop) {
|
||||
// await showDialog<void>(
|
||||
// context: context,
|
||||
// builder: (context) => DesktopDialog(
|
||||
// maxHeight: MediaQuery.of(context).size.height - 64,
|
||||
// maxWidth: 580,
|
||||
// child: TransactionV2DetailsView(
|
||||
// transaction: _transaction,
|
||||
// coin: coin,
|
||||
// walletId: walletId,
|
||||
// ),
|
||||
// ),
|
||||
// );
|
||||
await showDialog<void>(
|
||||
context: context,
|
||||
builder: (context) => DesktopDialog(
|
||||
maxWidth: 580,
|
||||
child: FusionGroupDetailsView(
|
||||
transactions: group.transactions,
|
||||
coin: coin,
|
||||
walletId: walletId,
|
||||
),
|
||||
),
|
||||
);
|
||||
} else {
|
||||
// unawaited(
|
||||
// Navigator.of(context).pushNamed(
|
||||
// TransactionV2DetailsView.routeName,
|
||||
// arguments: (
|
||||
// tx: _transaction,
|
||||
// coin: coin,
|
||||
// walletId: walletId,
|
||||
// ),
|
||||
// ),
|
||||
// );
|
||||
unawaited(
|
||||
Navigator.of(context).pushNamed(
|
||||
FusionGroupDetailsView.routeName,
|
||||
arguments: (
|
||||
transactions: group.transactions,
|
||||
coin: coin,
|
||||
walletId: walletId,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
},
|
||||
child: Padding(
|
||||
|
|
|
@ -171,7 +171,6 @@ class TxListItem extends ConsumerWidget {
|
|||
borderRadius: radius,
|
||||
),
|
||||
child: FusionTxGroupCard(
|
||||
// this may mess with combined firo transactions
|
||||
key: UniqueKey(),
|
||||
group: group,
|
||||
),
|
||||
|
|
|
@ -132,6 +132,7 @@ import 'package:stackwallet/pages/wallet_view/transaction_views/all_transactions
|
|||
import 'package:stackwallet/pages/wallet_view/transaction_views/edit_note_view.dart';
|
||||
import 'package:stackwallet/pages/wallet_view/transaction_views/transaction_details_view.dart';
|
||||
import 'package:stackwallet/pages/wallet_view/transaction_views/transaction_search_filter_view.dart';
|
||||
import 'package:stackwallet/pages/wallet_view/transaction_views/tx_v2/fusion_group_details_view.dart';
|
||||
import 'package:stackwallet/pages/wallet_view/transaction_views/tx_v2/transaction_v2_details_view.dart';
|
||||
import 'package:stackwallet/pages/wallet_view/wallet_view.dart';
|
||||
import 'package:stackwallet/pages/wallets_view/wallets_overview.dart';
|
||||
|
@ -1277,6 +1278,26 @@ class RouteGenerator {
|
|||
}
|
||||
return _routeError("${settings.name} invalid args: ${args.toString()}");
|
||||
|
||||
case FusionGroupDetailsView.routeName:
|
||||
if (args is ({
|
||||
List<TransactionV2> transactions,
|
||||
Coin coin,
|
||||
String walletId
|
||||
})) {
|
||||
return getRoute(
|
||||
shouldUseMaterialRoute: useMaterialPageRoute,
|
||||
builder: (_) => FusionGroupDetailsView(
|
||||
transactions: args.transactions,
|
||||
coin: args.coin,
|
||||
walletId: args.walletId,
|
||||
),
|
||||
settings: RouteSettings(
|
||||
name: settings.name,
|
||||
),
|
||||
);
|
||||
}
|
||||
return _routeError("${settings.name} invalid args: ${args.toString()}");
|
||||
|
||||
case AllTransactionsView.routeName:
|
||||
if (args is ({String walletId, bool isTokens})) {
|
||||
return getRoute(
|
||||
|
|
Loading…
Reference in a new issue