mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2025-06-28 12:29:51 +00:00
* 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>
235 lines
8.6 KiB
Dart
235 lines
8.6 KiB
Dart
import 'package:cake_wallet/bitcoin/bitcoin.dart';
|
|
import 'package:cake_wallet/src/screens/new_wallet/widgets/select_button.dart';
|
|
import 'package:cake_wallet/themes/extensions/keyboard_theme.dart';
|
|
import 'package:cake_wallet/di.dart';
|
|
import 'package:cake_wallet/src/screens/base_page.dart';
|
|
import 'package:cake_wallet/src/screens/monero_accounts/monero_account_list_page.dart';
|
|
import 'package:cake_wallet/anonpay/anonpay_donation_link_info.dart';
|
|
import 'package:cake_wallet/entities/preferences_key.dart';
|
|
import 'package:cw_core/receive_page_option.dart';
|
|
import 'package:cake_wallet/src/screens/dashboard/widgets/present_receive_option_picker.dart';
|
|
import 'package:cake_wallet/src/widgets/gradient_background.dart';
|
|
import 'package:cake_wallet/src/widgets/keyboard_done_button.dart';
|
|
import 'package:cake_wallet/themes/extensions/sync_indicator_theme.dart';
|
|
import 'package:cake_wallet/themes/theme_base.dart';
|
|
import 'package:cake_wallet/utils/responsive_layout_util.dart';
|
|
import 'package:cake_wallet/utils/share_util.dart';
|
|
import 'package:cake_wallet/utils/show_pop_up.dart';
|
|
import 'package:cake_wallet/view_model/dashboard/receive_option_view_model.dart';
|
|
import 'package:cake_wallet/view_model/dashboard/dashboard_view_model.dart';
|
|
import 'package:cw_core/wallet_type.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:cake_wallet/view_model/wallet_address_list/wallet_address_list_view_model.dart';
|
|
import 'package:cake_wallet/src/screens/receive/widgets/qr_widget.dart';
|
|
import 'package:cake_wallet/routes.dart';
|
|
import 'package:cake_wallet/generated/i18n.dart';
|
|
import 'package:flutter_mobx/flutter_mobx.dart';
|
|
import 'package:keyboard_actions/keyboard_actions.dart';
|
|
import 'package:mobx/mobx.dart';
|
|
import 'package:shared_preferences/shared_preferences.dart';
|
|
import 'package:cake_wallet/themes/extensions/balance_page_theme.dart';
|
|
|
|
class AddressPage extends BasePage {
|
|
AddressPage({
|
|
required this.addressListViewModel,
|
|
required this.dashboardViewModel,
|
|
required this.receiveOptionViewModel,
|
|
}) : _cryptoAmountFocus = FocusNode(),
|
|
_formKey = GlobalKey<FormState>(),
|
|
_amountController = TextEditingController() {
|
|
_amountController.addListener(() {
|
|
if (_formKey.currentState!.validate()) {
|
|
addressListViewModel.changeAmount(
|
|
_amountController.text,
|
|
);
|
|
}
|
|
});
|
|
}
|
|
|
|
final WalletAddressListViewModel addressListViewModel;
|
|
final DashboardViewModel dashboardViewModel;
|
|
final ReceiveOptionViewModel receiveOptionViewModel;
|
|
final TextEditingController _amountController;
|
|
final GlobalKey<FormState> _formKey;
|
|
|
|
final FocusNode _cryptoAmountFocus;
|
|
|
|
@override
|
|
bool get gradientBackground => true;
|
|
|
|
@override
|
|
bool get resizeToAvoidBottomInset => false;
|
|
|
|
bool effectsInstalled = false;
|
|
|
|
@override
|
|
Widget? leading(BuildContext context) {
|
|
final _backButton = Icon(
|
|
Icons.arrow_back_ios,
|
|
color: titleColor(context),
|
|
size: 16,
|
|
);
|
|
final _closeButton =
|
|
currentTheme.type == ThemeType.dark ? closeButtonImageDarkTheme : closeButtonImage;
|
|
|
|
bool isMobileView = responsiveLayoutUtil.shouldRenderMobileUI;
|
|
|
|
return MergeSemantics(
|
|
child: SizedBox(
|
|
height: isMobileView ? 37 : 45,
|
|
width: isMobileView ? 37 : 45,
|
|
child: ButtonTheme(
|
|
minWidth: double.minPositive,
|
|
child: Semantics(
|
|
label: !isMobileView ? S.of(context).close : S.of(context).seed_alert_back,
|
|
child: TextButton(
|
|
style: ButtonStyle(
|
|
overlayColor: MaterialStateColor.resolveWith((states) => Colors.transparent),
|
|
),
|
|
onPressed: () => onClose(context),
|
|
child: !isMobileView ? _closeButton : _backButton,
|
|
),
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
|
|
@override
|
|
Widget middle(BuildContext context) => PresentReceiveOptionPicker(
|
|
color: titleColor(context), receiveOptionViewModel: receiveOptionViewModel);
|
|
|
|
@override
|
|
Widget Function(BuildContext, Widget) get rootWrapper =>
|
|
(BuildContext context, Widget scaffold) => GradientBackground(scaffold: scaffold);
|
|
|
|
@override
|
|
Widget? trailing(BuildContext context) {
|
|
return Material(
|
|
color: Colors.transparent,
|
|
child: Semantics(
|
|
label: S.of(context).share,
|
|
child: IconButton(
|
|
padding: EdgeInsets.zero,
|
|
constraints: BoxConstraints(),
|
|
highlightColor: Colors.transparent,
|
|
splashColor: Colors.transparent,
|
|
iconSize: 25,
|
|
onPressed: () {
|
|
ShareUtil.share(
|
|
text: addressListViewModel.uri.toString(),
|
|
context: context,
|
|
);
|
|
},
|
|
icon: Icon(Icons.share, size: 20, color: pageIconColor(context)),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
|
|
@override
|
|
Widget body(BuildContext context) {
|
|
_setEffects(context);
|
|
|
|
return KeyboardActions(
|
|
autoScroll: false,
|
|
disableScroll: true,
|
|
tapOutsideBehavior: TapOutsideBehavior.translucentDismiss,
|
|
config: KeyboardActionsConfig(
|
|
keyboardActionsPlatform: KeyboardActionsPlatform.IOS,
|
|
keyboardBarColor: Theme.of(context).extension<KeyboardTheme>()!.keyboardBarColor,
|
|
nextFocus: false,
|
|
actions: [
|
|
KeyboardActionsItem(
|
|
focusNode: _cryptoAmountFocus,
|
|
toolbarButtons: [(_) => KeyboardDoneButton()],
|
|
)
|
|
]),
|
|
child: Container(
|
|
padding: EdgeInsets.fromLTRB(24, 0, 24, 32),
|
|
child: Column(
|
|
children: <Widget>[
|
|
Expanded(
|
|
child: Observer(
|
|
builder: (_) => QRWidget(
|
|
formKey: _formKey,
|
|
addressListViewModel: addressListViewModel,
|
|
amountTextFieldFocusNode: _cryptoAmountFocus,
|
|
amountController: _amountController,
|
|
isLight: dashboardViewModel.settingsStore.currentTheme.type ==
|
|
ThemeType.light))),
|
|
SizedBox(height: 16),
|
|
Observer(builder: (_) {
|
|
if (addressListViewModel.hasAddressList) {
|
|
return SelectButton(
|
|
text: addressListViewModel.buttonTitle,
|
|
onTap: () async => Navigator.of(context).pushNamed(Routes.receive),
|
|
textColor: Theme.of(context).extension<SyncIndicatorTheme>()!.textColor,
|
|
color: Theme.of(context).extension<SyncIndicatorTheme>()!.syncedBackgroundColor,
|
|
borderColor: Theme.of(context).extension<BalancePageTheme>()!.cardBorderColor,
|
|
arrowColor: Theme.of(context).extension<SyncIndicatorTheme>()!.textColor,
|
|
textSize: 14,
|
|
height: 50,
|
|
);
|
|
}
|
|
else {
|
|
return const SizedBox();
|
|
}
|
|
}),
|
|
],
|
|
),
|
|
));
|
|
}
|
|
|
|
void _setEffects(BuildContext context) {
|
|
if (effectsInstalled) {
|
|
return;
|
|
}
|
|
|
|
reaction((_) => receiveOptionViewModel.selectedReceiveOption, (ReceivePageOption option) {
|
|
if (bitcoin!.isBitcoinReceivePageOption(option)) {
|
|
addressListViewModel.setAddressType(bitcoin!.getOptionToType(option));
|
|
return;
|
|
}
|
|
|
|
switch (option) {
|
|
case ReceivePageOption.anonPayInvoice:
|
|
Navigator.pushNamed(
|
|
context,
|
|
Routes.anonPayInvoicePage,
|
|
arguments: [addressListViewModel.address.address, option],
|
|
);
|
|
break;
|
|
case ReceivePageOption.anonPayDonationLink:
|
|
final sharedPreferences = getIt.get<SharedPreferences>();
|
|
final clearnetUrl = sharedPreferences.getString(PreferencesKey.clearnetDonationLink);
|
|
final onionUrl = sharedPreferences.getString(PreferencesKey.onionDonationLink);
|
|
|
|
if (clearnetUrl != null && onionUrl != null) {
|
|
Navigator.pushNamed(
|
|
context,
|
|
Routes.anonPayReceivePage,
|
|
arguments: AnonpayDonationLinkInfo(
|
|
clearnetUrl: clearnetUrl,
|
|
onionUrl: onionUrl,
|
|
address: addressListViewModel.address.address,
|
|
),
|
|
);
|
|
} else {
|
|
Navigator.pushNamed(
|
|
context,
|
|
Routes.anonPayInvoicePage,
|
|
arguments: [addressListViewModel.address.address, option],
|
|
);
|
|
}
|
|
break;
|
|
default:
|
|
if (addressListViewModel.type == WalletType.bitcoin) {
|
|
addressListViewModel.setAddressType(bitcoin!.getBitcoinAddressType(option));
|
|
}
|
|
}
|
|
});
|
|
|
|
effectsInstalled = true;
|
|
}
|
|
}
|