2023-04-14 04:39:08 +00:00
|
|
|
import 'package:cake_wallet/generated/i18n.dart';
|
|
|
|
import 'package:cake_wallet/routes.dart';
|
|
|
|
import 'package:cake_wallet/view_model/dashboard/dashboard_view_model.dart';
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
|
|
|
class MainActions {
|
|
|
|
final String Function(BuildContext context) name;
|
|
|
|
final String image;
|
|
|
|
|
|
|
|
final bool Function(DashboardViewModel viewModel)? isEnabled;
|
|
|
|
final bool Function(DashboardViewModel viewModel)? canShow;
|
2023-12-02 02:26:43 +00:00
|
|
|
final Future<void> Function(
|
|
|
|
BuildContext context, DashboardViewModel viewModel) onTap;
|
2023-04-14 04:39:08 +00:00
|
|
|
|
|
|
|
MainActions._({
|
|
|
|
required this.name,
|
|
|
|
required this.image,
|
|
|
|
this.isEnabled,
|
|
|
|
this.canShow,
|
|
|
|
required this.onTap,
|
|
|
|
});
|
|
|
|
|
|
|
|
static List<MainActions> all = [
|
2024-11-09 19:00:56 +00:00
|
|
|
showWalletsAction,
|
2023-04-14 04:39:08 +00:00
|
|
|
receiveAction,
|
|
|
|
exchangeAction,
|
|
|
|
sendAction,
|
2024-11-09 19:00:56 +00:00
|
|
|
tradeAction,
|
2023-04-14 04:39:08 +00:00
|
|
|
];
|
|
|
|
|
2024-11-09 19:00:56 +00:00
|
|
|
static MainActions showWalletsAction = MainActions._(
|
|
|
|
name: (context) => S.of(context).wallets,
|
|
|
|
image: 'assets/images/wallet_new.png',
|
2023-04-14 04:39:08 +00:00
|
|
|
onTap: (BuildContext context, DashboardViewModel viewModel) async {
|
2024-11-09 19:00:56 +00:00
|
|
|
Navigator.pushNamed(context, Routes.walletList);
|
2023-04-14 04:39:08 +00:00
|
|
|
},
|
|
|
|
);
|
|
|
|
|
|
|
|
static MainActions receiveAction = MainActions._(
|
|
|
|
name: (context) => S.of(context).receive,
|
|
|
|
image: 'assets/images/received.png',
|
|
|
|
onTap: (BuildContext context, DashboardViewModel viewModel) async {
|
|
|
|
Navigator.pushNamed(context, Routes.addressPage);
|
|
|
|
},
|
|
|
|
);
|
|
|
|
|
|
|
|
static MainActions exchangeAction = MainActions._(
|
|
|
|
name: (context) => S.of(context).exchange,
|
|
|
|
image: 'assets/images/transfer.png',
|
|
|
|
isEnabled: (viewModel) => viewModel.isEnabledExchangeAction,
|
|
|
|
canShow: (viewModel) => viewModel.hasExchangeAction,
|
|
|
|
onTap: (BuildContext context, DashboardViewModel viewModel) async {
|
|
|
|
if (viewModel.isEnabledExchangeAction) {
|
|
|
|
await Navigator.of(context).pushNamed(Routes.exchange);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
);
|
|
|
|
|
|
|
|
static MainActions sendAction = MainActions._(
|
|
|
|
name: (context) => S.of(context).send,
|
|
|
|
image: 'assets/images/upload.png',
|
|
|
|
onTap: (BuildContext context, DashboardViewModel viewModel) async {
|
|
|
|
Navigator.pushNamed(context, Routes.send);
|
|
|
|
},
|
|
|
|
);
|
|
|
|
|
2023-06-13 23:15:10 +00:00
|
|
|
|
2024-11-09 19:00:56 +00:00
|
|
|
static MainActions tradeAction = MainActions._(
|
2024-11-25 16:26:41 +00:00
|
|
|
name: (context) => '${S.of(context).buy}/${S.of(context).sell}',
|
2024-11-09 19:00:56 +00:00
|
|
|
image: 'assets/images/buy_sell.png',
|
|
|
|
isEnabled: (viewModel) => viewModel.isEnabledTradeAction,
|
|
|
|
canShow: (viewModel) => viewModel.hasTradeAction,
|
|
|
|
onTap: (BuildContext context, DashboardViewModel viewModel) async {
|
|
|
|
if (!viewModel.isEnabledTradeAction) return;
|
|
|
|
await Navigator.of(context).pushNamed(Routes.buySellPage, arguments: false);
|
2023-04-14 04:39:08 +00:00
|
|
|
},
|
|
|
|
);
|
2023-12-28 19:20:59 +00:00
|
|
|
}
|