2023-05-26 21:21:16 +00:00
|
|
|
/*
|
|
|
|
* 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
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2022-09-19 17:32:33 +00:00
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
2024-05-23 00:37:06 +00:00
|
|
|
import '../../models/isar/models/ethereum/eth_contract.dart';
|
|
|
|
import '../../pages/token_view/sub_widgets/token_summary.dart';
|
|
|
|
import '../../providers/db/main_db_provider.dart';
|
|
|
|
import '../../providers/providers.dart';
|
|
|
|
import '../../themes/stack_colors.dart';
|
|
|
|
import '../../utilities/text_styles.dart';
|
|
|
|
import '../../utilities/util.dart';
|
|
|
|
import '../custom_buttons/blue_text_button.dart';
|
|
|
|
import 'sub_widgets/wallet_info_row_balance.dart';
|
|
|
|
import 'sub_widgets/wallet_info_row_coin_icon.dart';
|
2022-09-19 17:32:33 +00:00
|
|
|
|
|
|
|
class WalletInfoRow extends ConsumerWidget {
|
|
|
|
const WalletInfoRow({
|
|
|
|
Key? key,
|
|
|
|
required this.walletId,
|
2023-03-27 20:29:30 +00:00
|
|
|
this.onPressedDesktop,
|
2023-03-28 22:18:11 +00:00
|
|
|
this.contractAddress,
|
2022-11-28 21:21:18 +00:00
|
|
|
this.padding = const EdgeInsets.all(0),
|
2022-09-19 17:32:33 +00:00
|
|
|
}) : super(key: key);
|
|
|
|
|
|
|
|
final String walletId;
|
2023-03-28 22:18:11 +00:00
|
|
|
final String? contractAddress;
|
2023-03-27 20:29:30 +00:00
|
|
|
final VoidCallback? onPressedDesktop;
|
2022-11-28 21:21:18 +00:00
|
|
|
final EdgeInsets padding;
|
2022-09-19 17:32:33 +00:00
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context, WidgetRef ref) {
|
2023-11-03 19:46:55 +00:00
|
|
|
final wallet = ref.watch(pWallets).getWallet(walletId);
|
2022-09-19 17:32:33 +00:00
|
|
|
|
2023-03-28 22:18:11 +00:00
|
|
|
EthContract? contract;
|
|
|
|
if (contractAddress != null) {
|
|
|
|
contract = ref.watch(mainDBProvider
|
|
|
|
.select((value) => value.getEthContractSync(contractAddress!)));
|
|
|
|
}
|
|
|
|
|
2022-10-13 19:07:48 +00:00
|
|
|
if (Util.isDesktop) {
|
2023-04-03 22:22:40 +00:00
|
|
|
return Padding(
|
|
|
|
padding: padding,
|
|
|
|
child: Container(
|
|
|
|
color: Colors.transparent,
|
|
|
|
child: Row(
|
|
|
|
children: [
|
|
|
|
Expanded(
|
|
|
|
flex: 3,
|
|
|
|
child: Row(
|
|
|
|
children: [
|
|
|
|
WalletInfoCoinIcon(
|
2023-11-03 19:46:55 +00:00
|
|
|
coin: wallet.info.coin,
|
2023-04-03 22:22:40 +00:00
|
|
|
contractAddress: contractAddress,
|
2022-11-28 21:21:18 +00:00
|
|
|
),
|
2023-04-03 22:22:40 +00:00
|
|
|
const SizedBox(
|
|
|
|
width: 12,
|
2022-11-28 21:21:18 +00:00
|
|
|
),
|
2023-04-03 22:22:40 +00:00
|
|
|
contract != null
|
|
|
|
? Row(
|
|
|
|
children: [
|
|
|
|
Text(
|
|
|
|
contract.name,
|
|
|
|
style:
|
|
|
|
STextStyles.desktopTextExtraSmall(context)
|
|
|
|
.copyWith(
|
|
|
|
color: Theme.of(context)
|
|
|
|
.extension<StackColors>()!
|
|
|
|
.textDark,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
const SizedBox(
|
|
|
|
width: 4,
|
|
|
|
),
|
|
|
|
CoinTickerTag(
|
|
|
|
walletId: walletId,
|
|
|
|
),
|
|
|
|
],
|
|
|
|
)
|
|
|
|
: Text(
|
2023-11-03 19:46:55 +00:00
|
|
|
wallet.info.name,
|
2023-04-03 22:22:40 +00:00
|
|
|
style: STextStyles.desktopTextExtraSmall(context)
|
|
|
|
.copyWith(
|
|
|
|
color: Theme.of(context)
|
|
|
|
.extension<StackColors>()!
|
|
|
|
.textDark,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
2022-11-28 21:21:18 +00:00
|
|
|
),
|
2023-04-03 22:22:40 +00:00
|
|
|
Expanded(
|
|
|
|
flex: 4,
|
|
|
|
child: WalletInfoRowBalance(
|
|
|
|
walletId: walletId,
|
|
|
|
contractAddress: contractAddress,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
Expanded(
|
|
|
|
flex: 2,
|
|
|
|
child: Row(
|
|
|
|
mainAxisAlignment: MainAxisAlignment.end,
|
|
|
|
children: [
|
|
|
|
CustomTextButton(
|
|
|
|
text: "Open wallet",
|
|
|
|
onTap: onPressedDesktop,
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
)
|
|
|
|
],
|
2022-10-13 19:07:48 +00:00
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
} else {
|
|
|
|
return Row(
|
|
|
|
children: [
|
2023-03-28 22:18:11 +00:00
|
|
|
WalletInfoCoinIcon(
|
2023-11-03 19:46:55 +00:00
|
|
|
coin: wallet.info.coin,
|
2023-03-28 22:18:11 +00:00
|
|
|
contractAddress: contractAddress,
|
|
|
|
),
|
2022-10-13 19:07:48 +00:00
|
|
|
const SizedBox(
|
|
|
|
width: 12,
|
|
|
|
),
|
|
|
|
Expanded(
|
|
|
|
child: Column(
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
children: [
|
2023-03-28 22:18:11 +00:00
|
|
|
contract != null
|
|
|
|
? Row(
|
|
|
|
children: [
|
|
|
|
Text(
|
|
|
|
contract.name,
|
|
|
|
style: STextStyles.titleBold12(context),
|
|
|
|
),
|
|
|
|
const SizedBox(
|
|
|
|
width: 4,
|
|
|
|
),
|
|
|
|
CoinTickerTag(
|
|
|
|
walletId: walletId,
|
|
|
|
),
|
|
|
|
],
|
|
|
|
)
|
|
|
|
: Text(
|
2023-11-03 19:46:55 +00:00
|
|
|
wallet.info.name,
|
2023-03-28 22:18:11 +00:00
|
|
|
style: STextStyles.titleBold12(context),
|
|
|
|
),
|
2022-10-13 19:07:48 +00:00
|
|
|
const SizedBox(
|
|
|
|
height: 2,
|
|
|
|
),
|
2023-03-28 22:18:11 +00:00
|
|
|
WalletInfoRowBalance(
|
|
|
|
walletId: walletId,
|
|
|
|
contractAddress: contractAddress,
|
|
|
|
),
|
2022-10-13 19:07:48 +00:00
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
);
|
|
|
|
}
|
2022-09-19 17:32:33 +00:00
|
|
|
}
|
|
|
|
}
|