From 882f13011c70247d1686d229dbba486c2a4d5767 Mon Sep 17 00:00:00 2001 From: M Date: Thu, 29 Oct 2020 20:10:09 +0200 Subject: [PATCH] Fixes. --- .../dashboard/widgets/filter_widget.dart | 2 +- .../screens/disclaimer/disclaimer_page.dart | 497 +++++++++--------- .../dashboard/dashboard_view_model.dart | 18 +- lib/view_model/dashboard/filter_item.dart | 2 +- 4 files changed, 261 insertions(+), 258 deletions(-) diff --git a/lib/src/screens/dashboard/widgets/filter_widget.dart b/lib/src/screens/dashboard/widgets/filter_widget.dart index d5197c355..c6f3bb412 100644 --- a/lib/src/screens/dashboard/widgets/filter_widget.dart +++ b/lib/src/screens/dashboard/widgets/filter_widget.dart @@ -97,7 +97,7 @@ class FilterWidget extends StatelessWidget { final item = section[index2]; final content = item.onChanged != null ? CheckboxWidget( - value: item.value, + value: item.value(), caption: item.caption, onChanged: item.onChanged ) diff --git a/lib/src/screens/disclaimer/disclaimer_page.dart b/lib/src/screens/disclaimer/disclaimer_page.dart index 2142b2bd4..dc2eaa708 100644 --- a/lib/src/screens/disclaimer/disclaimer_page.dart +++ b/lib/src/screens/disclaimer/disclaimer_page.dart @@ -62,266 +62,269 @@ class DisclaimerBodyState extends State { @override Widget build(BuildContext context) { - return Container( - color: Theme.of(context).backgroundColor, - child: Column( - children: [ - SizedBox(height: 10.0), - Expanded( - child: Stack( + return WillPopScope( + onWillPop: () async => false, + child: Container( + color: Theme.of(context).backgroundColor, + child: Column( children: [ - SingleChildScrollView( - padding: EdgeInsets.only(left: 24.0, right: 24.0), - child: Column( - children: [ - Row( + SizedBox(height: 10.0), + Expanded( + child: Stack( + children: [ + SingleChildScrollView( + padding: EdgeInsets.only(left: 24.0, right: 24.0), + child: Column( children: [ - Expanded( - child: Text( - 'Terms and conditions', - textAlign: TextAlign.center, - style: TextStyle( - fontSize: 20.0, - fontWeight: FontWeight.bold, - color: Theme.of(context) - .primaryTextTheme - .title - .color), - ), - ) - ], - ), - SizedBox( - height: 20.0, - ), - Row( - children: [ - Expanded( - child: Text( - 'Legal Disclaimer\nAnd\nTerms of Use', - textAlign: TextAlign.center, - style: TextStyle( - fontSize: 12.0, - fontWeight: FontWeight.bold, - color: Theme.of(context) - .primaryTextTheme - .title - .color), - ), - ) - ], - ), - SizedBox( - height: 16.0, - ), - Row( - children: [ - Expanded( - child: Text( - _fileText, - style: TextStyle( - fontSize: 12.0, - fontWeight: FontWeight.normal, - color: Theme.of(context) - .primaryTextTheme - .title - .color), - )) - ], - ), - SizedBox( - height: 16.0, - ), - Row( - mainAxisAlignment: MainAxisAlignment.start, - children: [ - Expanded( - child: Text( - 'Other Terms and Conditions', - textAlign: TextAlign.left, - style: TextStyle( - fontSize: 14.0, - fontWeight: FontWeight.bold, - color: Theme.of(context) - .primaryTextTheme - .title - .color), - ), - ) - ], - ), - SizedBox( - height: 16.0, - ), - Row( - mainAxisAlignment: MainAxisAlignment.start, - children: [ - Expanded( - child: GestureDetector( - onTap: () => launchUrl(xmrtoUrl), - child: Text( - xmrtoUrl, - textAlign: TextAlign.left, - style: TextStyle( - color: Palette.blueCraiola, - fontSize: 14.0, - fontWeight: FontWeight.normal, - decoration: TextDecoration.underline), - ), - )) - ], - ), - SizedBox( - height: 16.0, - ), - Row( - mainAxisAlignment: MainAxisAlignment.start, - children: [ - Expanded( - child: GestureDetector( - onTap: () => launchUrl(changenowUrl), - child: Text( - changenowUrl, - textAlign: TextAlign.left, - style: TextStyle( - color: Palette.blueCraiola, - fontSize: 14.0, - fontWeight: FontWeight.normal, - decoration: TextDecoration.underline), - ), - )) - ], - ), - SizedBox( - height: 16.0, - ), - Row( - mainAxisAlignment: MainAxisAlignment.start, - children: [ - Expanded( - child: GestureDetector( - onTap: () => launchUrl(morphUrl), - child: Text( - morphUrl, - textAlign: TextAlign.left, - style: TextStyle( - color: Palette.blueCraiola, - fontSize: 14.0, - fontWeight: FontWeight.normal, - decoration: TextDecoration.underline), - ), - )) - ], - ), - SizedBox( - height: 16.0, - ) - ], - ), - ), - Container( - alignment: Alignment.bottomCenter, - child: Container( - height: 12.0, - child: ClipRect( - child: BackdropFilter( - filter: ImageFilter.blur(sigmaX: 0.7, sigmaY: 0.7), - child: Container( - decoration: BoxDecoration( - gradient: LinearGradient( - colors: [ - Theme.of(context) - .backgroundColor - .withOpacity(0.0), - Theme.of(context).backgroundColor, - ], - begin: FractionalOffset.topCenter, - end: FractionalOffset.bottomCenter, - ), - ), - ), - ), - ), - ), - ) - ], - )), - if (!widget.isReadOnly) ...[ - Row( - children: [ - Expanded( - child: Container( - padding: EdgeInsets.only( - left: 24.0, top: 10.0, right: 24.0, bottom: 10.0), - child: InkWell( - onTap: () { - setState(() { - _checked = !_checked; - }); - }, - child: Row( - mainAxisAlignment: MainAxisAlignment.start, + Row( children: [ - Container( - height: 24.0, - width: 24.0, - margin: EdgeInsets.only( - right: 10.0, + Expanded( + child: Text( + 'Terms and conditions', + textAlign: TextAlign.center, + style: TextStyle( + fontSize: 20.0, + fontWeight: FontWeight.bold, + color: Theme.of(context) + .primaryTextTheme + .title + .color), ), - decoration: BoxDecoration( - border: Border.all( - color: Theme.of(context) - .primaryTextTheme - .caption - .color, - width: 1.0), - borderRadius: - BorderRadius.all(Radius.circular(8.0)), - color: Theme.of(context).backgroundColor), - child: _checked - ? Icon( - Icons.check, - color: Colors.blue, - size: 20.0, - ) - : null, - ), - Text( - 'I agree to Terms of Use', + ) + ], + ), + SizedBox( + height: 20.0, + ), + Row( + children: [ + Expanded( + child: Text( + 'Legal Disclaimer\nAnd\nTerms of Use', + textAlign: TextAlign.center, + style: TextStyle( + fontSize: 12.0, + fontWeight: FontWeight.bold, + color: Theme.of(context) + .primaryTextTheme + .title + .color), + ), + ) + ], + ), + SizedBox( + height: 16.0, + ), + Row( + children: [ + Expanded( + child: Text( + _fileText, style: TextStyle( - fontWeight: FontWeight.bold, - fontSize: 14.0, + fontSize: 12.0, + fontWeight: FontWeight.normal, color: Theme.of(context) .primaryTextTheme .title .color), + )) + ], + ), + SizedBox( + height: 16.0, + ), + Row( + mainAxisAlignment: MainAxisAlignment.start, + children: [ + Expanded( + child: Text( + 'Other Terms and Conditions', + textAlign: TextAlign.left, + style: TextStyle( + fontSize: 14.0, + fontWeight: FontWeight.bold, + color: Theme.of(context) + .primaryTextTheme + .title + .color), + ), ) ], ), - )), + SizedBox( + height: 16.0, + ), + Row( + mainAxisAlignment: MainAxisAlignment.start, + children: [ + Expanded( + child: GestureDetector( + onTap: () => launchUrl(xmrtoUrl), + child: Text( + xmrtoUrl, + textAlign: TextAlign.left, + style: TextStyle( + color: Palette.blueCraiola, + fontSize: 14.0, + fontWeight: FontWeight.normal, + decoration: TextDecoration.underline), + ), + )) + ], + ), + SizedBox( + height: 16.0, + ), + Row( + mainAxisAlignment: MainAxisAlignment.start, + children: [ + Expanded( + child: GestureDetector( + onTap: () => launchUrl(changenowUrl), + child: Text( + changenowUrl, + textAlign: TextAlign.left, + style: TextStyle( + color: Palette.blueCraiola, + fontSize: 14.0, + fontWeight: FontWeight.normal, + decoration: TextDecoration.underline), + ), + )) + ], + ), + SizedBox( + height: 16.0, + ), + Row( + mainAxisAlignment: MainAxisAlignment.start, + children: [ + Expanded( + child: GestureDetector( + onTap: () => launchUrl(morphUrl), + child: Text( + morphUrl, + textAlign: TextAlign.left, + style: TextStyle( + color: Palette.blueCraiola, + fontSize: 14.0, + fontWeight: FontWeight.normal, + decoration: TextDecoration.underline), + ), + )) + ], + ), + SizedBox( + height: 16.0, + ) + ], + ), + ), + Container( + alignment: Alignment.bottomCenter, + child: Container( + height: 12.0, + child: ClipRect( + child: BackdropFilter( + filter: ImageFilter.blur(sigmaX: 0.7, sigmaY: 0.7), + child: Container( + decoration: BoxDecoration( + gradient: LinearGradient( + colors: [ + Theme.of(context) + .backgroundColor + .withOpacity(0.0), + Theme.of(context).backgroundColor, + ], + begin: FractionalOffset.topCenter, + end: FractionalOffset.bottomCenter, + ), + ), + ), + ), + ), + ), + ) + ], + )), + if (!widget.isReadOnly) ...[ + Row( + children: [ + Expanded( + child: Container( + padding: EdgeInsets.only( + left: 24.0, top: 10.0, right: 24.0, bottom: 10.0), + child: InkWell( + onTap: () { + setState(() { + _checked = !_checked; + }); + }, + child: Row( + mainAxisAlignment: MainAxisAlignment.start, + children: [ + Container( + height: 24.0, + width: 24.0, + margin: EdgeInsets.only( + right: 10.0, + ), + decoration: BoxDecoration( + border: Border.all( + color: Theme.of(context) + .primaryTextTheme + .caption + .color, + width: 1.0), + borderRadius: BorderRadius.all( + Radius.circular(8.0)), + color: Theme.of(context).backgroundColor), + child: _checked + ? Icon( + Icons.check, + color: Colors.blue, + size: 20.0, + ) + : null, + ), + Text( + 'I agree to Terms of Use', + style: TextStyle( + fontWeight: FontWeight.bold, + fontSize: 14.0, + color: Theme.of(context) + .primaryTextTheme + .title + .color), + ) + ], + ), + )), + ), + ], + ), + Container( + padding: + EdgeInsets.only(left: 24.0, right: 24.0, bottom: 24.0), + child: PrimaryButton( + onPressed: _checked + ? () => Navigator.of(context) + .popAndPushNamed(Routes.welcome) + : null, + text: 'Accept', + color: Theme.of(context) + .accentTextTheme + .subtitle + .decorationColor, + textColor: Theme.of(context) + .accentTextTheme + .headline + .decorationColor), ), ], - ), - Container( - padding: EdgeInsets.only(left: 24.0, right: 24.0, bottom: 24.0), - child: PrimaryButton( - onPressed: _checked - ? () => - Navigator.of(context).popAndPushNamed(Routes.welcome) - : null, - text: 'Accept', - color: Theme.of(context) - .accentTextTheme - .subtitle - .decorationColor, - textColor: Theme.of(context) - .accentTextTheme - .headline - .decorationColor), - ), - ], - ], - ), - ); + ], + ), + )); } } diff --git a/lib/view_model/dashboard/dashboard_view_model.dart b/lib/view_model/dashboard/dashboard_view_model.dart index 1dacbd949..500c9fb92 100644 --- a/lib/view_model/dashboard/dashboard_view_model.dart +++ b/lib/view_model/dashboard/dashboard_view_model.dart @@ -39,31 +39,31 @@ abstract class DashboardViewModelBase with Store { filterItems = { S.current.transactions: [ FilterItem( - value: transactionFilterStore.displayIncoming, + value: () => transactionFilterStore.displayIncoming, caption: S.current.incoming, onChanged: (value) => transactionFilterStore.toggleIncoming()), FilterItem( - value: transactionFilterStore.displayOutgoing, + value: () => transactionFilterStore.displayOutgoing, caption: S.current.outgoing, onChanged: (value) => transactionFilterStore.toggleOutgoing()), - FilterItem( - value: false, - caption: S.current.transactions_by_date, - onChanged: null), + // FilterItem( + // value: () => false, + // caption: S.current.transactions_by_date, + // onChanged: null), ], S.current.trades: [ FilterItem( - value: tradeFilterStore.displayXMRTO, + value: () => tradeFilterStore.displayXMRTO, caption: 'XMR.TO', onChanged: (value) => tradeFilterStore .toggleDisplayExchange(ExchangeProviderDescription.xmrto)), FilterItem( - value: tradeFilterStore.displayChangeNow, + value: () => tradeFilterStore.displayChangeNow, caption: 'Change.NOW', onChanged: (value) => tradeFilterStore .toggleDisplayExchange(ExchangeProviderDescription.changeNow)), FilterItem( - value: tradeFilterStore.displayMorphToken, + value: () => tradeFilterStore.displayMorphToken, caption: 'MorphToken', onChanged: (value) => tradeFilterStore .toggleDisplayExchange(ExchangeProviderDescription.morphToken)), diff --git a/lib/view_model/dashboard/filter_item.dart b/lib/view_model/dashboard/filter_item.dart index 33500b345..28e1524bb 100644 --- a/lib/view_model/dashboard/filter_item.dart +++ b/lib/view_model/dashboard/filter_item.dart @@ -1,7 +1,7 @@ class FilterItem { FilterItem({this.value, this.caption, this.onChanged}); - bool value; + bool Function() value; String caption; Function(bool) onChanged; } \ No newline at end of file