From e4fafbfbd12b6ac15598c91e953ee9c8cd2dc84c Mon Sep 17 00:00:00 2001 From: oleksandrK Date: Thu, 2 Mar 2023 22:37:49 +0100 Subject: [PATCH 1/2] Added lightning fees configs. --- lib/app/locator.dart | 2 + .../payment_options/payment_options_page.dart | 146 +++++++++----- .../remote_configs/remote_config_service.dart | 1 + lib/widgets/back_button.dart | 2 +- lib/widgets/styles/app_color_scheme.dart | 8 + lib/widgets/styles/lightning_fees_confs.dart | 182 ++++++++++++++++++ lib/widgets/text_form_field_app.dart | 14 +- 7 files changed, 301 insertions(+), 54 deletions(-) create mode 100644 lib/widgets/styles/lightning_fees_confs.dart diff --git a/lib/app/locator.dart b/lib/app/locator.dart index 04ad5083a..3c5bffee1 100644 --- a/lib/app/locator.dart +++ b/lib/app/locator.dart @@ -10,6 +10,7 @@ Future setupColorScheme( String currencyScreen, String backupSecurityScreen, String network, + String lightningFeesScreen, ) async { locator.allowReassignment = true; @@ -19,5 +20,6 @@ Future setupColorScheme( currencyScreen, backupSecurityScreen, network, + lightningFeesScreen, )); } diff --git a/lib/routes/payment_options/payment_options_page.dart b/lib/routes/payment_options/payment_options_page.dart index 25083b2ab..4c65bf96f 100644 --- a/lib/routes/payment_options/payment_options_page.dart +++ b/lib/routes/payment_options/payment_options_page.dart @@ -2,12 +2,18 @@ import 'package:clovrlabs_wallet/bloc/backup/backup_bloc.dart'; import 'package:clovrlabs_wallet/bloc/blocs_provider.dart'; import 'package:clovrlabs_wallet/bloc/payment_options/payment_options_actions.dart'; import 'package:clovrlabs_wallet/bloc/payment_options/payment_options_bloc.dart'; +import 'package:clovrlabs_wallet/utils/colors_ext.dart'; import 'package:clovrlabs_wallet/widgets/back_button.dart' as backBtn; +import 'package:clovrlabs_wallet/widgets/text_form_field_app.dart'; import 'package:clovrlabs_wallet/widgets/warning_box.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flutter_gen/gen_l10n/app_localizations.dart'; +import '../../app/locator.dart'; +import '../../widgets/styles/app_color_scheme.dart'; +import '../../widgets/styles/lightning_fees_confs.dart'; + class PaymentOptionsPage extends StatefulWidget { const PaymentOptionsPage({ Key key, @@ -69,44 +75,49 @@ class _PaymentOptionsPageState extends State { Widget build(BuildContext context) { final texts = AppLocalizations.of(context); final themeData = Theme.of(context); + final remoteConfigs = locator.get().lightningFeesConfs; return Scaffold( + backgroundColor: remoteConfigs.bgColor.toColor(), appBar: AppBar( iconTheme: themeData.appBarTheme.iconTheme, textTheme: themeData.appBarTheme.textTheme, - backgroundColor: themeData.canvasColor, + backgroundColor: remoteConfigs.bgColor.toColor(), automaticallyImplyLeading: false, - leading: backBtn.BackButton(), + leading: backBtn.BackButton( + color: remoteConfigs.backArrowColor.toColor(), + ), title: Text( texts.payment_options_title, - // style: themeData.appBarTheme.textTheme.headline6, + style: TextStyle( + color: remoteConfigs.txtColorTitle.toColor(), + ), ), elevation: 0.0, ), body: (_loadingOverride || _loadingBaseFee || _loadingProportionalFee) ? Container() - : _body(context), + : _body(context, remoteConfigs), ); } - Widget _body(BuildContext context) { + Widget _body(BuildContext context, LightningFeesConfs remoteConfigs) { return SingleChildScrollView( child: Column( children: [ - _headerFee(context), - _overrideFee(context), - _baseFeeWidget(context), - _proportionalFeeWidget(context), - _actionsFee(context), - _warningBox(context), + _headerFee(context, remoteConfigs), + _overrideFee(context, remoteConfigs), + _baseFeeWidget(context, remoteConfigs), + _proportionalFeeWidget(context, remoteConfigs), + _actionsFee(context, remoteConfigs), + _warningBox(context, remoteConfigs), ], ), ); } - Widget _headerFee(BuildContext context) { + Widget _headerFee(BuildContext context, LightningFeesConfs remoteConfigs) { final texts = AppLocalizations.of(context); - final themeData = Theme.of(context); return Row( children: [ @@ -115,8 +126,8 @@ class _PaymentOptionsPageState extends State { padding: const EdgeInsets.fromLTRB(16.0, 16.0, 16.0, 8.0), child: Text( texts.payment_options_fee_header, - style: themeData.primaryTextTheme.headline3.copyWith( - color: Colors.white, + style: TextStyle( + color: remoteConfigs.txtSubtitleFees.toColor(), ), ), ), @@ -125,26 +136,32 @@ class _PaymentOptionsPageState extends State { ); } - Widget _overrideFee(BuildContext context) { + Widget _overrideFee(BuildContext context, LightningFeesConfs remoteConfigs) { final texts = AppLocalizations.of(context); - final themeData = Theme.of(context); - return CheckboxListTile( - activeColor: Colors.white, - checkColor: themeData.canvasColor, - controlAffinity: ListTileControlAffinity.leading, - value: _overriding, - onChanged: (value) => setState(() => _overriding = value), - title: Text( - texts.payment_options_fee_override_enable, - style: themeData.primaryTextTheme.headline3.copyWith( - color: Colors.white, + return Theme( + data: ThemeData( + unselectedWidgetColor: remoteConfigs.txtEnforceFees.toColor(), + primaryColor: remoteConfigs.txtEnforceFees.toColor(), + ), + child: CheckboxListTile( + activeColor: remoteConfigs.checkBoxFees.toColor(), + checkColor: remoteConfigs.bgColor.toColor(), + controlAffinity: ListTileControlAffinity.leading, + value: _overriding, + onChanged: (value) => setState(() => _overriding = value), + title: Text( + texts.payment_options_fee_override_enable, + style: TextStyle( + color: remoteConfigs.txtEnforceFees.toColor(), + ), ), ), ); } - Widget _baseFeeWidget(BuildContext context) { + Widget _baseFeeWidget( + BuildContext context, LightningFeesConfs remoteConfigs) { final texts = AppLocalizations.of(context); return Row( @@ -153,17 +170,13 @@ class _PaymentOptionsPageState extends State { child: Padding( padding: const EdgeInsets.fromLTRB(16.0, 0.0, 16.0, 8.0), child: Form( - child: TextFormField( + child: TextFormFieldApp( enabled: _overriding, keyboardType: TextInputType.numberWithOptions(decimal: false), inputFormatters: [ FilteringTextInputFormatter.digitsOnly, ], - controller: _baseFeeController, - decoration: InputDecoration( - labelText: texts.payment_options_base_fee_label, - border: UnderlineInputBorder(), - ), + peerController: _baseFeeController, validator: (value) { if (value.isEmpty) { return texts.payment_options_base_fee_label; @@ -179,6 +192,16 @@ class _PaymentOptionsPageState extends State { return null; }, onChanged: (value) => _saveBase(context, value), + label: texts.payment_options_proportional_fee_label, + primaryColor: remoteConfigs.txtHintBaseFee.toColor(), + hintColor: remoteConfigs.txtHintBaseFee.toColor(), + indicatorColor: remoteConfigs.txtHintBaseFee.toColor(), + highlightColor: remoteConfigs.txtHintBaseFee.toColor(), + txtColor: remoteConfigs.txtBaseFee.toColor(), + errorColor: remoteConfigs.txtHintBaseFee.toColor(), + enabledBorder: remoteConfigs.txtHintBaseFee.toColor(), + disabledBorder: remoteConfigs.txtHintBaseFee.toColor(), + cursorColor: remoteConfigs.txtHintBaseFee.toColor(), ), ), ), @@ -187,7 +210,8 @@ class _PaymentOptionsPageState extends State { ); } - Widget _proportionalFeeWidget(BuildContext context) { + Widget _proportionalFeeWidget( + BuildContext context, LightningFeesConfs remoteConfigs) { final texts = AppLocalizations.of(context); return Row( @@ -196,17 +220,13 @@ class _PaymentOptionsPageState extends State { child: Padding( padding: const EdgeInsets.fromLTRB(16.0, 8.0, 16.0, 8.0), child: Form( - child: TextFormField( + child: TextFormFieldApp( enabled: _overriding, keyboardType: TextInputType.numberWithOptions(decimal: true), inputFormatters: [ FilteringTextInputFormatter.allow(RegExp(r'^\d+\.?\d{0,2}')), ], - controller: _proportionalFeeController, - decoration: InputDecoration( - labelText: texts.payment_options_proportional_fee_label, - border: UnderlineInputBorder(), - ), + peerController: _proportionalFeeController, validator: (value) { if (value.isEmpty) { return texts.payment_options_proportional_fee_label; @@ -222,6 +242,16 @@ class _PaymentOptionsPageState extends State { return null; }, onChanged: (value) => _saveProportional(context, value), + label: texts.payment_options_proportional_fee_label, + primaryColor: remoteConfigs.txtHintProportionalFee.toColor(), + hintColor: remoteConfigs.txtHintProportionalFee.toColor(), + indicatorColor: remoteConfigs.txtHintProportionalFee.toColor(), + highlightColor: remoteConfigs.txtHintProportionalFee.toColor(), + txtColor: remoteConfigs.txtProportionalFee.toColor(), + errorColor: remoteConfigs.txtHintProportionalFee.toColor(), + enabledBorder: remoteConfigs.txtHintProportionalFee.toColor(), + disabledBorder: remoteConfigs.txtHintProportionalFee.toColor(), + cursorColor: remoteConfigs.txtHintProportionalFee.toColor(), ), ), ), @@ -230,7 +260,7 @@ class _PaymentOptionsPageState extends State { ); } - Widget _actionsFee(BuildContext context) { + Widget _actionsFee(BuildContext context, LightningFeesConfs remoteConfigs) { final texts = AppLocalizations.of(context); return Padding( @@ -240,22 +270,32 @@ class _PaymentOptionsPageState extends State { children: [ OutlinedButton( style: OutlinedButton.styleFrom( - side: BorderSide(color: Colors.white), - primary: Colors.white, + side: BorderSide( + color: remoteConfigs.btOutlineResetColor.toColor(), + ), + backgroundColor: remoteConfigs.btBgResetColor.toColor(), ), child: Text( texts.payment_options_fee_action_reset, + style: TextStyle( + color: remoteConfigs.btTxtResetColor.toColor(), + ), ), onPressed: () => _reset(context), ), SizedBox(width: 12.0), OutlinedButton( style: OutlinedButton.styleFrom( - side: BorderSide(color: Colors.white), - primary: Colors.white, + side: BorderSide( + color: remoteConfigs.btOutlineResetColor.toColor(), + ), + backgroundColor: remoteConfigs.btBgResetColor.toColor(), ), child: Text( texts.payment_options_fee_action_save, + style: TextStyle( + color: remoteConfigs.btTxtResetColor.toColor(), + ), ), onPressed: () { if (_overriding) { @@ -308,15 +348,19 @@ class _PaymentOptionsPageState extends State { ); } - Widget _warningBox(BuildContext context) { + Widget _warningBox(BuildContext context, LightningFeesConfs remoteConfigs) { final texts = AppLocalizations.of(context); return WarningBox( + backgroundColor: remoteConfigs.colorBgBanner.toColor(), + borderColor: remoteConfigs.colorFrameBanner.toColor(), child: Column( mainAxisSize: MainAxisSize.min, children: [ Text( texts.payment_options_fee_warning, - style: Theme.of(context).textTheme.headline6, + style: TextStyle( + color: remoteConfigs.txtColorBanner.toColor(), + ), textAlign: TextAlign.center, ), ], @@ -324,8 +368,7 @@ class _PaymentOptionsPageState extends State { ); } - void _saveProportional(BuildContext context, - String value) { + void _saveProportional(BuildContext context, String value) { double newProportionalFee = 0.0; try { newProportionalFee = double.parse(value); @@ -337,8 +380,7 @@ class _PaymentOptionsPageState extends State { }); } - void _saveBase(BuildContext context, - String value) { + void _saveBase(BuildContext context, String value) { int newBaseFee = 0; try { newBaseFee = int.parse(value); diff --git a/lib/services/remote_configs/remote_config_service.dart b/lib/services/remote_configs/remote_config_service.dart index d5cbb325f..689034289 100644 --- a/lib/services/remote_configs/remote_config_service.dart +++ b/lib/services/remote_configs/remote_config_service.dart @@ -27,6 +27,7 @@ class RemoteConfigService { _remoteConfig.getString("fiat_currency_screen"), _remoteConfig.getString("backup_security_screen"), _remoteConfig.getString("network_screen"), + _remoteConfig.getString("lightning_fees_screen"), ); return _remoteConfig; } diff --git a/lib/widgets/back_button.dart b/lib/widgets/back_button.dart index a91c4ecdb..30613f69e 100644 --- a/lib/widgets/back_button.dart +++ b/lib/widgets/back_button.dart @@ -10,7 +10,7 @@ class BackButton extends StatelessWidget { @override Widget build(BuildContext context) { return IconButton( - icon: Icon(iconData ?? Icons.arrow_back, color: Colors.white), + icon: Icon(iconData ?? Icons.arrow_back, color: color ?? Colors.white), onPressed: this.onPressed ?? () { Navigator.pop(context); diff --git a/lib/widgets/styles/app_color_scheme.dart b/lib/widgets/styles/app_color_scheme.dart index 6fb8189fd..0b5326235 100644 --- a/lib/widgets/styles/app_color_scheme.dart +++ b/lib/widgets/styles/app_color_scheme.dart @@ -5,6 +5,7 @@ import 'package:clovrlabs_wallet/widgets/styles/security_backup_screen.dart'; import 'Network_remote_confs.dart'; import 'drawer_screen_remote_confs.dart'; import 'fiat_currency_remote_confs.dart'; +import 'lightning_fees_confs.dart'; import 'main_screen_colors.dart'; class AppConfigScheme { @@ -15,6 +16,7 @@ class AppConfigScheme { SecurityBackupScreen get securityBackupScreen => _securityBackupScreen; NetworkRemoteConfs _networkRemoteConfs; + LightningFeesConfs _lightningFeesConfs; MainScreenRemoteConfs get mainScreenRemoteConfigs => _mainScreenRemoteConfigs; @@ -25,12 +27,15 @@ class AppConfigScheme { NetworkRemoteConfs get networkRemoteConfs => _networkRemoteConfs; + LightningFeesConfs get lightningFeesConfs => _lightningFeesConfs; + AppConfigScheme( String mainScreenConfs, String drawerItemConfig, String fiatCurrencyRemoteConfs, String securityBackupScreen, String networkRemoteConfs, + String lightningFeesScreen, ) { _mainScreenRemoteConfigs = MainScreenRemoteConfs.fromJson( json.decode(mainScreenConfs), @@ -47,5 +52,8 @@ class AppConfigScheme { _securityBackupScreen = SecurityBackupScreen.fromJson( json.decode(securityBackupScreen), ); + _lightningFeesConfs = LightningFeesConfs.fromJson( + json.decode(lightningFeesScreen), + ); } } diff --git a/lib/widgets/styles/lightning_fees_confs.dart b/lib/widgets/styles/lightning_fees_confs.dart new file mode 100644 index 000000000..43b179e9a --- /dev/null +++ b/lib/widgets/styles/lightning_fees_confs.dart @@ -0,0 +1,182 @@ +class LightningFeesConfs { + String _txtColorTitle; + String _backArrowColor; + String _txtSubtitleFees; + String _checkBoxFees; + String _txtEnforceFees; + String _txtHintBaseFee; + String _txtBaseFee; + String _txtHintProportionalFee; + String _txtProportionalFee; + String _btBgResetColor; + String _btTxtResetColor; + String _btTxtSaveColor; + String _btOutlineSaveColor; + String _btOutlineResetColor; + String _colorBgBanner; + String _colorFrameBanner; + String _txtColorBanner; + String _bgColor; + + LightningFeesConfs({ + String txtColorTitle, + String backArrowColor, + String txtSubtitleFees, + String checkBoxFees, + String txtEnforceFees, + String txtHintBaseFee, + String txtBaseFee, + String txtHintProportionalFee, + String txtProportionalFee, + String btBgResetColor, + String btTxtResetColor, + String btTxtSaveColor, + String btOutlineSaveColor, + String btOutlineResetColor, + String colorBgBanner, + String colorFrameBanner, + String txtColorBanner, + String bgColor, + }) { + _txtColorTitle = txtColorTitle; + _backArrowColor = backArrowColor; + _txtSubtitleFees = txtSubtitleFees; + _checkBoxFees = checkBoxFees; + _txtEnforceFees = txtEnforceFees; + _txtHintBaseFee = txtHintBaseFee; + _txtBaseFee = txtBaseFee; + _txtHintProportionalFee = txtHintProportionalFee; + _txtProportionalFee = txtProportionalFee; + _btBgResetColor = btBgResetColor; + _btTxtResetColor = btTxtResetColor; + _btTxtSaveColor = btTxtSaveColor; + _btOutlineSaveColor = btOutlineSaveColor; + _btOutlineResetColor = btOutlineResetColor; + _colorBgBanner = colorBgBanner; + _colorFrameBanner = colorFrameBanner; + _txtColorBanner = txtColorBanner; + _bgColor = bgColor; + } + + LightningFeesConfs.fromJson(dynamic json) { + _txtColorTitle = json['txt_color_title']; + _backArrowColor = json['back_arrow_color']; + _txtSubtitleFees = json['txt_subtitle_fees']; + _checkBoxFees = json['check_box_fees']; + _txtEnforceFees = json['txt_enforce_fees']; + _txtHintBaseFee = json['txt_hint_base_fee']; + _txtBaseFee = json['txt_base_fee']; + _txtHintProportionalFee = json['txt_hint_proportional_fee']; + _txtProportionalFee = json['txt_proportional_fee']; + _btBgResetColor = json['bt_bg_reset_color']; + _btTxtResetColor = json['bt_txt_reset_color']; + _btTxtSaveColor = json['bt_txt_save_color']; + _btOutlineSaveColor = json['bt_outline_save_color']; + _btOutlineResetColor = json['bt_outline_reset_color']; + _colorBgBanner = json['color_bg_banner']; + _colorFrameBanner = json['color_frame_banner']; + _txtColorBanner = json['txt_color_banner']; + _bgColor = json['bg_color']; + } + + LightningFeesConfs copyWith({ + String txtColorTitle, + String backArrowColor, + String txtSubtitleFees, + String checkBoxFees, + String txtEnforceFees, + String txtHintBaseFee, + String txtBaseFee, + String txtHintProportionalFee, + String txtProportionalFee, + String btBgResetColor, + String btTxtResetColor, + String btTxtSaveColor, + String btOutlineSaveColor, + String btOutlineResetColor, + String colorBgBanner, + String colorFrameBanner, + String txtColorBanner, + String bgColor, + }) => + LightningFeesConfs( + txtColorTitle: txtColorTitle ?? _txtColorTitle, + backArrowColor: backArrowColor ?? _backArrowColor, + txtSubtitleFees: txtSubtitleFees ?? _txtSubtitleFees, + checkBoxFees: checkBoxFees ?? _checkBoxFees, + txtEnforceFees: txtEnforceFees ?? _txtEnforceFees, + txtHintBaseFee: txtHintBaseFee ?? _txtHintBaseFee, + txtBaseFee: txtBaseFee ?? _txtBaseFee, + txtHintProportionalFee: + txtHintProportionalFee ?? _txtHintProportionalFee, + txtProportionalFee: txtProportionalFee ?? _txtProportionalFee, + btBgResetColor: btBgResetColor ?? _btBgResetColor, + btTxtResetColor: btTxtResetColor ?? _btTxtResetColor, + btTxtSaveColor: btTxtSaveColor ?? _btTxtSaveColor, + btOutlineSaveColor: btOutlineSaveColor ?? _btOutlineSaveColor, + btOutlineResetColor: btOutlineResetColor ?? _btOutlineResetColor, + colorBgBanner: colorBgBanner ?? _colorBgBanner, + colorFrameBanner: colorFrameBanner ?? _colorFrameBanner, + txtColorBanner: txtColorBanner ?? _txtColorBanner, + bgColor: bgColor ?? _bgColor, + ); + + String get bgColor => _bgColor; + + String get txtColorTitle => _txtColorTitle; + + String get backArrowColor => _backArrowColor; + + String get txtSubtitleFees => _txtSubtitleFees; + + String get checkBoxFees => _checkBoxFees; + + String get txtEnforceFees => _txtEnforceFees; + + String get txtHintBaseFee => _txtHintBaseFee; + + String get txtBaseFee => _txtBaseFee; + + String get txtHintProportionalFee => _txtHintProportionalFee; + + String get txtProportionalFee => _txtProportionalFee; + + String get btBgResetColor => _btBgResetColor; + + String get btTxtResetColor => _btTxtResetColor; + + String get btTxtSaveColor => _btTxtSaveColor; + + String get btOutlineSaveColor => _btOutlineSaveColor; + + String get btOutlineResetColor => _btOutlineResetColor; + + String get colorBgBanner => _colorBgBanner; + + String get colorFrameBanner => _colorFrameBanner; + + String get txtColorBanner => _txtColorBanner; + + Map toJson() { + final map = {}; + map['txt_color_title'] = _txtColorTitle; + map['back_arrow_color'] = _backArrowColor; + map['txt_subtitle_fees'] = _txtSubtitleFees; + map['check_box_fees'] = _checkBoxFees; + map['txt_enforce_fees'] = _txtEnforceFees; + map['txt_hint_base_fee'] = _txtHintBaseFee; + map['txt_base_fee'] = _txtBaseFee; + map['txt_hint_proportional_fee'] = _txtHintProportionalFee; + map['txt_proportional_fee'] = _txtProportionalFee; + map['bt_bg_reset_color'] = _btBgResetColor; + map['bt_txt_reset_color'] = _btTxtResetColor; + map['bt_txt_save_color'] = _btTxtSaveColor; + map['bt_outline_save_color'] = _btOutlineSaveColor; + map['bt_outline_reset_color'] = _btOutlineResetColor; + map['color_bg_banner'] = _colorBgBanner; + map['color_frame_banner'] = _colorFrameBanner; + map['txt_color_banner'] = _txtColorBanner; + map['bg_color'] = _bgColor; + return map; + } +} diff --git a/lib/widgets/text_form_field_app.dart b/lib/widgets/text_form_field_app.dart index 982be9ee8..cfaefefe7 100644 --- a/lib/widgets/text_form_field_app.dart +++ b/lib/widgets/text_form_field_app.dart @@ -1,4 +1,5 @@ import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; import 'package:flutter_gen/gen_l10n/app_localizations.dart'; class TextFormFieldApp extends StatelessWidget { @@ -14,6 +15,10 @@ class TextFormFieldApp extends StatelessWidget { final Color enabledBorder; final Color disabledBorder; final Color txtColor; + final bool enabled; + final TextInputType keyboardType; + final List inputFormatters; + final ValueChanged onChanged; const TextFormFieldApp({ Key key, @@ -29,7 +34,10 @@ class TextFormFieldApp extends StatelessWidget { @required this.disabledBorder, @required this.cursorColor, @required this.txtColor, - + this.enabled, + this.keyboardType, + this.inputFormatters, + this.onChanged, }) : super(key: key); @override @@ -54,6 +62,9 @@ class TextFormFieldApp extends StatelessWidget { ), ), child: TextFormField( + keyboardType: keyboardType, + inputFormatters: inputFormatters, + enabled: enabled, cursorColor: cursorColor, decoration: InputDecoration( enabledBorder: UnderlineInputBorder( @@ -74,6 +85,7 @@ class TextFormFieldApp extends StatelessWidget { controller: peerController, autovalidateMode: AutovalidateMode.onUserInteraction, validator: validator, + onChanged: onChanged, ), ); } From 1035ba9c9c9c729fd75ddddb3c30d5485e92d32a Mon Sep 17 00:00:00 2001 From: oleksandrK Date: Fri, 24 Mar 2023 22:11:13 +0100 Subject: [PATCH 2/2] LightningFees/Developer screen --- lib/app/locator.dart | 2 + lib/routes/dev/default_commands.dart | 167 +++++++++++------- lib/routes/dev/dev.dart | 122 +++++++++---- .../fiat_currency_settings.dart | 1 - .../remote_configs/remote_config_service.dart | 1 + lib/widgets/styles/app_color_scheme.dart | 12 ++ .../styles/dev_screen_remote_confs.dart | 132 ++++++++++++++ lib/widgets/text_form_field_app.dart | 7 +- 8 files changed, 349 insertions(+), 95 deletions(-) create mode 100644 lib/widgets/styles/dev_screen_remote_confs.dart diff --git a/lib/app/locator.dart b/lib/app/locator.dart index 3c5bffee1..cc26ff493 100644 --- a/lib/app/locator.dart +++ b/lib/app/locator.dart @@ -11,6 +11,7 @@ Future setupColorScheme( String backupSecurityScreen, String network, String lightningFeesScreen, + String devScreen, ) async { locator.allowReassignment = true; @@ -21,5 +22,6 @@ Future setupColorScheme( backupSecurityScreen, network, lightningFeesScreen, + devScreen, )); } diff --git a/lib/routes/dev/default_commands.dart b/lib/routes/dev/default_commands.dart index 256417815..f1cf2dd22 100644 --- a/lib/routes/dev/default_commands.dart +++ b/lib/routes/dev/default_commands.dart @@ -1,10 +1,15 @@ +import 'package:clovrlabs_wallet/utils/colors_ext.dart'; import 'package:flutter/material.dart'; +import '../../app/locator.dart'; +import '../../widgets/styles/app_color_scheme.dart'; + class Command extends StatelessWidget { final String command; final Function(String command) onTap; + final remoteConfigs = locator.get().devScreenRemoteConfs; - const Command(this.command, this.onTap, {Key key}) : super(key: key); + Command(this.command, this.onTap, {Key key}) : super(key: key); @override Widget build(BuildContext context) { @@ -13,12 +18,14 @@ class Command extends StatelessWidget { this.onTap(command); }, child: Container( - alignment: Alignment.centerLeft, + alignment: Alignment.centerLeft, padding: EdgeInsets.symmetric(vertical: 8.0, horizontal: 24.0), child: Text( command, textAlign: TextAlign.left, - style: TextStyle(color: Colors.black), + style: TextStyle( + color: remoteConfigs.txtSubItemColor.toColor(), + ), ))); } } @@ -34,63 +41,99 @@ class Category extends StatelessWidget { } } -List defaultCliCommandsText(Function(String command) onCommand) => [ - ExpansionTile(title: Text("General"), children: [ - Command("getinfo", onCommand), - Command("debuglevel", onCommand), - Command("stop", onCommand), - ]), - ExpansionTile(title: Text("Channels"), children: [ - Command("openchannel", onCommand), - Command("closechannel", onCommand), - Command("closeallchannels", onCommand), - Command("abandonchannel", onCommand), - Command("channelbalance", onCommand), - Command("pendingchannels", onCommand), - Command("listchannels", onCommand), - Command("closedchannels", onCommand), - Command("getchaninfo", onCommand), - Command("getnetworkinfo", onCommand), - Command("feereport", onCommand), - Command("updatechanpolicy", onCommand), - ]), - ExpansionTile(title: Text("On-chain"), children: [ - Command("estimatefee", onCommand), - Command("sendmany", onCommand), - Command("listunspent", onCommand), - Command("listchaintxns", onCommand), - ]), - ExpansionTile(title: Text("Payments"), children: [ - Command("sendpayment", onCommand), - Command("payinvoice", onCommand), - Command("sendtoroute", onCommand), - Command("addinvoice", onCommand), - Command("lookupinvoice", onCommand), - Command("listinvoices", onCommand), - Command("queryroutes", onCommand), - Command("decodepayreq", onCommand), - Command("fwdinghistory", onCommand), - Command("querymc", onCommand), - Command("queryprob", onCommand), - Command("resetmc", onCommand), - Command("buildroute", onCommand), - Command("cancelinvoice", onCommand), - Command("addholdinvoice", onCommand), - Command("settleinvoice", onCommand), - ]), - ExpansionTile(title: Text("Peers"), children: [ - Command("connect", onCommand), - Command("disconnect", onCommand), - Command("listpeers", onCommand), - Command("describegraph", onCommand), - Command("getnodeinfo", onCommand), - ]), - ExpansionTile(title: Text("Wallet"), children: [ - Command("newaddress", onCommand), - Command("walletbalance", onCommand), - Command("signmessage", onCommand), - Command("verifymessage", onCommand), - Command("wallet pendingsweeps", onCommand), - Command("wallet bumpfee", onCommand) - ]), +List defaultCliCommandsText( + Function(String command) onCommand, Color color) => + [ + ExpansionTile( + iconColor: color, + title: Text( + "General", + style: (TextStyle(color: color)), + ), + children: [ + Command("getinfo", onCommand), + Command("debuglevel", onCommand), + Command("stop", onCommand), + ]), + ExpansionTile( + iconColor: color, + title: Text( + "Channels", + style: (TextStyle(color: color)), + ), + children: [ + Command("openchannel", onCommand), + Command("closechannel", onCommand), + Command("closeallchannels", onCommand), + Command("abandonchannel", onCommand), + Command("channelbalance", onCommand), + Command("pendingchannels", onCommand), + Command("listchannels", onCommand), + Command("closedchannels", onCommand), + Command("getchaninfo", onCommand), + Command("getnetworkinfo", onCommand), + Command("feereport", onCommand), + Command("updatechanpolicy", onCommand), + ]), + ExpansionTile( + iconColor: color, + title: Text( + "On-chain", + style: (TextStyle(color: color)), + ), + children: [ + Command("estimatefee", onCommand), + Command("sendmany", onCommand), + Command("listunspent", onCommand), + Command("listchaintxns", onCommand), + ]), + ExpansionTile( + iconColor: color, + title: Text( + "Payments", + style: (TextStyle(color: color)), + ), + children: [ + Command("sendpayment", onCommand), + Command("payinvoice", onCommand), + Command("sendtoroute", onCommand), + Command("addinvoice", onCommand), + Command("lookupinvoice", onCommand), + Command("listinvoices", onCommand), + Command("queryroutes", onCommand), + Command("decodepayreq", onCommand), + Command("fwdinghistory", onCommand), + Command("querymc", onCommand), + Command("queryprob", onCommand), + Command("resetmc", onCommand), + Command("buildroute", onCommand), + Command("cancelinvoice", onCommand), + Command("addholdinvoice", onCommand), + Command("settleinvoice", onCommand), + ]), + ExpansionTile( + title: Text( + "Peers", + style: (TextStyle(color: color)), + ), + children: [ + Command("connect", onCommand), + Command("disconnect", onCommand), + Command("listpeers", onCommand), + Command("describegraph", onCommand), + Command("getnodeinfo", onCommand), + ]), + ExpansionTile( + title: Text( + "Wallet", + style: (TextStyle(color: color)), + ), + children: [ + Command("newaddress", onCommand), + Command("walletbalance", onCommand), + Command("signmessage", onCommand), + Command("verifymessage", onCommand), + Command("wallet pendingsweeps", onCommand), + Command("wallet bumpfee", onCommand) + ]), ]; diff --git a/lib/routes/dev/dev.dart b/lib/routes/dev/dev.dart index 16a117500..edbd212ba 100644 --- a/lib/routes/dev/dev.dart +++ b/lib/routes/dev/dev.dart @@ -15,13 +15,18 @@ import 'package:clovrlabs_wallet/services/breezlib/breez_bridge.dart'; import 'package:clovrlabs_wallet/services/injector.dart'; import 'package:clovrlabs_wallet/services/permissions.dart'; import 'package:clovrlabs_wallet/theme_data.dart' as theme; +import 'package:clovrlabs_wallet/utils/colors_ext.dart'; import 'package:clovrlabs_wallet/widgets/back_button.dart' as backBtn; import 'package:clovrlabs_wallet/widgets/error_dialog.dart'; import 'package:clovrlabs_wallet/widgets/loader.dart'; +import 'package:clovrlabs_wallet/widgets/styles/dev_screen_remote_confs.dart'; import 'package:flutter/material.dart'; import 'package:flutter_downloader/flutter_downloader.dart'; import 'package:path_provider/path_provider.dart'; import 'package:share_extend/share_extend.dart'; +import '../../app/locator.dart'; +import '../../widgets/styles/app_color_scheme.dart'; +import '../../widgets/text_form_field_app.dart'; import 'default_commands.dart'; bool allowRebroadcastRefunds = false; @@ -98,21 +103,30 @@ class DevViewState extends State { }); } - Widget _renderBody() { + Widget _renderBody(DevScreenRemoteConfs remoteConfigs) { if (_showDefaultCommands) { return Theme( data: Theme.of(context).copyWith( dividerColor: Colors.transparent, ), - child: ListView(children: defaultCliCommandsText((command) { - _cliInputController.text = command + " "; - FocusScope.of(_scaffoldKey.currentState.context) - .requestFocus(_cliEntryFocusNode); - }))); + child: ListView( + children: defaultCliCommandsText( + (command) { + _cliInputController.text = command + " "; + FocusScope.of(_scaffoldKey.currentState.context) + .requestFocus(_cliEntryFocusNode); + }, + remoteConfigs.txtItemColor.toColor(), + ))); } return ListView( children: [ - RichText(text: TextSpan(style: _cliTextStyle, children: _richCliText)) + RichText( + text: TextSpan( + style: _cliTextStyle.copyWith( + color: remoteConfigs.txtItemColor.toColor(), + ), + children: _richCliText)) ], ); } @@ -123,6 +137,8 @@ class DevViewState extends State { BackupBloc backupBloc = AppBlocsProvider.of(context); AddFundsBloc addFundsBloc = BlocProvider.of(context); UserProfileBloc userBloc = AppBlocsProvider.of(context); + final remoteConfigs = locator.get().devScreenRemoteConfs; + return StreamBuilder( stream: backupBloc.backupStateStream, builder: (ctx, backupSnapshot) => StreamBuilder( @@ -144,17 +160,21 @@ class DevViewState extends State { iconTheme: Theme.of(context).appBarTheme.iconTheme, backgroundColor: - Theme.of(context).canvasColor, - leading: backBtn.BackButton(), + remoteConfigs.bgColor.toColor(), + leading: backBtn.BackButton( + color: + remoteConfigs.backArrowColor.toColor(), + ), elevation: 0.0, actions: [ PopupMenuButton( onSelected: widget._select, - color: Theme.of(context).backgroundColor, + color: remoteConfigs.colorContextMenu + .toColor(), icon: Icon( Icons.more_vert, - color: - Theme.of(context).iconTheme.color, + color: remoteConfigs.colorContextMenu + .toColor(), ), itemBuilder: (BuildContext context) { return getChoices( @@ -185,6 +205,8 @@ class DevViewState extends State { // ., ), ), + backgroundColor: + remoteConfigs.bgColor.toColor(), body: Column( crossAxisAlignment: CrossAxisAlignment.start, @@ -196,25 +218,58 @@ class DevViewState extends State { child: Row( children: [ Flexible( - child: TextField( + child: TextFormFieldApp( focusNode: _cliEntryFocusNode, - controller: _cliInputController, - decoration: InputDecoration( - hintText: - 'Enter a command or use the links below'), - onSubmitted: (command) { + peerController: + _cliInputController, + highlightColor: remoteConfigs + .editTxtHint + .toColor(), + hintColor: remoteConfigs + .editTxtHint + .toColor(), + label: + 'Enter a command or use the links below', + onChanged: (command) { _sendCommand(command); }, + indicatorColor: remoteConfigs + .editTxtHint + .toColor(), + primaryColor: remoteConfigs + .editTxtHint + .toColor(), + errorColor: remoteConfigs + .txtErrorColor + .toColor(), + enabledBorder: remoteConfigs + .editTxt + .toColor(), + disabledBorder: remoteConfigs + .editTxtHint + .toColor(), + cursorColor: remoteConfigs + .editTxtHint + .toColor(), + txtColor: remoteConfigs + .editTxtHint + .toColor(), )), IconButton( + color: remoteConfigs + .btExecuteColor + .toColor(), icon: Icon(Icons.play_arrow), tooltip: 'Run', onPressed: () { _sendCommand( - _cliInputController.text); + _cliInputController.text, + ); }, ), IconButton( + color: remoteConfigs.btCloseColor + .toColor(), icon: Icon(Icons.clear), tooltip: 'Clear', onPressed: () { @@ -241,12 +296,15 @@ class DevViewState extends State { ? EdgeInsets.all(0.0) : EdgeInsets.all(2.0), decoration: BoxDecoration( - border: _showDefaultCommands - ? null - : Border.all( - width: 1.0, - color: Color( - 0x80FFFFFF))), + border: _showDefaultCommands + ? null + : Border.all( + width: 1.0, + color: remoteConfigs + .bgColor + .toColor(), + ), + ), child: Column( mainAxisSize: MainAxisSize.max, crossAxisAlignment: @@ -280,8 +338,9 @@ class DevViewState extends State { .snackBarStyle, ), backgroundColor: - theme - .snackBarBackgroundColor, + remoteConfigs + .bgColor + .toColor(), duration: Duration( seconds: @@ -304,7 +363,9 @@ class DevViewState extends State { ) ], ), - Expanded(child: _renderBody()) + Expanded( + child: _renderBody( + remoteConfigs)) ], ), ), @@ -376,7 +437,8 @@ class DevViewState extends State { function: () { _resetBugReportBehavior(accBloc, settings); })); - }; + } + ; // choices.add(Choice( // title: // "${addFundsSettings.moonpayIpCheck ? "Disable" : "Enable"} MoonPay IP Check", @@ -610,7 +672,7 @@ class DevViewState extends State { }); } - void _downloadGraph() async{ + void _downloadGraph() async { await widget._breezBridge.syncGraphIfNeeded().whenComplete(() { log.info("download complete"); }); diff --git a/lib/routes/fiat_currencies/fiat_currency_settings.dart b/lib/routes/fiat_currencies/fiat_currency_settings.dart index c8dbf5295..4154a22de 100644 --- a/lib/routes/fiat_currencies/fiat_currency_settings.dart +++ b/lib/routes/fiat_currencies/fiat_currency_settings.dart @@ -9,7 +9,6 @@ import 'package:clovrlabs_wallet/theme_data.dart' as theme; import 'package:clovrlabs_wallet/utils/colors_ext.dart'; import 'package:clovrlabs_wallet/widgets/back_button.dart' as backBtn; import 'package:clovrlabs_wallet/widgets/flushbar.dart'; -import 'package:clovrlabs_wallet/widgets/loader.dart'; import 'package:clovrlabs_wallet/widgets/styles/fiat_currency_remote_confs.dart'; import 'package:drag_and_drop_lists/drag_and_drop_lists.dart'; import 'package:flutter/foundation.dart'; diff --git a/lib/services/remote_configs/remote_config_service.dart b/lib/services/remote_configs/remote_config_service.dart index 689034289..d28ea8bae 100644 --- a/lib/services/remote_configs/remote_config_service.dart +++ b/lib/services/remote_configs/remote_config_service.dart @@ -28,6 +28,7 @@ class RemoteConfigService { _remoteConfig.getString("backup_security_screen"), _remoteConfig.getString("network_screen"), _remoteConfig.getString("lightning_fees_screen"), + _remoteConfig.getString("developer_screen"), ); return _remoteConfig; } diff --git a/lib/widgets/styles/app_color_scheme.dart b/lib/widgets/styles/app_color_scheme.dart index 0b5326235..a7f035144 100644 --- a/lib/widgets/styles/app_color_scheme.dart +++ b/lib/widgets/styles/app_color_scheme.dart @@ -1,5 +1,6 @@ import 'dart:convert'; +import 'package:clovrlabs_wallet/widgets/styles/dev_screen_remote_confs.dart'; import 'package:clovrlabs_wallet/widgets/styles/security_backup_screen.dart'; import 'Network_remote_confs.dart'; @@ -13,6 +14,7 @@ class AppConfigScheme { DrawerRemoteConfs _drawerItemConfig; FiatCurrencyRemoteConfs _fiatCurrencyRemoteConfs; SecurityBackupScreen _securityBackupScreen; + DevScreenRemoteConfs _devScreenRemoteConfs; SecurityBackupScreen get securityBackupScreen => _securityBackupScreen; NetworkRemoteConfs _networkRemoteConfs; @@ -27,6 +29,12 @@ class AppConfigScheme { NetworkRemoteConfs get networkRemoteConfs => _networkRemoteConfs; + DevScreenRemoteConfs get devScreenRemoteConfs => _devScreenRemoteConfs; + + set devScreenRemoteConfs(DevScreenRemoteConfs value) { + _devScreenRemoteConfs = value; + } + LightningFeesConfs get lightningFeesConfs => _lightningFeesConfs; AppConfigScheme( @@ -36,6 +44,7 @@ class AppConfigScheme { String securityBackupScreen, String networkRemoteConfs, String lightningFeesScreen, + String devRemoteConfs, ) { _mainScreenRemoteConfigs = MainScreenRemoteConfs.fromJson( json.decode(mainScreenConfs), @@ -52,6 +61,9 @@ class AppConfigScheme { _securityBackupScreen = SecurityBackupScreen.fromJson( json.decode(securityBackupScreen), ); + _devScreenRemoteConfs = DevScreenRemoteConfs.fromJson( + json.decode(devRemoteConfs), + ); _lightningFeesConfs = LightningFeesConfs.fromJson( json.decode(lightningFeesScreen), ); diff --git a/lib/widgets/styles/dev_screen_remote_confs.dart b/lib/widgets/styles/dev_screen_remote_confs.dart new file mode 100644 index 000000000..2c274c35e --- /dev/null +++ b/lib/widgets/styles/dev_screen_remote_confs.dart @@ -0,0 +1,132 @@ +class DevScreenRemoteConfs { + String _txtColorTitle; + String _backArrowColor; + String _colorContextMenu; + String _bgColor; + String _editTxtHint; + String _editTxt; + String _btExecuteColor; + String _btCloseColor; + String _txtItemColor; + String _txtSubItemColor; + String _arrowDropDownColor; + String _txtErrorColor; + + DevScreenRemoteConfs({ + String txtColorTitle, + String backArrowColor, + String bgColor, + String colorContextMenu, + String editTxtHint, + String editTxt, + String btExecuteColor, + String btCloseColor, + String txtItemColor, + String txtSubItemColor, + String txtErrorColor, + String arrowDropDownColor, + }) { + _txtColorTitle = txtColorTitle; + _backArrowColor = backArrowColor; + _bgColor = bgColor; + _colorContextMenu = colorContextMenu; + _editTxtHint = editTxtHint; + _editTxt = editTxt; + _btExecuteColor = btExecuteColor; + _btCloseColor = btCloseColor; + _txtItemColor = txtItemColor; + _txtSubItemColor = txtSubItemColor; + _txtErrorColor = txtErrorColor; + _arrowDropDownColor = arrowDropDownColor; + } + + DevScreenRemoteConfs.fromJson(dynamic json) { + _txtColorTitle = json['txt_color_title']; + _backArrowColor = json['back_arrow_color']; + _colorContextMenu = json['color_context_menu']; + _bgColor = json['background']; + _editTxtHint = json['edit_txt_hint']; + _editTxt = json['edit_txt']; + _btExecuteColor = json['bt_execute_color']; + _btCloseColor = json['bt_close_color']; + _txtItemColor = json['txt_item_color']; + _txtSubItemColor = json['txt_sub_item_color']; + _txtErrorColor = json['edit_txt_error_color']; + _arrowDropDownColor = json['arrow_drop_down_color']; + } + + DevScreenRemoteConfs copyWith({ + String txtColorTitle, + String backArrowColor, + String bgColor, + String colorContextMenu, + String editTxtHint, + String editTxt, + String btExecuteColor, + String btCloseColor, + String txtItemColor, + String txtSubItemColor, + String arrowDropDownColor, + String errorEditTextColor, + String txtErrorColor, + }) => + DevScreenRemoteConfs( + txtColorTitle: txtColorTitle ?? _txtColorTitle, + backArrowColor: backArrowColor ?? _backArrowColor, + bgColor: bgColor ?? _bgColor, + colorContextMenu: colorContextMenu ?? _colorContextMenu, + editTxtHint: editTxtHint ?? _editTxtHint, + editTxt: editTxt ?? _editTxt, + btExecuteColor: btExecuteColor ?? _btExecuteColor, + btCloseColor: btCloseColor ?? _btCloseColor, + txtItemColor: txtItemColor ?? _txtItemColor, + txtSubItemColor: txtSubItemColor ?? _txtSubItemColor, + arrowDropDownColor: arrowDropDownColor ?? _arrowDropDownColor, + txtErrorColor: txtErrorColor ?? _txtErrorColor, + ); + + String get txtColorTitle => _txtColorTitle; + + String get backArrowColor => _backArrowColor; + + String get colorContextMenu => _colorContextMenu; + + String get editTxtHint => _editTxtHint; + + String get editTxt => _editTxt; + + String get btExecuteColor => _btExecuteColor; + + String get btCloseColor => _btCloseColor; + + String get txtItemColor => _txtItemColor; + + String get txtSubItemColor => _txtSubItemColor; + + String get arrowDropDownColor => _arrowDropDownColor; + + String get bgColor => _bgColor; + + Map toJson() { + final map = {}; + map['txt_color_title'] = _txtColorTitle; + map['back_arrow_color'] = _backArrowColor; + map['background'] = _bgColor; + map['color_context_menu'] = _colorContextMenu; + map['edit_txt_hint'] = _editTxtHint; + map['edit_txt'] = _editTxt; + map['bt_execute_color'] = _btExecuteColor; + map['bt_close_color'] = _btCloseColor; + map['txt_item_color'] = _txtItemColor; + map['txt_sub_item_color'] = _txtSubItemColor; + map['edit_txt_error_color'] = _txtErrorColor; + map['arrow_drop_down_color'] = _arrowDropDownColor; + return map; + } + + String get txtErrorColor => _txtErrorColor; + + set txtErrorColor(String value) { + _txtErrorColor = value; + } +} diff --git a/lib/widgets/text_form_field_app.dart b/lib/widgets/text_form_field_app.dart index cfaefefe7..17bbdeea6 100644 --- a/lib/widgets/text_form_field_app.dart +++ b/lib/widgets/text_form_field_app.dart @@ -19,10 +19,11 @@ class TextFormFieldApp extends StatelessWidget { final TextInputType keyboardType; final List inputFormatters; final ValueChanged onChanged; + final FocusNode focusNode; const TextFormFieldApp({ Key key, - @required this.validator, + this.validator, @required this.peerController, @required this.label, @required this.primaryColor, @@ -38,6 +39,7 @@ class TextFormFieldApp extends StatelessWidget { this.keyboardType, this.inputFormatters, this.onChanged, + this.focusNode, }) : super(key: key); @override @@ -51,7 +53,7 @@ class TextFormFieldApp extends StatelessWidget { highlightColor: highlightColor, inputDecorationTheme: InputDecorationTheme( labelStyle: TextStyle( - color: errorColor, + color: primaryColor, ), errorStyle: TextStyle( color: errorColor, @@ -66,6 +68,7 @@ class TextFormFieldApp extends StatelessWidget { inputFormatters: inputFormatters, enabled: enabled, cursorColor: cursorColor, + focusNode: focusNode, decoration: InputDecoration( enabledBorder: UnderlineInputBorder( borderSide: BorderSide(