mirror of
https://github.com/immich-app/immich
synced 2025-11-14 17:36:12 +00:00
refactor(mobile): build context extensions (#4923)
* refactor: move all extensions to separate package * refactor(mobile): add BuildContext extension * refactor(mobile): use theme getters from context * refactor(mobile): use media query size from context * refactor(mobile): use auto router methods from context * refactor(mobile): use navigator methods from context --------- Co-authored-by: shalong-tanwen <139912620+shalong-tanwen@users.noreply.github.com>
This commit is contained in:
parent
a147dee4b6
commit
bffc2cdf60
106 changed files with 660 additions and 628 deletions
|
|
@ -1,9 +1,9 @@
|
|||
import 'dart:io';
|
||||
import 'package:auto_route/auto_route.dart';
|
||||
import 'package:easy_localization/easy_localization.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_hooks/flutter_hooks.dart' hide Store;
|
||||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||
import 'package:immich_mobile/extensions/build_context_extensions.dart';
|
||||
import 'package:immich_mobile/modules/login/providers/oauth.provider.dart';
|
||||
import 'package:immich_mobile/modules/onboarding/providers/gallery_permission.provider.dart';
|
||||
import 'package:immich_mobile/routing/router.dart';
|
||||
|
|
@ -150,7 +150,7 @@ class LoginForm extends HookConsumerWidget {
|
|||
// Resume backup (if enable) then navigate
|
||||
if (ref.read(authenticationProvider).shouldChangePassword &&
|
||||
!ref.read(authenticationProvider).isAdmin) {
|
||||
AutoRouter.of(context).push(const ChangePasswordRoute());
|
||||
context.autoPush(const ChangePasswordRoute());
|
||||
} else {
|
||||
final hasPermission = await ref
|
||||
.read(galleryPermissionNotifier.notifier)
|
||||
|
|
@ -159,7 +159,7 @@ class LoginForm extends HookConsumerWidget {
|
|||
// Don't resume the backup until we have gallery permission
|
||||
ref.read(backupProvider.notifier).resumeBackup();
|
||||
}
|
||||
AutoRouter.of(context).replace(const TabControllerRoute());
|
||||
context.autoReplace(const TabControllerRoute());
|
||||
}
|
||||
} else {
|
||||
ImmichToast.show(
|
||||
|
|
@ -212,9 +212,7 @@ class LoginForm extends HookConsumerWidget {
|
|||
if (permission.isGranted || permission.isLimited) {
|
||||
ref.watch(backupProvider.notifier).resumeBackup();
|
||||
}
|
||||
AutoRouter.of(context).replace(
|
||||
const TabControllerRoute(),
|
||||
);
|
||||
context.autoReplace(const TabControllerRoute());
|
||||
} else {
|
||||
ImmichToast.show(
|
||||
context: context,
|
||||
|
|
@ -260,8 +258,7 @@ class LoginForm extends HookConsumerWidget {
|
|||
),
|
||||
),
|
||||
),
|
||||
onPressed: () =>
|
||||
AutoRouter.of(context).push(const SettingsRoute()),
|
||||
onPressed: () => context.autoPush(const SettingsRoute()),
|
||||
icon: const Icon(Icons.settings_rounded),
|
||||
label: const SizedBox.shrink(),
|
||||
),
|
||||
|
|
@ -303,7 +300,7 @@ class LoginForm extends HookConsumerWidget {
|
|||
children: [
|
||||
Text(
|
||||
serverEndpointController.text,
|
||||
style: Theme.of(context).textTheme.displaySmall,
|
||||
style: context.textTheme.displaySmall,
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
if (isPasswordLoginEnable.value) ...[
|
||||
|
|
@ -339,8 +336,7 @@ class LoginForm extends HookConsumerWidget {
|
|||
horizontal: 16.0,
|
||||
),
|
||||
child: Divider(
|
||||
color: Brightness.dark ==
|
||||
Theme.of(context).brightness
|
||||
color: context.isDarkTheme
|
||||
? Colors.white
|
||||
: Colors.black,
|
||||
),
|
||||
|
|
@ -588,7 +584,7 @@ class OAuthLoginButton extends ConsumerWidget {
|
|||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
return ElevatedButton.icon(
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: Theme.of(context).primaryColor.withAlpha(230),
|
||||
backgroundColor: context.primaryColor.withAlpha(230),
|
||||
padding: const EdgeInsets.symmetric(vertical: 12),
|
||||
),
|
||||
onPressed: onPressed,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue