2023-07-07 14:47:55 +03:00
|
|
|
import 'package:cake_wallet/src/screens/exchange_trade/information_page.dart';
|
2022-03-18 16:47:57 +06:00
|
|
|
import 'package:cake_wallet/store/settings_store.dart';
|
|
|
|
import 'package:cake_wallet/themes/theme_base.dart';
|
2023-04-14 06:39:08 +02:00
|
|
|
import 'package:cake_wallet/utils/responsive_layout_util.dart';
|
2023-07-07 14:47:55 +03:00
|
|
|
import 'package:cake_wallet/utils/show_pop_up.dart';
|
2020-07-21 20:22:41 +03:00
|
|
|
import 'package:flutter/material.dart';
|
2020-07-23 15:20:52 +03:00
|
|
|
import 'package:cake_wallet/view_model/dashboard/dashboard_view_model.dart';
|
2020-07-21 20:22:41 +03:00
|
|
|
import 'package:flutter_mobx/flutter_mobx.dart';
|
2020-09-29 11:45:35 +03:00
|
|
|
import 'package:auto_size_text/auto_size_text.dart';
|
2022-08-30 21:03:02 +03:00
|
|
|
import 'package:cake_wallet/src/widgets/introducing_card.dart';
|
|
|
|
import 'package:cake_wallet/generated/i18n.dart';
|
|
|
|
|
2023-04-20 16:46:41 +03:00
|
|
|
class BalancePage extends StatelessWidget {
|
2022-10-12 13:09:57 -04:00
|
|
|
BalancePage({required this.dashboardViewModel, required this.settingsStore});
|
2020-07-21 20:22:41 +03:00
|
|
|
|
|
|
|
final DashboardViewModel dashboardViewModel;
|
2022-03-18 16:47:57 +06:00
|
|
|
final SettingsStore settingsStore;
|
2022-03-30 17:57:04 +02:00
|
|
|
|
2020-07-21 20:22:41 +03:00
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
2021-03-31 20:22:41 +03:00
|
|
|
return GestureDetector(
|
2023-04-20 16:46:41 +03:00
|
|
|
onLongPress: () => dashboardViewModel.balanceViewModel.isReversing =
|
|
|
|
!dashboardViewModel.balanceViewModel.isReversing,
|
|
|
|
onLongPressUp: () => dashboardViewModel.balanceViewModel.isReversing =
|
|
|
|
!dashboardViewModel.balanceViewModel.isReversing,
|
|
|
|
child: SingleChildScrollView(
|
|
|
|
child: Column(crossAxisAlignment: CrossAxisAlignment.start, children: [
|
|
|
|
SizedBox(height: 56),
|
2022-03-18 16:47:57 +06:00
|
|
|
Container(
|
2023-04-20 16:46:41 +03:00
|
|
|
margin: const EdgeInsets.only(left: 24, bottom: 16),
|
|
|
|
child: Observer(builder: (_) {
|
|
|
|
return Text(dashboardViewModel.balanceViewModel.asset,
|
|
|
|
style: TextStyle(
|
|
|
|
fontSize: 24,
|
|
|
|
fontFamily: 'Lato',
|
|
|
|
fontWeight: FontWeight.w600,
|
2023-05-24 20:19:51 -03:00
|
|
|
color: Theme.of(context)
|
|
|
|
.accentTextTheme!
|
|
|
|
.displayMedium!
|
|
|
|
.backgroundColor!,
|
2023-04-20 16:46:41 +03:00
|
|
|
height: 1),
|
|
|
|
maxLines: 1,
|
|
|
|
textAlign: TextAlign.center);
|
|
|
|
})),
|
2022-08-30 21:03:02 +03:00
|
|
|
Observer(builder: (_) {
|
2023-04-20 16:46:41 +03:00
|
|
|
if (dashboardViewModel.balanceViewModel.isShowCard) {
|
2022-08-30 21:03:02 +03:00
|
|
|
return IntroducingCard(
|
2023-04-20 16:46:41 +03:00
|
|
|
title: S.of(context).introducing_cake_pay,
|
2022-08-30 21:03:02 +03:00
|
|
|
subTitle: S.of(context).cake_pay_learn_more,
|
|
|
|
borderColor: settingsStore.currentTheme.type == ThemeType.bright
|
|
|
|
? Color.fromRGBO(255, 255, 255, 0.2)
|
|
|
|
: Colors.transparent,
|
2023-04-20 16:46:41 +03:00
|
|
|
closeCard: dashboardViewModel.balanceViewModel.disableIntroCakePayCard);
|
2022-08-30 21:03:02 +03:00
|
|
|
}
|
2023-04-20 16:46:41 +03:00
|
|
|
return Container();
|
2022-08-30 21:03:02 +03:00
|
|
|
}),
|
2022-03-30 17:57:04 +02:00
|
|
|
Observer(builder: (_) {
|
|
|
|
return ListView.separated(
|
2023-04-20 16:46:41 +03:00
|
|
|
physics: NeverScrollableScrollPhysics(),
|
|
|
|
shrinkWrap: true,
|
|
|
|
separatorBuilder: (_, __) => Container(padding: EdgeInsets.only(bottom: 8)),
|
|
|
|
itemCount: dashboardViewModel.balanceViewModel.formattedBalances.length,
|
|
|
|
itemBuilder: (__, index) {
|
|
|
|
final balance =
|
|
|
|
dashboardViewModel.balanceViewModel.formattedBalances.elementAt(index);
|
|
|
|
return buildBalanceRow(context,
|
|
|
|
availableBalanceLabel:
|
|
|
|
'${dashboardViewModel.balanceViewModel.availableBalanceLabel}',
|
2022-03-30 17:57:04 +02:00
|
|
|
availableBalance: balance.availableBalance,
|
|
|
|
availableFiatBalance: balance.fiatAvailableBalance,
|
2023-04-20 16:46:41 +03:00
|
|
|
additionalBalanceLabel:
|
|
|
|
'${dashboardViewModel.balanceViewModel.additionalBalanceLabel}',
|
2022-03-30 17:57:04 +02:00
|
|
|
additionalBalance: balance.additionalBalance,
|
|
|
|
additionalFiatBalance: balance.fiatAdditionalBalance,
|
2023-04-20 16:46:41 +03:00
|
|
|
frozenBalance: balance.frozenBalance,
|
|
|
|
frozenFiatBalance: balance.fiatFrozenBalance,
|
2022-03-30 17:57:04 +02:00
|
|
|
currency: balance.formattedAssetTitle);
|
2023-04-20 16:46:41 +03:00
|
|
|
});
|
|
|
|
})
|
|
|
|
])));
|
2022-03-30 17:57:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
Widget buildBalanceRow(BuildContext context,
|
2023-04-20 16:46:41 +03:00
|
|
|
{required String availableBalanceLabel,
|
2022-10-12 13:09:57 -04:00
|
|
|
required String availableBalance,
|
|
|
|
required String availableFiatBalance,
|
|
|
|
required String additionalBalanceLabel,
|
|
|
|
required String additionalBalance,
|
|
|
|
required String additionalFiatBalance,
|
2023-04-20 16:46:41 +03:00
|
|
|
required String frozenBalance,
|
|
|
|
required String frozenFiatBalance,
|
2022-10-12 13:09:57 -04:00
|
|
|
required String currency}) {
|
2023-04-20 16:46:41 +03:00
|
|
|
return Container(
|
2022-03-30 17:57:04 +02:00
|
|
|
margin: const EdgeInsets.only(left: 16, right: 16),
|
|
|
|
decoration: BoxDecoration(
|
2023-04-20 16:46:41 +03:00
|
|
|
borderRadius: BorderRadius.circular(30.0),
|
|
|
|
border: Border.all(
|
|
|
|
color: settingsStore.currentTheme.type == ThemeType.bright
|
|
|
|
? Color.fromRGBO(255, 255, 255, 0.2)
|
|
|
|
: Colors.transparent,
|
|
|
|
width: 1,
|
|
|
|
),
|
2023-05-24 20:19:51 -03:00
|
|
|
color: Theme.of(context).textTheme!.titleLarge!.backgroundColor!),
|
2022-03-30 17:57:04 +02:00
|
|
|
child: Container(
|
2023-04-20 16:46:41 +03:00
|
|
|
margin: const EdgeInsets.only(top: 16, left: 24, right: 24, bottom: 24),
|
2023-07-07 14:47:55 +03:00
|
|
|
child: Column(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
children: [
|
2023-06-14 02:04:52 +03:00
|
|
|
Row(
|
2023-07-07 14:47:55 +03:00
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
children: [
|
|
|
|
GestureDetector(
|
|
|
|
behavior: HitTestBehavior.opaque,
|
|
|
|
onTap: () => _showBalanceDescription(context),
|
|
|
|
child: Column(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
children: [
|
|
|
|
Row(
|
|
|
|
children: [
|
|
|
|
Text('${availableBalanceLabel}',
|
|
|
|
style: TextStyle(
|
|
|
|
fontSize: 12,
|
|
|
|
fontFamily: 'Lato',
|
|
|
|
fontWeight: FontWeight.w400,
|
|
|
|
color: Theme.of(context)
|
|
|
|
.accentTextTheme!
|
|
|
|
.displaySmall!
|
|
|
|
.backgroundColor!,
|
|
|
|
height: 1)),
|
|
|
|
Padding(
|
|
|
|
padding: const EdgeInsets.symmetric(horizontal: 4),
|
|
|
|
child: Icon(Icons.help_outline,
|
|
|
|
size: 16,
|
|
|
|
color: Theme.of(context)
|
|
|
|
.accentTextTheme!
|
|
|
|
.displaySmall!
|
|
|
|
.backgroundColor!),
|
|
|
|
)
|
|
|
|
],
|
|
|
|
),SizedBox(
|
|
|
|
height: 6,
|
|
|
|
),
|
|
|
|
AutoSizeText(availableBalance,
|
|
|
|
style: TextStyle(
|
|
|
|
fontSize: 24,
|
|
|
|
fontFamily: 'Lato',
|
|
|
|
fontWeight: FontWeight.w900,
|
|
|
|
color: Theme.of(context)
|
|
|
|
.accentTextTheme!
|
|
|
|
.displayMedium!
|
|
|
|
.backgroundColor!,
|
|
|
|
height: 1),
|
|
|
|
maxLines: 1,
|
|
|
|
textAlign: TextAlign.start),
|
|
|
|
SizedBox(
|
|
|
|
height: 6,
|
|
|
|
),
|
|
|
|
Text('${availableFiatBalance}',
|
|
|
|
textAlign: TextAlign.center,
|
|
|
|
style: TextStyle(
|
|
|
|
fontSize: 16,
|
|
|
|
fontFamily: 'Lato',
|
|
|
|
fontWeight: FontWeight.w500,
|
|
|
|
color: Theme.of(context)
|
|
|
|
.accentTextTheme!
|
|
|
|
.displayMedium!
|
|
|
|
.backgroundColor!,
|
|
|
|
height: 1)),
|
|
|
|
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
Text(currency,
|
2023-06-14 02:04:52 +03:00
|
|
|
style: TextStyle(
|
2023-07-07 14:47:55 +03:00
|
|
|
fontSize: 28,
|
2023-06-14 02:04:52 +03:00
|
|
|
fontFamily: 'Lato',
|
2023-07-07 14:47:55 +03:00
|
|
|
fontWeight: FontWeight.w800,
|
2023-06-14 02:04:52 +03:00
|
|
|
color: Theme.of(context)
|
|
|
|
.accentTextTheme!
|
|
|
|
.displayMedium!
|
|
|
|
.backgroundColor!,
|
2023-07-07 14:47:55 +03:00
|
|
|
height: 1)),
|
|
|
|
],
|
2023-04-20 16:46:41 +03:00
|
|
|
),
|
|
|
|
SizedBox(height: 26),
|
|
|
|
if (frozenBalance.isNotEmpty)
|
|
|
|
Column(crossAxisAlignment: CrossAxisAlignment.start, children: [
|
|
|
|
Text(S.current.frozen_balance,
|
|
|
|
textAlign: TextAlign.center,
|
2022-03-30 17:57:04 +02:00
|
|
|
style: TextStyle(
|
2023-04-20 16:46:41 +03:00
|
|
|
fontSize: 12,
|
2022-03-30 17:57:04 +02:00
|
|
|
fontFamily: 'Lato',
|
2023-04-20 16:46:41 +03:00
|
|
|
fontWeight: FontWeight.w400,
|
2023-05-24 20:19:51 -03:00
|
|
|
color: Theme.of(context)
|
|
|
|
.accentTextTheme!
|
|
|
|
.displaySmall!
|
|
|
|
.backgroundColor!,
|
2022-03-30 17:57:04 +02:00
|
|
|
height: 1)),
|
2023-04-20 16:46:41 +03:00
|
|
|
SizedBox(height: 8),
|
|
|
|
AutoSizeText(frozenBalance,
|
2022-03-30 17:57:04 +02:00
|
|
|
style: TextStyle(
|
2023-04-20 16:46:41 +03:00
|
|
|
fontSize: 20,
|
2022-03-30 17:57:04 +02:00
|
|
|
fontFamily: 'Lato',
|
|
|
|
fontWeight: FontWeight.w400,
|
2023-05-24 20:19:51 -03:00
|
|
|
color: Theme.of(context)
|
|
|
|
.accentTextTheme!
|
|
|
|
.displayMedium!
|
|
|
|
.backgroundColor!,
|
2022-03-30 17:57:04 +02:00
|
|
|
height: 1),
|
|
|
|
maxLines: 1,
|
|
|
|
textAlign: TextAlign.center),
|
2023-04-20 16:46:41 +03:00
|
|
|
SizedBox(height: 4),
|
|
|
|
Text(
|
|
|
|
frozenFiatBalance,
|
|
|
|
textAlign: TextAlign.center,
|
|
|
|
style: TextStyle(
|
|
|
|
fontSize: 12,
|
|
|
|
fontFamily: 'Lato',
|
|
|
|
fontWeight: FontWeight.w400,
|
2023-05-24 20:19:51 -03:00
|
|
|
color: Theme.of(context)
|
|
|
|
.accentTextTheme!
|
|
|
|
.displayMedium!
|
|
|
|
.backgroundColor!,
|
2023-04-20 16:46:41 +03:00
|
|
|
height: 1),
|
|
|
|
),
|
|
|
|
SizedBox(height: 24)
|
|
|
|
]),
|
|
|
|
Text('${additionalBalanceLabel}',
|
2022-03-30 17:57:04 +02:00
|
|
|
textAlign: TextAlign.center,
|
|
|
|
style: TextStyle(
|
2023-04-20 16:46:41 +03:00
|
|
|
fontSize: 12,
|
|
|
|
fontFamily: 'Lato',
|
|
|
|
fontWeight: FontWeight.w400,
|
2023-05-24 20:19:51 -03:00
|
|
|
color: Theme.of(context)
|
|
|
|
.accentTextTheme!
|
|
|
|
.displaySmall!
|
|
|
|
.backgroundColor!,
|
2023-04-20 16:46:41 +03:00
|
|
|
height: 1)),
|
|
|
|
SizedBox(height: 8),
|
|
|
|
AutoSizeText(additionalBalance,
|
|
|
|
style: TextStyle(
|
|
|
|
fontSize: 20,
|
|
|
|
fontFamily: 'Lato',
|
|
|
|
fontWeight: FontWeight.w400,
|
2023-05-24 20:19:51 -03:00
|
|
|
color: Theme.of(context)
|
|
|
|
.accentTextTheme!
|
|
|
|
.displayMedium!
|
|
|
|
.backgroundColor!,
|
2023-04-20 16:46:41 +03:00
|
|
|
height: 1),
|
|
|
|
maxLines: 1,
|
|
|
|
textAlign: TextAlign.center),
|
|
|
|
SizedBox(
|
|
|
|
height: 4,
|
|
|
|
),
|
|
|
|
Text(
|
|
|
|
'${additionalFiatBalance}',
|
|
|
|
textAlign: TextAlign.center,
|
|
|
|
style: TextStyle(
|
2022-03-30 17:57:04 +02:00
|
|
|
fontSize: 12,
|
|
|
|
fontFamily: 'Lato',
|
|
|
|
fontWeight: FontWeight.w400,
|
2023-05-24 20:19:51 -03:00
|
|
|
color: Theme.of(context)
|
|
|
|
.accentTextTheme!
|
|
|
|
.displayMedium!
|
|
|
|
.backgroundColor!,
|
2022-03-30 17:57:04 +02:00
|
|
|
height: 1),
|
2023-04-20 16:46:41 +03:00
|
|
|
)
|
|
|
|
])),
|
2021-01-11 19:15:27 +02:00
|
|
|
);
|
2020-07-21 20:22:41 +03:00
|
|
|
}
|
2023-07-07 14:47:55 +03:00
|
|
|
|
|
|
|
void _showBalanceDescription(BuildContext context) {
|
|
|
|
showPopUp<void>(
|
|
|
|
context: context,
|
|
|
|
builder: (_) => InformationPage(information: S.current.available_balance_description));
|
|
|
|
}
|
2020-07-21 20:22:41 +03:00
|
|
|
}
|