stack_wallet/lib/widgets/wallet_info_row/wallet_info_row.dart

174 lines
5.7 KiB
Dart
Raw Normal View History

/*
* 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';
import 'package:stackwallet/models/isar/models/ethereum/eth_contract.dart';
import 'package:stackwallet/pages/token_view/sub_widgets/token_summary.dart';
import 'package:stackwallet/providers/db/main_db_provider.dart';
2022-09-19 17:32:33 +00:00
import 'package:stackwallet/providers/providers.dart';
import 'package:stackwallet/themes/stack_colors.dart';
2022-09-19 17:32:33 +00:00
import 'package:stackwallet/utilities/text_styles.dart';
import 'package:stackwallet/utilities/util.dart';
2023-04-03 22:22:40 +00:00
import 'package:stackwallet/widgets/custom_buttons/blue_text_button.dart';
2023-04-10 16:02:19 +00:00
import 'package:stackwallet/widgets/wallet_info_row/sub_widgets/wallet_info_row_balance.dart';
2022-09-19 17:32:33 +00:00
import 'package:stackwallet/widgets/wallet_info_row/sub_widgets/wallet_info_row_coin_icon.dart';
class WalletInfoRow extends ConsumerWidget {
const WalletInfoRow({
Key? key,
required this.walletId,
2023-03-27 20:29:30 +00:00
this.onPressedDesktop,
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;
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) {
final manager = ref.watch(ref
.watch(walletsChangeNotifierProvider.notifier)
.getManagerProvider(walletId));
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(
coin: manager.coin,
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(
manager.walletName,
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: [
WalletInfoCoinIcon(
coin: manager.coin,
contractAddress: contractAddress,
),
2022-10-13 19:07:48 +00:00
const SizedBox(
width: 12,
),
Expanded(
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
contract != null
? Row(
children: [
Text(
contract.name,
style: STextStyles.titleBold12(context),
),
const SizedBox(
width: 4,
),
CoinTickerTag(
walletId: walletId,
),
],
)
: Text(
manager.walletName,
style: STextStyles.titleBold12(context),
),
2022-10-13 19:07:48 +00:00
const SizedBox(
height: 2,
),
WalletInfoRowBalance(
walletId: walletId,
contractAddress: contractAddress,
),
2022-10-13 19:07:48 +00:00
],
),
),
],
);
}
2022-09-19 17:32:33 +00:00
}
}