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
Changes from all 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
166 changes: 75 additions & 91 deletions packages/smooth_app/lib/pages/onboarding/consent_analytics_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ 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 {
Expand All @@ -14,10 +15,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,15 +33,14 @@ class ConsentAnalytics extends StatelessWidget {

SizedBox(height: size.height * 0.01),

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

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

ConstrainedBox(
constraints: BoxConstraints(
Expand All @@ -56,7 +53,7 @@ class ConsentAnalytics extends StatelessWidget {
),
),

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

ConstrainedBox(
constraints: BoxConstraints(
Expand All @@ -72,93 +69,23 @@ class ConsentAnalytics extends StatelessWidget {
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 +109,61 @@ 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>();
return InkWell(
onTap: () {
_analyticsLogic(
isAccepted,
userPreferences,
localDatabase,
context,
);
},
child: Padding(
padding: EdgeInsets.fromLTRB(
bhattabhi013 marked this conversation as resolved.
Show resolved Hide resolved
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: <Widget>[
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,
),
],
),
),
),
),
);
}
}