cake_wallet/lib/entities/main_actions.dart
Omar Hatem 59e8550e4e
Generic fixes (#1823)
* add timeout for mempool fee api and make it only in bitcoin

* disable Monero Ledger for desktop

* handle onramper tag issue

* better handle main actions UI

* make service status scrollable with a better UI

* fix stupid race condition

* minor handling

* update btc fee api
update our xmr node to use ssl

* manually add supported unstoppable domains for now

* change bitcoin default node
code enhancement

* revert debugging code [skip ci]

* minor enhancements [skip ci]

* increase sync indicator size [skip ci]

* fix selecting USA country not triggering the reaction

* fix scrolling on cake features page [skip ci]
2024-11-25 18:26:41 +02:00

78 lines
No EOL
2.5 KiB
Dart

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;
final Future<void> Function(
BuildContext context, DashboardViewModel viewModel) onTap;
MainActions._({
required this.name,
required this.image,
this.isEnabled,
this.canShow,
required this.onTap,
});
static List<MainActions> all = [
showWalletsAction,
receiveAction,
exchangeAction,
sendAction,
tradeAction,
];
static MainActions showWalletsAction = MainActions._(
name: (context) => S.of(context).wallets,
image: 'assets/images/wallet_new.png',
onTap: (BuildContext context, DashboardViewModel viewModel) async {
Navigator.pushNamed(context, Routes.walletList);
},
);
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);
},
);
static MainActions tradeAction = MainActions._(
name: (context) => '${S.of(context).buy}/${S.of(context).sell}',
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);
},
);
}