2024-02-09 00:11:41 +01:00
|
|
|
import 'dart:io';
|
|
|
|
|
2024-05-04 20:44:50 -05:00
|
|
|
import 'package:cake_wallet/generated/i18n.dart';
|
2023-12-02 03:26:43 +01:00
|
|
|
import 'package:cake_wallet/reactions/wallet_connect.dart';
|
2024-05-04 20:44:50 -05:00
|
|
|
import 'package:cake_wallet/routes.dart';
|
|
|
|
import 'package:cake_wallet/src/screens/base_page.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';
|
2024-05-04 20:44:50 -05:00
|
|
|
import 'package:cake_wallet/src/widgets/alert_with_two_actions.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';
|
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(
|
Cw 453 (#1306)
* feat: rebase btc-addr-types, migrate to bitcoin_base
* feat: allow scanning elect-rs using get_tweaks
* feat: scanning and adding addresses working with getTweaks, add btc SP address type
* chore: pubspec.lock
* chore: pubspec.lock
* fix: scan when switching, fix multiple unspents in same tx
* fix: initial scan
* fix: initial scan
* fix: scanning issues
* fix: sync, storing silent unspents
* chore: deps
* fix: label issues, clear spent utxo
* chore: deps
* fix: build
* fix: missing types
* feat: new electrs API & changes, fixes for last block scanning
* feat: Scan Silent Payments homepage toggle
* chore: build configure
* feat: generic fixes, testnet UI improvements, useSSL on bitcoin nodes
* fix: invalid Object in sendData
* feat: improve addresses page & address book displays
* feat: silent payments labeled addresses disclaimer
* fix: missing i18n
* chore: print
* feat: single block scan, rescan by date working for btc mainnet
* feat: new cake features page replace market page, move sp scan toggle, auto switch node pop up alert
* feat: delete silent addresses
* fix: red dot in non ssl nodes
* fix: inconsistent connection states, fix tx history
* fix: tx & balance displays, cpfp sending
* feat: new rust lib
* chore: node path
* fix: check node based on network
* fix: missing txcount from addresses
* style: padding in feature page cards
* fix: restore not getting all wallet addresses by type
* fix: auto switch node broken
* fix: silent payment txs not being restored
* feat: change scanning to subscription model, sync improvements
* fix: scan re-subscription
* fix: default nodes
* fix: improve scanning by date, fix single block scan
* refactor: common function for input tx selection
* fix: nodes & build
* fix: send all with multiple outs
* refactor: unchanged file
* Update pr_test_build.yml
* chore: upgrade
* chore: merge changes
* refactor: unchanged files [skip ci]
* fix: scan fixes, add date, allow sending while scanning
* feat: sync fixes, sp settings
* feat: fix resyncing
* fix: date from height logic, status disconnected & chain tip get
* fix: params
* feat: electrum migration if using cake electrum
* fix nodes
update versions
* re-enable tron
* update sp_scanner to work on iOS [skip ci]
* fix: wrong socket for old electrum nodes
* Fix unchecked wallet type call
* fix: double balance
* feat: node domain
* fix: menu name
* fix: update tip on set scanning
* fix: connection switching back and forth
* feat: check if node is electrs, and supports sp
* chore: fix build
* minor enhancements
* fixes and enhancements
* solve conflicts with main
* fix: status toggle
* minor enhancement
* Monero.com fixes
* update sp_scanner to include windows and linux
---------
Co-authored-by: Omar Hatem <omarh.ismail1@gmail.com>
2024-05-29 11:43:48 -03:00
|
|
|
title: dashboardViewModel.hasSilentPayments
|
|
|
|
? S.current.silent_payments_scanning
|
|
|
|
: S.current.rescan,
|
2023-02-06 18:46:18 +02:00
|
|
|
handler: (context) => Navigator.of(context).pushNamed(Routes.rescan),
|
|
|
|
),
|
2024-03-29 20:54:59 +02:00
|
|
|
if (DeviceInfo.instance.isMobile && FeatureFlag.isBackgroundSyncEnabled) ...[
|
2023-08-04 20:55:56 +03:00
|
|
|
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),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
);
|
|
|
|
},
|
|
|
|
),
|
2024-05-04 20:44:50 -05:00
|
|
|
if (isWalletConnectCompatibleChain(dashboardViewModel.wallet.type) &&
|
|
|
|
!dashboardViewModel.wallet.isHardwareWallet) ...[ // ToDo: Remove this line once WalletConnect is implemented
|
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());
|
|
|
|
},
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|