mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2024-12-27 05:49:21 +00:00
173 lines
5.4 KiB
Dart
173 lines
5.4 KiB
Dart
/*
|
|
* 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 '../../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';
|
|
|
|
class WalletInfoRow extends ConsumerWidget {
|
|
const WalletInfoRow({
|
|
super.key,
|
|
required this.walletId,
|
|
this.onPressedDesktop,
|
|
this.contractAddress,
|
|
this.padding = const EdgeInsets.all(0),
|
|
});
|
|
|
|
final String walletId;
|
|
final String? contractAddress;
|
|
final VoidCallback? onPressedDesktop;
|
|
final EdgeInsets padding;
|
|
|
|
@override
|
|
Widget build(BuildContext context, WidgetRef ref) {
|
|
final wallet = ref.watch(pWallets).getWallet(walletId);
|
|
|
|
EthContract? contract;
|
|
if (contractAddress != null) {
|
|
contract = ref.watch(
|
|
mainDBProvider
|
|
.select((value) => value.getEthContractSync(contractAddress!)),
|
|
);
|
|
}
|
|
|
|
if (Util.isDesktop) {
|
|
return Padding(
|
|
padding: padding,
|
|
child: Container(
|
|
color: Colors.transparent,
|
|
child: Row(
|
|
children: [
|
|
Expanded(
|
|
flex: 3,
|
|
child: Row(
|
|
children: [
|
|
WalletInfoCoinIcon(
|
|
coin: wallet.info.coin,
|
|
contractAddress: contractAddress,
|
|
),
|
|
const SizedBox(
|
|
width: 12,
|
|
),
|
|
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(
|
|
wallet.info.name,
|
|
style: STextStyles.desktopTextExtraSmall(context)
|
|
.copyWith(
|
|
color: Theme.of(context)
|
|
.extension<StackColors>()!
|
|
.textDark,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
Expanded(
|
|
flex: 4,
|
|
child: WalletInfoRowBalance(
|
|
walletId: walletId,
|
|
contractAddress: contractAddress,
|
|
),
|
|
),
|
|
Expanded(
|
|
flex: 2,
|
|
child: Row(
|
|
mainAxisAlignment: MainAxisAlignment.end,
|
|
children: [
|
|
CustomTextButton(
|
|
text: "Open wallet",
|
|
onTap: onPressedDesktop,
|
|
),
|
|
],
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
} else {
|
|
return Row(
|
|
children: [
|
|
WalletInfoCoinIcon(
|
|
coin: wallet.info.coin,
|
|
contractAddress: contractAddress,
|
|
),
|
|
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(
|
|
wallet.info.name,
|
|
style: STextStyles.titleBold12(context),
|
|
),
|
|
const SizedBox(
|
|
height: 2,
|
|
),
|
|
WalletInfoRowBalance(
|
|
walletId: walletId,
|
|
contractAddress: contractAddress,
|
|
),
|
|
],
|
|
),
|
|
),
|
|
],
|
|
);
|
|
}
|
|
}
|
|
}
|