mirror of
https://github.com/Xevion/paperless-mobile.git
synced 2025-12-15 02:12:25 -06:00
feat: Migrated strings, and translations to native flutter l10n plugin
This commit is contained in:
@@ -5,7 +5,8 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter_form_builder/flutter_form_builder.dart';
|
||||
import 'package:paperless_mobile/extensions/flutter_extensions.dart';
|
||||
import 'package:paperless_mobile/features/login/model/client_certificate.dart';
|
||||
import 'package:paperless_mobile/generated/l10n.dart';
|
||||
import 'package:paperless_mobile/generated/l10n/app_localizations.dart';
|
||||
|
||||
import 'package:paperless_mobile/constants.dart';
|
||||
import 'package:permission_handler/permission_handler.dart';
|
||||
|
||||
@@ -40,7 +41,7 @@ class _ClientCertificateFormFieldState
|
||||
}
|
||||
assert(_selectedFile != null);
|
||||
if (_selectedFile?.path.split(".").last != 'pfx') {
|
||||
return S.of(context).invalidCertificateFormat;
|
||||
return S.of(context)!.invalidCertificateFormat;
|
||||
}
|
||||
return null;
|
||||
},
|
||||
@@ -50,8 +51,8 @@ class _ClientCertificateFormFieldState
|
||||
return Theme(
|
||||
data: theme,
|
||||
child: ExpansionTile(
|
||||
title: Text(S.of(context).clientcertificate),
|
||||
subtitle: Text(S.of(context).configureMutualTLSAuthentication),
|
||||
title: Text(S.of(context)!.clientcertificate),
|
||||
subtitle: Text(S.of(context)!.configureMutualTLSAuthentication),
|
||||
children: [
|
||||
InputDecorator(
|
||||
decoration: InputDecoration(
|
||||
@@ -67,7 +68,7 @@ class _ClientCertificateFormFieldState
|
||||
children: [
|
||||
ElevatedButton(
|
||||
onPressed: () => _onSelectFile(field),
|
||||
child: Text(S.of(context).select),
|
||||
child: Text(S.of(context)!.select),
|
||||
),
|
||||
_buildSelectedFileText(field).paddedOnly(left: 8),
|
||||
],
|
||||
@@ -85,7 +86,7 @@ class _ClientCertificateFormFieldState
|
||||
// ListTile(
|
||||
// leading: ElevatedButton(
|
||||
// onPressed: () => _onSelectFile(field),
|
||||
// child: Text(S.of(context).select),
|
||||
// child: Text(S.of(context)!.select),
|
||||
// ),
|
||||
// title: _buildSelectedFileText(field),
|
||||
// trailing: AbsorbPointer(
|
||||
@@ -108,7 +109,7 @@ class _ClientCertificateFormFieldState
|
||||
onChanged: (value) => field.didChange(
|
||||
field.value?.copyWith(passphrase: value),
|
||||
),
|
||||
label: S.of(context).passphrase,
|
||||
label: S.of(context)!.passphrase,
|
||||
).padded(),
|
||||
] else
|
||||
...[]
|
||||
@@ -143,7 +144,7 @@ class _ClientCertificateFormFieldState
|
||||
if (field.value == null) {
|
||||
assert(_selectedFile == null);
|
||||
return Text(
|
||||
S.of(context).selectFile,
|
||||
S.of(context)!.selectFile,
|
||||
style: Theme.of(context).textTheme.labelMedium?.apply(
|
||||
color: Theme.of(context).hintColor,
|
||||
),
|
||||
|
||||
@@ -3,7 +3,7 @@ import 'dart:developer';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_form_builder/flutter_form_builder.dart';
|
||||
import 'package:form_builder_validators/form_builder_validators.dart';
|
||||
import 'package:paperless_mobile/generated/l10n.dart';
|
||||
import 'package:paperless_mobile/generated/l10n/app_localizations.dart';
|
||||
|
||||
class ServerAddressFormField extends StatefulWidget {
|
||||
static const String fkServerAddress = "serverAddress";
|
||||
@@ -44,16 +44,16 @@ class _ServerAddressFormFieldState extends State<ServerAddressFormField> {
|
||||
autovalidateMode: AutovalidateMode.onUserInteraction,
|
||||
validator: FormBuilderValidators.compose([
|
||||
FormBuilderValidators.required(
|
||||
errorText: S.of(context).serverAddressMustNotBeEmpty,
|
||||
errorText: S.of(context)!.serverAddressMustNotBeEmpty,
|
||||
),
|
||||
FormBuilderValidators.match(
|
||||
r"https?://.*",
|
||||
errorText: S.of(context).serverAddressMustIncludeAScheme,
|
||||
errorText: S.of(context)!.serverAddressMustIncludeAScheme,
|
||||
)
|
||||
]),
|
||||
decoration: InputDecoration(
|
||||
hintText: "http://192.168.1.50:8000",
|
||||
labelText: S.of(context).serverAddress,
|
||||
labelText: S.of(context)!.serverAddress,
|
||||
suffixIcon: _canClear
|
||||
? IconButton(
|
||||
icon: const Icon(Icons.clear),
|
||||
|
||||
@@ -4,7 +4,7 @@ import 'package:form_builder_validators/form_builder_validators.dart';
|
||||
import 'package:paperless_mobile/extensions/flutter_extensions.dart';
|
||||
import 'package:paperless_mobile/features/login/model/user_credentials.model.dart';
|
||||
import 'package:paperless_mobile/features/login/view/widgets/form_fields/obscured_input_text_form_field.dart';
|
||||
import 'package:paperless_mobile/generated/l10n.dart';
|
||||
import 'package:paperless_mobile/generated/l10n/app_localizations.dart';
|
||||
|
||||
class UserCredentialsFormField extends StatefulWidget {
|
||||
static const fkCredentials = 'credentials';
|
||||
@@ -37,22 +37,22 @@ class _UserCredentialsFormFieldState extends State<UserCredentialsFormField> {
|
||||
UserCredentials(username: username),
|
||||
),
|
||||
validator: FormBuilderValidators.required(
|
||||
errorText: S.of(context).usernameMustNotBeEmpty,
|
||||
errorText: S.of(context)!.usernameMustNotBeEmpty,
|
||||
),
|
||||
autofillHints: const [AutofillHints.username],
|
||||
decoration: InputDecoration(
|
||||
label: Text(S.of(context).username),
|
||||
label: Text(S.of(context)!.username),
|
||||
),
|
||||
),
|
||||
ObscuredInputTextFormField(
|
||||
key: const ValueKey('login-password'),
|
||||
label: S.of(context).password,
|
||||
label: S.of(context)!.password,
|
||||
onChanged: (password) => field.didChange(
|
||||
field.value?.copyWith(password: password) ??
|
||||
UserCredentials(password: password),
|
||||
),
|
||||
validator: FormBuilderValidators.required(
|
||||
errorText: S.of(context).passwordMustNotBeEmpty,
|
||||
errorText: S.of(context)!.passwordMustNotBeEmpty,
|
||||
),
|
||||
),
|
||||
].map((child) => child.padded()).toList(),
|
||||
@@ -73,11 +73,11 @@ class _UserCredentialsFormFieldState extends State<UserCredentialsFormField> {
|
||||
FocusScope.of(context).requestFocus(_focusNodes[fkPassword]);
|
||||
},
|
||||
validator: FormBuilderValidators.required(
|
||||
errorText: S.of(context).usernameMustNotBeEmpty,
|
||||
errorText: S.of(context)!.usernameMustNotBeEmpty,
|
||||
),
|
||||
autofillHints: const [AutofillHints.username],
|
||||
decoration: InputDecoration(
|
||||
labelText: S.of(context).username,
|
||||
labelText: S.of(context)!.username,
|
||||
),
|
||||
).padded(),
|
||||
FormBuilderTextField(
|
||||
@@ -88,11 +88,11 @@ class _UserCredentialsFormFieldState extends State<UserCredentialsFormField> {
|
||||
},
|
||||
autofillHints: const [AutofillHints.password],
|
||||
validator: FormBuilderValidators.required(
|
||||
errorText: S.of(context).passwordMustNotBeEmpty,
|
||||
errorText: S.of(context)!.passwordMustNotBeEmpty,
|
||||
),
|
||||
obscureText: true,
|
||||
decoration: InputDecoration(
|
||||
labelText: S.of(context).password,
|
||||
labelText: S.of(context)!.password,
|
||||
),
|
||||
).padded(),
|
||||
],
|
||||
|
||||
@@ -6,7 +6,8 @@ import 'package:paperless_mobile/extensions/flutter_extensions.dart';
|
||||
import 'package:paperless_mobile/features/login/model/reachability_status.dart';
|
||||
import 'package:paperless_mobile/features/login/view/widgets/form_fields/client_certificate_form_field.dart';
|
||||
import 'package:paperless_mobile/features/login/view/widgets/form_fields/server_address_form_field.dart';
|
||||
import 'package:paperless_mobile/generated/l10n.dart';
|
||||
import 'package:paperless_mobile/generated/l10n/app_localizations.dart';
|
||||
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
class ServerConnectionPage extends StatefulWidget {
|
||||
@@ -32,7 +33,7 @@ class _ServerConnectionPageState extends State<ServerConnectionPage> {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
toolbarHeight: kToolbarHeight - 4,
|
||||
title: Text(S.of(context).connectToPaperless),
|
||||
title: Text(S.of(context)!.connectToPaperless),
|
||||
bottom: PreferredSize(
|
||||
child: _isCheckingConnection
|
||||
? const LinearProgressIndicator()
|
||||
@@ -65,7 +66,7 @@ class _ServerConnectionPageState extends State<ServerConnectionPage> {
|
||||
onPressed: _updateReachability,
|
||||
),
|
||||
FilledButton(
|
||||
child: Text(S.of(context).continueLabel),
|
||||
child: Text(S.of(context)!.continueLabel),
|
||||
onPressed: _reachabilityStatus == ReachabilityStatus.reachable
|
||||
? widget.onContinue
|
||||
: null,
|
||||
@@ -108,37 +109,37 @@ class _ServerConnectionPageState extends State<ServerConnectionPage> {
|
||||
case ReachabilityStatus.reachable:
|
||||
return _buildIconText(
|
||||
Icons.done,
|
||||
S.of(context).connectionSuccessfulylEstablished,
|
||||
S.of(context)!.connectionSuccessfulylEstablished,
|
||||
Colors.green,
|
||||
);
|
||||
case ReachabilityStatus.notReachable:
|
||||
return _buildIconText(
|
||||
Icons.close,
|
||||
S.of(context).couldNotEstablishConnectionToTheServer,
|
||||
S.of(context)!.couldNotEstablishConnectionToTheServer,
|
||||
errorColor,
|
||||
);
|
||||
case ReachabilityStatus.unknownHost:
|
||||
return _buildIconText(
|
||||
Icons.close,
|
||||
S.of(context).hostCouldNotBeResolved,
|
||||
S.of(context)!.hostCouldNotBeResolved,
|
||||
errorColor,
|
||||
);
|
||||
case ReachabilityStatus.missingClientCertificate:
|
||||
return _buildIconText(
|
||||
Icons.close,
|
||||
S.of(context).loginPageReachabilityMissingClientCertificateText,
|
||||
S.of(context)!.loginPageReachabilityMissingClientCertificateText,
|
||||
errorColor,
|
||||
);
|
||||
case ReachabilityStatus.invalidClientCertificateConfiguration:
|
||||
return _buildIconText(
|
||||
Icons.close,
|
||||
S.of(context).incorrectOrMissingCertificatePassphrase,
|
||||
S.of(context)!.incorrectOrMissingCertificatePassphrase,
|
||||
errorColor,
|
||||
);
|
||||
case ReachabilityStatus.connectionTimeout:
|
||||
return _buildIconText(
|
||||
Icons.close,
|
||||
S.of(context).connectionTimedOut,
|
||||
S.of(context)!.connectionTimedOut,
|
||||
errorColor,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ import 'package:flutter_form_builder/flutter_form_builder.dart';
|
||||
import 'package:paperless_mobile/extensions/flutter_extensions.dart';
|
||||
import 'package:paperless_mobile/features/login/view/widgets/form_fields/server_address_form_field.dart';
|
||||
import 'package:paperless_mobile/features/login/view/widgets/form_fields/user_credentials_form_field.dart';
|
||||
import 'package:paperless_mobile/generated/l10n.dart';
|
||||
import 'package:paperless_mobile/generated/l10n/app_localizations.dart';
|
||||
|
||||
class ServerLoginPage extends StatefulWidget {
|
||||
final Future<void> Function() onDone;
|
||||
@@ -29,7 +29,7 @@ class _ServerLoginPageState extends State<ServerLoginPage> {
|
||||
'';
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text(S.of(context).loginPageSignInTitle),
|
||||
title: Text(S.of(context)!.loginPageSignInTitle),
|
||||
bottom: _isLoginLoading
|
||||
? const PreferredSize(
|
||||
preferredSize: Size.fromHeight(4.0),
|
||||
@@ -39,7 +39,7 @@ class _ServerLoginPageState extends State<ServerLoginPage> {
|
||||
),
|
||||
body: ListView(
|
||||
children: [
|
||||
Text(S.of(context).signInToServer(serverAddress)).padded(),
|
||||
Text(S.of(context)!.signInToServer(serverAddress)).padded(),
|
||||
const UserCredentialsFormField(),
|
||||
],
|
||||
),
|
||||
@@ -53,7 +53,7 @@ class _ServerLoginPageState extends State<ServerLoginPage> {
|
||||
await widget.onDone();
|
||||
setState(() => _isLoginLoading = false);
|
||||
},
|
||||
child: Text(S.of(context).signIn),
|
||||
child: Text(S.of(context)!.signIn),
|
||||
)
|
||||
],
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user