Refresh desktop dashboard actions on wallet change

This commit is contained in:
OmarHatem 2023-02-10 20:26:07 +02:00
parent a116241185
commit 2b2bebe98f

View file

@ -2,6 +2,7 @@ import 'package:cake_wallet/entities/main_actions.dart';
import 'package:cake_wallet/src/screens/dashboard/desktop_widgets/desktop_action_button.dart'; import 'package:cake_wallet/src/screens/dashboard/desktop_widgets/desktop_action_button.dart';
import 'package:cake_wallet/view_model/dashboard/dashboard_view_model.dart'; import 'package:cake_wallet/view_model/dashboard/dashboard_view_model.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_mobx/flutter_mobx.dart';
class DesktopDashboardActions extends StatelessWidget { class DesktopDashboardActions extends StatelessWidget {
final DashboardViewModel dashboardViewModel; final DashboardViewModel dashboardViewModel;
@ -10,62 +11,66 @@ class DesktopDashboardActions extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Column( return Observer(
children: [ builder: (_) {
const SizedBox(height: 16), return Column(
DesktopActionButton(
title: MainActions.exchangeAction.name(context),
image: MainActions.exchangeAction.image,
canShow: MainActions.exchangeAction.canShow?.call(dashboardViewModel),
isEnabled: MainActions.exchangeAction.isEnabled?.call(dashboardViewModel),
onTap: () async => await MainActions.exchangeAction.onTap(context, dashboardViewModel),
),
Row(
children: [ children: [
Expanded( const SizedBox(height: 16),
child: DesktopActionButton( DesktopActionButton(
title: MainActions.receiveAction.name(context), title: MainActions.exchangeAction.name(context),
image: MainActions.receiveAction.image, image: MainActions.exchangeAction.image,
canShow: MainActions.receiveAction.canShow?.call(dashboardViewModel), canShow: MainActions.exchangeAction.canShow?.call(dashboardViewModel),
isEnabled: MainActions.receiveAction.isEnabled?.call(dashboardViewModel), isEnabled: MainActions.exchangeAction.isEnabled?.call(dashboardViewModel),
onTap: () async => onTap: () async => await MainActions.exchangeAction.onTap(context, dashboardViewModel),
await MainActions.receiveAction.onTap(context, dashboardViewModel),
),
), ),
Expanded( Row(
child: DesktopActionButton( children: [
title: MainActions.sendAction.name(context), Expanded(
image: MainActions.sendAction.image, child: DesktopActionButton(
canShow: MainActions.sendAction.canShow?.call(dashboardViewModel), title: MainActions.receiveAction.name(context),
isEnabled: MainActions.sendAction.isEnabled?.call(dashboardViewModel), image: MainActions.receiveAction.image,
onTap: () async => await MainActions.sendAction.onTap(context, dashboardViewModel), canShow: MainActions.receiveAction.canShow?.call(dashboardViewModel),
), isEnabled: MainActions.receiveAction.isEnabled?.call(dashboardViewModel),
onTap: () async =>
await MainActions.receiveAction.onTap(context, dashboardViewModel),
),
),
Expanded(
child: DesktopActionButton(
title: MainActions.sendAction.name(context),
image: MainActions.sendAction.image,
canShow: MainActions.sendAction.canShow?.call(dashboardViewModel),
isEnabled: MainActions.sendAction.isEnabled?.call(dashboardViewModel),
onTap: () async => await MainActions.sendAction.onTap(context, dashboardViewModel),
),
),
],
),
Row(
children: [
Expanded(
child: DesktopActionButton(
title: MainActions.buyAction.name(context),
image: MainActions.buyAction.image,
canShow: MainActions.buyAction.canShow?.call(dashboardViewModel),
isEnabled: MainActions.buyAction.isEnabled?.call(dashboardViewModel),
onTap: () async => await MainActions.buyAction.onTap(context, dashboardViewModel),
),
),
Expanded(
child: DesktopActionButton(
title: MainActions.sellAction.name(context),
image: MainActions.sellAction.image,
canShow: MainActions.sellAction.canShow?.call(dashboardViewModel),
isEnabled: MainActions.sellAction.isEnabled?.call(dashboardViewModel),
onTap: () async => await MainActions.sellAction.onTap(context, dashboardViewModel),
),
),
],
), ),
], ],
), );
Row( }
children: [
Expanded(
child: DesktopActionButton(
title: MainActions.buyAction.name(context),
image: MainActions.buyAction.image,
canShow: MainActions.buyAction.canShow?.call(dashboardViewModel),
isEnabled: MainActions.buyAction.isEnabled?.call(dashboardViewModel),
onTap: () async => await MainActions.buyAction.onTap(context, dashboardViewModel),
),
),
Expanded(
child: DesktopActionButton(
title: MainActions.sellAction.name(context),
image: MainActions.sellAction.image,
canShow: MainActions.sellAction.canShow?.call(dashboardViewModel),
isEnabled: MainActions.sellAction.isEnabled?.call(dashboardViewModel),
onTap: () async => await MainActions.sellAction.onTap(context, dashboardViewModel),
),
),
],
),
],
); );
} }
} }