| 1 | import 'package:cake_wallet/reactions/wallet_connect.dart'; |
| 2 | import 'package:cake_wallet/src/screens/dashboard/pages/balance/crypto_balance_widget.dart'; |
| 3 | import 'package:cake_wallet/src/screens/dashboard/pages/nft_listing_page.dart'; |
| 4 | import 'package:cake_wallet/store/settings_store.dart'; |
| 5 | import 'package:cake_wallet/view_model/dashboard/dashboard_view_model.dart'; |
| 6 | import 'package:cake_wallet/view_model/dashboard/nft_view_model.dart'; |
| 7 | import 'package:flutter/material.dart'; |
| 8 | import 'package:flutter_mobx/flutter_mobx.dart'; |
| 9 | |
| 10 | class BalancePage extends StatelessWidget { |
| 11 | BalancePage({ |
| 12 | required this.dashboardViewModel, |
| 13 | required this.settingsStore, |
| 14 | required this.nftViewModel, |
| 15 | }); |
| 16 | |
| 17 | final DashboardViewModel dashboardViewModel; |
| 18 | final NFTViewModel nftViewModel; |
| 19 | final SettingsStore settingsStore; |
| 20 | |
| 21 | @override |
| 22 | Widget build(BuildContext context) { |
| 23 | return Observer( |
| 24 | builder: (context) { |
| 25 | final isNFTActivated = isNFTACtivatedChain(dashboardViewModel.type, |
| 26 | chainId: dashboardViewModel.wallet.chainId); |
| 27 | return DefaultTabController( |
| 28 | key: ValueKey<bool>(isNFTActivated), |
| 29 | length: isNFTActivated ? 2 : 1, |
| 30 | child: Column( |
| 31 | children: [ |
| 32 | if (isNFTActivated) |
| 33 | Align( |
| 34 | alignment: Alignment.centerLeft, |
| 35 | child: Padding( |
| 36 | padding: const EdgeInsets.only(left: 8), |
| 37 | child: TabBar( |
| 38 | indicatorSize: TabBarIndicatorSize.label, |
| 39 | isScrollable: true, |
| 40 | physics: const NeverScrollableScrollPhysics(), |
| 41 | labelStyle: Theme.of(context).textTheme.titleMedium?.copyWith( |
| 42 | fontWeight: FontWeight.w600, |
| 43 | fontSize: 18, |
| 44 | height: 1, |
| 45 | color: Theme.of(context).colorScheme.primary, |
| 46 | ), |
| 47 | unselectedLabelStyle: Theme.of(context).textTheme.titleMedium?.copyWith( |
| 48 | fontWeight: FontWeight.w600, |
| 49 | fontSize: 18, |
| 50 | height: 1, |
| 51 | color: Theme.of(context).colorScheme.primary, |
| 52 | ), |
| 53 | labelColor: Theme.of(context).colorScheme.primary, |
| 54 | dividerColor: Colors.transparent, |
| 55 | indicatorColor: Theme.of(context).colorScheme.primary, |
| 56 | unselectedLabelColor: |
| 57 | Theme.of(context).colorScheme.secondary.withOpacity(0.7), |
| 58 | tabAlignment: TabAlignment.start, |
| 59 | tabs: const [ |
| 60 | Tab(text: 'My Crypto'), |
| 61 | Tab(text: 'My NFTs'), |
| 62 | ], |
| 63 | ), |
| 64 | ), |
| 65 | ), |
| 66 | Expanded( |
| 67 | child: TabBarView( |
| 68 | physics: const NeverScrollableScrollPhysics(), |
| 69 | children: [ |
| 70 | CryptoBalanceWidget(dashboardViewModel: dashboardViewModel), |
| 71 | if (isNFTActivated) NFTListingPage(nftViewModel: nftViewModel) |
| 72 | ], |
| 73 | ), |
| 74 | ), |
| 75 | ], |
| 76 | ), |
| 77 | ); |
| 78 | }, |
| 79 | ); |
| 80 | } |
| 81 | } |