High performance self-hosted photo and video management solution.
TypeScript backup-toolfluttergoogle-photosgoogle-photos-alternativejavascriptmobile-appnestjsnodejsphoto-galleryphotosphotos-managementself-hostedsveltesveltekittypescriptvideos
feat(mobile): render login fields/buttons based on server configuration (#3339)
Dhrumil Shahbaf1ea313e29
diff --git a/mobile/assets/i18n/en-US.json b/mobile/assets/i18n/en-US.jsonindex 47e60789ce..11a4f8a9ec 100644--- a/mobile/assets/i18n/en-US.json+++ b/mobile/assets/i18n/en-US.json@@ -186,6 +186,7 @@"login_form_save_login": "Stay logged in","login_form_server_empty": "Enter a server URL.","login_form_server_error": "Could not connect to server.",+ "login_disabled": "Login has been disabled","monthly_title_text_date_format": "MMMM y","motion_photos_page_title": "Motion Photos","notification_permission_dialog_cancel": "Cancel",@@ -290,4 +291,4 @@"version_announcement_overlay_text_2": "please take your time to visit the ","version_announcement_overlay_text_3": " and ensure your docker-compose and .env setup is up-to-date to prevent any misconfigurations, especially if you use WatchTower or any mechanism that handles updating your server application automatically.","version_announcement_overlay_title": "New Server Version Available \uD83C\uDF89"-}\ No newline at end of file+}diff --git a/mobile/lib/modules/login/ui/login_form.dart b/mobile/lib/modules/login/ui/login_form.dartindex a216bdb038..f50e6661b7 100644--- a/mobile/lib/modules/login/ui/login_form.dart+++ b/mobile/lib/modules/login/ui/login_form.dart@@ -36,6 +36,7 @@ class LoginForm extends HookConsumerWidget {final isLoading = useState<bool>(false);final isLoadingServer = useState<bool>(false);final isOauthEnable = useState<bool>(false);+ final isPasswordLoginEnable = useState<bool>(false);final oAuthButtonLabel = useState<String>('OAuth');final logoAnimationController = useAnimationController(duration: const Duration(seconds: 60),@@ -69,9 +70,11 @@ class LoginForm extends HookConsumerWidget {if (loginConfig != null) {isOauthEnable.value = loginConfig.enabled;+ isPasswordLoginEnable.value = loginConfig.passwordLoginEnabled;oAuthButtonLabel.value = loginConfig.buttonText ?? 'OAuth';} else {isOauthEnable.value = false;+ isPasswordLoginEnable.value = true;}serverEndpoint.value = endpoint;@@ -82,6 +85,7 @@ class LoginForm extends HookConsumerWidget {toastType: ToastType.error,);isOauthEnable.value = false;+ isPasswordLoginEnable.value = true;isLoadingServer.value = false;return false;} catch (e) {@@ -91,6 +95,7 @@ class LoginForm extends HookConsumerWidget {toastType: ToastType.error,);isOauthEnable.value = false;+ isPasswordLoginEnable.value = true;isLoadingServer.value = false;return false;}@@ -262,18 +267,20 @@ class LoginForm extends HookConsumerWidget {style: Theme.of(context).textTheme.displaySmall,textAlign: TextAlign.center,),- const SizedBox(height: 18),- EmailInput(- controller: usernameController,- focusNode: emailFocusNode,- onSubmit: passwordFocusNode.requestFocus,- ),- const SizedBox(height: 8),- PasswordInput(- controller: passwordController,- focusNode: passwordFocusNode,- onSubmit: login,- ),+ if (isPasswordLoginEnable.value) ...[+ const SizedBox(height: 18),+ EmailInput(+ controller: usernameController,+ focusNode: emailFocusNode,+ onSubmit: passwordFocusNode.requestFocus,+ ),+ const SizedBox(height: 8),+ PasswordInput(+ controller: passwordController,+ focusNode: passwordFocusNode,+ onSubmit: login,+ ),+ ],// Note: This used to have an AnimatedSwitcher, but was removed// because of https://github.com/flutter/flutter/issues/120874@@ -295,19 +302,21 @@ class LoginForm extends HookConsumerWidget {mainAxisAlignment: MainAxisAlignment.center,children: [const SizedBox(height: 18),- LoginButton(onPressed: login),+ if (isPasswordLoginEnable.value)+ LoginButton(onPressed: login),if (isOauthEnable.value) ...[- Padding(- padding: const EdgeInsets.symmetric(- horizontal: 16.0,+ if (isPasswordLoginEnable.value)+ Padding(+ padding: const EdgeInsets.symmetric(+ horizontal: 16.0,+ ),+ child: Divider(+ color: Brightness.dark ==+ Theme.of(context).brightness+ ? Colors.white+ : Colors.black,+ ),),- child: Divider(- color:- Brightness.dark == Theme.of(context).brightness- ? Colors.white- : Colors.black,- ),- ),OAuthLoginButton(serverEndpointController: serverEndpointController,buttonLabel: oAuthButtonLabel.value,@@ -317,6 +326,10 @@ class LoginForm extends HookConsumerWidget {],],),+ if (!isOauthEnable.value && !isPasswordLoginEnable.value)+ Center(+ child: const Text('login_disabled').tr(),+ ),const SizedBox(height: 12),TextButton.icon(icon: const Icon(Icons.arrow_back),