mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2024-12-23 12:09:43 +00:00
Merge branch 'new-world' into CAKE-116-all-button-validation-bug
# Conflicts: # lib/src/screens/send/send_page.dart
This commit is contained in:
commit
8495122bcd
10 changed files with 207 additions and 183 deletions
10
lib/di.dart
10
lib/di.dart
|
@ -222,10 +222,10 @@ Future setup(
|
||||||
addressEditOrCreateViewModel:
|
addressEditOrCreateViewModel:
|
||||||
getIt.get<WalletAddressEditOrCreateViewModel>(param1: item)));
|
getIt.get<WalletAddressEditOrCreateViewModel>(param1: item)));
|
||||||
|
|
||||||
// getIt.get<SendTemplateStore>()
|
|
||||||
getIt.registerFactory<SendViewModel>(() => SendViewModel(
|
getIt.registerFactory<SendViewModel>(() => SendViewModel(
|
||||||
getIt.get<AppStore>().wallet,
|
getIt.get<AppStore>().wallet,
|
||||||
getIt.get<AppStore>().settingsStore,
|
getIt.get<AppStore>().settingsStore,
|
||||||
|
getIt.get<SendTemplateStore>(),
|
||||||
getIt.get<FiatConversionStore>()));
|
getIt.get<FiatConversionStore>()));
|
||||||
|
|
||||||
getIt.registerFactory(
|
getIt.registerFactory(
|
||||||
|
@ -318,10 +318,10 @@ Future setup(
|
||||||
() => NodeCreateOrEditPage(getIt.get<NodeCreateOrEditViewModel>()));
|
() => NodeCreateOrEditPage(getIt.get<NodeCreateOrEditViewModel>()));
|
||||||
|
|
||||||
getIt.registerFactory(() => ExchangeViewModel(
|
getIt.registerFactory(() => ExchangeViewModel(
|
||||||
wallet: getIt.get<AppStore>().wallet,
|
getIt.get<AppStore>().wallet,
|
||||||
exchangeTemplateStore: getIt.get<ExchangeTemplateStore>(),
|
tradesSource,
|
||||||
trades: tradesSource,
|
getIt.get<ExchangeTemplateStore>(),
|
||||||
tradesStore: getIt.get<TradesStore>()));
|
getIt.get<TradesStore>()));
|
||||||
|
|
||||||
getIt.registerFactory(() => ExchangeTradeViewModel(
|
getIt.registerFactory(() => ExchangeTradeViewModel(
|
||||||
wallet: getIt.get<AppStore>().wallet,
|
wallet: getIt.get<AppStore>().wallet,
|
||||||
|
|
|
@ -120,7 +120,7 @@ class App extends StatelessWidget {
|
||||||
settingsStore.isDarkTheme ? Brightness.light : Brightness.dark;
|
settingsStore.isDarkTheme ? Brightness.light : Brightness.dark;
|
||||||
final authenticationStore = getIt.get<AuthenticationStore>();
|
final authenticationStore = getIt.get<AuthenticationStore>();
|
||||||
final initialRoute = authenticationStore.state == AuthenticationState.denied
|
final initialRoute = authenticationStore.state == AuthenticationState.denied
|
||||||
? Routes.welcome
|
? Routes.disclaimer
|
||||||
: Routes.login;
|
: Routes.login;
|
||||||
|
|
||||||
SystemChrome.setSystemUIOverlayStyle(SystemUiOverlayStyle(
|
SystemChrome.setSystemUIOverlayStyle(SystemUiOverlayStyle(
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
import 'dart:ui';
|
import 'dart:ui';
|
||||||
import 'package:cake_wallet/palette.dart';
|
import 'package:cake_wallet/palette.dart';
|
||||||
|
import 'package:cake_wallet/routes.dart';
|
||||||
import 'package:cake_wallet/utils/show_pop_up.dart';
|
import 'package:cake_wallet/utils/show_pop_up.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
|
@ -19,26 +20,28 @@ class DisclaimerPage extends BasePage {
|
||||||
String get title => 'Terms of Use';
|
String get title => 'Terms of Use';
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget body(BuildContext context) => DisclaimerPageBody(isReadOnly: true);
|
Widget leading(BuildContext context) =>
|
||||||
|
isReadOnly ? super.leading(context) : null;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget body(BuildContext context) => DisclaimerPageBody(isReadOnly: isReadOnly);
|
||||||
}
|
}
|
||||||
|
|
||||||
class DisclaimerPageBody extends StatefulWidget {
|
class DisclaimerPageBody extends StatefulWidget {
|
||||||
DisclaimerPageBody({this.isReadOnly = true});
|
DisclaimerPageBody({this.isReadOnly});
|
||||||
|
|
||||||
final bool isReadOnly;
|
final bool isReadOnly;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
DisclaimerBodyState createState() => DisclaimerBodyState(false);
|
DisclaimerBodyState createState() => DisclaimerBodyState();
|
||||||
}
|
}
|
||||||
|
|
||||||
class DisclaimerBodyState extends State<DisclaimerPageBody> {
|
class DisclaimerBodyState extends State<DisclaimerPageBody> {
|
||||||
DisclaimerBodyState(this._isAccepted);
|
|
||||||
|
|
||||||
static const xmrtoUrl = 'https://xmr.to/terms-of-service';
|
static const xmrtoUrl = 'https://xmr.to/terms-of-service';
|
||||||
static const changenowUrl = 'https://changenow.io/terms-of-use';
|
static const changenowUrl = 'https://changenow.io/terms-of-use';
|
||||||
static const morphUrl = 'http://morphtoken.com/terms';
|
static const morphUrl = 'http://morphtoken.com/terms';
|
||||||
|
|
||||||
final bool _isAccepted;
|
|
||||||
bool _checked = false;
|
bool _checked = false;
|
||||||
String _fileText = '';
|
String _fileText = '';
|
||||||
|
|
||||||
|
@ -51,26 +54,10 @@ class DisclaimerBodyState extends State<DisclaimerPageBody> {
|
||||||
setState(() {});
|
setState(() {});
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> _showAlertDialog(BuildContext context) async {
|
|
||||||
await showPopUp<void>(
|
|
||||||
context: context,
|
|
||||||
builder: (BuildContext context) {
|
|
||||||
return AlertWithOneAction(
|
|
||||||
alertTitle: 'Terms and conditions',
|
|
||||||
alertContent: 'By using this app, you agree to the Terms of Agreement set forth to below',
|
|
||||||
buttonText: S.of(context).ok,
|
|
||||||
buttonAction: () => Navigator.of(context).pop()
|
|
||||||
);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
void _afterLayout(Duration _) => _showAlertDialog(context);
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
getFileLines();
|
getFileLines();
|
||||||
if (_isAccepted) WidgetsBinding.instance.addPostFrameCallback(_afterLayout);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
@ -87,8 +74,7 @@ class DisclaimerBodyState extends State<DisclaimerPageBody> {
|
||||||
padding: EdgeInsets.only(left: 24.0, right: 24.0),
|
padding: EdgeInsets.only(left: 24.0, right: 24.0),
|
||||||
child: Column(
|
child: Column(
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
!_isAccepted
|
Row(
|
||||||
? Row(
|
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
Expanded(
|
Expanded(
|
||||||
child: Text(
|
child: Text(
|
||||||
|
@ -102,13 +88,10 @@ class DisclaimerBodyState extends State<DisclaimerPageBody> {
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
],
|
],
|
||||||
)
|
),
|
||||||
: Offstage(),
|
SizedBox(
|
||||||
!_isAccepted
|
|
||||||
? SizedBox(
|
|
||||||
height: 20.0,
|
height: 20.0,
|
||||||
)
|
),
|
||||||
: Offstage(),
|
|
||||||
Row(
|
Row(
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
Expanded(
|
Expanded(
|
||||||
|
@ -254,8 +237,7 @@ class DisclaimerBodyState extends State<DisclaimerPageBody> {
|
||||||
],
|
],
|
||||||
)),
|
)),
|
||||||
if (!widget.isReadOnly) ...[
|
if (!widget.isReadOnly) ...[
|
||||||
!_isAccepted
|
Row(
|
||||||
? Row(
|
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
Expanded(
|
Expanded(
|
||||||
child: Container(
|
child: Container(
|
||||||
|
@ -303,25 +285,19 @@ class DisclaimerBodyState extends State<DisclaimerPageBody> {
|
||||||
)),
|
)),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
)
|
),
|
||||||
: Offstage(),
|
Container(
|
||||||
!_isAccepted
|
|
||||||
? Container(
|
|
||||||
padding:
|
padding:
|
||||||
EdgeInsets.only(left: 24.0, right: 24.0, bottom: 24.0),
|
EdgeInsets.only(left: 24.0, right: 24.0, bottom: 24.0),
|
||||||
child: PrimaryButton(
|
child: PrimaryButton(
|
||||||
onPressed: _checked ? () {} : null,
|
onPressed: _checked ? () =>
|
||||||
|
Navigator.of(context).popAndPushNamed(Routes.welcome)
|
||||||
|
: null,
|
||||||
text: 'Accept',
|
text: 'Accept',
|
||||||
color: Colors.green,
|
color: Colors.green,
|
||||||
textColor: Colors.white,
|
textColor: Colors.white,
|
||||||
),
|
),
|
||||||
)
|
),
|
||||||
: Offstage(),
|
|
||||||
_isAccepted
|
|
||||||
? SizedBox(
|
|
||||||
height: 24.0,
|
|
||||||
)
|
|
||||||
: Offstage()
|
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
|
|
@ -307,8 +307,7 @@ class ExchangePage extends BasePage {
|
||||||
),
|
),
|
||||||
Observer(builder: (_) {
|
Observer(builder: (_) {
|
||||||
final templates = exchangeViewModel.templates;
|
final templates = exchangeViewModel.templates;
|
||||||
final itemCount =
|
final itemCount = templates.length;
|
||||||
exchangeViewModel.templates.length;
|
|
||||||
|
|
||||||
return ListView.builder(
|
return ListView.builder(
|
||||||
scrollDirection: Axis.horizontal,
|
scrollDirection: Axis.horizontal,
|
||||||
|
@ -338,24 +337,22 @@ class ExchangePage extends BasePage {
|
||||||
alertContent: S
|
alertContent: S
|
||||||
.of(context)
|
.of(context)
|
||||||
.confirm_delete_template,
|
.confirm_delete_template,
|
||||||
leftButtonText:
|
|
||||||
S.of(context).delete,
|
|
||||||
rightButtonText:
|
rightButtonText:
|
||||||
|
S.of(context).delete,
|
||||||
|
leftButtonText:
|
||||||
S.of(context).cancel,
|
S.of(context).cancel,
|
||||||
actionLeftButton: () {
|
actionRightButton: () {
|
||||||
Navigator.of(
|
Navigator.of(
|
||||||
dialogContext)
|
dialogContext)
|
||||||
.pop();
|
.pop();
|
||||||
exchangeViewModel
|
exchangeViewModel
|
||||||
.exchangeTemplateStore
|
.removeTemplate(
|
||||||
.remove(
|
|
||||||
template:
|
template:
|
||||||
template);
|
template);
|
||||||
exchangeViewModel
|
exchangeViewModel
|
||||||
.exchangeTemplateStore
|
.updateTemplate();
|
||||||
.update();
|
|
||||||
},
|
},
|
||||||
actionRightButton: () =>
|
actionLeftButton: () =>
|
||||||
Navigator.of(
|
Navigator.of(
|
||||||
dialogContext)
|
dialogContext)
|
||||||
.pop());
|
.pop());
|
||||||
|
|
|
@ -134,6 +134,7 @@ class ExchangeTemplatePage extends BasePage {
|
||||||
initialIsAddressEditable: exchangeViewModel
|
initialIsAddressEditable: exchangeViewModel
|
||||||
.isDepositAddressEnabled,
|
.isDepositAddressEnabled,
|
||||||
isAmountEstimated: false,
|
isAmountEstimated: false,
|
||||||
|
hasRefundAddress: true,
|
||||||
currencies: CryptoCurrency.all,
|
currencies: CryptoCurrency.all,
|
||||||
onCurrencySelected: (currency) =>
|
onCurrencySelected: (currency) =>
|
||||||
exchangeViewModel.changeDepositCurrency(
|
exchangeViewModel.changeDepositCurrency(
|
||||||
|
@ -220,7 +221,7 @@ class ExchangeTemplatePage extends BasePage {
|
||||||
PrimaryButton(
|
PrimaryButton(
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
if (_formKey.currentState.validate()) {
|
if (_formKey.currentState.validate()) {
|
||||||
exchangeViewModel.exchangeTemplateStore.addTemplate(
|
exchangeViewModel.addTemplate(
|
||||||
amount: exchangeViewModel.depositAmount,
|
amount: exchangeViewModel.depositAmount,
|
||||||
depositCurrency:
|
depositCurrency:
|
||||||
exchangeViewModel.depositCurrency.toString(),
|
exchangeViewModel.depositCurrency.toString(),
|
||||||
|
@ -229,7 +230,7 @@ class ExchangeTemplatePage extends BasePage {
|
||||||
provider: exchangeViewModel.provider.toString(),
|
provider: exchangeViewModel.provider.toString(),
|
||||||
depositAddress: exchangeViewModel.depositAddress,
|
depositAddress: exchangeViewModel.depositAddress,
|
||||||
receiveAddress: exchangeViewModel.receiveAddress);
|
receiveAddress: exchangeViewModel.receiveAddress);
|
||||||
exchangeViewModel.exchangeTemplateStore.update();
|
exchangeViewModel.updateTemplate();
|
||||||
Navigator.of(context).pop();
|
Navigator.of(context).pop();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
import 'dart:ui';
|
import 'dart:ui';
|
||||||
import 'package:cake_wallet/entities/transaction_priority.dart';
|
import 'package:cake_wallet/entities/transaction_priority.dart';
|
||||||
|
import 'package:cake_wallet/src/widgets/alert_with_two_actions.dart';
|
||||||
import 'package:cake_wallet/src/widgets/keyboard_done_button.dart';
|
import 'package:cake_wallet/src/widgets/keyboard_done_button.dart';
|
||||||
import 'package:cake_wallet/src/widgets/picker.dart';
|
import 'package:cake_wallet/src/widgets/picker.dart';
|
||||||
|
import 'package:cake_wallet/src/widgets/template_tile.dart';
|
||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
|
@ -161,73 +163,70 @@ class SendPage extends BasePage {
|
||||||
.decorationColor),
|
.decorationColor),
|
||||||
validator: sendViewModel.addressValidator,
|
validator: sendViewModel.addressValidator,
|
||||||
),
|
),
|
||||||
Observer(
|
Padding(
|
||||||
builder: (_) => Padding(
|
padding: const EdgeInsets.only(top: 20),
|
||||||
padding: const EdgeInsets.only(top: 20),
|
child: BaseTextFormField(
|
||||||
child: BaseTextFormField(
|
focusNode: _cryptoAmountFocus,
|
||||||
focusNode: _cryptoAmountFocus,
|
controller: _cryptoAmountController,
|
||||||
controller: _cryptoAmountController,
|
keyboardType:
|
||||||
keyboardType:
|
|
||||||
TextInputType.numberWithOptions(
|
TextInputType.numberWithOptions(
|
||||||
signed: false, decimal: true),
|
signed: false, decimal: true),
|
||||||
prefixIcon: Padding(
|
prefixIcon: Padding(
|
||||||
padding: EdgeInsets.only(top: 9),
|
padding: EdgeInsets.only(top: 9),
|
||||||
child: Text(
|
child: Text(
|
||||||
sendViewModel.currency.title + ':',
|
sendViewModel.currency.title + ':',
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 16,
|
||||||
|
fontWeight: FontWeight.w600,
|
||||||
|
color: Colors.white,
|
||||||
|
)),
|
||||||
|
),
|
||||||
|
suffixIcon: Container(
|
||||||
|
height: 32,
|
||||||
|
width: 32,
|
||||||
|
margin: EdgeInsets.only(
|
||||||
|
left: 14, top: 4, bottom: 10),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: Theme.of(context)
|
||||||
|
.primaryTextTheme
|
||||||
|
.display1
|
||||||
|
.color,
|
||||||
|
borderRadius: BorderRadius.all(
|
||||||
|
Radius.circular(6))),
|
||||||
|
child: InkWell(
|
||||||
|
onTap: () =>
|
||||||
|
sendViewModel.setSendAll(),
|
||||||
|
child: Center(
|
||||||
|
child: Text(S.of(context).all,
|
||||||
|
textAlign: TextAlign.center,
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontSize: 16,
|
fontSize: 12,
|
||||||
fontWeight: FontWeight.w600,
|
fontWeight: FontWeight.bold,
|
||||||
color: Colors.white,
|
color: Theme.of(context)
|
||||||
)),
|
.primaryTextTheme
|
||||||
|
.display1
|
||||||
|
.decorationColor)),
|
||||||
),
|
),
|
||||||
suffixIcon: Container(
|
),
|
||||||
height: 32,
|
),
|
||||||
width: 32,
|
hintText: '0.0000',
|
||||||
margin: EdgeInsets.only(
|
borderColor: Theme.of(context)
|
||||||
left: 14, top: 4, bottom: 10),
|
.primaryTextTheme
|
||||||
decoration: BoxDecoration(
|
.headline
|
||||||
color: Theme.of(context)
|
.color,
|
||||||
.primaryTextTheme
|
textStyle: TextStyle(
|
||||||
.display1
|
fontSize: 14,
|
||||||
.color,
|
fontWeight: FontWeight.w500,
|
||||||
borderRadius: BorderRadius.all(
|
color: Colors.white),
|
||||||
Radius.circular(6))),
|
placeholderTextStyle: TextStyle(
|
||||||
child: InkWell(
|
color: Theme.of(context)
|
||||||
onTap: () =>
|
|
||||||
sendViewModel.setSendAll(),
|
|
||||||
child: Center(
|
|
||||||
child: Text(S.of(context).all,
|
|
||||||
textAlign: TextAlign.center,
|
|
||||||
style: TextStyle(
|
|
||||||
fontSize: 12,
|
|
||||||
fontWeight: FontWeight.bold,
|
|
||||||
color: Theme.of(context)
|
|
||||||
.primaryTextTheme
|
|
||||||
.display1
|
|
||||||
.decorationColor)),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
hintText: '0.0000',
|
|
||||||
borderColor: Theme.of(context)
|
|
||||||
.primaryTextTheme
|
.primaryTextTheme
|
||||||
.headline
|
.headline
|
||||||
.color,
|
.decorationColor,
|
||||||
textStyle: TextStyle(
|
fontWeight: FontWeight.w500,
|
||||||
fontSize: 14,
|
fontSize: 14),
|
||||||
fontWeight: FontWeight.w500,
|
validator:
|
||||||
color: Colors.white),
|
sendViewModel.amountValidator)),
|
||||||
placeholderTextStyle: TextStyle(
|
|
||||||
color: Theme.of(context)
|
|
||||||
.primaryTextTheme
|
|
||||||
.headline
|
|
||||||
.decorationColor,
|
|
||||||
fontWeight: FontWeight.w500,
|
|
||||||
fontSize: 14),
|
|
||||||
validator:
|
|
||||||
sendViewModel.sendAll
|
|
||||||
? sendViewModel.allAmountValidator
|
|
||||||
: sendViewModel.amountValidator))),
|
|
||||||
Observer(
|
Observer(
|
||||||
builder: (_) => Padding(
|
builder: (_) => Padding(
|
||||||
padding: EdgeInsets.only(top: 10),
|
padding: EdgeInsets.only(top: 10),
|
||||||
|
@ -419,53 +418,53 @@ class SendPage extends BasePage {
|
||||||
)),
|
)),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
// Observer(
|
Observer(
|
||||||
// builder: (_) {
|
builder: (_) {
|
||||||
// final templates = sendViewModel.templates;
|
final templates = sendViewModel.templates;
|
||||||
// final itemCount = templates.length;
|
final itemCount = templates.length;
|
||||||
|
|
||||||
// return ListView.builder(
|
return ListView.builder(
|
||||||
// scrollDirection: Axis.horizontal,
|
scrollDirection: Axis.horizontal,
|
||||||
// shrinkWrap: true,
|
shrinkWrap: true,
|
||||||
// physics: NeverScrollableScrollPhysics(),
|
physics: NeverScrollableScrollPhysics(),
|
||||||
// itemCount: itemCount,
|
itemCount: itemCount,
|
||||||
// itemBuilder: (context, index) {
|
itemBuilder: (context, index) {
|
||||||
// final template = templates[index];
|
final template = templates[index];
|
||||||
|
|
||||||
// return TemplateTile(
|
return TemplateTile(
|
||||||
// key: UniqueKey(),
|
key: UniqueKey(),
|
||||||
// to: template.name,
|
to: template.name,
|
||||||
// amount: template.amount,
|
amount: template.amount,
|
||||||
// from: template.cryptoCurrency,
|
from: template.cryptoCurrency,
|
||||||
// onTap: () {
|
onTap: () {
|
||||||
// _addressController.text = template.address;
|
_addressController.text = template.address;
|
||||||
// _cryptoAmountController.text = template.amount;
|
_cryptoAmountController.text = template.amount;
|
||||||
// getOpenaliasRecord(context);
|
getOpenaliasRecord(context);
|
||||||
// },
|
},
|
||||||
// onRemove: () {
|
onRemove: () {
|
||||||
// showPopUp<void>(
|
showPopUp<void>(
|
||||||
// context: context,
|
context: context,
|
||||||
// builder: (dialogContext) {
|
builder: (dialogContext) {
|
||||||
// return AlertWithTwoActions(
|
return AlertWithTwoActions(
|
||||||
// alertTitle: S.of(context).template,
|
alertTitle: S.of(context).template,
|
||||||
// alertContent: S.of(context).confirm_delete_template,
|
alertContent: S.of(context).confirm_delete_template,
|
||||||
// leftButtonText: S.of(context).delete,
|
rightButtonText: S.of(context).delete,
|
||||||
// rightButtonText: S.of(context).cancel,
|
leftButtonText: S.of(context).cancel,
|
||||||
// actionLeftButton: () {
|
actionRightButton: () {
|
||||||
// Navigator.of(dialogContext).pop();
|
Navigator.of(dialogContext).pop();
|
||||||
// sendViewModel.sendTemplateStore.remove(template: template);
|
sendViewModel.removeTemplate(template: template);
|
||||||
// sendViewModel.sendTemplateStore.update();
|
sendViewModel.updateTemplate();
|
||||||
// },
|
},
|
||||||
// actionRightButton: () => Navigator.of(dialogContext).pop()
|
actionLeftButton: () => Navigator.of(dialogContext).pop()
|
||||||
// );
|
);
|
||||||
// }
|
}
|
||||||
// );
|
);
|
||||||
// },
|
},
|
||||||
// );
|
);
|
||||||
// }
|
}
|
||||||
// );
|
);
|
||||||
// }
|
}
|
||||||
// )
|
)
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
@ -514,7 +513,6 @@ class SendPage extends BasePage {
|
||||||
final amount = _fiatAmountController.text;
|
final amount = _fiatAmountController.text;
|
||||||
|
|
||||||
if (amount != sendViewModel.fiatAmount) {
|
if (amount != sendViewModel.fiatAmount) {
|
||||||
sendViewModel.sendAll = false;
|
|
||||||
sendViewModel.setFiatAmount(amount);
|
sendViewModel.setFiatAmount(amount);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -134,7 +134,7 @@ class SendTemplatePage extends BasePage {
|
||||||
signed: false, decimal: true),
|
signed: false, decimal: true),
|
||||||
inputFormatters: [
|
inputFormatters: [
|
||||||
BlacklistingTextInputFormatter(
|
BlacklistingTextInputFormatter(
|
||||||
RegExp('[\\-|\\ |\\,]'))
|
RegExp('[\\-|\\ ]'))
|
||||||
],
|
],
|
||||||
prefixIcon: Padding(
|
prefixIcon: Padding(
|
||||||
padding: EdgeInsets.only(top: 9),
|
padding: EdgeInsets.only(top: 9),
|
||||||
|
@ -172,7 +172,7 @@ class SendTemplatePage extends BasePage {
|
||||||
signed: false, decimal: true),
|
signed: false, decimal: true),
|
||||||
inputFormatters: [
|
inputFormatters: [
|
||||||
BlacklistingTextInputFormatter(
|
BlacklistingTextInputFormatter(
|
||||||
RegExp('[\\-|\\ |\\,]'))
|
RegExp('[\\-|\\ ]'))
|
||||||
],
|
],
|
||||||
prefixIcon: Padding(
|
prefixIcon: Padding(
|
||||||
padding: EdgeInsets.only(top: 9),
|
padding: EdgeInsets.only(top: 9),
|
||||||
|
@ -210,12 +210,12 @@ class SendTemplatePage extends BasePage {
|
||||||
bottomSection: PrimaryButton(
|
bottomSection: PrimaryButton(
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
if (_formKey.currentState.validate()) {
|
if (_formKey.currentState.validate()) {
|
||||||
// sendViewModel.sendTemplateStore.addTemplate(
|
sendViewModel.addTemplate(
|
||||||
// name: _nameController.text,
|
name: _nameController.text,
|
||||||
// address: _addressController.text,
|
address: _addressController.text,
|
||||||
// cryptoCurrency: sendViewModel.currency.title,
|
cryptoCurrency: sendViewModel.currency.title,
|
||||||
// amount: _cryptoAmountController.text);
|
amount: _cryptoAmountController.text);
|
||||||
// sendViewModel.sendTemplateStore.update();
|
sendViewModel.updateTemplate();
|
||||||
Navigator.of(context).pop();
|
Navigator.of(context).pop();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -249,6 +249,22 @@ class SendTemplatePage extends BasePage {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
_cryptoAmountController.addListener(() {
|
||||||
|
final amount = _cryptoAmountController.text;
|
||||||
|
|
||||||
|
if (amount != sendViewModel.cryptoAmount) {
|
||||||
|
sendViewModel.setCryptoAmount(amount);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
_fiatAmountController.addListener(() {
|
||||||
|
final amount = _fiatAmountController.text;
|
||||||
|
|
||||||
|
if (amount != sendViewModel.fiatAmount) {
|
||||||
|
sendViewModel.setFiatAmount(amount);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
_addressController.addListener(() {
|
_addressController.addListener(() {
|
||||||
final address = _addressController.text;
|
final address = _addressController.text;
|
||||||
|
|
||||||
|
|
|
@ -27,10 +27,10 @@ class ExchangeViewModel = ExchangeViewModelBase with _$ExchangeViewModel;
|
||||||
|
|
||||||
abstract class ExchangeViewModelBase with Store {
|
abstract class ExchangeViewModelBase with Store {
|
||||||
ExchangeViewModelBase(
|
ExchangeViewModelBase(
|
||||||
{this.wallet,
|
this.wallet,
|
||||||
this.trades,
|
this.trades,
|
||||||
this.exchangeTemplateStore,
|
this._exchangeTemplateStore,
|
||||||
this.tradesStore}) {
|
this.tradesStore) {
|
||||||
providerList = [
|
providerList = [
|
||||||
XMRTOExchangeProvider(),
|
XMRTOExchangeProvider(),
|
||||||
ChangeNowExchangeProvider(),
|
ChangeNowExchangeProvider(),
|
||||||
|
@ -54,7 +54,7 @@ abstract class ExchangeViewModelBase with Store {
|
||||||
|
|
||||||
final WalletBase wallet;
|
final WalletBase wallet;
|
||||||
final Box<Trade> trades;
|
final Box<Trade> trades;
|
||||||
final ExchangeTemplateStore exchangeTemplateStore;
|
final ExchangeTemplateStore _exchangeTemplateStore;
|
||||||
final TradesStore tradesStore;
|
final TradesStore tradesStore;
|
||||||
|
|
||||||
@observable
|
@observable
|
||||||
|
@ -101,7 +101,7 @@ abstract class ExchangeViewModelBase with Store {
|
||||||
|
|
||||||
@computed
|
@computed
|
||||||
ObservableList<ExchangeTemplate> get templates =>
|
ObservableList<ExchangeTemplate> get templates =>
|
||||||
exchangeTemplateStore.templates;
|
_exchangeTemplateStore.templates;
|
||||||
|
|
||||||
@action
|
@action
|
||||||
void changeProvider({ExchangeProvider provider}) {
|
void changeProvider({ExchangeProvider provider}) {
|
||||||
|
@ -267,6 +267,22 @@ abstract class ExchangeViewModelBase with Store {
|
||||||
_onPairChange();
|
_onPairChange();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void updateTemplate() => _exchangeTemplateStore.update();
|
||||||
|
|
||||||
|
void addTemplate({String amount, String depositCurrency, String receiveCurrency,
|
||||||
|
String provider, String depositAddress, String receiveAddress}) =>
|
||||||
|
_exchangeTemplateStore.addTemplate(
|
||||||
|
amount: amount,
|
||||||
|
depositCurrency: depositCurrency,
|
||||||
|
receiveCurrency: receiveCurrency,
|
||||||
|
provider: provider,
|
||||||
|
depositAddress: depositAddress,
|
||||||
|
receiveAddress: receiveAddress
|
||||||
|
);
|
||||||
|
|
||||||
|
void removeTemplate({ExchangeTemplate template}) =>
|
||||||
|
_exchangeTemplateStore.remove(template: template);
|
||||||
|
|
||||||
List<ExchangeProvider> providersForCurrentPair() {
|
List<ExchangeProvider> providersForCurrentPair() {
|
||||||
return _providersForPair(from: depositCurrency, to: receiveCurrency);
|
return _providersForPair(from: depositCurrency, to: receiveCurrency);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
import 'package:cake_wallet/entities/openalias_record.dart';
|
import 'package:cake_wallet/entities/openalias_record.dart';
|
||||||
|
import 'package:cake_wallet/entities/template.dart';
|
||||||
|
import 'package:cake_wallet/store/templates/send_template_store.dart';
|
||||||
import 'package:intl/intl.dart';
|
import 'package:intl/intl.dart';
|
||||||
import 'package:mobx/mobx.dart';
|
import 'package:mobx/mobx.dart';
|
||||||
import 'package:cake_wallet/core/template_validator.dart';
|
import 'package:cake_wallet/core/template_validator.dart';
|
||||||
|
@ -29,7 +31,8 @@ class SendViewModel = SendViewModelBase with _$SendViewModel;
|
||||||
|
|
||||||
abstract class SendViewModelBase with Store {
|
abstract class SendViewModelBase with Store {
|
||||||
SendViewModelBase(
|
SendViewModelBase(
|
||||||
this._wallet, this._settingsStore, this._fiatConversationStore)
|
this._wallet, this._settingsStore, this._sendTemplateStore,
|
||||||
|
this._fiatConversationStore)
|
||||||
: state = InitialExecutionState(),
|
: state = InitialExecutionState(),
|
||||||
_cryptoNumberFormat = NumberFormat(),
|
_cryptoNumberFormat = NumberFormat(),
|
||||||
sendAll = false {
|
sendAll = false {
|
||||||
|
@ -90,8 +93,12 @@ abstract class SendViewModelBase with Store {
|
||||||
@computed
|
@computed
|
||||||
bool get isReadyForSend => _wallet.syncStatus is SyncedSyncStatus;
|
bool get isReadyForSend => _wallet.syncStatus is SyncedSyncStatus;
|
||||||
|
|
||||||
|
@computed
|
||||||
|
ObservableList<Template> get templates => _sendTemplateStore.templates;
|
||||||
|
|
||||||
final WalletBase _wallet;
|
final WalletBase _wallet;
|
||||||
final SettingsStore _settingsStore;
|
final SettingsStore _settingsStore;
|
||||||
|
final SendTemplateStore _sendTemplateStore;
|
||||||
final FiatConversionStore _fiatConversationStore;
|
final FiatConversionStore _fiatConversationStore;
|
||||||
final NumberFormat _cryptoNumberFormat;
|
final NumberFormat _cryptoNumberFormat;
|
||||||
|
|
||||||
|
@ -221,4 +228,17 @@ abstract class SendViewModelBase with Store {
|
||||||
|
|
||||||
_cryptoNumberFormat.maximumFractionDigits = maximumFractionDigits;
|
_cryptoNumberFormat.maximumFractionDigits = maximumFractionDigits;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void updateTemplate() => _sendTemplateStore.update();
|
||||||
|
|
||||||
|
void addTemplate({String name, String address, String cryptoCurrency,
|
||||||
|
String amount}) => _sendTemplateStore
|
||||||
|
.addTemplate(
|
||||||
|
name: name,
|
||||||
|
address: address,
|
||||||
|
cryptoCurrency: cryptoCurrency,
|
||||||
|
amount: amount);
|
||||||
|
|
||||||
|
void removeTemplate({Template template}) =>
|
||||||
|
_sendTemplateStore.remove(template: template);
|
||||||
}
|
}
|
||||||
|
|
|
@ -144,7 +144,7 @@ abstract class SettingsViewModelBase with Store {
|
||||||
RegularListItem(
|
RegularListItem(
|
||||||
title: S.current.settings_terms_and_conditions,
|
title: S.current.settings_terms_and_conditions,
|
||||||
handler: (BuildContext context) =>
|
handler: (BuildContext context) =>
|
||||||
Navigator.of(context).pushNamed(Routes.disclaimer),
|
Navigator.of(context).pushNamed(Routes.readDisclaimer),
|
||||||
),
|
),
|
||||||
RegularListItem(
|
RegularListItem(
|
||||||
title: S.current.faq,
|
title: S.current.faq,
|
||||||
|
|
Loading…
Reference in a new issue