2020-11-18 19:09:34 +02:00
|
|
|
import 'package:cake_wallet/src/widgets/keyboard_done_button.dart';
|
2022-12-23 23:58:39 +02:00
|
|
|
import 'package:cake_wallet/src/widgets/section_divider.dart';
|
2020-12-16 22:45:45 +02:00
|
|
|
import 'package:cake_wallet/themes/theme_base.dart';
|
2023-02-08 20:16:12 +02:00
|
|
|
import 'package:cake_wallet/utils/share_util.dart';
|
2020-09-25 18:32:44 +03:00
|
|
|
import 'package:cake_wallet/utils/show_pop_up.dart';
|
2022-03-23 19:53:53 +02:00
|
|
|
import 'package:cw_core/wallet_type.dart';
|
2020-01-04 21:31:52 +02:00
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:flutter_mobx/flutter_mobx.dart';
|
|
|
|
import 'package:cake_wallet/routes.dart';
|
|
|
|
import 'package:cake_wallet/generated/i18n.dart';
|
2020-07-06 23:09:03 +03:00
|
|
|
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';
|
2020-05-06 20:40:36 +03:00
|
|
|
import 'package:cake_wallet/src/screens/receive/widgets/header_tile.dart';
|
2020-06-20 10:10:00 +03:00
|
|
|
import 'package:cake_wallet/src/screens/receive/widgets/address_cell.dart';
|
2020-07-06 23:09:03 +03:00
|
|
|
import 'package:cake_wallet/view_model/wallet_address_list/wallet_account_list_header.dart';
|
|
|
|
import 'package:cake_wallet/view_model/wallet_address_list/wallet_address_list_header.dart';
|
|
|
|
import 'package:cake_wallet/view_model/wallet_address_list/wallet_address_list_item.dart';
|
|
|
|
import 'package:cake_wallet/view_model/wallet_address_list/wallet_address_list_view_model.dart';
|
2020-07-28 19:03:34 +03:00
|
|
|
import 'package:cake_wallet/src/screens/receive/widgets/qr_widget.dart';
|
2020-11-16 20:17:03 +02:00
|
|
|
import 'package:keyboard_actions/keyboard_actions.dart';
|
2020-01-04 21:31:52 +02:00
|
|
|
|
2020-06-20 10:10:00 +03:00
|
|
|
class ReceivePage extends BasePage {
|
2022-10-12 13:09:57 -04:00
|
|
|
ReceivePage({required this.addressListViewModel}) : _cryptoAmountFocus = FocusNode();
|
2020-01-04 21:31:52 +02:00
|
|
|
|
2020-07-06 23:09:03 +03:00
|
|
|
final WalletAddressListViewModel addressListViewModel;
|
2020-01-04 21:31:52 +02:00
|
|
|
|
|
|
|
@override
|
2020-07-28 19:03:34 +03:00
|
|
|
String get title => S.current.receive;
|
2020-01-04 21:31:52 +02:00
|
|
|
|
2020-06-20 10:10:00 +03:00
|
|
|
@override
|
2020-12-16 22:45:45 +02:00
|
|
|
Color get backgroundLightColor => currentTheme.type == ThemeType.bright
|
|
|
|
? Colors.transparent : Colors.white;
|
2020-05-05 20:59:56 +03:00
|
|
|
|
2020-06-20 10:10:00 +03:00
|
|
|
@override
|
2020-08-19 20:57:06 +03:00
|
|
|
Color get backgroundDarkColor => Colors.transparent;
|
|
|
|
|
2021-05-10 20:58:05 +03:00
|
|
|
@override
|
|
|
|
bool get resizeToAvoidBottomInset => false;
|
|
|
|
|
2020-12-11 20:46:20 +02:00
|
|
|
final FocusNode _cryptoAmountFocus;
|
|
|
|
|
2020-08-19 20:57:06 +03:00
|
|
|
@override
|
2020-12-11 20:46:20 +02:00
|
|
|
Widget leading(BuildContext context) {
|
|
|
|
final _backButton = Icon(Icons.arrow_back_ios,
|
2022-10-12 13:09:57 -04:00
|
|
|
color: Theme.of(context).accentTextTheme!.headline2!.backgroundColor!,
|
2020-12-11 20:46:20 +02:00
|
|
|
size: 16,);
|
2020-08-19 20:57:06 +03:00
|
|
|
|
2020-12-11 20:46:20 +02:00
|
|
|
return SizedBox(
|
|
|
|
height: 37,
|
|
|
|
width: 37,
|
|
|
|
child: ButtonTheme(
|
|
|
|
minWidth: double.minPositive,
|
2022-10-12 13:09:57 -04:00
|
|
|
child: TextButton(
|
|
|
|
// FIX-ME: Style
|
|
|
|
//highlightColor: Colors.transparent,
|
|
|
|
//splashColor: Colors.transparent,
|
|
|
|
//padding: EdgeInsets.all(0),
|
2020-12-11 20:46:20 +02:00
|
|
|
onPressed: () => onClose(context),
|
|
|
|
child: _backButton),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget middle(BuildContext context) {
|
|
|
|
return Text(
|
|
|
|
title,
|
|
|
|
style: TextStyle(
|
|
|
|
fontSize: 18.0,
|
|
|
|
fontWeight: FontWeight.bold,
|
|
|
|
fontFamily: 'Lato',
|
2022-10-12 13:09:57 -04:00
|
|
|
color: Theme.of(context).accentTextTheme!.headline2!.backgroundColor!),
|
2020-12-11 20:46:20 +02:00
|
|
|
);
|
|
|
|
}
|
2020-11-16 20:17:03 +02:00
|
|
|
|
2020-08-19 20:57:06 +03:00
|
|
|
@override
|
|
|
|
Widget Function(BuildContext, Widget) get rootWrapper =>
|
2020-09-25 18:32:44 +03:00
|
|
|
(BuildContext context, Widget scaffold) => Container(
|
2020-08-19 20:57:06 +03:00
|
|
|
decoration: BoxDecoration(
|
|
|
|
gradient: LinearGradient(colors: [
|
2020-09-25 18:32:44 +03:00
|
|
|
Theme.of(context).accentColor,
|
|
|
|
Theme.of(context).scaffoldBackgroundColor,
|
|
|
|
Theme.of(context).primaryColor,
|
|
|
|
], begin: Alignment.topRight, end: Alignment.bottomLeft)),
|
2020-08-19 20:57:06 +03:00
|
|
|
child: scaffold);
|
2020-01-04 21:31:52 +02:00
|
|
|
|
2020-06-20 10:10:00 +03:00
|
|
|
@override
|
|
|
|
Widget trailing(BuildContext context) {
|
2020-09-25 18:32:44 +03:00
|
|
|
final shareImage =
|
2020-12-11 20:46:20 +02:00
|
|
|
Image.asset('assets/images/share.png',
|
2022-10-12 13:09:57 -04:00
|
|
|
color: Theme.of(context).accentTextTheme!.headline2!.backgroundColor!);
|
2020-05-29 18:10:11 +03:00
|
|
|
|
2022-10-26 18:05:08 +03:00
|
|
|
return Material(
|
|
|
|
color: Colors.transparent,
|
|
|
|
child: IconButton(
|
|
|
|
padding: EdgeInsets.zero,
|
|
|
|
constraints: BoxConstraints(),
|
|
|
|
highlightColor: Colors.transparent,
|
|
|
|
splashColor: Colors.transparent,
|
|
|
|
iconSize: 25,
|
2023-02-08 00:06:47 +02:00
|
|
|
onPressed: () {
|
2023-02-08 20:16:12 +02:00
|
|
|
ShareUtil.share(
|
|
|
|
text: addressListViewModel.address.address,
|
|
|
|
context: context,
|
2023-02-08 00:06:47 +02:00
|
|
|
);
|
|
|
|
},
|
2022-10-26 18:05:08 +03:00
|
|
|
icon: shareImage
|
|
|
|
)
|
2020-06-20 10:10:00 +03:00
|
|
|
);
|
|
|
|
}
|
2020-05-29 18:10:11 +03:00
|
|
|
|
2020-06-20 10:10:00 +03:00
|
|
|
@override
|
|
|
|
Widget body(BuildContext context) {
|
2022-03-30 17:57:04 +02:00
|
|
|
return (addressListViewModel.type == WalletType.monero || addressListViewModel.type == WalletType.haven)
|
2022-03-23 19:53:53 +02:00
|
|
|
? KeyboardActions(
|
2020-11-16 20:17:03 +02:00
|
|
|
config: KeyboardActionsConfig(
|
|
|
|
keyboardActionsPlatform: KeyboardActionsPlatform.IOS,
|
2022-10-12 13:09:57 -04:00
|
|
|
keyboardBarColor: Theme.of(context).accentTextTheme!.bodyText1!
|
|
|
|
.backgroundColor!,
|
2020-11-16 20:17:03 +02:00
|
|
|
nextFocus: false,
|
|
|
|
actions: [
|
|
|
|
KeyboardActionsItem(
|
|
|
|
focusNode: _cryptoAmountFocus,
|
|
|
|
toolbarButtons: [(_) => KeyboardDoneButton()],
|
|
|
|
)
|
|
|
|
]),
|
|
|
|
child: SingleChildScrollView(
|
|
|
|
child: Column(
|
|
|
|
children: <Widget>[
|
|
|
|
Padding(
|
2021-01-26 21:10:31 +02:00
|
|
|
padding: EdgeInsets.fromLTRB(24, 80, 24, 24),
|
2020-11-16 20:17:03 +02:00
|
|
|
child: QRWidget(
|
|
|
|
addressListViewModel: addressListViewModel,
|
|
|
|
isAmountFieldShow: true,
|
2021-06-04 20:48:33 +03:00
|
|
|
amountTextFieldFocusNode: _cryptoAmountFocus,
|
2022-02-07 20:32:09 +06:00
|
|
|
isLight: currentTheme.type == ThemeType.light),
|
2020-11-16 20:17:03 +02:00
|
|
|
),
|
|
|
|
Observer(
|
2022-03-15 10:31:45 +02:00
|
|
|
builder: (_) => ListView.separated(
|
2020-12-03 22:47:00 +02:00
|
|
|
padding: EdgeInsets.all(0),
|
2022-12-28 14:00:59 +02:00
|
|
|
separatorBuilder: (context, _) => const SectionDivider(),
|
2020-12-03 22:47:00 +02:00
|
|
|
shrinkWrap: true,
|
|
|
|
physics: NeverScrollableScrollPhysics(),
|
|
|
|
itemCount: addressListViewModel.items.length,
|
|
|
|
itemBuilder: (context, index) {
|
|
|
|
final item = addressListViewModel.items[index];
|
|
|
|
Widget cell = Container();
|
|
|
|
|
|
|
|
if (item is WalletAccountListHeader) {
|
|
|
|
cell = HeaderTile(
|
|
|
|
onTap: () async => await showPopUp<void>(
|
|
|
|
context: context,
|
|
|
|
builder: (_) =>
|
|
|
|
getIt.get<MoneroAccountListPage>()),
|
|
|
|
title: S.of(context).accounts,
|
|
|
|
icon: Icon(
|
|
|
|
Icons.arrow_forward_ios,
|
|
|
|
size: 14,
|
|
|
|
color:
|
2022-10-12 13:09:57 -04:00
|
|
|
Theme.of(context).textTheme!.headline4!.color!,
|
2020-12-03 22:47:00 +02:00
|
|
|
));
|
|
|
|
}
|
|
|
|
|
|
|
|
if (item is WalletAddressListHeader) {
|
|
|
|
cell = HeaderTile(
|
|
|
|
onTap: () => Navigator.of(context)
|
|
|
|
.pushNamed(Routes.newSubaddress),
|
|
|
|
title: S.of(context).addresses,
|
|
|
|
icon: Icon(
|
|
|
|
Icons.add,
|
|
|
|
size: 20,
|
|
|
|
color:
|
2022-10-12 13:09:57 -04:00
|
|
|
Theme.of(context).textTheme!.headline4!.color!,
|
2020-12-03 22:47:00 +02:00
|
|
|
));
|
|
|
|
}
|
|
|
|
|
|
|
|
if (item is WalletAddressListItem) {
|
|
|
|
cell = Observer(builder: (_) {
|
|
|
|
final isCurrent = item.address ==
|
|
|
|
addressListViewModel.address.address;
|
|
|
|
final backgroundColor = isCurrent
|
|
|
|
? Theme.of(context)
|
2022-10-12 13:09:57 -04:00
|
|
|
.textTheme!
|
|
|
|
.headline2!
|
|
|
|
.decorationColor!
|
2020-12-03 22:47:00 +02:00
|
|
|
: Theme.of(context)
|
2022-10-12 13:09:57 -04:00
|
|
|
.textTheme!
|
|
|
|
.headline3!
|
|
|
|
.decorationColor!;
|
2020-12-03 22:47:00 +02:00
|
|
|
final textColor = isCurrent
|
2022-10-12 13:09:57 -04:00
|
|
|
? Theme.of(context).textTheme!.headline2!.color!
|
|
|
|
: Theme.of(context).textTheme!.headline3!.color!;
|
2020-12-03 22:47:00 +02:00
|
|
|
|
|
|
|
return AddressCell.fromItem(item,
|
|
|
|
isCurrent: isCurrent,
|
|
|
|
backgroundColor: backgroundColor,
|
|
|
|
textColor: textColor,
|
|
|
|
onTap: (_) => addressListViewModel.setAddress(item),
|
|
|
|
onEdit: () => Navigator.of(context).pushNamed(
|
|
|
|
Routes.newSubaddress,
|
|
|
|
arguments: item));
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
return index != 0
|
|
|
|
? cell
|
|
|
|
: ClipRRect(
|
|
|
|
borderRadius: BorderRadius.only(
|
|
|
|
topLeft: Radius.circular(30),
|
|
|
|
topRight: Radius.circular(30)),
|
|
|
|
child: cell,
|
|
|
|
);
|
2022-03-15 10:31:45 +02:00
|
|
|
})),
|
2020-11-16 20:17:03 +02:00
|
|
|
],
|
2020-05-29 18:10:11 +03:00
|
|
|
),
|
2022-03-23 19:53:53 +02:00
|
|
|
)) : Padding(
|
|
|
|
padding: EdgeInsets.fromLTRB(24, 24, 24, 32),
|
|
|
|
child: Column(
|
|
|
|
children: [
|
|
|
|
Expanded(
|
|
|
|
flex: 7,
|
|
|
|
child: QRWidget(
|
|
|
|
addressListViewModel: addressListViewModel,
|
|
|
|
isAmountFieldShow: true,
|
|
|
|
amountTextFieldFocusNode: _cryptoAmountFocus,
|
|
|
|
isLight: currentTheme.type == ThemeType.light),
|
|
|
|
),
|
|
|
|
Expanded(
|
|
|
|
flex: 2,
|
|
|
|
child: SizedBox(),
|
|
|
|
),
|
|
|
|
Text(S.of(context).electrum_address_disclaimer,
|
|
|
|
textAlign: TextAlign.center,
|
|
|
|
style: TextStyle(
|
|
|
|
fontSize: 15,
|
|
|
|
color: Theme.of(context)
|
2022-10-12 13:09:57 -04:00
|
|
|
.accentTextTheme!
|
|
|
|
.headline3!
|
|
|
|
.backgroundColor!)),
|
2022-03-23 19:53:53 +02:00
|
|
|
],
|
|
|
|
),
|
|
|
|
);
|
2020-01-04 21:31:52 +02:00
|
|
|
}
|
2020-06-20 10:10:00 +03:00
|
|
|
}
|