Skip to content

Commit

Permalink
step-32
Browse files Browse the repository at this point in the history
  • Loading branch information
vandadnp committed Jan 23, 2022
1 parent 0a66337 commit 2690957
Show file tree
Hide file tree
Showing 19 changed files with 282 additions and 72 deletions.
5 changes: 5 additions & 0 deletions ios/Runner/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleLocalizations</key>
<array>
<string>en</string>
<string>sv</string>
</array>
<key>CFBundleDevelopmentRegion</key>
<string>$(DEVELOPMENT_LANGUAGE)</string>
<key>CFBundleDisplayName</key>
Expand Down
3 changes: 3 additions & 0 deletions l10n.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
arb-dir: lib/l10n
template-arb-file: intl_en.arb
output-localization-file: app_localizations.dart
7 changes: 7 additions & 0 deletions lib/extensions/buildcontext/loc.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import 'package:flutter/material.dart' show BuildContext;
import 'package:flutter_gen/gen_l10n/app_localizations.dart'
show AppLocalizations;

extension Localization on BuildContext {
AppLocalizations get loc => AppLocalizations.of(this)!;
}
62 changes: 62 additions & 0 deletions lib/l10n/intl_en.arb
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
{

"logout_button": "Log out",
"note": "Note",
"cancel": "Cancel",
"yes": "Yes",
"delete": "Delete",
"sharing": "Sharing",
"ok": "OK",
"login": "Login",
"verify_email": "Verify email",
"register": "Register",
"restart": "Restart",

"start_typing_your_note": "Start typing your note",
"delete_note_prompt": "Are you sure you want to delete this note?",
"cannot_share_empty_note_prompt": "Cannot share an empty note!",
"generic_error_prompt": "An error occurred",
"logout_dialog_prompt": "Are you sure you want to log out?",

"password_reset": "Password reset",
"password_reset_dialog_prompt": "We have now sent you a password reset link. Please check your email for more information.",

"login_error_cannot_find_user": "Cannot find a user with the entered credentials!",
"login_error_wrong_credentials": "Wrong credentials",
"login_error_auth_error": "Authentication error",

"login_view_prompt": "Please log in to your account in order to interact with and create notes!",

"login_view_forgot_password": "I forgot my password",
"login_view_not_registered_yet": "Not registered yet? Register here!",

"email_text_field_placeholder": "Enter your email here",
"password_text_field_placeholder": "Enter your password here",

"forgot_password": "Forgot Password",
"forgot_password_view_generic_error": "We could not process your request. Please make sure that you are a registered user, or if not, register a user now by going back one step.",
"forgot_password_view_prompt": "If you forgot your password, simply enter your email and we will send you a password reset link.",
"forgot_password_view_send_me_link": "Send me password reset link",
"forgot_password_view_back_to_login": "Back to login page",

"register_error_weak_password": "This password is not secure enough. Please choose another password!",
"register_error_email_already_in_use": "This email is already registered to another user. Please choose another email!",
"register_error_generic": "Failed to register. Please try again later!",
"register_error_invalid_email": "The email address you entered appears to be invalid. Please try another email address!",
"register_view_prompt": "Enter your email and password to see your notes!",
"register_view_already_registered": "Already registered? Login here!",

"verify_email_view_prompt": "We've sent you an email verification. Please open it to verify your account. If you haven't received a verification email yet, press the button below!",
"verify_email_send_email_verification": "Send email verification",

"notes_title": "{count, plural, =0{No notes yet} =1{1 note} other{{count} notes}}",
"@notes_title": {
"placeholders": {
"count": {
"type": "int",
"example": "3 notes"
}
}
}

}
62 changes: 62 additions & 0 deletions lib/l10n/intl_sv.arb
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
{

"logout_button": "Logga ut",
"note": "Antäckning",
"cancel": "Avbryt",
"yes": "Ja",
"delete": "Radera",
"sharing": "Delning",
"ok": "OK",
"login": "Logga in",
"verify_email": "Verifera",
"register": "Registrera",
"restart": "Börja om",

"start_typing_your_note": "Skriv din antäckning här",
"delete_note_prompt": "Are du säker på att du vill radera den här antäckningen?",
"cannot_share_empty_note_prompt": "Kan inte dela en tom antäckning!",
"generic_error_prompt": "Ett fel har inträffats",
"logout_dialog_prompt": "Är du säker på att du vill logga ut?",

"password_reset": "Nollställ ditt lösenord",
"password_reset_dialog_prompt": "Vi har nu skickat ett mejl till dig. Mejlet innehåller instruktioner på hur du kan nollställa ditt lösenord!",

"login_error_cannot_find_user": "Kunde inte hitta en användare med de angivna uppgifter!",
"login_error_wrong_credentials": "Fel inloggnings uppgifter!",
"login_error_auth_error": "Ett autentiseringsfel har inträffats!",

"login_view_prompt": "Logga in för att kunna se dina antäckningar!",

"login_view_forgot_password": "Glömt lösenord?",
"login_view_not_registered_yet": "Har inte registrerar än? Tryck här!",

"email_text_field_placeholder": "Skriv ditt mejladdress här",
"password_text_field_placeholder": "Skriv ditt lösenord här",

"forgot_password": "Glömt Lösenord",
"forgot_password_view_generic_error": "Vi kunde inte hantera din begäran. Var vänlig och skriv ditt inloggningsuppgifter och prova igen!",
"forgot_password_view_prompt": "Om du har glömt ditt lösenord, mata in ditt mejladdress så kan vi skicka ett mejl till dig där du kan nollställa ditt lösenord!",
"forgot_password_view_send_me_link": "Skicka mejlet",
"forgot_password_view_back_to_login": "Tillbaka till loginskärmen",

"register_error_weak_password": "Ditt valda lösenord är inte säkert nog. Var vänlig och välj ett annat lösenord!",
"register_error_email_already_in_use": "Mejladdresset som du angav är redan taget. Var vänlig och välj ett annat mejladdress!",
"register_error_generic": "Kunde tyvärr inte hantera din begäran. Var vänlig försök igen senare.",
"register_error_invalid_email": "Ditt valda mejladdress verkar inte vara giltigt. Var vänlig försök med ett annat mejladdress.",
"register_view_prompt": "Mata in ditt mejladdress och ditt lösenord för att se dina antäckningar!",
"register_view_already_registered": "Redan registrerat? Logga in här!",

"verify_email_view_prompt": "Vi har skickat ett mejl till ditt mejladdress. Du behöver trycka på länken i mejlet för att verifiera ditt mejladdress. Om du inte har redan fått mejlet efter en stund, tryck på knappen nedan för att skicka ett till mejl!",
"verify_email_send_email_verification": "Skicka verifieringsmejlet igen",

"notes_title": "{count, plural, =0{Inga antäckningar än} =1{1 antäckning} other{{count} antäckningar}}",
"@notes_title": {
"placeholders": {
"count": {
"type": "int",
"example": "3 antäckningar"
}
}
}

}
3 changes: 3 additions & 0 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,14 @@ import 'package:mynotes/views/notes/create_update_note_view.dart';
import 'package:mynotes/views/notes/notes_view.dart';
import 'package:mynotes/views/register_view.dart';
import 'package:mynotes/views/verify_email_view.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';

