From fb1e5605d260fa47be30a00607fe53d14a26c943 Mon Sep 17 00:00:00 2001 From: cli1005 Date: Tue, 10 May 2022 12:15:55 +0200 Subject: [PATCH 1/3] fix: #1698 - layout page analytics --- .../onboarding/consent_analytics_page.dart | 127 ++++++------------ 1 file changed, 43 insertions(+), 84 deletions(-) diff --git a/packages/smooth_app/lib/pages/onboarding/consent_analytics_page.dart b/packages/smooth_app/lib/pages/onboarding/consent_analytics_page.dart index cc185ade37b..7f55d060aae 100644 --- a/packages/smooth_app/lib/pages/onboarding/consent_analytics_page.dart +++ b/packages/smooth_app/lib/pages/onboarding/consent_analytics_page.dart @@ -1,12 +1,10 @@ import 'package:flutter/material.dart'; import 'package:flutter_gen/gen_l10n/app_localizations.dart'; -import 'package:flutter_svg/flutter_svg.dart'; import 'package:provider/provider.dart'; import 'package:smooth_app/data_models/onboarding_loader.dart'; import 'package:smooth_app/data_models/user_preferences.dart'; import 'package:smooth_app/database/local_database.dart'; import 'package:smooth_app/generic_lib/design_constants.dart'; -import 'package:smooth_app/generic_lib/widgets/smooth_card.dart'; import 'package:smooth_app/pages/onboarding/onboarding_flow_navigator.dart'; class ConsentAnalytics extends StatelessWidget { @@ -16,35 +14,24 @@ class ConsentAnalytics extends StatelessWidget { Widget build(BuildContext context) { final Size size = MediaQuery.of(context).size; final AppLocalizations appLocalizations = AppLocalizations.of(context)!; - const String assetName = 'assets/onboarding/analytics.svg'; return Scaffold( body: Center( child: SingleChildScrollView( child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ - SizedBox( - height: size.height * 0.2, - width: size.width * 0.45, - child: SvgPicture.asset( - assetName, - semanticsLabel: - appLocalizations.analytics_consent_image_semantic_label, - fit: BoxFit.contain, - ), + Icon( + Icons.analytics, + size: size.width * 0.4, ), - - SizedBox(height: size.height * 0.01), - + SizedBox(height: size.height * 0.02), Center( child: Text( appLocalizations.consent_analytics_title, - style: Theme.of(context).textTheme.displayMedium, + style: Theme.of(context).textTheme.titleLarge, ), ), - SizedBox(height: size.height * 0.04), - ConstrainedBox( constraints: BoxConstraints( maxWidth: size.width * 0.8, @@ -52,12 +39,9 @@ class ConsentAnalytics extends StatelessWidget { child: Text( appLocalizations.consent_analytics_body1, textAlign: TextAlign.center, - style: Theme.of(context).textTheme.displaySmall, ), ), - SizedBox(height: size.height * 0.02), - ConstrainedBox( constraints: BoxConstraints( maxWidth: size.width * 0.8, @@ -65,35 +49,13 @@ class ConsentAnalytics extends StatelessWidget { child: Text( appLocalizations.consent_analytics_body2, textAlign: TextAlign.center, - style: Theme.of(context).textTheme.displaySmall, ), ), - - SizedBox(height: size.height * 0.02), - - // Authorize Button - _buildButton( - context, - Colors.green, - appLocalizations.authorize_button_label, - Icons.check, - true, - ), - - SizedBox(height: size.height * 0.01), - - // Reject button - _buildButton( - context, - Colors.red, - appLocalizations.refuse_button_label, - Icons.close, - false, - ), ], ), ), ), + bottomNavigationBar: _buildBottomAppBar(context, appLocalizations), ); } @@ -115,18 +77,48 @@ class ConsentAnalytics extends StatelessWidget { ); } + BottomAppBar _buildBottomAppBar( + BuildContext context, AppLocalizations appLocalizations) { + return BottomAppBar( + child: Row( + crossAxisAlignment: CrossAxisAlignment.center, + mainAxisAlignment: MainAxisAlignment.spaceBetween, + mainAxisSize: MainAxisSize.max, + children: [ + _buildButton( + context, + appLocalizations.refuse_button_label, + const Icon( + Icons.close_rounded, + ), + false), + _buildButton( + context, + appLocalizations.authorize_button_label, + const Icon( + Icons.check_rounded, + ), + true), + ], + ), + ); + } + Widget _buildButton( BuildContext context, - Color btnColor, String label, - IconData icon, + Icon icon, bool isAccepted, ) { - final Size size = MediaQuery.of(context).size; final LocalDatabase localDatabase = context.watch(); final UserPreferences userPreferences = context.watch(); - return InkWell( - onTap: () { + return TextButton.icon( + style: ButtonStyle( + padding: MaterialStateProperty.all( + const EdgeInsets.symmetric( + horizontal: VERY_LARGE_SPACE, vertical: SMALL_SPACE)), + ), + onPressed: () { _analyticsLogic( isAccepted, userPreferences, @@ -134,41 +126,8 @@ class ConsentAnalytics extends StatelessWidget { context, ); }, - child: Padding( - padding: EdgeInsets.fromLTRB( - size.width * 0.2, - 0, - size.width * 0.2, - 0, - ), - child: SmoothCard( - color: btnColor, - elevation: 5, - child: ConstrainedBox( - constraints: BoxConstraints( - minHeight: size.height * 0.04, - ), - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Text( - label, - style: TextStyle( - fontWeight: FontWeight.bold, - color: WHITE_COLOR, - fontSize: size.height * 0.025, - ), - ), - Icon( - icon, - color: WHITE_COLOR, - size: size.height * 0.05, - ), - ], - ), - ), - ), - ), + icon: icon, + label: Text(label), ); } } From 612864dd0aa624f2dd9322c0dc557d094325c4f1 Mon Sep 17 00:00:00 2001 From: cli1005 Date: Wed, 11 May 2022 11:12:39 +0200 Subject: [PATCH 2/3] fix: #1698 - refactoring code review --- .../assets/onboarding/analytics.svg | 92 ------------------- .../onboarding/consent_analytics_page.dart | 5 +- 2 files changed, 2 insertions(+), 95 deletions(-) delete mode 100644 packages/smooth_app/assets/onboarding/analytics.svg diff --git a/packages/smooth_app/assets/onboarding/analytics.svg b/packages/smooth_app/assets/onboarding/analytics.svg deleted file mode 100644 index 74fdc378216..00000000000 --- a/packages/smooth_app/assets/onboarding/analytics.svg +++ /dev/null @@ -1,92 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/packages/smooth_app/lib/pages/onboarding/consent_analytics_page.dart b/packages/smooth_app/lib/pages/onboarding/consent_analytics_page.dart index 7f55d060aae..f210c186968 100644 --- a/packages/smooth_app/lib/pages/onboarding/consent_analytics_page.dart +++ b/packages/smooth_app/lib/pages/onboarding/consent_analytics_page.dart @@ -80,9 +80,8 @@ class ConsentAnalytics extends StatelessWidget { BottomAppBar _buildBottomAppBar( BuildContext context, AppLocalizations appLocalizations) { return BottomAppBar( - child: Row( - crossAxisAlignment: CrossAxisAlignment.center, - mainAxisAlignment: MainAxisAlignment.spaceBetween, + child: ButtonBar( + alignment: MainAxisAlignment.spaceBetween, mainAxisSize: MainAxisSize.max, children: [ _buildButton( From 131ad95cf3b3c1de505aa40e4906933cdd7be9de Mon Sep 17 00:00:00 2001 From: cli1005 Date: Thu, 12 May 2022 09:52:33 +0200 Subject: [PATCH 3/3] fix: #1698 - refactoring --- .../onboarding/consent_analytics_page.dart | 26 ++++++++++--------- 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/packages/smooth_app/lib/pages/onboarding/consent_analytics_page.dart b/packages/smooth_app/lib/pages/onboarding/consent_analytics_page.dart index f210c186968..d421e1b5c97 100644 --- a/packages/smooth_app/lib/pages/onboarding/consent_analytics_page.dart +++ b/packages/smooth_app/lib/pages/onboarding/consent_analytics_page.dart @@ -85,19 +85,21 @@ class ConsentAnalytics extends StatelessWidget { mainAxisSize: MainAxisSize.max, children: [ _buildButton( - context, - appLocalizations.refuse_button_label, - const Icon( - Icons.close_rounded, - ), - false), + context, + appLocalizations.refuse_button_label, + const Icon( + Icons.close_rounded, + ), + false, + ), _buildButton( - context, - appLocalizations.authorize_button_label, - const Icon( - Icons.check_rounded, - ), - true), + context, + appLocalizations.authorize_button_label, + const Icon( + Icons.check_rounded, + ), + true, + ), ], ), );