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

refactor: localizations and shadow styles #10

Merged
merged 5 commits into from
Feb 9, 2024
Merged
Show file tree
Hide file tree
Changes from 3 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
11 changes: 0 additions & 11 deletions lib/app/constants/ui.dart
Original file line number Diff line number Diff line change
@@ -1,14 +1,3 @@
import 'package:flutter/material.dart';

const double kDefaultPadding = 44.0;
const double kDefaultIconButtonSide = 44.0;
const double kDefaultNavHeaderTopPadding = 50.0;

ice-hector marked this conversation as resolved.
Show resolved Hide resolved
const TextStyle shadowStyle = TextStyle(
shadows: <Shadow>[
Shadow(
offset: Offset(0, 0.5),
color: Color.fromRGBO(0, 0, 0, 0.4),
),
],
);
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)!;
}
18 changes: 9 additions & 9 deletions lib/app/features/auth/views/pages/auth_page/auth_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -58,17 +58,16 @@ class AuthPage extends HookConsumerWidget {
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 +81,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 +109,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 +133,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
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,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 +61,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
10 changes: 5 additions & 5 deletions lib/app/features/auth/views/pages/enter_code/enter_code.dart
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,15 @@ class EnterCode extends HookConsumerWidget {
height: 9,
),
Text(
'Enter the code',
context.i18n.enter_code_title,
style: context.theme.appTextThemes.headline1,
),
],
),
Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
const Text('Please enter the code sent to'),
Text(context.i18n.enter_code_description),
Text(
phoneNumber,
style: context.theme.appTextThemes.subtitle,
Expand Down Expand Up @@ -117,7 +117,7 @@ class EnterCode extends HookConsumerWidget {
),
if (invalidCode.value)
Text(
'Invalid code, please try again!',
context.i18n.enter_code_invalid_code,
style: context.theme.appTextThemes.body
.copyWith(color: context.theme.appColors.attentionRed),
),
Expand All @@ -127,11 +127,11 @@ class EnterCode extends HookConsumerWidget {
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Text(
'New code available in',
context.i18n.enter_code_available_in,
style: context.theme.appTextThemes.subtitle2,
),
Text(
' 30s',
' 30s', // TODO: Add countdown timer
style: context.theme.appTextThemes.subtitle2
.copyWith(color: context.theme.appColors.primaryAccent),
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,11 @@ class FillProfile extends HookConsumerWidget {
height: 19,
),
Text(
'Your profile',
context.i18n.fill_profile_title,
style: context.theme.appTextThemes.headline1,
),
Text(
'Customize your account',
context.i18n.fill_profile_description,
style: context.theme.appTextThemes.body2.copyWith(
color: context.theme.appColors.tertararyText,
),
Expand Down Expand Up @@ -138,7 +138,7 @@ class FillProfile extends HookConsumerWidget {
// autofocus: true,
leadingIcon:
ImageIcon(AssetImage(Assets.images.fieldName.path)),
label: 'Name',
label: context.i18n.fill_profile_input_name,
controller: nameController.controller,
validator: (String? value) => validateName(value!),
showLeadingSeparator: true,
Expand All @@ -147,7 +147,7 @@ class FillProfile extends HookConsumerWidget {
InputField(
leadingIcon:
ImageIcon(AssetImage(Assets.images.fieldNickname.path)),
label: 'Nickname',
label: context.i18n.fill_profile_input_nickname,
controller: nicknameController.controller,
validator: (String? value) => validateNickname(value!),
showLeadingSeparator: true,
Expand All @@ -157,7 +157,7 @@ class FillProfile extends HookConsumerWidget {
InputField(
leadingIcon:
ImageIcon(AssetImage(Assets.images.fieldInviter.path)),
label: 'Who invited you',
label: context.i18n.fill_profile_input_who_invited,
controller: inviterController.controller,
validator: (String? value) => validateWhoInvited(value!),
showLeadingSeparator: true,
Expand All @@ -174,7 +174,7 @@ class FillProfile extends HookConsumerWidget {
size: 24,
),
onPressed: onSave,
label: const Text('Save'),
label: Text(context.i18n.button_save),
mainAxisSize: MainAxisSize.max,
),
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class IntroPage extends HookConsumerWidget {
bottom: 10,
),
child: Text(
'The Global Currency Reset',
context.i18n.intro_title,
style: TextStyle(
fontSize: 36,
fontWeight: FontWeight.w900,
Expand All @@ -59,7 +59,7 @@ class IntroPage extends HookConsumerWidget {
child: Align(
alignment: Alignment.centerLeft,
child: Text(
'#DecentralizedFuture',
context.i18n.intro_description,
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.w800,
Expand All @@ -80,7 +80,7 @@ class IntroPage extends HookConsumerWidget {
onPressed: () {
showMyBottomSheet(context);
},
child: const Text('Continue'),
child: Text(context.i18n.button_continue),
),
),
),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
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/features/auth/views/pages/nostr_login/nostr_login.dart';
import 'package:ice/app/shared/widgets/auth_header/auth_header.dart';
import 'package:ice/app/shared/widgets/button/button.dart';
Expand Down Expand Up @@ -33,8 +34,8 @@ class NostrAuth extends HookConsumerWidget {
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
AuthHeaderWidget(
title: 'Nostr',
description: 'Create an account or login using your existing one',
title: context.i18n.nostr_auth_title,
description: context.i18n.nostr_auth_description,
),
Image.asset(
Assets.images.ostrichlogo.path,
Expand All @@ -56,7 +57,7 @@ class NostrAuth extends HookConsumerWidget {
// );
},
type: ButtonType.outlined,
label: const Text('Create account'),
label: Text(context.i18n.button_create_account),
mainAxisSize: MainAxisSize.max,
),
),
Expand All @@ -75,7 +76,7 @@ class NostrAuth extends HookConsumerWidget {
context,
);
},
label: const Text('Login'),
label: Text(context.i18n.button_login),
mainAxisSize: MainAxisSize.max,
),
),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
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/features/auth/views/pages/nostr_login/controllers/name_controller.dart';
import 'package:ice/app/shared/widgets/auth_header/auth_header.dart';
import 'package:ice/app/shared/widgets/button/button.dart';
Expand All @@ -20,8 +21,8 @@ class NostrLogin extends HookConsumerWidget {
child: Column(
children: <Widget>[
AuthHeaderWidget(
title: 'Nostr',
description: 'Enter your Nostr private key',
title: context.i18n.nostr_login_title,
description: context.i18n.nostr_login_description,
),
const SizedBox(
height: 15,
Expand All @@ -40,7 +41,7 @@ class NostrLogin extends HookConsumerWidget {
leadingIcon: ImageIcon(
AssetImage(Assets.images.fieldPrivatekey.path),
),
label: 'Your Private Key',
label: context.i18n.nostr_login_input_private_key,
controller: privateKeyController.controller,
validator: (String? value) =>
privateKeyController.onVerify(),
Expand All @@ -57,7 +58,7 @@ class NostrLogin extends HookConsumerWidget {
),
onPressed: () {},
type: ButtonType.disabled,
label: const Text('Paste from clipboard'),
label: Text(context.i18n.button_paste),
mainAxisSize: MainAxisSize.max,
),
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ class SelectCountries extends HookConsumerWidget {
color: context.theme.appColors.secondaryBackground,
child: Stack(
children: <Widget>[
const NavigationHeader(title: 'Select country'),
NavigationHeader(
title: context.i18n.select_countries_nav_title,
),
Padding(
padding: const EdgeInsets.only(top: navigationHeaderHeight),
child: Column(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,9 @@ class SelectLanguages extends HookConsumerWidget {
),
child: Column(
children: <Widget>[
const TitleDescription(
title: 'Select languages',
description:
'You’ll be shown content in the selected language',
TitleDescription(
title: context.i18n.select_languages_title,
description: context.i18n.select_languages_description,
),
Padding(
padding: const EdgeInsets.only(bottom: 12),
Expand Down
Loading
Loading