Merge branch 'flutter-upgrade' of https://github.com/cake-tech/cake_wallet into CW-182-allow-trusted-nodes

This commit is contained in:
OmarHatem
2022-11-03 21:34:20 +02:00
96 changed files with 1383 additions and 671 deletions
+39 -38
View File
@@ -1,5 +1,5 @@
import 'package:another_flushbar/flushbar.dart';
import 'package:cake_wallet/utils/show_bar.dart';
// import 'package:flushbar/flushbar.dart';
import 'package:mobx/mobx.dart';
import 'package:flutter/material.dart';
import 'package:flutter/cupertino.dart';
@@ -31,9 +31,8 @@ class AuthPageState extends State<AuthPage> {
final _backArrowImageDarkTheme =
Image.asset('assets/images/close_button.png');
ReactionDisposer? _reaction;
// FIX-ME: replace Flushbar
// Flushbar<void>? _authBar;
// Flushbar<void>? _progressBar;
Flushbar<void>? _authBar;
Flushbar<void>? _progressBar;
@override
void initState() {
@@ -48,39 +47,34 @@ class AuthPageState extends State<AuthPage> {
if (state is IsExecutingState) {
WidgetsBinding.instance.addPostFrameCallback((_) {
// FIX-ME: Changes related to flutter upgreade.
// Could be incorrect value for duration of auth bar
// _authBar =
// createBar<void>(S.of(context).authentication, duration: Duration())
// ..show(context);
// null duration to make it indefinite until its disposed
_authBar =
createBar<void>(S.of(context).authentication, duration: null)
..show(context);
});
}
if (state is FailureState) {
print('X');
print(state.error);
WidgetsBinding.instance.addPostFrameCallback((_) {
WidgetsBinding.instance.addPostFrameCallback((_) async {
_pinCodeKey.currentState?.clear();
// _authBar?.dismiss();
dismissFlushBar(_authBar);
showBar<void>(
context, S.of(context).failed_authentication(state.error));
if (widget.onAuthenticationFinished != null) {
widget.onAuthenticationFinished(false, this);
}
widget.onAuthenticationFinished(false, this);
});
}
if (state is AuthenticationBanned) {
WidgetsBinding.instance.addPostFrameCallback((_) {
WidgetsBinding.instance.addPostFrameCallback((_) async {
_pinCodeKey.currentState?.clear();
// _authBar?.dismiss();
dismissFlushBar(_authBar);
showBar<void>(
context, S.of(context).failed_authentication(state.error));
if (widget.onAuthenticationFinished != null) {
widget.onAuthenticationFinished(false, this);
}
widget.onAuthenticationFinished(false, this);
});
}
});
@@ -102,26 +96,32 @@ class AuthPageState extends State<AuthPage> {
}
void changeProcessText(String text) {
// _authBar?.dismiss();
// FIX-ME: Changes related to flutter upgreade.
// Could be incorrect value for duration of auth bar
// _progressBar = createBar<void>(text, duration: Duration())
// ..show(_key.currentContext);
dismissFlushBar(_authBar);
_progressBar = createBar<void>(text, duration: null)
..show(_key.currentContext!);
}
void hideProgressText() {
// _progressBar?.dismiss();
// _progressBar = null;
dismissFlushBar(_progressBar);
_progressBar = null;
}
void close() {
Future<void> close({String? route}) async {
if (_key.currentContext == null) {
throw Exception('Key context is null. Should be not happened');
}
// _authBar?.dismiss();
// _progressBar?.dismiss();
Navigator.of(_key.currentContext!).pop();
WidgetsBinding.instance.addPostFrameCallback((_) {
dismissFlushBar(_authBar);
dismissFlushBar(_progressBar);
WidgetsBinding.instance.addPostFrameCallback((_) {
if (route != null) {
Navigator.of(_key.currentContext!).pushReplacementNamed(route);
} else {
Navigator.of(_key.currentContext!).pop();
}
});
});
}
@override
@@ -135,14 +135,9 @@ class AuthPageState extends State<AuthPage> {
child: SizedBox(
height: 37,
width: 37,
child: ButtonTheme(
minWidth: double.minPositive,
child: TextButton(
//highlightColor: Colors.transparent,
//splashColor: Colors.transparent,
//padding: EdgeInsets.all(0),
onPressed: () => Navigator.of(context).pop(),
child: _backArrowImageDarkTheme),
child: InkWell(
onTap: () => Navigator.of(context).pop(),
child: _backArrowImageDarkTheme,
),
))
: Container(),
@@ -152,4 +147,10 @@ class AuthPageState extends State<AuthPage> {
body: PinCode((pin, _) => widget.authViewModel.auth(password: pin),
(_) => null, widget.authViewModel.pinLength, false, _pinCodeKey));
}
void dismissFlushBar(Flushbar<dynamic>? bar) {
WidgetsBinding.instance.addPostFrameCallback((_) async {
await bar?.dismiss();
});
}
}
+20 -10
View File
@@ -1,10 +1,10 @@
import 'dart:io';
import 'package:cake_wallet/palette.dart';
import 'package:flutter/material.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/services.dart';
import 'package:flutter_mobx/flutter_mobx.dart';
// import 'package:esys_flutter_share/esys_flutter_share.dart';
import 'package:share_plus/share_plus.dart';
import 'package:cross_file/cross_file.dart';
import 'package:cake_wallet/utils/show_bar.dart';
import 'package:cake_wallet/routes.dart';
import 'package:cake_wallet/generated/i18n.dart';
@@ -103,12 +103,14 @@ class BackupPage extends BasePage {
Navigator.of(dialogContext).pop();
final backup = await backupViewModelBase.exportBackup();
if (backup == null) {
return;
}
if (Platform.isAndroid) {
onExportAndroid(context, backup!);
onExportAndroid(context, backup);
} else {
// FIX-ME: Share esys_flutter_share.dart
// await Share.file(S.of(context).backup_file, backup.name,
// backup.content, 'application/*');
await share(backup);
}
},
actionLeftButton: () => Navigator.of(dialogContext).pop());
@@ -136,12 +138,20 @@ class BackupPage extends BasePage {
backup.name, backup.content);
Navigator.of(dialogContext).pop();
},
actionLeftButton: () {
actionLeftButton: () async {
Navigator.of(dialogContext).pop();
// FIX-ME: Share esys_flutter_share.dart
// Share.file(S.of(context).backup_file, backup.name,
// backup.content, 'application/*');
await share(backup);
});
});
}
Future<void> share(BackupExportFile backup) async {
const mimeType = 'application/*';
final path = await backupViewModelBase.saveBackupFileLocally(backup);
await Share.shareXFiles(<XFile>[XFile(
path,
name: backup.name,
mimeType: mimeType)]);
await backupViewModelBase.removeBackupFileLocally(backup);
}
}
+86
View File
@@ -0,0 +1,86 @@
import 'dart:io';
import 'package:cake_wallet/generated/i18n.dart';
import 'package:cake_wallet/src/screens/base_page.dart';
import 'package:cake_wallet/store/settings_store.dart';
import 'package:cw_core/wallet_base.dart';
import 'package:flutter/material.dart';
import 'package:webview_flutter/webview_flutter.dart';
import 'package:cake_wallet/.secrets.g.dart' as secrets;
class OnRamperPage extends BasePage {
OnRamperPage({
required this.settingsStore,
required this.wallet});
final SettingsStore settingsStore;
final WalletBase wallet;
@override
String get title => S.current.buy;
@override
Widget body(BuildContext context) {
final darkMode = Theme.of(context).brightness == Brightness.dark;
return OnRamperPageBody(
settingsStore: settingsStore,
wallet: wallet,
darkMode: darkMode,
backgroundColor: darkMode
? backgroundDarkColor
: backgroundLightColor,
supportSell: false,
supportSwap: false);
}
}
class OnRamperPageBody extends StatefulWidget {
OnRamperPageBody({
required this.settingsStore,
required this.wallet,
required this.darkMode,
required this.supportSell,
required this.supportSwap,
required this.backgroundColor});
static const baseUrl = 'widget.onramper.com';
final SettingsStore settingsStore;
final WalletBase wallet;
final Color backgroundColor;
final bool darkMode;
final bool supportSell;
final bool supportSwap;
Uri get uri
=> Uri.https(
baseUrl,
'',
<String, dynamic>{
'apiKey': secrets.onramperApiKey,
'defaultCrypto': wallet.currency.title,
'defaultFiat': settingsStore.fiatCurrency.title,
'wallets': '${wallet.currency.title}:${wallet.walletAddresses.address}',
'darkMode': darkMode.toString(),
'supportSell': supportSell.toString(),
'supportSwap': supportSwap.toString()});
@override
OnRamperPageBodyState createState() => OnRamperPageBodyState();
}
class OnRamperPageBodyState extends State<OnRamperPageBody> {
OnRamperPageBodyState();
@override
void initState() {
super.initState();
if (Platform.isAndroid) WebView.platform = SurfaceAndroidWebView();
}
@override
Widget build(BuildContext context) {
return WebView(
initialUrl: widget.uri.toString(),
backgroundColor: widget.backgroundColor,
javascriptMode: JavascriptMode.unrestricted);
}
}
+10 -11
View File
@@ -80,7 +80,7 @@ class PreOrderPage extends BasePage {
return KeyboardActions(
config: KeyboardActionsConfig(
keyboardActionsPlatform: KeyboardActionsPlatform.IOS,
keyboardBarColor: Theme.of(context).accentTextTheme!.bodyText1!
keyboardBarColor: Theme.of(context).accentTextTheme.bodyText1!
.backgroundColor!,
nextFocus: false,
actions: [
@@ -102,10 +102,9 @@ class PreOrderPage extends BasePage {
bottomLeft: Radius.circular(24),
bottomRight: Radius.circular(24)),
gradient: LinearGradient(colors: [
Theme.of(context).primaryTextTheme!.subtitle1!.color!,
Theme.of(context).primaryTextTheme.subtitle1!.color!,
Theme.of(context)
.primaryTextTheme!
.subtitle1!
.primaryTextTheme.subtitle1!
.decorationColor!,
], begin: Alignment.topLeft, end: Alignment.bottomRight),
),
@@ -161,11 +160,11 @@ class PreOrderPage extends BasePage {
),
),
hintText: '0.00',
borderColor: Theme.of(context).primaryTextTheme!.bodyText1!.decorationColor!,
borderColor: Theme.of(context).primaryTextTheme.bodyText1!.decorationColor!,
borderWidth: 0.5,
textStyle: TextStyle(fontSize: 36, fontWeight: FontWeight.w500, color: Colors.white),
placeholderTextStyle: TextStyle(
color: Theme.of(context).primaryTextTheme!.headline5!.decorationColor!,
color: Theme.of(context).primaryTextTheme.headline5!.decorationColor!,
fontWeight: FontWeight.w500,
fontSize: 36,
),
@@ -180,7 +179,7 @@ class PreOrderPage extends BasePage {
S.of(context).buy_with + ':',
textAlign: TextAlign.center,
style: TextStyle(
color: Theme.of(context).primaryTextTheme!.headline6!.color!,
color: Theme.of(context).primaryTextTheme.headline6!.color!,
fontSize: 18,
fontWeight: FontWeight.bold
),
@@ -197,11 +196,11 @@ class PreOrderPage extends BasePage {
double achAmount;
int minAmount;
if (snapshot.hasData) {
if (snapshot.hasData && snapshot.data != null) {
sourceAmount = snapshot.data!.sourceAmount;
destAmount = snapshot.data!.destAmount;
minAmount = snapshot.data!.minAmount;
achAmount = snapshot.data!.achSourceAmount!;
achAmount = snapshot.data!.achSourceAmount ?? 0;
} else {
sourceAmount = 0.0;
destAmount = 0.0;
@@ -215,7 +214,7 @@ class PreOrderPage extends BasePage {
child: Observer(builder: (_) {
return BuyListItem(
selectedProvider:
buyViewModel.selectedProvider!,
buyViewModel.selectedProvider,
provider: item.provider,
sourceAmount: sourceAmount,
sourceCurrency: buyViewModel.fiatCurrency,
@@ -247,7 +246,7 @@ class PreOrderPage extends BasePage {
? S.of(context).buy
: S.of(context).buy_with +
' ${buyViewModel.selectedProvider!.description.title}',
color: Theme.of(context).accentTextTheme!.bodyText1!.color!,
color: Theme.of(context).accentTextTheme.bodyText1!.color!,
textColor: Colors.white,
isLoading: buyViewModel.isRunning,
isDisabled: (buyViewModel.selectedProvider == null) ||
@@ -18,7 +18,7 @@ class BuyListItem extends StatelessWidget {
this.onTap
});
final BuyProvider selectedProvider;
final BuyProvider? selectedProvider;
final BuyProvider provider;
final double sourceAmount;
final FiatCurrency sourceCurrency;
+44 -37
View File
@@ -1,4 +1,5 @@
import 'package:cake_wallet/entities/contact_base.dart';
import 'package:cake_wallet/entities/contact_record.dart';
import 'package:cake_wallet/utils/show_bar.dart';
import 'package:cake_wallet/utils/show_pop_up.dart';
import 'package:flutter/material.dart';
@@ -34,12 +35,12 @@ class ContactListPage extends BasePage {
height: 32.0,
decoration: BoxDecoration(
shape: BoxShape.circle,
color: Theme.of(context).accentTextTheme!.caption!.color!),
color: Theme.of(context).accentTextTheme.caption!.color!),
child: Stack(
alignment: Alignment.center,
children: <Widget>[
Icon(Icons.add,
color: Theme.of(context).primaryTextTheme!.headline6!.color!,
color: Theme.of(context).primaryTextTheme.headline6!.color!,
size: 22.0),
ButtonTheme(
minWidth: 32.0,
@@ -66,9 +67,9 @@ class ContactListPage extends BasePage {
return CollapsibleSectionList(
context: context,
sectionCount: 2,
themeColor: Theme.of(context).primaryTextTheme!.headline6!.color!,
themeColor: Theme.of(context).primaryTextTheme.headline6!.color!,
dividerThemeColor:
Theme.of(context).primaryTextTheme!.caption!.decorationColor!,
Theme.of(context).primaryTextTheme.caption!.decorationColor!,
sectionTitleBuilder: (_, int sectionIndex) {
var title = 'Contacts';
@@ -91,37 +92,13 @@ class ContactListPage extends BasePage {
final contact = contactListViewModel.contacts[index];
final content = generateRaw(context, contact);
// FIX-ME: Slidable
return content;
// return !isEditable
// ? content
// : Slidable(
// key: Key('${contact.key}'),
// actionPane: SlidableDrawerActionPane(),
// child: content,
// secondaryActions: <Widget>[
// IconSlideAction(
// caption: S.of(context).edit,
// color: Colors.blue,
// icon: Icons.edit,
// onTap: () async => await Navigator.of(context)
// .pushNamed(Routes.addressBookAddContact,
// arguments: contact),
// ),
// IconSlideAction(
// caption: S.of(context).delete,
// color: Colors.red,
// icon: CupertinoIcons.delete,
// onTap: () async {
// final isDelete =
// await showAlertDialog(context) ?? false;
// if (isDelete) {
// await contactListViewModel.delete(contact);
// }
// },
// ),
// ]);
return !isEditable
? content
: Slidable(
key: Key('${contact.key}'),
endActionPane: _actionPane(context, contact),
child: content,
);
},
);
},
@@ -141,7 +118,7 @@ class ContactListPage extends BasePage {
final isCopied = await showNameAndAddressDialog(
context, contact.name, contact.address);
if (isCopied != null && isCopied) {
if (isCopied) {
await Clipboard.setData(ClipboardData(text: contact.address));
await showBar<void>(context, S.of(context).copied_to_clipboard);
}
@@ -165,7 +142,7 @@ class ContactListPage extends BasePage {
style: TextStyle(
fontSize: 14,
fontWeight: FontWeight.normal,
color: Theme.of(context).primaryTextTheme!.headline6!.color!),
color: Theme.of(context).primaryTextTheme.headline6!.color!),
),
)
)
@@ -266,4 +243,34 @@ class ContactListPage extends BasePage {
actionLeftButton: () => Navigator.of(context).pop(false));
}) ?? false;
}
ActionPane _actionPane(BuildContext context, ContactRecord contact) => ActionPane(
motion: const ScrollMotion(),
extentRatio: 0.4,
children: [
SlidableAction(
onPressed: (_) async => await Navigator.of(context)
.pushNamed(Routes.addressBookAddContact,
arguments: contact),
backgroundColor: Colors.blue,
foregroundColor: Colors.white,
icon: Icons.edit,
label: S.of(context).edit,
),
SlidableAction(
onPressed: (_) async {
final isDelete =
await showAlertDialog(context);
if (isDelete) {
await contactListViewModel.delete(contact);
}
},
backgroundColor: Colors.red,
foregroundColor: Colors.white,
icon: CupertinoIcons.delete,
label: S.of(context).delete,
),
],
);
}
@@ -271,10 +271,10 @@ class DashboardPage extends BasePage {
switch (walletType) {
case WalletType.bitcoin:
Navigator.of(context).pushNamed(Routes.preOrder);
Navigator.of(context).pushNamed(Routes.onramperPage);
break;
case WalletType.litecoin:
Navigator.of(context).pushNamed(Routes.preOrder);
Navigator.of(context).pushNamed(Routes.onramperPage);
break;
default:
await showPopUp<void>(
+16 -2
View File
@@ -42,8 +42,7 @@ class WalletMenu {
Navigator.of(context).pushNamed(Routes.auth,
arguments: (bool isAuthenticatedSuccessfully, AuthPageState auth) {
if (isAuthenticatedSuccessfully) {
auth.close();
Navigator.of(auth.context).pushNamed(Routes.showKeys);
auth.close(route: Routes.showKeys);
}
});
}),
@@ -52,6 +51,21 @@ class WalletMenu {
image: Image.asset('assets/images/open_book_menu.png',
height: 16, width: 16),
handler: () => Navigator.of(context).pushNamed(Routes.addressBook)),
WalletMenuItem(
title: S.current.backup,
image: Image.asset('assets/images/restore_wallet.png',
height: 16,
width: 16,
color: Palette.darkBlue),
handler: () {
Navigator.of(context).pushNamed(
Routes.auth,
arguments: (bool isAuthenticatedSuccessfully, AuthPageState auth) {
if (isAuthenticatedSuccessfully) {
auth.close(route:Routes.backup);
}
});
}),
WalletMenuItem(
title: S.current.settings_title,
image: Image.asset('assets/images/settings_menu.png',
@@ -15,6 +15,7 @@ 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:share_plus/share_plus.dart';
class AddressPage extends BasePage {
AddressPage({
@@ -85,6 +86,26 @@ class AddressPage extends BasePage {
], begin: Alignment.topRight, end: Alignment.bottomLeft)),
child: scaffold);
@override
Widget? trailing(BuildContext context) {
final shareImage =
Image.asset('assets/images/share.png',
color: Theme.of(context).accentTextTheme!.headline2!.backgroundColor!);
return !addressListViewModel.hasAddressList ? Material(
color: Colors.transparent,
child: IconButton(
padding: EdgeInsets.zero,
constraints: BoxConstraints(),
highlightColor: Colors.transparent,
splashColor: Colors.transparent,
iconSize: 25,
onPressed: () => Share.share(addressListViewModel.address.address),
icon: shareImage,
),
) : null;
}
@override
Widget body(BuildContext context) {
autorun((_) async {
+29 -3
View File
@@ -111,6 +111,10 @@ class ExchangePage extends BasePage {
WidgetsBinding.instance
.addPostFrameCallback((_) => _setReactions(context, exchangeViewModel));
if (exchangeViewModel.isLowFee) {
_showFeeAlert(context);
}
return KeyboardActions(
disableScroll: true,
config: KeyboardActionsConfig(
@@ -179,6 +183,7 @@ class ExchangePage extends BasePage {
padding: EdgeInsets.fromLTRB(24, 100, 24, 32),
child: Observer(
builder: (_) => ExchangeCard(
onDispose: disposeBestRateSync,
hasAllAmount: exchangeViewModel.hasAllAmount,
allAmount: exchangeViewModel.hasAllAmount
? () => exchangeViewModel
@@ -265,6 +270,7 @@ class ExchangePage extends BasePage {
EdgeInsets.only(top: 29, left: 24, right: 24),
child: Observer(
builder: (_) => ExchangeCard(
onDispose: disposeBestRateSync,
amountFocusNode: _receiveAmountFocus,
addressFocusNode: _receiveAddressFocus,
key: receiveKey,
@@ -743,13 +749,13 @@ class ExchangePage extends BasePage {
if (_receiveAmountFocus.hasFocus) {
exchangeViewModel.isFixedRateMode = true;
}
exchangeViewModel.changeReceiveAmount(amount: receiveAmountController.text);
// exchangeViewModel.changeReceiveAmount(amount: receiveAmountController.text);
});
_depositAmountFocus.addListener(() {
exchangeViewModel.isFixedRateMode = false;
exchangeViewModel.changeDepositAmount(
amount: depositAmountController.text);
// exchangeViewModel.changeDepositAmount(
// amount: depositAmountController.text);
});
_isReactionsSet = true;
@@ -791,4 +797,24 @@ class ExchangePage extends BasePage {
final address = await extractAddressFromParsed(context, parsedAddress);
return address;
}
void _showFeeAlert(BuildContext context) async {
await Future<void>.delayed(Duration(seconds: 1));
final confirmed = await showPopUp<bool>(
context: context,
builder: (dialogContext) {
return AlertWithTwoActions(
alertTitle: S.of(context).low_fee,
alertContent: S.of(context).low_fee_alert,
leftButtonText: S.of(context).ignor,
rightButtonText: S.of(context).use_suggested,
actionLeftButton: () => Navigator.of(context).pop(false),
actionRightButton: () => Navigator.of(context).pop(true));
}) ?? false;
if (confirmed) {
exchangeViewModel.setDefaultTransactionPriority();
}
}
void disposeBestRateSync() => exchangeViewModel.bestRateSync?.cancel();
}
@@ -6,6 +6,7 @@ import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:cw_core/crypto_currency.dart';
import 'package:cake_wallet/src/widgets/alert_background.dart';
import 'package:cake_wallet/palette.dart';
import 'currency_picker_widget.dart';
class CurrencyPicker extends StatefulWidget {
@@ -104,7 +105,7 @@ class CurrencyPickerState extends State<CurrencyPicker> {
Padding(
padding: const EdgeInsets.all(16),
child: TextFormField(
style: TextStyle(color: Theme.of(context).primaryTextTheme!.headline6!.color!),
style: TextStyle(color: Palette.darkBlueCraiola),
decoration: InputDecoration(
hintText: widget.hintText,
prefixIcon: Image.asset("assets/images/search_icon.png"),
@@ -37,7 +37,8 @@ class ExchangeCard extends StatefulWidget {
this.addressFocusNode,
this.allAmount,
this.onPushPasteButton,
this.onPushAddressBookButton})
this.onPushAddressBookButton,
this.onDispose})
: super(key: key);
final List<CryptoCurrency> currencies;
@@ -63,6 +64,7 @@ class ExchangeCard extends StatefulWidget {
final VoidCallback? allAmount;
final void Function(BuildContext context)? onPushPasteButton;
final void Function(BuildContext context)? onPushAddressBookButton;
final Function()? onDispose;
@override
ExchangeCardState createState() => ExchangeCardState();
@@ -106,6 +108,13 @@ class ExchangeCardState extends State<ExchangeCard> {
super.initState();
}
@override
void dispose() {
widget.onDispose?.call();
super.dispose();
}
void changeLimits({String? min, String? max}) {
setState(() {
_min = min;
@@ -20,9 +20,12 @@ class PresentProviderPicker extends StatelessWidget {
return TextButton(
onPressed: () => _presentProviderPicker(context),
// FIX-ME: Style
//highlightColor: Colors.transparent,
//splashColor: Colors.transparent,
style: ButtonStyle(
padding: MaterialStateProperty.all(EdgeInsets.zero),
splashFactory: NoSplash.splashFactory,
foregroundColor: MaterialStateProperty.all(Colors.transparent),
overlayColor: MaterialStateProperty.all(Colors.transparent),
),
child: Row(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
@@ -46,7 +49,7 @@ class PresentProviderPicker extends StatelessWidget {
style: TextStyle(
fontSize: 10.0,
fontWeight: FontWeight.w500,
color: Theme.of(context).textTheme!.headline5!.color!)))
color: Theme.of(context).textTheme.headline5!.color!)))
],
),
SizedBox(width: 5),
@@ -1,15 +1,6 @@
import 'package:cake_wallet/core/execution_state.dart';
import 'package:cake_wallet/di.dart';
import 'package:cw_core/wallet_type.dart';
import 'package:cake_wallet/routes.dart';
import 'package:cake_wallet/store/settings_store.dart';
import 'package:cake_wallet/utils/show_bar.dart';
import 'package:cake_wallet/view_model/wallet_new_vm.dart';
// import 'package:flushbar/flushbar.dart';
import 'package:cw_core/wallet_type.dart';
import 'package:cake_wallet/themes/theme_base.dart';
import 'package:flutter/material.dart';
import 'package:flutter/cupertino.dart';
import 'package:cake_wallet/generated/i18n.dart';
import 'package:cake_wallet/src/screens/base_page.dart';
import 'package:cake_wallet/src/widgets/primary_button.dart';
@@ -67,8 +58,6 @@ class WalletTypeFormState extends State<WalletTypeForm> {
WalletType? selected;
List<WalletType> types;
// FIX-ME: Replace Flushbar
// Flushbar<void>? _progressBar;
@override
void initState() {
@@ -97,7 +86,7 @@ class WalletTypeFormState extends State<WalletTypeForm> {
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.w500,
color: Theme.of(context).primaryTextTheme!.headline6!.color!),
color: Theme.of(context).primaryTextTheme.headline6!.color!),
),
),
...types.map((type) => Padding(
@@ -114,7 +103,7 @@ class WalletTypeFormState extends State<WalletTypeForm> {
bottomSection: PrimaryButton(
onPressed: () => onTypeSelected(),
text: S.of(context).seed_language_next,
color: Theme.of(context).accentTextTheme!.bodyText1!.color!,
color: Theme.of(context).accentTextTheme.bodyText1!.color!,
textColor: Colors.white,
isDisabled: selected == null,
),
+44 -36
View File
@@ -1,4 +1,5 @@
import 'package:cake_wallet/utils/show_pop_up.dart';
import 'package:cw_core/node.dart';
import 'package:flutter/material.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter_mobx/flutter_mobx.dart';
@@ -26,7 +27,7 @@ class NodeListPage extends BasePage {
height: 32,
decoration: BoxDecoration(
borderRadius: BorderRadius.all(Radius.circular(16)),
color: Theme.of(context).accentTextTheme!.caption!.color!),
color: Theme.of(context).accentTextTheme.caption!.color!),
child: ButtonTheme(
minWidth: double.minPositive,
child: TextButton(
@@ -85,7 +86,7 @@ class NodeListPage extends BasePage {
final node = nodeListViewModel.nodes[index];
final isSelected =
node.keyIndex == nodeListViewModel.currentNode?.keyIndex;
node.keyIndex == nodeListViewModel.currentNode.keyIndex;
final nodeListRow = NodeListRow(
title: node.uriRaw,
isSelected: isSelected,
@@ -114,45 +115,52 @@ class NodeListPage extends BasePage {
});
});
});
// FIX-ME: Slidable
// final dismissibleRow = Slidable(
// key: Key('${node.keyIndex}'),
// actionPane: SlidableDrawerActionPane(),
// child: nodeListRow,
// secondaryActions: <Widget>[
// IconSlideAction(
// caption: S.of(context).delete,
// color: Colors.red,
// icon: CupertinoIcons.delete,
// onTap: () async {
// final confirmed = await showPopUp<bool>(
// context: context,
// builder: (BuildContext context) {
// return AlertWithTwoActions(
// alertTitle: S.of(context).remove_node,
// alertContent:
// S.of(context).remove_node_message,
// rightButtonText: S.of(context).remove,
// leftButtonText: S.of(context).cancel,
// actionRightButton: () =>
// Navigator.pop(context, true),
// actionLeftButton: () =>
// Navigator.pop(context, false));
// }) ??
// false;
// if (confirmed) {
// await nodeListViewModel.delete(node);
// }
// },
// ),
// ]);
final dismissibleRow = Slidable(
key: Key('${node.keyIndex}'),
startActionPane: _actionPane(context, node),
endActionPane: _actionPane(context, node),
child: nodeListRow,
);
return nodeListRow;
// return isSelected ? nodeListRow : dismissibleRow;
return isSelected ? nodeListRow : dismissibleRow;
});
},
),
);
}
ActionPane _actionPane(BuildContext context, Node node) => ActionPane(
motion: const ScrollMotion(),
extentRatio: 0.3,
children: [
SlidableAction(
onPressed: (context) async {
final confirmed = await showPopUp<bool>(
context: context,
builder: (BuildContext context) {
return AlertWithTwoActions(
alertTitle: S.of(context).remove_node,
alertContent:
S.of(context).remove_node_message,
rightButtonText: S.of(context).remove,
leftButtonText: S.of(context).cancel,
actionRightButton: () =>
Navigator.pop(context, true),
actionLeftButton: () =>
Navigator.pop(context, false));
}) ??
false;
if (confirmed) {
await nodeListViewModel.delete(node);
}
},
backgroundColor: Colors.red,
foregroundColor: Colors.white,
icon: CupertinoIcons.delete,
label: S.of(context).delete,
),
],
);
}
+7 -10
View File
@@ -1,7 +1,6 @@
import 'package:cake_wallet/utils/show_bar.dart';
// import 'package:flushbar/flushbar.dart';
import 'package:another_flushbar/flushbar.dart';
import 'package:flutter/material.dart';
import 'package:flutter/cupertino.dart';
import 'package:cake_wallet/generated/i18n.dart';
class PinCodeWidget extends StatefulWidget {
@@ -40,8 +39,7 @@ class PinCodeState<T extends PinCodeWidget> extends State<T> {
String pin;
String title;
double _aspectRatio;
// FIX-ME: Replace Flushbar
// Flushbar<void>? _progressBar;
Flushbar<void>? _progressBar;
int currentPinLength() => pin.length;
@@ -91,19 +89,18 @@ class PinCodeState<T extends PinCodeWidget> extends State<T> {
void changeProcessText(String text) {
hideProgressText();
// FIX-ME: Empty Duration,
// _progressBar = createBar<void>(text, duration: Duration())
// ..show(_key.currentContext);
_progressBar = createBar<void>(text, duration: null)
..show(_key.currentContext!);
}
void close() {
// _progressBar?.dismiss();
_progressBar?.dismiss();
Navigator.of(_key.currentContext!).pop();
}
void hideProgressText() {
// _progressBar?.dismiss();
// _progressBar = null;
_progressBar?.dismiss();
_progressBar = null;
}
@override
+12 -18
View File
@@ -6,7 +6,7 @@ import 'package:cw_core/wallet_type.dart';
import 'package:flutter/material.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter_mobx/flutter_mobx.dart';
// import 'package:esys_flutter_share/esys_flutter_share.dart';
import 'package:share_plus/share_plus.dart';
import 'package:cake_wallet/routes.dart';
import 'package:cake_wallet/generated/i18n.dart';
import 'package:cake_wallet/di.dart';
@@ -92,23 +92,17 @@ class ReceivePage extends BasePage {
Image.asset('assets/images/share.png',
color: Theme.of(context).accentTextTheme!.headline2!.backgroundColor!);
return SizedBox(
height: 20.0,
width: 20.0,
child: ButtonTheme(
minWidth: double.minPositive,
child: TextButton(
// FIX-ME: Style
//highlightColor: Colors.transparent,
//splashColor: Colors.transparent,
//padding: EdgeInsets.all(0),
onPressed: () {
// FIX-ME: Share esys_flutter_share.dart
// Share.text(S.current.share_address,
// addressListViewModel.address.address, 'text/plain')
},
child: shareImage),
),
return Material(
color: Colors.transparent,
child: IconButton(
padding: EdgeInsets.zero,
constraints: BoxConstraints(),
highlightColor: Colors.transparent,
splashColor: Colors.transparent,
iconSize: 25,
onPressed: () => Share.share(addressListViewModel.address.address),
icon: shareImage
)
);
}
@@ -57,6 +57,7 @@ class AddressCell extends StatelessWidget {
final Widget cell = InkWell(
onTap: () => onTap?.call(address),
child: Container(
width: double.infinity,
color: backgroundColor,
padding: EdgeInsets.only(left: 24, right: 24, top: 28, bottom: 28),
child: Text(
@@ -69,20 +70,25 @@ class AddressCell extends StatelessWidget {
),
),
));
// FIX-ME: Slidable
return cell;
// return Container(
// color: backgroundColor,
// child: Slidable(
// key: Key(address),
// actionPane: SlidableDrawerActionPane(),
// child: cell,
// secondaryActions: <Widget>[
// IconSlideAction(
// caption: S.of(context).edit,
// color: Colors.blue,
// icon: Icons.edit,
// onTap: () => onEdit?.call())
// ]));
return Slidable(
key: Key(address),
startActionPane: _actionPane(context),
endActionPane: _actionPane(context),
child: cell,
);
}
ActionPane _actionPane(BuildContext context) => ActionPane(
motion: const ScrollMotion(),
extentRatio: 0.3,
children: [
SlidableAction(
onPressed: (_) => onEdit?.call(),
backgroundColor: Colors.blue,
foregroundColor: Colors.white,
icon: Icons.edit,
label: S.of(context).edit,
),
],
);
}
+3 -8
View File
@@ -6,7 +6,7 @@ import 'package:cake_wallet/utils/show_pop_up.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
// import 'package:esys_flutter_share/esys_flutter_share.dart';
import 'package:share_plus/share_plus.dart';
import 'package:flutter_mobx/flutter_mobx.dart';
import 'package:cake_wallet/generated/i18n.dart';
import 'package:cake_wallet/src/widgets/primary_button.dart';
@@ -159,13 +159,8 @@ class WalletSeedPage extends BasePage {
child: Container(
padding: EdgeInsets.only(right: 8.0),
child: PrimaryButton(
onPressed: () {
// FIX-ME: Share esys_flutter_share
// Share.text(
// S.of(context).seed_share,
// walletSeedViewModel.seed,
// 'text/plain')
},
onPressed: () =>
Share.share(walletSeedViewModel.seed),
text: S.of(context).save,
color: Colors.green,
textColor: Colors.white),
@@ -20,7 +20,7 @@ class SettingsLinkProviderCell extends StandardListRow {
@override
Widget? buildLeading(BuildContext context) =>
icon != null ? Image.asset(icon!, color: iconColor, height: 30, width: 30) : null;
icon != null ? Image.asset(icon!, color: iconColor, height: 24, width: 24) : null;
@override
Widget buildTrailing(BuildContext context) => Text(linkTitle,
@@ -1,3 +1,4 @@
import 'package:auto_size_text/auto_size_text.dart';
import 'package:cake_wallet/utils/show_bar.dart';
import 'package:flutter/material.dart';
import 'package:flutter/cupertino.dart';
@@ -18,7 +19,36 @@ class WalletKeysPage extends BasePage {
@override
Widget body(BuildContext context) {
return Container(
return Column(
children: [
Expanded(
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 24.0),
child: Container(
width: double.infinity,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(12.0),
color: Theme.of(context).accentTextTheme!.caption!.color!,
),
child: Center(
child: Padding(
padding: const EdgeInsets.all(8.0),
child: AutoSizeText(
S.of(context).do_not_share_warning_text.toUpperCase(),
textAlign: TextAlign.center,
maxLines: 4,
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.w500,
color: Colors.red)),
),
),
),
),
),
Expanded(
flex: 7,
child: Container(
padding: EdgeInsets.only(top: 20.0, bottom: 20.0),
child: Observer(
builder: (_) {
@@ -48,6 +78,6 @@ class WalletKeysPage extends BasePage {
);
});
},
));
)))]);
}
}
@@ -3,7 +3,7 @@ import 'package:cake_wallet/src/widgets/alert_with_two_actions.dart';
import 'package:cake_wallet/utils/show_bar.dart';
import 'package:cake_wallet/utils/show_pop_up.dart';
import 'package:cake_wallet/view_model/wallet_list/wallet_list_item.dart';
// import 'package:flushbar/flushbar.dart';
import 'package:another_flushbar/flushbar.dart';
import 'package:flutter/material.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter_mobx/flutter_mobx.dart';
@@ -49,7 +49,7 @@ class WalletListBodyState extends State<WalletListBody> {
Image.asset('assets/images/haven_logo.png', height: 24, width: 24);
final scrollController = ScrollController();
final double tileHeight = 60;
// Flushbar<void>? _progressBar;
Flushbar<void>? _progressBar;
@override
Widget build(BuildContext context) {
@@ -156,22 +156,14 @@ class WalletListBodyState extends State<WalletListBody> {
),
));
// FIX-ME: Slidable for current
return row;
// return wallet.isCurrent
// ? row
// : Slidable(
// key: Key('${wallet.key}'),
// actionPane: SlidableDrawerActionPane(),
// child: row,
// secondaryActions: <Widget>[
// IconSlideAction(
// caption: S.of(context).delete,
// color: Colors.red,
// icon: CupertinoIcons.delete,
// onTap: () async => _removeWallet(wallet),
// )
// ]);
return wallet.isCurrent
? row
: Slidable(
key: Key('${wallet.key}'),
startActionPane: _actionPane(wallet),
endActionPane: _actionPane(wallet),
child: row,
);
}),
),
),
@@ -240,7 +232,9 @@ class WalletListBodyState extends State<WalletListBody> {
await widget.walletListViewModel.loadWallet(wallet);
auth.hideProgressText();
auth.close();
Navigator.of(context).pop();
WidgetsBinding.instance.addPostFrameCallback((_) {
Navigator.of(context).pop();
});
} catch (e) {
auth.changeProcessText(S
.of(context)
@@ -256,14 +250,34 @@ class WalletListBodyState extends State<WalletListBody> {
return;
}
try {
auth.changeProcessText(
S.of(context).wallet_list_removing_wallet(wallet.name));
await widget.walletListViewModel.remove(wallet);
} catch (e) {
auth.changeProcessText(S
.of(context)
.wallet_list_failed_to_remove(wallet.name, e.toString()));
bool confirmed = false;
await showPopUp<void>(
context: context,
builder: (BuildContext context) {
return AlertWithTwoActions(
alertTitle: S.of(context).delete_wallet,
alertContent: S.of(context).delete_wallet_confirm_message(wallet.name),
leftButtonText: S.of(context).cancel,
rightButtonText: S.of(context).delete,
actionLeftButton: () => Navigator.of(context).pop(),
actionRightButton: () {
confirmed = true;
Navigator.of(context).pop();
},
);
});
if (confirmed) {
try {
auth.changeProcessText(
S.of(context).wallet_list_removing_wallet(wallet.name));
await widget.walletListViewModel.remove(wallet);
} catch (e) {
auth.changeProcessText(S
.of(context)
.wallet_list_failed_to_remove(wallet.name, e.toString()));
}
}
auth.close();
@@ -271,12 +285,25 @@ class WalletListBodyState extends State<WalletListBody> {
}
void changeProcessText(String text) {
// FIX-ME: Duration
// _progressBar = createBar<void>(text, duration: Duration())..show(context);
_progressBar = createBar<void>(text, duration: null)..show(context);
}
void hideProgressText() {
// _progressBar?.dismiss();
// _progressBar = null;
_progressBar?.dismiss();
_progressBar = null;
}
ActionPane _actionPane(WalletListItem wallet) => ActionPane(
motion: const ScrollMotion(),
extentRatio: 0.3,
children: [
SlidableAction(
onPressed: (_) => _removeWallet(wallet),
backgroundColor: Colors.red,
foregroundColor: Colors.white,
icon: CupertinoIcons.delete,
label: S.of(context).delete,
),
],
);
}