Skip to content

Commit

Permalink
fix: #1698 - layout page analytics (#1802)
Browse files Browse the repository at this point in the history
* fix: #1698 - layout page analytics

* fix: #1698 - refactoring code review

* fix: #1698 - refactoring
  • Loading branch information
cli1005 authored May 12, 2022
1 parent 5e7e957 commit e135c19
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 176 deletions.
92 changes: 0 additions & 92 deletions packages/smooth_app/assets/onboarding/analytics.svg

This file was deleted.

128 changes: 44 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';
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,58 @@ class ConsentAnalytics extends StatelessWidget {
);
}

BottomAppBar _buildBottomAppBar(
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,
),
_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<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),
);
}
}

0 comments on commit e135c19

Please sign in to comment.