Minor refactor
This commit is contained in:
parent
43dd473037
commit
287a19fe3d
3 changed files with 24 additions and 15 deletions
6
lib/l10n/l10n.dart
Normal file
6
lib/l10n/l10n.dart
Normal file
|
@ -0,0 +1,6 @@
|
|||
import "package:flutter/widgets.dart";
|
||||
import "package:photos/generated/l10n.dart";
|
||||
|
||||
extension AppLocalizationsX on BuildContext {
|
||||
S get l10n => S.of(this);
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import "package:photos/generated/l10n.dart";
|
||||
import "package:photos/l10n/l10n.dart";
|
||||
import 'package:photos/services/user_service.dart';
|
||||
import 'package:photos/utils/dialog_util.dart';
|
||||
import 'package:photos/utils/email_util.dart';
|
||||
|
@ -16,20 +16,21 @@ class _ChangeEmailDialogState extends State<ChangeEmailDialog> {
|
|||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final l10n = context.l10n;
|
||||
return AlertDialog(
|
||||
title: Text(S.of(context).enterYourEmailAddress),
|
||||
title: Text(l10n.enterYourEmailAddress),
|
||||
content: SingleChildScrollView(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
TextFormField(
|
||||
decoration: const InputDecoration(
|
||||
hintText: S.of(context).email,
|
||||
hintStyle: TextStyle(
|
||||
decoration: InputDecoration(
|
||||
hintText: l10n.email,
|
||||
hintStyle: const TextStyle(
|
||||
color: Colors.white30,
|
||||
),
|
||||
contentPadding: EdgeInsets.all(12),
|
||||
contentPadding: const EdgeInsets.all(12),
|
||||
),
|
||||
onChanged: (value) {
|
||||
setState(() {
|
||||
|
@ -46,9 +47,9 @@ class _ChangeEmailDialogState extends State<ChangeEmailDialog> {
|
|||
),
|
||||
actions: [
|
||||
TextButton(
|
||||
child: const Text(
|
||||
S.of(context).cancel,
|
||||
style: TextStyle(
|
||||
child: Text(
|
||||
l10n.cancel,
|
||||
style: const TextStyle(
|
||||
color: Colors.redAccent,
|
||||
),
|
||||
),
|
||||
|
@ -57,9 +58,9 @@ class _ChangeEmailDialogState extends State<ChangeEmailDialog> {
|
|||
},
|
||||
),
|
||||
TextButton(
|
||||
child: const Text(
|
||||
S.of(context).verify,
|
||||
style: TextStyle(
|
||||
child: Text(
|
||||
l10n.verify,
|
||||
style: const TextStyle(
|
||||
color: Colors.green,
|
||||
),
|
||||
),
|
||||
|
@ -67,7 +68,7 @@ class _ChangeEmailDialogState extends State<ChangeEmailDialog> {
|
|||
if (!isValidEmail(_email)) {
|
||||
showErrorDialog(
|
||||
context,
|
||||
S.of(context).invalidEmailAddress,
|
||||
l10n.invalidEmailAddress,
|
||||
"Please enter a valid email address.",
|
||||
);
|
||||
return;
|
||||
|
|
|
@ -2,6 +2,7 @@ import 'package:email_validator/email_validator.dart';
|
|||
import 'package:flutter/gestures.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:photos/core/configuration.dart';
|
||||
import "package:photos/l10n/l10n.dart";
|
||||
import 'package:photos/services/user_service.dart';
|
||||
import 'package:photos/ui/common/dynamic_fab.dart';
|
||||
import 'package:photos/ui/common/web_page.dart';
|
||||
|
@ -67,6 +68,7 @@ class _LoginPageState extends State<LoginPage> {
|
|||
}
|
||||
|
||||
Widget _getBody() {
|
||||
final l10n = context.l10n;
|
||||
return Column(
|
||||
children: [
|
||||
Expanded(
|
||||
|
@ -77,7 +79,7 @@ class _LoginPageState extends State<LoginPage> {
|
|||
padding:
|
||||
const EdgeInsets.symmetric(vertical: 30, horizontal: 20),
|
||||
child: Text(
|
||||
S.of(context).accountWelcomeBack,
|
||||
l10n.accountWelcomeBack,
|
||||
style: Theme.of(context).textTheme.headline4,
|
||||
),
|
||||
),
|
||||
|
@ -88,7 +90,7 @@ class _LoginPageState extends State<LoginPage> {
|
|||
decoration: InputDecoration(
|
||||
fillColor: _emailInputFieldColor,
|
||||
filled: true,
|
||||
hintText: S.of(context).email,
|
||||
hintText: l10n.email,
|
||||
contentPadding: const EdgeInsets.symmetric(
|
||||
horizontal: 15,
|
||||
vertical: 15,
|
||||
|
|
Loading…
Add table
Reference in a new issue