mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2024-12-23 03:59:23 +00:00
02f53055b1
* init commit * onramper * moonPay * dfx provider * meld * dfx payment methods * fiat buy credentials * moonpay payment method * payment loading state * dfx sell quote * onramper launch trade * meld launch trade * country picker * update option tile * buy/sell action * meld refactor * update pr_test_build.yml * ui fixes * revert country picker commit * update the ui * recommended providers * payment method [skip ci] * provider option tile * remove buy action * minor fixes * update the best rate when the amount is changed * fixes for currency title * fix icons * code refactoring * null issue * code review fixes * Update pr_test_build_linux.yml * Update meld_buy_provider.dart * Update meld_buy_provider.dart * add show wallets action * remove default sell / buy provider setting * localisation * providerTypes * icons * remove duplicate file [skip ci] * minor changes [skip ci] * fixes from review * disable dfx for non eur/chf currencies fix providers to be fetched with the selected currency * fix breaking from loop if one element failed * fix minor naming issue from merging conflicts * add fiat check for moonpay * fix address validation * merge conflict * fix destination and source currency * minor fix * minor fix * update the flow * fix bch address format * fix wallet addresses * fix initial fetching amount. * Update address_validator.dart * review comments * revert switch case to return null * minor fix --------- Co-authored-by: OmarHatem <omarh.ismail1@gmail.com>
80 lines
No EOL
2.7 KiB
Dart
80 lines
No EOL
2.7 KiB
Dart
import 'package:cake_wallet/generated/i18n.dart';
|
|
import 'package:cake_wallet/routes.dart';
|
|
import 'package:cake_wallet/src/widgets/alert_with_one_action.dart';
|
|
import 'package:cake_wallet/utils/show_pop_up.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);
|
|
},
|
|
);
|
|
} |