Skip to content

Commit

Permalink
refactor: localizations and shadow styles (#10)
Browse files Browse the repository at this point in the history
  • Loading branch information
ice-hector authored Feb 9, 2024
1 parent 16b5b3b commit f95ac34
Show file tree
Hide file tree
Showing 32 changed files with 484 additions and 286 deletions.
14 changes: 0 additions & 14 deletions lib/app/constants/ui.dart

This file was deleted.

5 changes: 5 additions & 0 deletions lib/app/extensions/build_context.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
import 'package:flutter/material.dart';
import 'package:ice/generated/app_localizations.dart';

extension ThemeGetter on BuildContext {
/// Usage example: `context.theme`
ThemeData get theme => Theme.of(this);
}

extension I18nGetter on BuildContext {
I18n get i18n => I18n.of(this)!;
}
23 changes: 11 additions & 12 deletions lib/app/features/auth/views/pages/auth_page/auth_page.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import 'package:flutter/material.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';
import 'package:ice/app/constants/ui.dart';
import 'package:ice/app/extensions/build_context.dart';
import 'package:ice/app/extensions/theme_data.dart';
import 'package:ice/app/features/auth/data/models/auth_state.dart';
Expand All @@ -21,6 +20,7 @@ import 'package:ice/app/shared/widgets/auth_header/auth_header.dart';
import 'package:ice/app/shared/widgets/button/button.dart';
import 'package:ice/app/shared/widgets/inputs/text_fields.dart';
import 'package:ice/app/shared/widgets/modal_wrapper.dart';
import 'package:ice/app/shared/widgets/screen_side_offset/screen_side_offset.dart';
import 'package:ice/app/shared/widgets/secured_by/secured_by.dart';
import 'package:ice/app/shared/widgets/socials/socials.dart';
import 'package:ice/app/shared/widgets/terms_privacy/terms_privacy.dart';
Expand Down Expand Up @@ -53,22 +53,20 @@ class AuthPage extends HookConsumerWidget {
final PhoneNumberController numberController = PhoneNumberController();

return Scaffold(
body: Container(
margin: const EdgeInsets.symmetric(horizontal: kDefaultPadding),
body: ScreenSideOffset.large(
child: Column(
children: <Widget>[
AuthHeaderWidget(
title: 'Get started',
description: 'Choose your login method',
title: context.i18n.auth_signIn_title,
description: context.i18n.auth_signIn_description,
),
// EmailInput(formKey: emailFormKey),
if (isEmailMode)
InputField(
leadingIcon: Image.asset(
Assets.images.fieldEmail.path,
color: context.theme.appColors.primaryText,
),
label: 'Email address',
label: context.i18n.auth_signIn_input_email,
controller: emailController.controller,
validator: (String? value) => emailController.onVerify(),
showLeadingSeparator: true,
Expand All @@ -82,12 +80,11 @@ class AuthPage extends HookConsumerWidget {
context,
),
),
label: 'Phone number',
label: context.i18n.auth_signIn_input_phone_number,
controller: numberController.controller,
validator: (String? value) => numberController.onVerify(),
showLeadingSeparator: true,
),

const SizedBox(
height: 16,
),
Expand All @@ -111,14 +108,14 @@ class AuthPage extends HookConsumerWidget {
.read(authProvider.notifier)
.signIn(email: '[email protected]', password: '123'),
},
label: const Text('Continue'),
label: Text(context.i18n.button_continue),
mainAxisSize: MainAxisSize.max,
),
),
Padding(
padding: const EdgeInsets.only(top: 14, bottom: 14),
child: Text(
'or',
context.i18n.auth_signIn_or,
style: context.theme.appTextThemes.caption
.copyWith(color: context.theme.appColors.tertararyText),
),
Expand All @@ -135,7 +132,9 @@ class AuthPage extends HookConsumerWidget {
ref.read(isEmailModeProvider.notifier).state = !isEmailMode;
},
label: Text(
isEmailMode ? 'Continue with Email' : 'Continue with Phone',
isEmailMode
? context.i18n.auth_signIn_button_email
: context.i18n.auth_signIn_button_phone_number,
),
mainAxisSize: MainAxisSize.max,
),
Expand Down
11 changes: 5 additions & 6 deletions lib/app/features/auth/views/pages/check_email/check_email.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import 'dart:async';

import 'package:flutter/material.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';
import 'package:ice/app/constants/ui.dart';
import 'package:ice/app/extensions/build_context.dart';
import 'package:ice/app/extensions/theme_data.dart';
import 'package:ice/app/shared/widgets/screen_side_offset/screen_side_offset.dart';
import 'package:ice/app/shared/widgets/terms_privacy/terms_privacy.dart';
import 'package:ice/generated/assets.gen.dart';
import 'package:pin_code_fields/pin_code_fields.dart';
Expand All @@ -21,8 +21,7 @@ class CheckEmail extends HookConsumerWidget {
TextEditingController(text: '1234');

return Scaffold(
body: Container(
margin: const EdgeInsets.symmetric(horizontal: kDefaultPadding),
body: ScreenSideOffset.large(
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Expand All @@ -38,15 +37,15 @@ class CheckEmail extends HookConsumerWidget {
height: 12,
),
Text(
'Check email',
context.i18n.check_email_title,
style: context.theme.appTextThemes.headline1,
),
],
),
Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
const Text('We emailed a magic link to'),
Text(context.i18n.check_email_subtitle),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Expand All @@ -61,7 +60,7 @@ class CheckEmail extends HookConsumerWidget {
padding:
const EdgeInsets.symmetric(vertical: 36, horizontal: 20),
child: Text(
'Click the link and enter the code to log in or sign up.',
context.i18n.check_email_description,
textAlign: TextAlign.center,
style: context.theme.appTextThemes.subtitle2.copyWith(
color: context.theme.appColors.secondaryText,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,9 @@ class DiscoverCreators extends HookConsumerWidget {
),
child: Column(
children: <Widget>[
const TitleDescription(
title: 'Discover creators',
description:
'Connect with visionaries and inspiring voices',
TitleDescription(
title: context.i18n.discover_creators_title,
description: context.i18n.discover_creators_description,
),
Padding(
padding: const EdgeInsets.only(bottom: 12),
Expand Down Expand Up @@ -177,7 +176,9 @@ class DiscoverCreators extends HookConsumerWidget {
? null
: context.theme.appColors.primaryAccent,
label: Text(
isFollowing ? 'Following' : 'Follow',
isFollowing
? context.i18n.button_following
: context.i18n.button_follow,
style: context.theme.appTextThemes.caption
.copyWith(
color: isFollowing
Expand Down
Loading

0 comments on commit f95ac34

Please sign in to comment.