void main() {
WidgetsFlutterBinding.ensureInitialized();
runApp(
MaterialApp(
supportedLocales: AppLocalizations.supportedLocales,
localizationsDelegates: AppLocalizations.localizationsDelegates,
title: 'Flutter Demo',
debugShowCheckedModeBanner: false,
theme: ThemeData(
Expand Down
7 changes: 4 additions & 3 deletions lib/utilities/dialogs/cannot_share_empty_note_dialog.dart
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import 'package:flutter/material.dart';
import 'package:mynotes/extensions/buildcontext/loc.dart';
import 'package:mynotes/utilities/dialogs/generic_dialog.dart';

Future<void> showCannotShareEmptyNoteDialog(BuildContext context) {
return showGenericDialog<void>(
context: context,
title: 'Sharing',
content: 'You cannot share an empty note!',
title: context.loc.sharing,
content: context.loc.cannot_share_empty_note_prompt,
optionsBuilder: () => {
'OK': null,
context.loc.ok: null,
},
);
}
9 changes: 5 additions & 4 deletions lib/utilities/dialogs/delete_dialog.dart
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import 'package:flutter/material.dart';
import 'package:mynotes/extensions/buildcontext/loc.dart';
import 'package:mynotes/utilities/dialogs/generic_dialog.dart';

Future<bool> showDeleteDialog(BuildContext context) {
return showGenericDialog<bool>(
context: context,
title: 'Delete',
content: 'Are you sure you want to delete this item?',
title: context.loc.delete,
content: context.loc.delete_note_prompt,
optionsBuilder: () => {
'Cancel': false,
'Yes': true,
context.loc.cancel: false,
context.loc.yes: true,
},
).then(
(value) => value ?? false,
Expand Down
5 changes: 3 additions & 2 deletions lib/utilities/dialogs/error_dialog.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'package:flutter/material.dart';
import 'package:mynotes/extensions/buildcontext/loc.dart';
import 'package:mynotes/utilities/dialogs/generic_dialog.dart';

Future<void> showErrorDialog(
Expand All @@ -7,10 +8,10 @@ Future<void> showErrorDialog(
) {
return showGenericDialog<void>(
context: context,
title: 'An error occurred',
title: context.loc.generic_error_prompt,
content: text,
optionsBuilder: () => {
'OK': null,
context.loc.ok: null,
},
);
}
9 changes: 5 additions & 4 deletions lib/utilities/dialogs/logout_dialog.dart
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import 'package:flutter/material.dart';
import 'package:mynotes/extensions/buildcontext/loc.dart';
import 'package:mynotes/utilities/dialogs/generic_dialog.dart';

Future<bool> showLogOutDialog(BuildContext context) {
return showGenericDialog<bool>(
context: context,
title: 'Log out',
content: 'Are you sure you want to log out?',
title: context.loc.logout_button,
content: context.loc.logout_dialog_prompt,
optionsBuilder: () => {
'Cancel': false,
'Log out': true,
context.loc.cancel: false,
context.loc.logout_button: true,
},
).then(
(value) => value ?? false,
Expand Down
8 changes: 4 additions & 4 deletions lib/utilities/dialogs/password_reset_email_sent_dialog.dart
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import 'package:flutter/material.dart';
import 'package:mynotes/extensions/buildcontext/loc.dart';
import 'package:mynotes/utilities/dialogs/generic_dialog.dart';

Future<void> showPasswordResetSentDialog(BuildContext context) {
return showGenericDialog<void>(
context: context,
title: 'Password Reset',
content:
'We have now sent you a password reset link. Please check your email for more information.',
title: context.loc.password_reset,
content: context.loc.password_reset_dialog_prompt,
optionsBuilder: () => {
'OK': null,
context.loc.ok: null,
},
);
}
26 changes: 17 additions & 9 deletions lib/views/forgot_password_view.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:mynotes/extensions/buildcontext/loc.dart';
import 'package:mynotes/services/auth/bloc/auth_bloc.dart';
import 'package:mynotes/services/auth/bloc/auth_event.dart';
import 'package:mynotes/services/auth/bloc/auth_state.dart';
Expand Down Expand Up @@ -38,29 +39,32 @@ class _ForgotPasswordViewState extends State<ForgotPasswordView> {
await showPasswordResetSentDialog(context);
}
if (state.exception != null) {
await showErrorDialog(context,
'We could not process your request. Please make sure that you are a registered user, or if not, register a user now by going back one step.');
await showErrorDialog(
context,
context.loc.forgot_password_view_generic_error,
);
}
}
},
child: Scaffold(
appBar: AppBar(
title: const Text('Forgot Password'),
title: Text(context.loc.forgot_password),
),
body: Padding(
padding: const EdgeInsets.all(16.0),
child: SingleChildScrollView(
child: Column(
children: [
const Text(
'If you forgot your password, simply enter your email and we will send you a password reset link.'),
Text(
context.loc.forgot_password_view_prompt,
),
TextField(
keyboardType: TextInputType.emailAddress,
autocorrect: false,
autofocus: true,
controller: _controller,
decoration: const InputDecoration(
hintText: 'Your email address....',
decoration: InputDecoration(
hintText: context.loc.email_text_field_placeholder,
),
),
TextButton(
Expand All @@ -70,15 +74,19 @@ class _ForgotPasswordViewState extends State<ForgotPasswordView> {
.read<AuthBloc>()
.add(AuthEventForgotPassword(email: email));
},
child: const Text('Send me password reset link'),
child: Text(
context.loc.forgot_password_view_send_me_link,
),
),
TextButton(
onPressed: () {
context.read<AuthBloc>().add(
const AuthEventLogOut(),
);
},
child: const Text('Back to login page'),
child: Text(
context.loc.forgot_password_view_back_to_login,
),
),
],
),
Expand Down
Loading

0 comments on commit 2690957

Please sign in to comment.