mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2025-01-10 20:54:33 +00:00
Merge remote-tracking branch 'origin/fusion' into fusion
This commit is contained in:
commit
d04caa0fb7
5 changed files with 280 additions and 37 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/material.dart';
|
||||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||||
import 'package:stackwallet/models/isar/models/blockchain_data/v2/transaction_v2.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/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/providers/providers.dart';
|
||||||
import 'package:stackwallet/themes/stack_colors.dart';
|
import 'package:stackwallet/themes/stack_colors.dart';
|
||||||
import 'package:stackwallet/utilities/constants.dart';
|
import 'package:stackwallet/utilities/constants.dart';
|
||||||
import 'package:stackwallet/utilities/format.dart';
|
import 'package:stackwallet/utilities/format.dart';
|
||||||
import 'package:stackwallet/utilities/text_styles.dart';
|
import 'package:stackwallet/utilities/text_styles.dart';
|
||||||
import 'package:stackwallet/utilities/util.dart';
|
import 'package:stackwallet/utilities/util.dart';
|
||||||
|
import 'package:stackwallet/widgets/desktop/desktop_dialog.dart';
|
||||||
|
|
||||||
class FusionTxGroup {
|
class FusionTxGroup {
|
||||||
final List<TransactionV2> transactions;
|
final List<TransactionV2> transactions;
|
||||||
|
@ -46,29 +50,28 @@ class FusionTxGroupCard extends ConsumerWidget {
|
||||||
),
|
),
|
||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
if (Util.isDesktop) {
|
if (Util.isDesktop) {
|
||||||
// await showDialog<void>(
|
await showDialog<void>(
|
||||||
// context: context,
|
context: context,
|
||||||
// builder: (context) => DesktopDialog(
|
builder: (context) => DesktopDialog(
|
||||||
// maxHeight: MediaQuery.of(context).size.height - 64,
|
maxWidth: 580,
|
||||||
// maxWidth: 580,
|
child: FusionGroupDetailsView(
|
||||||
// child: TransactionV2DetailsView(
|
transactions: group.transactions,
|
||||||
// transaction: _transaction,
|
coin: coin,
|
||||||
// coin: coin,
|
walletId: walletId,
|
||||||
// walletId: walletId,
|
),
|
||||||
// ),
|
),
|
||||||
// ),
|
);
|
||||||
// );
|
|
||||||
} else {
|
} else {
|
||||||
// unawaited(
|
unawaited(
|
||||||
// Navigator.of(context).pushNamed(
|
Navigator.of(context).pushNamed(
|
||||||
// TransactionV2DetailsView.routeName,
|
FusionGroupDetailsView.routeName,
|
||||||
// arguments: (
|
arguments: (
|
||||||
// tx: _transaction,
|
transactions: group.transactions,
|
||||||
// coin: coin,
|
coin: coin,
|
||||||
// walletId: walletId,
|
walletId: walletId,
|
||||||
// ),
|
),
|
||||||
// ),
|
),
|
||||||
// );
|
);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
child: Padding(
|
child: Padding(
|
||||||
|
|
|
@ -119,9 +119,6 @@ class _TransactionsV2ListState extends ConsumerState<TransactionsV2List> {
|
||||||
final thisTime =
|
final thisTime =
|
||||||
DateTime.fromMillisecondsSinceEpoch(tx.timestamp * 1000);
|
DateTime.fromMillisecondsSinceEpoch(tx.timestamp * 1000);
|
||||||
|
|
||||||
print(
|
|
||||||
"DIFFERERNCE: ${prevTime.difference(thisTime).inMinutes}");
|
|
||||||
|
|
||||||
if (prevTime.difference(thisTime).inMinutes > 30) {
|
if (prevTime.difference(thisTime).inMinutes > 30) {
|
||||||
_txns.add(FusionTxGroup(fusions));
|
_txns.add(FusionTxGroup(fusions));
|
||||||
fusions = [tx];
|
fusions = [tx];
|
||||||
|
@ -146,17 +143,6 @@ class _TransactionsV2ListState extends ConsumerState<TransactionsV2List> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// sanity check
|
|
||||||
int count = 0;
|
|
||||||
for (final e in _txns) {
|
|
||||||
if (e is TransactionV2) {
|
|
||||||
count++;
|
|
||||||
} else if (e is FusionTxGroup) {
|
|
||||||
count += e.transactions.length;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
assert(count == _transactions.length);
|
|
||||||
|
|
||||||
return RefreshIndicator(
|
return RefreshIndicator(
|
||||||
onRefresh: () async {
|
onRefresh: () async {
|
||||||
final managerProvider = ref
|
final managerProvider = ref
|
||||||
|
|
|
@ -171,7 +171,6 @@ class TxListItem extends ConsumerWidget {
|
||||||
borderRadius: radius,
|
borderRadius: radius,
|
||||||
),
|
),
|
||||||
child: FusionTxGroupCard(
|
child: FusionTxGroupCard(
|
||||||
// this may mess with combined firo transactions
|
|
||||||
key: UniqueKey(),
|
key: UniqueKey(),
|
||||||
group: group,
|
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/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_details_view.dart';
|
||||||
import 'package:stackwallet/pages/wallet_view/transaction_views/transaction_search_filter_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/transaction_views/tx_v2/transaction_v2_details_view.dart';
|
||||||
import 'package:stackwallet/pages/wallet_view/wallet_view.dart';
|
import 'package:stackwallet/pages/wallet_view/wallet_view.dart';
|
||||||
import 'package:stackwallet/pages/wallets_view/wallets_overview.dart';
|
import 'package:stackwallet/pages/wallets_view/wallets_overview.dart';
|
||||||
|
@ -1277,6 +1278,26 @@ class RouteGenerator {
|
||||||
}
|
}
|
||||||
return _routeError("${settings.name} invalid args: ${args.toString()}");
|
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:
|
case AllTransactionsView.routeName:
|
||||||
if (args is ({String walletId, bool isTokens})) {
|
if (args is ({String walletId, bool isTokens})) {
|
||||||
return getRoute(
|
return getRoute(
|
||||||
|
|
Loading…
Reference in a new issue