1
0
Fork 0
mirror of https://github.com/immich-app/immich.git synced 2025-01-04 02:46:47 +01:00

improve login ux (#2004)

removed animated switchers to resolve issue with flutter/issues/120874
This commit is contained in:
martyfuhry 2023-03-15 15:38:26 -04:00 committed by GitHub
parent 3a1d5de742
commit 08ed71e51e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 134 additions and 132 deletions

View file

@ -242,5 +242,6 @@
"permission_onboarding_go_to_settings": "Go to settings", "permission_onboarding_go_to_settings": "Go to settings",
"permission_onboarding_permission_limited": "Permission limited. To let Immich backup and manage your entire gallery collection, grant photo and video permissions in Settings.", "permission_onboarding_permission_limited": "Permission limited. To let Immich backup and manage your entire gallery collection, grant photo and video permissions in Settings.",
"permission_onboarding_continue_anyway": "Continue anyway", "permission_onboarding_continue_anyway": "Continue anyway",
"permission_onboarding_log_out": "Log out" "permission_onboarding_log_out": "Log out",
"login_form_next_button": "Next"
} }

View file

@ -166,7 +166,6 @@ class LoginForm extends HookConsumerWidget {
} }
} }
oAuthLogin() async { oAuthLogin() async {
var oAuthService = ref.watch(oAuthServiceProvider); var oAuthService = ref.watch(oAuthServiceProvider);
ref.watch(assetProvider.notifier).clearAllAsset(); ref.watch(assetProvider.notifier).clearAllAsset();
@ -230,10 +229,7 @@ class LoginForm extends HookConsumerWidget {
} }
buildSelectServer() { buildSelectServer() {
return ConstrainedBox( return Column(
key: const ValueKey('server'),
constraints: const BoxConstraints(maxWidth: 300),
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch, crossAxisAlignment: CrossAxisAlignment.stretch,
children: [ children: [
ServerEndpointInput( ServerEndpointInput(
@ -249,7 +245,7 @@ class LoginForm extends HookConsumerWidget {
onPressed: isLoadingServer.value ? null : getServerLoginCredential, onPressed: isLoadingServer.value ? null : getServerLoginCredential,
icon: const Icon(Icons.arrow_forward_rounded), icon: const Icon(Icons.arrow_forward_rounded),
label: const Text( label: const Text(
'Next', 'login_form_next_button',
style: TextStyle(fontSize: 14, fontWeight: FontWeight.bold), style: TextStyle(fontSize: 14, fontWeight: FontWeight.bold),
).tr(), ).tr(),
), ),
@ -261,15 +257,11 @@ class LoginForm extends HookConsumerWidget {
), ),
), ),
], ],
),
); );
} }
buildLogin() { buildLogin() {
return ConstrainedBox( return AutofillGroup(
key: const ValueKey('login'),
constraints: const BoxConstraints(maxWidth: 300),
child: AutofillGroup(
child: Column( child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch, crossAxisAlignment: CrossAxisAlignment.stretch,
children: [ children: [
@ -290,15 +282,21 @@ class LoginForm extends HookConsumerWidget {
focusNode: passwordFocusNode, focusNode: passwordFocusNode,
onSubmit: login, onSubmit: login,
), ),
AnimatedSwitcher(
duration: const Duration(milliseconds: 500), // Note: This used to have an AnimatedSwitcher, but was removed
child: isLoading.value // because of https://github.com/flutter/flutter/issues/120874
? const SizedBox( isLoading.value
? const Padding(
padding: EdgeInsets.only(top: 18.0),
child: SizedBox(
width: 24, width: 24,
height: 24, height: 24,
child: FittedBox(
child: CircularProgressIndicator( child: CircularProgressIndicator(
strokeWidth: 2, strokeWidth: 2,
), ),
),
),
) )
: Column( : Column(
crossAxisAlignment: CrossAxisAlignment.stretch, crossAxisAlignment: CrossAxisAlignment.stretch,
@ -327,7 +325,6 @@ class LoginForm extends HookConsumerWidget {
], ],
], ],
), ),
),
const SizedBox(height: 12), const SizedBox(height: 12),
TextButton.icon( TextButton.icon(
icon: const Icon(Icons.arrow_back), icon: const Icon(Icons.arrow_back),
@ -336,16 +333,18 @@ class LoginForm extends HookConsumerWidget {
), ),
], ],
), ),
),
); );
} }
final child = serverEndpoint.value == null final serverSelectionOrLogin = serverEndpoint.value == null
? buildSelectServer() ? buildSelectServer()
: buildLogin(); : buildLogin();
return LayoutBuilder( return LayoutBuilder(
builder: (context, constraints) { builder: (context, constraints) {
return SingleChildScrollView( return SingleChildScrollView(
child: Center(
child: Container(
constraints: const BoxConstraints(maxWidth: 300),
child: Column( child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch, crossAxisAlignment: CrossAxisAlignment.stretch,
mainAxisAlignment: MainAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center,
@ -370,12 +369,14 @@ class LoginForm extends HookConsumerWidget {
], ],
), ),
const SizedBox(height: 18), const SizedBox(height: 18),
AnimatedSwitcher(
duration: const Duration(milliseconds: 500), // Note: This used to have an AnimatedSwitcher, but was removed
child: child, // because of https://github.com/flutter/flutter/issues/120874
), serverSelectionOrLogin,
], ],
), ),
),
),
); );
}, },
); );