2024-02-09 00:11:41 +01:00
|
|
|
import 'dart:io';
|
|
|
|
|
2023-12-02 03:26:43 +01:00
|
|
|
import 'package:cake_wallet/reactions/wallet_connect.dart';
|
2022-11-16 09:29:14 +02:00
|
|
|
import 'package:cake_wallet/src/screens/settings/widgets/settings_cell_with_arrow.dart';
|
2023-08-04 20:55:56 +03:00
|
|
|
import 'package:cake_wallet/src/screens/settings/widgets/settings_picker_cell.dart';
|
|
|
|
import 'package:cake_wallet/src/screens/settings/widgets/settings_switcher_cell.dart';
|
2023-10-03 15:56:10 +01:00
|
|
|
import 'package:cake_wallet/src/screens/settings/widgets/wallet_connect_button.dart';
|
2023-08-04 20:55:56 +03:00
|
|
|
import 'package:cake_wallet/utils/device_info.dart';
|
2023-11-20 19:40:47 +02:00
|
|
|
import 'package:cake_wallet/utils/feature_flag.dart';
|
2022-11-16 09:29:14 +02:00
|
|
|
import 'package:cake_wallet/utils/show_pop_up.dart';
|
|
|
|
import 'package:cake_wallet/view_model/dashboard/dashboard_view_model.dart';
|
2023-08-04 20:55:56 +03:00
|
|
|
import 'package:cake_wallet/view_model/settings/sync_mode.dart';
|
2024-02-09 00:11:41 +01:00
|
|
|
import 'package:cw_core/battery_optimization_native.dart';
|
2022-11-16 09:29:14 +02:00
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:cake_wallet/routes.dart';
|
|
|
|
import 'package:cake_wallet/generated/i18n.dart';
|
|
|
|
import 'package:cake_wallet/src/screens/base_page.dart';
|
|
|
|
import 'package:cake_wallet/src/widgets/standard_list.dart';
|
|
|
|
import 'package:cake_wallet/src/widgets/alert_with_two_actions.dart';
|
2023-08-04 20:55:56 +03:00
|
|
|
import 'package:flutter_mobx/flutter_mobx.dart';
|
2022-11-16 09:29:14 +02:00
|
|
|
|
|
|
|
class ConnectionSyncPage extends BasePage {
|
2023-12-13 15:03:07 +01:00
|
|
|
ConnectionSyncPage(this.dashboardViewModel);
|
2022-11-16 09:29:14 +02:00
|
|
|
|
|
|
|
@override
|
|
|
|
String get title => S.current.connection_sync;
|
|
|
|
|
|
|
|
final DashboardViewModel dashboardViewModel;
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget body(BuildContext context) {
|
|
|
|
return Container(
|
|
|
|
padding: EdgeInsets.only(top: 10),
|
|
|
|
child: Column(
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
children: [
|
|
|
|
SettingsCellWithArrow(
|
|
|
|
title: S.current.reconnect,
|
|
|
|
handler: (context) => _presentReconnectAlert(context),
|
|
|
|
),
|
2023-08-04 20:55:56 +03:00
|
|
|
if (dashboardViewModel.hasRescan) ...[
|
2023-02-06 18:46:18 +02:00
|
|
|
SettingsCellWithArrow(
|
|
|
|
title: S.current.rescan,
|
|
|
|
handler: (context) => Navigator.of(context).pushNamed(Routes.rescan),
|
|
|
|
),
|
2023-08-04 20:55:56 +03:00
|
|
|
if (DeviceInfo.instance.isMobile) ...[
|
|
|
|
Observer(builder: (context) {
|
|
|
|
return SettingsPickerCell<SyncMode>(
|
2024-02-09 00:11:41 +01:00
|
|
|
title: S.current.background_sync_mode,
|
|
|
|
items: SyncMode.all,
|
|
|
|
displayItem: (SyncMode syncMode) => syncMode.name,
|
|
|
|
selectedItem: dashboardViewModel.syncMode,
|
|
|
|
onItemSelected: (syncMode) async {
|
|
|
|
dashboardViewModel.setSyncMode(syncMode);
|
|
|
|
|
2024-02-11 02:04:46 +02:00
|
|
|
if (Platform.isIOS) return;
|
|
|
|
|
2024-02-09 00:11:41 +01:00
|
|
|
if (syncMode.type != SyncType.disabled) {
|
|
|
|
final isDisabled = await isBatteryOptimizationDisabled();
|
|
|
|
|
2024-02-11 02:04:46 +02:00
|
|
|
if (isDisabled) return;
|
2024-02-09 00:11:41 +01:00
|
|
|
|
|
|
|
await showPopUp<void>(
|
|
|
|
context: context,
|
|
|
|
builder: (BuildContext dialogContext) {
|
|
|
|
return AlertWithTwoActions(
|
|
|
|
alertTitle: S.current.disableBatteryOptimization,
|
|
|
|
alertContent: S.current.disableBatteryOptimizationDescription,
|
|
|
|
leftButtonText: S.of(context).cancel,
|
|
|
|
rightButtonText: S.of(context).ok,
|
|
|
|
actionLeftButton: () => Navigator.of(dialogContext).pop(),
|
|
|
|
actionRightButton: () async {
|
|
|
|
await requestDisableBatteryOptimization();
|
|
|
|
|
|
|
|
Navigator.of(dialogContext).pop();
|
|
|
|
},
|
|
|
|
);
|
|
|
|
},
|
|
|
|
);
|
|
|
|
}
|
|
|
|
});
|
2023-08-04 20:55:56 +03:00
|
|
|
}),
|
|
|
|
Observer(builder: (context) {
|
|
|
|
return SettingsSwitcherCell(
|
|
|
|
title: S.current.sync_all_wallets,
|
|
|
|
value: dashboardViewModel.syncAll,
|
|
|
|
onValueChange: (_, bool value) => dashboardViewModel.setSyncAll(value),
|
|
|
|
);
|
|
|
|
}),
|
|
|
|
],
|
|
|
|
],
|
|
|
|
SettingsCellWithArrow(
|
|
|
|
title: S.current.manage_nodes,
|
|
|
|
handler: (context) => Navigator.of(context).pushNamed(Routes.manageNodes),
|
2022-11-16 09:29:14 +02:00
|
|
|
),
|
2023-10-04 21:09:07 -04:00
|
|
|
Observer(
|
|
|
|
builder: (context) {
|
|
|
|
if (!dashboardViewModel.hasPowNodes) return const SizedBox();
|
|
|
|
|
|
|
|
return Column(
|
|
|
|
children: [
|
|
|
|
SettingsCellWithArrow(
|
|
|
|
title: S.current.manage_pow_nodes,
|
|
|
|
handler: (context) => Navigator.of(context).pushNamed(Routes.managePowNodes),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
);
|
|
|
|
},
|
|
|
|
),
|
CW-555-Add-Solana-Wallet (#1272)
* chore: Create cw_solana package and clean up files
* feat: Add Solana Wallet - Create, Restore form seed, restore from Key, Restore from QR, Send, Receive, transaction history, spl tokens
* fix: Make transactions file specific to solana only for solana transactions
* chore: Revert inject app details script
* fix: Fix issue with node and switch current node to main beta instead of testnet
* fix: Fix merge conflicts and adjust migration version
* fix: Fetch spl token error
Signed-off-by: Blazebrain <davidadegoke16@gmail.com>
* fix: Diplay and activate spl tokens bug
* fix: Review and fixes
* fix: reverted formatting for cryptocurrency class
* fix: Review comments, split sending flow into signing and sending separately, fix issues
* fix: Revert throwing unimplenented error
* chore: Fix comment
* chore: Fix comment
* fix: Errors in flow
* Update provider_types.dart [skip ci]
* fix: Issues with solana wallet
* Update solana_wallet.dart [skip ci]
* fix: Review comments
* fix: Date time config
* fix: Revert bash script for app details
* fix: Error with balance, displaying fees, fixing sent or received identifier bug, displaying token symbol with token transaction item in transactions list
* fix: Issues with address validation when sending spl tokens and walletconnect initial setup
* fix: Issues with sending, fetching transactions history, almost wrapping up walletconnect
* fix: Adjust imports that would affect monerocom building successfully
* fix: Refine transaction direction and continue work on walletconnect
* feat: Display SPL token transfers in the transaction history and finally settle the transaction direction
* fix: Delay in transactions history dispaly, show native token transactions first, then process spl token transactions
* feat: Switch node and revert solana chain id to previous id
* fix: Remove print statement
* fix: Remove await for transactions, fetch all transaction histories instantly and adjust solana send success message
* chore: Code refactoring and streamlined wallet type check for solana send success message
* fix: Make timeout error for node silent and add spl token images
---------
Signed-off-by: Blazebrain <davidadegoke16@gmail.com>
Co-authored-by: Omar Hatem <omarh.ismail1@gmail.com>
2024-02-23 14:39:19 +01:00
|
|
|
if (isWalletConnectCompatibleChain(dashboardViewModel.wallet.type)) ...[
|
2023-10-03 15:56:10 +01:00
|
|
|
WalletConnectTile(
|
2023-11-02 15:41:11 +01:00
|
|
|
onTap: () => Navigator.of(context).pushNamed(Routes.walletConnectConnectionsListing),
|
2023-10-03 15:56:10 +01:00
|
|
|
),
|
2023-11-18 15:43:15 +02:00
|
|
|
],
|
2023-11-20 19:40:47 +02:00
|
|
|
if (FeatureFlag.isInAppTorEnabled)
|
|
|
|
SettingsCellWithArrow(
|
|
|
|
title: S.current.tor_connection,
|
|
|
|
handler: (context) => Navigator.of(context).pushNamed(Routes.torPage),
|
|
|
|
),
|
2022-11-16 09:29:14 +02:00
|
|
|
],
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
Future<void> _presentReconnectAlert(BuildContext context) async {
|
|
|
|
await showPopUp<void>(
|
|
|
|
context: context,
|
|
|
|
builder: (BuildContext context) {
|
|
|
|
return AlertWithTwoActions(
|
|
|
|
alertTitle: S.of(context).reconnection,
|
|
|
|
alertContent: S.of(context).reconnect_alert_text,
|
|
|
|
rightButtonText: S.of(context).ok,
|
|
|
|
leftButtonText: S.of(context).cancel,
|
|
|
|
actionRightButton: () async {
|
|
|
|
Navigator.of(context).pop();
|
|
|
|
await dashboardViewModel.reconnect();
|
|
|
|
},
|
|
|
|
actionLeftButton: () => Navigator.of(context).pop());
|
|
|
|
},
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|