Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Non-aligned button texts and icons on "send anonymous analytics" page #1443

Merged
merged 3 commits into from
Apr 3, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/smooth_app/lib/l10n/app_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -618,7 +618,7 @@
"@authorize":{
"description":"Button to accept the request of sending the anonymous analytics"
},
"refuse_button_label":"Refuse",
"refuse_button_label":"Refuse ",
bhattabhi013 marked this conversation as resolved.
Show resolved Hide resolved
"@refuse":{
"description":"Button to decline the request of sending the anonymous analytics"
}
Expand Down
208 changes: 95 additions & 113 deletions packages/smooth_app/lib/pages/onboarding/consent_analytics_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,7 @@ class ConsentAnalytics extends StatelessWidget {
@override
Widget build(BuildContext context) {
final Size size = MediaQuery.of(context).size;
final LocalDatabase localDatabase = context.watch<LocalDatabase>();
final UserPreferences userPreferences = context.watch<UserPreferences>();
final AppLocalizations appLocalizations = AppLocalizations.of(context)!;
const Color shadowColor = Color.fromARGB(144, 0, 0, 0);
const String assetName = 'assets/onboarding/analytics.svg';
return Scaffold(
body: Column(
Expand All @@ -35,130 +32,45 @@ class ConsentAnalytics extends StatelessWidget {

SizedBox(height: size.height * 0.01),

Align(
alignment: Alignment.center,
child: Text(
appLocalizations.consent_analytics_title,
style: Theme.of(context).textTheme.displayMedium,
),
_buildTextHeader(
context,
appLocalizations.consent_analytics_title,
),

SizedBox(height: size.height * 0.034),
SizedBox(height: size.height * 0.04),

ConstrainedBox(
constraints: BoxConstraints(
maxWidth: size.width * 0.8,
),
child: Text(
appLocalizations.consent_analytics_body1,
textAlign: TextAlign.center,
style: Theme.of(context).textTheme.displaySmall,
),
_buildTextBody(
context,
appLocalizations.consent_analytics_body1,
),

SizedBox(height: size.height * 0.03),
SizedBox(height: size.height * 0.02),

ConstrainedBox(
constraints: BoxConstraints(
maxWidth: size.width * 0.8,
),
child: Text(
appLocalizations.consent_analytics_body2,
textAlign: TextAlign.center,
style: Theme.of(context).textTheme.displaySmall,
),
_buildTextBody(
context,
appLocalizations.consent_analytics_body2,
),

SizedBox(height: size.height * 0.02),

// Authorize Button
InkWell(
borderRadius: CIRCULAR_BORDER_RADIUS,
onTap: () {
_analyticsLogic(true, userPreferences, localDatabase, context);
},
child: Ink(
height: size.height * 0.06,
width: size.width * 0.7,
decoration: BoxDecoration(
color: LIGHT_GREEN_COLOR,
borderRadius: CIRCULAR_BORDER_RADIUS,
boxShadow: <BoxShadow>[
BoxShadow(
blurRadius: 3.0,
color: shadowColor,
offset: Offset(size.width * 0.004, size.height * 0.004),
)
],
),
child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Text(
appLocalizations.authorize_button_label,
style: TextStyle(
fontWeight: FontWeight.bold,
color: WHITE_COLOR,
fontSize: size.height * 0.025),
),
Padding(
padding: EdgeInsets.only(left: size.width * 0.02),
child: Icon(
Icons.check,
color: WHITE_COLOR,
size: size.height * 0.04,
),
)
],
),
),
_buildButton(
context,
Colors.green,
appLocalizations.authorize_button_label,
Icons.check,
true,
),

SizedBox(height: size.height * 0.02),
SizedBox(height: size.height * 0.01),

// Refuse Button
InkWell(
borderRadius: CIRCULAR_BORDER_RADIUS,
onTap: () {
_analyticsLogic(false, userPreferences, localDatabase, context);
},
child: Ink(
height: size.height * 0.06,
width: size.width * 0.7,
decoration: BoxDecoration(
color: RED_COLOR,
borderRadius: CIRCULAR_BORDER_RADIUS,
boxShadow: <BoxShadow>[
BoxShadow(
blurRadius: 3.0,
color: shadowColor,
offset: Offset(size.width * 0.004, size.height * 0.004),
),
],
),
child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Text(
appLocalizations.refuse_button_label,
style: TextStyle(
fontWeight: FontWeight.bold,
color: WHITE_COLOR,
fontSize: size.height * 0.025),
),
Padding(
padding: EdgeInsets.only(left: size.width * 0.02),
child: Icon(
Icons.close,
color: WHITE_COLOR,
size: size.height * 0.04,
),
)
],
),
),
// Reject button
_buildButton(
context,
Colors.red,
appLocalizations.refuse_button_label,
Icons.close,
false,
),
],
),
Expand All @@ -182,4 +94,74 @@ class ConsentAnalytics extends StatelessWidget {
OnboardingFlowNavigator.getNextPage(OnboardingPage.CONSENT_PAGE),
);
}

Widget _buildButton(
BuildContext context,
Color btnColor,
String label,
IconData icon,
bool isAccepted,
) {
final Size size = MediaQuery.of(context).size;
final LocalDatabase localDatabase = context.watch<LocalDatabase>();
final UserPreferences userPreferences = context.watch<UserPreferences>();
const Color shadowColor = Color.fromARGB(144, 0, 0, 0);
return ElevatedButton.icon(
style: ElevatedButton.styleFrom(
fixedSize: Size(
size.width * 0.9,
size.height * 0.05,
),
elevation: 2,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(30.0),
),
primary: btnColor,
shadowColor: shadowColor,
),
onPressed: () {
_analyticsLogic(
isAccepted,
userPreferences,
localDatabase,
context,
);
},
icon: Icon(
icon,
color: WHITE_COLOR,
size: size.height * 0.05,
),
label: Text(
label,
style: TextStyle(
fontWeight: FontWeight.bold,
color: WHITE_COLOR,
fontSize: size.height * 0.025,
),
),
);
}

Widget _buildTextHeader(BuildContext context, String title) {
return Center(
bhattabhi013 marked this conversation as resolved.
Show resolved Hide resolved
child: Text(
title,
style: Theme.of(context).textTheme.displayMedium,
),
);
}

Widget _buildTextBody(BuildContext context, String title) {
return ConstrainedBox(
constraints: BoxConstraints(
maxWidth: MediaQuery.of(context).size.width * 0.8,
),
child: Text(
title,
textAlign: TextAlign.center,
style: Theme.of(context).textTheme.displaySmall,
),
);
}
}