2023-01-20 17:24:19 +00:00
|
|
|
import 'package:event_bus/event_bus.dart';
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
|
|
|
import 'package:flutter_svg/svg.dart';
|
2023-02-23 22:59:58 +00:00
|
|
|
import 'package:stackwallet/models/ethereum/eth_token.dart';
|
2023-01-20 17:24:19 +00:00
|
|
|
import 'package:stackwallet/pages/wallet_view/sub_widgets/transactions_list.dart';
|
|
|
|
import 'package:stackwallet/pages/wallet_view/transaction_views/all_transactions_view.dart';
|
2023-02-23 22:59:58 +00:00
|
|
|
import 'package:stackwallet/services/ethereum/ethereum_token_service.dart';
|
2023-01-20 17:24:19 +00:00
|
|
|
import 'package:stackwallet/utilities/assets.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/theme/stack_colors.dart';
|
|
|
|
import 'package:stackwallet/widgets/background.dart';
|
|
|
|
import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart';
|
|
|
|
import 'package:stackwallet/widgets/custom_buttons/blue_text_button.dart';
|
|
|
|
|
|
|
|
/// [eventBus] should only be set during testing
|
|
|
|
class TokenView extends ConsumerStatefulWidget {
|
|
|
|
const TokenView({
|
|
|
|
Key? key,
|
2023-01-25 16:08:27 +00:00
|
|
|
required this.walletId,
|
|
|
|
required this.token,
|
2023-02-23 22:59:58 +00:00
|
|
|
required this.tokenService,
|
2023-01-25 16:08:27 +00:00
|
|
|
this.eventBus,
|
2023-01-20 17:24:19 +00:00
|
|
|
}) : super(key: key);
|
|
|
|
|
|
|
|
static const String routeName = "/token";
|
|
|
|
static const double navBarHeight = 65.0;
|
|
|
|
|
2023-01-25 16:08:27 +00:00
|
|
|
final String walletId;
|
2023-02-23 22:59:58 +00:00
|
|
|
final EthToken token;
|
|
|
|
final EthereumTokenService tokenService;
|
2023-01-25 16:08:27 +00:00
|
|
|
final EventBus? eventBus;
|
2023-01-20 17:24:19 +00:00
|
|
|
|
|
|
|
@override
|
|
|
|
ConsumerState<TokenView> createState() => _TokenViewState();
|
|
|
|
}
|
|
|
|
|
|
|
|
class _TokenViewState extends ConsumerState<TokenView> {
|
|
|
|
@override
|
|
|
|
void initState() {
|
|
|
|
super.initState();
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
void dispose() {
|
|
|
|
super.dispose();
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
debugPrint("BUILD: $runtimeType");
|
2023-01-26 18:08:12 +00:00
|
|
|
// print("MY TOTAL BALANCE IS ${widget.token.totalBalance}");
|
2023-01-25 16:08:27 +00:00
|
|
|
|
2023-02-24 16:23:39 +00:00
|
|
|
return Background(
|
|
|
|
child: Scaffold(
|
|
|
|
backgroundColor: Theme.of(context).extension<StackColors>()!.background,
|
|
|
|
appBar: AppBar(
|
|
|
|
leading: AppBarBackButton(
|
|
|
|
onPressed: () {
|
|
|
|
Navigator.of(context).pop();
|
|
|
|
},
|
|
|
|
),
|
|
|
|
titleSpacing: 0,
|
|
|
|
title: Row(
|
|
|
|
children: [
|
|
|
|
SvgPicture.asset(
|
|
|
|
Assets.svg.iconFor(coin: Coin.ethereum),
|
|
|
|
// color: Theme.of(context).extension<StackColors>()!.accentColorDark
|
|
|
|
width: 24,
|
|
|
|
height: 24,
|
|
|
|
),
|
|
|
|
const SizedBox(
|
|
|
|
width: 16,
|
|
|
|
),
|
|
|
|
Expanded(
|
|
|
|
child: Text(
|
|
|
|
widget.token.name,
|
|
|
|
style: STextStyles.navBarTitle(context),
|
|
|
|
overflow: TextOverflow.ellipsis,
|
2023-01-25 16:08:27 +00:00
|
|
|
),
|
2023-02-24 16:23:39 +00:00
|
|
|
),
|
|
|
|
Expanded(
|
|
|
|
child: Text(
|
|
|
|
widget.token.symbol,
|
|
|
|
style: STextStyles.navBarTitle(context),
|
|
|
|
overflow: TextOverflow.ellipsis,
|
2023-01-26 18:08:12 +00:00
|
|
|
),
|
2023-02-24 16:23:39 +00:00
|
|
|
)
|
|
|
|
],
|
2023-01-25 16:08:27 +00:00
|
|
|
),
|
2023-02-24 16:23:39 +00:00
|
|
|
),
|
|
|
|
body: Container(
|
|
|
|
color: Theme.of(context).extension<StackColors>()!.background,
|
|
|
|
child: Column(
|
|
|
|
children: [
|
|
|
|
const SizedBox(
|
|
|
|
height: 10,
|
|
|
|
),
|
|
|
|
// Center(
|
|
|
|
// child: Padding(
|
|
|
|
// padding: const EdgeInsets.symmetric(horizontal: 16),
|
|
|
|
// child: TokenSummary(
|
|
|
|
// walletId: widget.walletId,
|
|
|
|
// managerProvider: managerProvider,
|
|
|
|
// initialSyncStatus: ref.watch(managerProvider
|
|
|
|
// .select((value) => value.isRefreshing))
|
|
|
|
// ? WalletSyncStatus.syncing
|
|
|
|
// : WalletSyncStatus.synced,
|
|
|
|
// ),
|
|
|
|
// ),
|
|
|
|
// ),
|
|
|
|
const SizedBox(
|
|
|
|
height: 20,
|
|
|
|
),
|
|
|
|
Padding(
|
|
|
|
padding: const EdgeInsets.symmetric(horizontal: 16),
|
|
|
|
child: Row(
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
|
children: [
|
|
|
|
Text(
|
|
|
|
"Transactions",
|
|
|
|
style: STextStyles.itemSubtitle(context).copyWith(
|
|
|
|
color: Theme.of(context)
|
|
|
|
.extension<StackColors>()!
|
|
|
|
.textDark3,
|
2023-01-25 16:08:27 +00:00
|
|
|
),
|
|
|
|
),
|
2023-02-24 16:23:39 +00:00
|
|
|
CustomTextButton(
|
|
|
|
text: "See all",
|
|
|
|
onTap: () {
|
|
|
|
Navigator.of(context).pushNamed(
|
|
|
|
AllTransactionsView.routeName,
|
|
|
|
arguments: widget.walletId,
|
|
|
|
);
|
|
|
|
},
|
2023-01-25 16:08:27 +00:00
|
|
|
),
|
2023-02-24 16:23:39 +00:00
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
const SizedBox(
|
|
|
|
height: 12,
|
|
|
|
),
|
|
|
|
Expanded(
|
|
|
|
child: Padding(
|
|
|
|
padding: const EdgeInsets.symmetric(horizontal: 16),
|
|
|
|
child: ClipRRect(
|
|
|
|
borderRadius: BorderRadius.vertical(
|
|
|
|
top: Radius.circular(
|
|
|
|
Constants.size.circularBorderRadius,
|
|
|
|
),
|
|
|
|
bottom: Radius.circular(
|
|
|
|
// TokenView.navBarHeight / 2.0,
|
|
|
|
Constants.size.circularBorderRadius,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
child: Container(
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
color: Colors.transparent,
|
|
|
|
borderRadius: BorderRadius.circular(
|
|
|
|
Constants.size.circularBorderRadius,
|
2023-01-25 16:08:27 +00:00
|
|
|
),
|
2023-02-24 16:23:39 +00:00
|
|
|
),
|
|
|
|
child: Column(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
|
|
|
children: [
|
|
|
|
Expanded(
|
|
|
|
child: TransactionsList(
|
|
|
|
managerProvider: managerProvider,
|
|
|
|
walletId: walletId,
|
2023-01-25 16:08:27 +00:00
|
|
|
),
|
2023-02-24 16:23:39 +00:00
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
2023-01-25 16:08:27 +00:00
|
|
|
),
|
|
|
|
),
|
2023-02-24 16:23:39 +00:00
|
|
|
),
|
2023-01-25 16:08:27 +00:00
|
|
|
),
|
2023-02-24 16:23:39 +00:00
|
|
|
],
|
2023-01-25 16:08:27 +00:00
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
2023-01-20 17:24:19 +00:00
|
|
|
}
|
|
|
|
}
|