diff --git a/lib/di.dart b/lib/di.dart index 108776cc0..3cc4dacae 100644 --- a/lib/di.dart +++ b/lib/di.dart @@ -124,6 +124,7 @@ import 'package:cake_wallet/store/templates/exchange_template_store.dart'; import 'package:cake_wallet/entities/template.dart'; import 'package:cake_wallet/exchange/exchange_template.dart'; import 'package:cake_wallet/.secrets.g.dart' as secrets; +import 'package:cake_wallet/src/screens/dashboard/widgets/address_page.dart'; final getIt = GetIt.instance; @@ -314,6 +315,9 @@ Future setup( getIt.registerFactory(() => DashboardPage( balancePage: getIt.get(), walletViewModel: getIt.get(), addressListViewModel: getIt.get())); getIt.registerFactory(() => ReceivePage( addressListViewModel: getIt.get())); + getIt.registerFactory(() => AddressPage( + addressListViewModel: getIt.get(), + walletViewModel: getIt.get())); getIt.registerFactoryParam( (dynamic item, _) => WalletAddressEditOrCreateViewModel( diff --git a/lib/router.dart b/lib/router.dart index ddde350ba..acfb18684 100644 --- a/lib/router.dart +++ b/lib/router.dart @@ -69,6 +69,7 @@ import 'package:flutter/services.dart'; import 'package:hive/hive.dart'; import 'package:cake_wallet/wallet_type_utils.dart'; import 'package:cake_wallet/wallet_types.g.dart'; +import 'package:cake_wallet/src/screens/dashboard/widgets/address_page.dart'; RouteSettings currentRouteSettings; @@ -217,6 +218,10 @@ Route createRoute(RouteSettings settings) { return CupertinoPageRoute( fullscreenDialog: true, builder: (_) => getIt.get()); + case Routes.addressPage: + return CupertinoPageRoute( + fullscreenDialog: true, builder: (_) => getIt.get()); + case Routes.transactionDetails: return CupertinoPageRoute( fullscreenDialog: true, diff --git a/lib/routes.dart b/lib/routes.dart index afb64f9ad..23e236023 100644 --- a/lib/routes.dart +++ b/lib/routes.dart @@ -59,4 +59,5 @@ class Routes { static const unspentCoinsDetails = '/unspent_coins_details'; static const moneroRestoreWalletFromWelcome = '/monero_restore_wallet'; static const moneroNewWalletFromWelcome = '/monero_new_wallet'; + static const addressPage = '/address_page'; } \ No newline at end of file diff --git a/lib/src/screens/dashboard/dashboard_page.dart b/lib/src/screens/dashboard/dashboard_page.dart index fa364c819..eb8c9ab17 100644 --- a/lib/src/screens/dashboard/dashboard_page.dart +++ b/lib/src/screens/dashboard/dashboard_page.dart @@ -165,7 +165,7 @@ class DashboardPage extends BasePage { ActionButton( image: receiveImage, title: S.of(context).receive, - route: Routes.receive), + route: Routes.addressPage), if (walletViewModel.hasExchangeAction) ActionButton( image: Image.asset('assets/images/transfer.png', diff --git a/lib/src/screens/dashboard/widgets/address_page.dart b/lib/src/screens/dashboard/widgets/address_page.dart index da9391131..d67e636f6 100644 --- a/lib/src/screens/dashboard/widgets/address_page.dart +++ b/lib/src/screens/dashboard/widgets/address_page.dart @@ -1,3 +1,4 @@ +import 'package:cake_wallet/src/screens/base_page.dart'; import 'package:cake_wallet/src/widgets/alert_with_one_action.dart'; import 'package:cake_wallet/src/widgets/alert_with_two_actions.dart'; import 'package:cake_wallet/src/widgets/keyboard_done_button.dart'; @@ -15,7 +16,7 @@ import 'package:flutter_mobx/flutter_mobx.dart'; import 'package:keyboard_actions/keyboard_actions.dart'; import 'package:mobx/mobx.dart'; -class AddressPage extends StatelessWidget { +class AddressPage extends BasePage { AddressPage({@required this.addressListViewModel, this.walletViewModel}) : _cryptoAmountFocus = FocusNode(); @@ -26,7 +27,64 @@ class AddressPage extends StatelessWidget { final FocusNode _cryptoAmountFocus; @override - Widget build(BuildContext context) { + String get title => S.current.receive; + + @override + Color get backgroundLightColor => currentTheme.type == ThemeType.bright + ? Colors.transparent : Colors.white; + + @override + Color get backgroundDarkColor => Colors.transparent; + + @override + bool get resizeToAvoidBottomInset => false; + + @override + Widget leading(BuildContext context) { + final _backButton = Icon(Icons.arrow_back_ios, + color: Theme.of(context).accentTextTheme.display3.backgroundColor, + size: 16,); + + return SizedBox( + height: 37, + width: 37, + child: ButtonTheme( + minWidth: double.minPositive, + child: FlatButton( + highlightColor: Colors.transparent, + splashColor: Colors.transparent, + padding: EdgeInsets.all(0), + onPressed: () => onClose(context), + child: _backButton), + ), + ); + } + + @override + Widget middle(BuildContext context) { + return Text( + title, + style: TextStyle( + fontSize: 18.0, + fontWeight: FontWeight.bold, + fontFamily: 'Lato', + color: Theme.of(context).accentTextTheme.display3.backgroundColor), + ); + } + + @override + Widget Function(BuildContext, Widget) get rootWrapper => + (BuildContext context, Widget scaffold) => Container( + decoration: BoxDecoration( + gradient: LinearGradient(colors: [ + Theme.of(context).accentColor, + Theme.of(context).scaffoldBackgroundColor, + Theme.of(context).primaryColor, + ], begin: Alignment.topRight, end: Alignment.bottomLeft)), + child: scaffold); + + @override + Widget body(BuildContext context) { autorun((_) async { if (!walletViewModel.isOutdatedElectrumWallet || !walletViewModel.settingsStore.shouldShowReceiveWarning) { @@ -66,7 +124,6 @@ class AddressPage extends StatelessWidget { ) ]), child: Container( - height: 1, padding: EdgeInsets.fromLTRB(24, 24, 24, 32), child: Column( children: [ diff --git a/lib/src/screens/receive/receive_page.dart b/lib/src/screens/receive/receive_page.dart index cf5d20426..9e86f2b1c 100644 --- a/lib/src/screens/receive/receive_page.dart +++ b/lib/src/screens/receive/receive_page.dart @@ -109,7 +109,7 @@ class ReceivePage extends BasePage { @override Widget body(BuildContext context) { - return addressListViewModel.type == WalletType.monero + return (addressListViewModel.type == WalletType.monero || addressListViewModel.type == WalletType.haven) ? KeyboardActions( config: KeyboardActionsConfig( keyboardActionsPlatform: KeyboardActionsPlatform.IOS, diff --git a/lib/src/screens/receive/widgets/qr_widget.dart b/lib/src/screens/receive/widgets/qr_widget.dart index b85979f5b..1bfbd6230 100644 --- a/lib/src/screens/receive/widgets/qr_widget.dart +++ b/lib/src/screens/receive/widgets/qr_widget.dart @@ -133,54 +133,7 @@ class QRWidget extends StatelessWidget { ], ), ))), - ), - Observer(builder: (_) { - return addressListViewModel.emoji.isNotEmpty - ? Padding( - padding: EdgeInsets.only(bottom: 10), - child: Builder( - builder: (context) => GestureDetector( - onTap: () { - Clipboard.setData(ClipboardData( - text: addressListViewModel.emoji)); - showBar( - context, S.of(context).copied_to_clipboard); - }, - child: Column( - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - Text( - S.of(context).yat, - textAlign: TextAlign.center, - style: TextStyle( - fontSize: 13, - fontWeight: FontWeight.normal, - color: Theme.of(context).accentTextTheme. - display3.backgroundColor), - ), - Padding( - padding: EdgeInsets.only(top: 5), - child: Row( - mainAxisSize: MainAxisSize.max, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Expanded(child:Text( - addressListViewModel.emoji, - textAlign: TextAlign.center, - style: TextStyle( - fontSize: 26))), - Padding( - padding: EdgeInsets.only(left: 12), - child: copyImage, - )] - ), - ) - ] - ) - )), - ) - : Container(); - }) + ) ], ); } diff --git a/lib/view_model/wallet_address_list/wallet_address_list_view_model.dart b/lib/view_model/wallet_address_list/wallet_address_list_view_model.dart index 8b8d10833..30675926a 100644 --- a/lib/view_model/wallet_address_list/wallet_address_list_view_model.dart +++ b/lib/view_model/wallet_address_list/wallet_address_list_view_model.dart @@ -100,30 +100,7 @@ abstract class WalletAddressListViewModelBase with Store { }) { _appStore = appStore; _wallet = _appStore.wallet; - emoji = ''; hasAccounts = _wallet?.type == WalletType.monero || _wallet?.type == WalletType.haven; - reaction((_) => _wallet.walletAddresses.address, (String address) { - if (address == _wallet.walletInfo.yatLastUsedAddress) { - emoji = yatStore.emoji; - } else { - emoji = ''; - } - }); - - //reaction((_) => yatStore.emoji, (String emojiId) => this.emoji = emojiId); - - //_onLastUsedYatAddressSubscription = - // _wallet.walletInfo.yatLastUsedAddressStream.listen((String yatAddress) { - // if (yatAddress == _wallet.walletAddresses.address) { - // emoji = yatStore.emoji; - // } else { - // emoji = ''; - // } - //}); - - if (_wallet.walletAddresses.address == _wallet.walletInfo.yatLastUsedAddress) { - emoji = yatStore.emoji; - } _onWalletChangeReaction = reaction((_) => _appStore.wallet, (WalletBase< Balance, TransactionHistoryBase, TransactionInfo> @@ -243,9 +220,6 @@ abstract class WalletAddressListViewModelBase with Store { @computed bool get hasAddressList => _wallet.type == WalletType.monero || _wallet.type == WalletType.haven; - @observable - String emoji; - @observable WalletBase, TransactionInfo> _wallet; @@ -258,9 +232,6 @@ abstract class WalletAddressListViewModelBase with Store { ReactionDisposer _onWalletChangeReaction; - StreamSubscription _onLastUsedYatAddressSubscription; - StreamSubscription _onEmojiIdChangeSubscription; - @action void setAddress(WalletAddressListItem address) => _wallet.walletAddresses.address = address.address;