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';
|
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';
|
|
|
|
|
2020-07-21 20:22:41 +03:00
|
|
|
|
2022-03-18 16:47:57 +06: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(
|
2022-03-30 17:57:04 +02:00
|
|
|
onLongPress: () => dashboardViewModel.balanceViewModel.isReversing = !dashboardViewModel.balanceViewModel.isReversing,
|
|
|
|
onLongPressUp: () => dashboardViewModel.balanceViewModel.isReversing = !dashboardViewModel.balanceViewModel.isReversing,
|
|
|
|
child: SingleChildScrollView(
|
2022-03-18 16:47:57 +06:00
|
|
|
child: Column(
|
2022-03-30 17:57:04 +02:00
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
2022-03-18 16:47:57 +06:00
|
|
|
children: [
|
2023-04-14 06:39:08 +02:00
|
|
|
SizedBox(height: ResponsiveLayoutUtil.instance.isMobile(context) ? 56 : 16),
|
2022-03-18 16:47:57 +06:00
|
|
|
Container(
|
|
|
|
margin: const EdgeInsets.only(left: 24, bottom: 16),
|
|
|
|
child: Observer(builder: (_) {
|
2022-03-30 17:57:04 +02:00
|
|
|
return Text(
|
2022-03-18 16:47:57 +06:00
|
|
|
dashboardViewModel.balanceViewModel.asset,
|
|
|
|
style: TextStyle(
|
|
|
|
fontSize: 24,
|
|
|
|
fontFamily: 'Lato',
|
|
|
|
fontWeight: FontWeight.w600,
|
|
|
|
color: Theme.of(context)
|
2022-10-12 13:09:57 -04:00
|
|
|
.accentTextTheme!
|
|
|
|
.headline2!
|
|
|
|
.backgroundColor!,
|
2022-03-18 16:47:57 +06:00
|
|
|
height: 1),
|
|
|
|
maxLines: 1,
|
|
|
|
textAlign: TextAlign.center);
|
2022-03-30 17:57:04 +02:00
|
|
|
})),
|
2022-08-30 21:03:02 +03:00
|
|
|
Observer(builder: (_) {
|
|
|
|
if (dashboardViewModel.balanceViewModel.isShowCard){
|
|
|
|
return IntroducingCard(
|
|
|
|
title: S.of(context).introducing_cake_pay,
|
|
|
|
subTitle: S.of(context).cake_pay_learn_more,
|
|
|
|
borderColor: settingsStore.currentTheme.type == ThemeType.bright
|
|
|
|
? Color.fromRGBO(255, 255, 255, 0.2)
|
|
|
|
: Colors.transparent,
|
|
|
|
closeCard: dashboardViewModel.balanceViewModel.disableIntroCakePayCard
|
|
|
|
);
|
|
|
|
}
|
|
|
|
return Container ();
|
|
|
|
}),
|
2022-03-30 17:57:04 +02:00
|
|
|
Observer(builder: (_) {
|
|
|
|
return ListView.separated(
|
|
|
|
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}',
|
|
|
|
availableBalance: balance.availableBalance,
|
|
|
|
availableFiatBalance: balance.fiatAvailableBalance,
|
|
|
|
additionalBalanceLabel: '${dashboardViewModel.balanceViewModel.additionalBalanceLabel}',
|
|
|
|
additionalBalance: balance.additionalBalance,
|
|
|
|
additionalFiatBalance: balance.fiatAdditionalBalance,
|
|
|
|
currency: balance.formattedAssetTitle);
|
|
|
|
});
|
|
|
|
})
|
|
|
|
])));
|
|
|
|
}
|
|
|
|
|
|
|
|
Widget buildBalanceRow(BuildContext context,
|
2022-10-12 13:09:57 -04:00
|
|
|
{required String availableBalanceLabel,
|
|
|
|
required String availableBalance,
|
|
|
|
required String availableFiatBalance,
|
|
|
|
required String additionalBalanceLabel,
|
|
|
|
required String additionalBalance,
|
|
|
|
required String additionalFiatBalance,
|
|
|
|
required String currency}) {
|
2022-03-30 17:57:04 +02:00
|
|
|
return Container(
|
|
|
|
margin: const EdgeInsets.only(left: 16, right: 16),
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
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, ),
|
2022-10-12 13:09:57 -04:00
|
|
|
color:Theme.of(context).textTheme!.headline6!.backgroundColor!
|
2021-01-11 19:15:27 +02:00
|
|
|
),
|
2022-03-30 17:57:04 +02:00
|
|
|
child: Container(
|
|
|
|
margin: const EdgeInsets.only(top: 16, left: 24, right: 24, bottom: 24),
|
|
|
|
child: Column(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
children: [
|
|
|
|
SizedBox(height: 4,),
|
|
|
|
Text('${availableBalanceLabel}',
|
|
|
|
textAlign: TextAlign.center,
|
|
|
|
style: TextStyle(
|
|
|
|
fontSize: 12,
|
|
|
|
fontFamily: 'Lato',
|
|
|
|
fontWeight: FontWeight.w400,
|
|
|
|
color: Theme.of(context)
|
2022-10-12 13:09:57 -04:00
|
|
|
.accentTextTheme!
|
|
|
|
.headline3!
|
|
|
|
.backgroundColor!,
|
2022-03-30 17:57:04 +02:00
|
|
|
height: 1)),
|
|
|
|
SizedBox(height: 5),
|
|
|
|
Row(
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
|
children: [
|
|
|
|
AutoSizeText(
|
|
|
|
availableBalance,
|
|
|
|
style: TextStyle(
|
|
|
|
fontSize: 24,
|
|
|
|
fontFamily: 'Lato',
|
|
|
|
fontWeight: FontWeight.w900,
|
|
|
|
color: Theme.of(context)
|
2022-10-12 13:09:57 -04:00
|
|
|
.accentTextTheme!
|
|
|
|
.headline2!
|
|
|
|
.backgroundColor!,
|
2022-03-30 17:57:04 +02:00
|
|
|
height: 1),
|
|
|
|
maxLines: 1,
|
|
|
|
textAlign: TextAlign.center),
|
|
|
|
Text(currency,
|
|
|
|
style: TextStyle(
|
|
|
|
fontSize: 28,
|
|
|
|
fontFamily: 'Lato',
|
|
|
|
fontWeight: FontWeight.w800,
|
|
|
|
color: Theme.of(context)
|
2022-10-12 13:09:57 -04:00
|
|
|
.accentTextTheme!
|
|
|
|
.headline2!
|
|
|
|
.backgroundColor!,
|
2022-03-30 17:57:04 +02:00
|
|
|
height: 1)),
|
|
|
|
]),
|
|
|
|
SizedBox(height: 4,),
|
|
|
|
Text('${availableFiatBalance}',
|
|
|
|
textAlign: TextAlign.center,
|
|
|
|
style: TextStyle(
|
|
|
|
fontSize: 16,
|
|
|
|
fontFamily: 'Lato',
|
|
|
|
fontWeight: FontWeight.w500,
|
|
|
|
color: Theme.of(context)
|
2022-10-12 13:09:57 -04:00
|
|
|
.accentTextTheme!
|
|
|
|
.headline2!
|
|
|
|
.backgroundColor!,
|
2022-03-30 17:57:04 +02:00
|
|
|
height: 1)),
|
|
|
|
SizedBox(height: 26),
|
|
|
|
Text('${additionalBalanceLabel}',
|
|
|
|
textAlign: TextAlign.center,
|
|
|
|
style: TextStyle(
|
|
|
|
fontSize: 12,
|
|
|
|
fontFamily: 'Lato',
|
|
|
|
fontWeight: FontWeight.w400,
|
|
|
|
color: Theme.of(context)
|
2022-10-12 13:09:57 -04:00
|
|
|
.accentTextTheme!
|
|
|
|
.headline3!
|
|
|
|
.backgroundColor!,
|
2022-03-30 17:57:04 +02:00
|
|
|
height: 1)),
|
|
|
|
SizedBox(height: 8),
|
|
|
|
AutoSizeText(
|
|
|
|
additionalBalance,
|
|
|
|
style: TextStyle(
|
|
|
|
fontSize: 20,
|
|
|
|
fontFamily: 'Lato',
|
|
|
|
fontWeight: FontWeight.w400,
|
|
|
|
color: Theme.of(context)
|
2022-10-12 13:09:57 -04:00
|
|
|
.accentTextTheme!
|
|
|
|
.headline2!
|
|
|
|
.backgroundColor!,
|
2022-03-30 17:57:04 +02:00
|
|
|
height: 1),
|
|
|
|
maxLines: 1,
|
|
|
|
textAlign: TextAlign.center),
|
|
|
|
SizedBox(height: 4,),
|
|
|
|
Text('${additionalFiatBalance}',
|
|
|
|
textAlign: TextAlign.center,
|
|
|
|
style: TextStyle(
|
|
|
|
fontSize: 12,
|
|
|
|
fontFamily: 'Lato',
|
|
|
|
fontWeight: FontWeight.w400,
|
|
|
|
color: Theme.of(context)
|
2022-10-12 13:09:57 -04:00
|
|
|
.accentTextTheme!
|
|
|
|
.headline2!
|
|
|
|
.backgroundColor!,
|
2022-03-30 17:57:04 +02:00
|
|
|
height: 1),
|
|
|
|
)
|
|
|
|
])),
|
2021-01-11 19:15:27 +02:00
|
|
|
);
|
2020-07-21 20:22:41 +03:00
|
|
|
}
|
|
|
|
}
|
2022-08-30 21:03:02 +03:00
|
|
|
|