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: #1698 - layout page analytics #1802

Merged
merged 3 commits into from
May 12, 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
92 changes: 0 additions & 92 deletions packages/smooth_app/assets/onboarding/analytics.svg

This file was deleted.

126 changes: 42 additions & 84 deletions packages/smooth_app/lib/pages/onboarding/consent_analytics_page.dart
Original file line number Diff line number Diff line change
@@ -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 {
Expand All @@ -16,84 +14,48 @@ 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';
g123k marked this conversation as resolved.
Show resolved Hide resolved
return Scaffold(
body: Center(
child: SingleChildScrollView(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
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,
),
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,
),
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),
);
}

Expand All @@ -115,60 +77,56 @@ class ConsentAnalytics extends StatelessWidget {
);
}

BottomAppBar _buildBottomAppBar(
cli1005 marked this conversation as resolved.
Show resolved Hide resolved
BuildContext context, AppLocalizations appLocalizations) {
return BottomAppBar(
child: ButtonBar(
alignment: MainAxisAlignment.spaceBetween,
mainAxisSize: MainAxisSize.max,
children: <Widget>[
_buildButton(
context,
appLocalizations.refuse_button_label,
const Icon(
Icons.close_rounded,
),
false),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just for syntax, could you add an extra comma please?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

_buildButton(
context,
appLocalizations.authorize_button_label,
const Icon(
Icons.check_rounded,
),
true),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just for syntax, could you add an extra comma please?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

],
),
);
}

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<LocalDatabase>();
final UserPreferences userPreferences = context.watch<UserPreferences>();
return InkWell(
onTap: () {
return TextButton.icon(
style: ButtonStyle(
padding: MaterialStateProperty.all<EdgeInsets>(
const EdgeInsets.symmetric(
horizontal: VERY_LARGE_SPACE, vertical: SMALL_SPACE)),
),
onPressed: () {
_analyticsLogic(
isAccepted,
userPreferences,
localDatabase,
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: <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,
),
],
),
),
),
),
icon: icon,
label: Text(label),
);
}
}