more refactors
This commit is contained in:
@@ -1,11 +1,9 @@
|
||||
import 'package:auto_route/auto_route.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:immich_mobile/domain/interfaces/asset.interface.dart';
|
||||
import 'package:immich_mobile/domain/interfaces/renderlist.interface.dart';
|
||||
import 'package:immich_mobile/domain/utils/renderlist_providers.dart';
|
||||
import 'package:immich_mobile/presentation/components/grid/immich_asset_grid.state.dart';
|
||||
import 'package:immich_mobile/presentation/components/grid/immich_asset_grid.widget.dart';
|
||||
import 'package:immich_mobile/service_locator.dart';
|
||||
|
||||
@RoutePage()
|
||||
class HomePage extends StatelessWidget {
|
||||
@@ -16,8 +14,7 @@ class HomePage extends StatelessWidget {
|
||||
return Scaffold(
|
||||
body: BlocProvider(
|
||||
create: (_) => AssetGridCubit(
|
||||
renderStream: di<IRenderListRepository>().watchAll(),
|
||||
assetProvider: di<IAssetRepository>().getAll,
|
||||
renderListProvider: RenderListProvider.mainTimeline(),
|
||||
),
|
||||
child: const ImAssetGrid(),
|
||||
),
|
||||
|
||||
@@ -12,7 +12,7 @@ class LoginPageState {
|
||||
required this.isLoginSuccessful,
|
||||
});
|
||||
|
||||
factory LoginPageState.reset() {
|
||||
factory LoginPageState.initial() {
|
||||
return const LoginPageState(
|
||||
isServerValidated: false,
|
||||
isValidationInProgress: false,
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:immich_mobile/domain/interfaces/api/user_api.interface.dart';
|
||||
import 'package:immich_mobile/domain/interfaces/asset.interface.dart';
|
||||
import 'package:immich_mobile/domain/interfaces/store.interface.dart';
|
||||
import 'package:immich_mobile/domain/interfaces/user.interface.dart';
|
||||
@@ -8,7 +9,6 @@ import 'package:immich_mobile/domain/models/store.model.dart';
|
||||
import 'package:immich_mobile/domain/services/album_sync.service.dart';
|
||||
import 'package:immich_mobile/domain/services/asset_sync.service.dart';
|
||||
import 'package:immich_mobile/domain/services/login.service.dart';
|
||||
import 'package:immich_mobile/domain/services/user.service.dart';
|
||||
import 'package:immich_mobile/i18n/strings.g.dart';
|
||||
import 'package:immich_mobile/presentation/modules/login/models/login_page.model.dart';
|
||||
import 'package:immich_mobile/presentation/states/gallery_permission.state.dart';
|
||||
@@ -19,7 +19,7 @@ import 'package:immich_mobile/utils/mixins/log.mixin.dart';
|
||||
import 'package:immich_mobile/utils/snackbar_manager.dart';
|
||||
|
||||
class LoginPageCubit extends Cubit<LoginPageState> with LogMixin {
|
||||
LoginPageCubit() : super(LoginPageState.reset());
|
||||
LoginPageCubit() : super(LoginPageState.initial());
|
||||
|
||||
String _appendSchema(String url) {
|
||||
// Add schema if none is set
|
||||
@@ -68,8 +68,7 @@ class LoginPageCubit extends Cubit<LoginPageState> with LogMixin {
|
||||
url = await loginService.resolveEndpoint(uri);
|
||||
|
||||
di<IStoreRepository>().upsert(StoreKey.serverEndpoint, url);
|
||||
ServiceLocator.registerApiClient(url);
|
||||
ServiceLocator.registerPostValidationServices();
|
||||
await ServiceLocator.registerApiClient(url);
|
||||
ServiceLocator.registerPostGlobalStates();
|
||||
|
||||
// Fetch server features
|
||||
@@ -130,7 +129,7 @@ class LoginPageCubit extends Cubit<LoginPageState> with LogMixin {
|
||||
/// Set token to interceptor
|
||||
await di<ImApiClient>().init(accessToken: accessToken);
|
||||
|
||||
final user = await di<UserService>().getMyUser();
|
||||
final user = await di<IUserApiRepository>().getMyUser();
|
||||
if (user == null) {
|
||||
SnackbarManager.showError(t.login.error.error_login);
|
||||
return;
|
||||
@@ -152,6 +151,6 @@ class LoginPageCubit extends Cubit<LoginPageState> with LogMixin {
|
||||
}
|
||||
|
||||
void resetServerValidation() {
|
||||
emit(LoginPageState.reset());
|
||||
emit(LoginPageState.initial());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,73 +0,0 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
@immutable
|
||||
abstract class AppColors {
|
||||
const AppColors();
|
||||
|
||||
/// Blue color
|
||||
static const ColorScheme blueLight = ColorScheme(
|
||||
brightness: Brightness.light,
|
||||
primary: Color(0xff1145a4),
|
||||
onPrimary: Color(0xffffffff),
|
||||
primaryContainer: Color(0xffdae2ff),
|
||||
onPrimaryContainer: Color(0xff001848),
|
||||
secondary: Color(0xff4b73d3),
|
||||
onSecondary: Color(0xfffefbff),
|
||||
secondaryContainer: Color(0xffeef0ff),
|
||||
onSecondaryContainer: Color(0xff001848),
|
||||
tertiary: Color(0xff814b81),
|
||||
onTertiary: Color(0xfffffbff),
|
||||
tertiaryContainer: Color(0xffffd6fa),
|
||||
onTertiaryContainer: Color(0xff340439),
|
||||
error: Color(0xffba1a1a),
|
||||
onError: Color(0xfffffbff),
|
||||
errorContainer: Color(0xffffdad6),
|
||||
onErrorContainer: Color(0xff410002),
|
||||
surface: Color(0xFFF0EFF4),
|
||||
onSurface: Color(0xff1a1b21),
|
||||
onSurfaceVariant: Color(0xff444651),
|
||||
surfaceContainer: Color(0xfffefbff),
|
||||
surfaceContainerHighest: Color(0xffe0e2ef),
|
||||
outline: Color(0xff747782),
|
||||
outlineVariant: Color(0xffc4c6d3),
|
||||
shadow: Color(0xff000000),
|
||||
scrim: Color(0xff000000),
|
||||
inverseSurface: Color(0xff2f3036),
|
||||
onInverseSurface: Color(0xfff1f0f7),
|
||||
inversePrimary: Color(0xffb2c5ff),
|
||||
surfaceTint: Color(0xff06409f),
|
||||
);
|
||||
|
||||
static const ColorScheme blueDark = ColorScheme(
|
||||
brightness: Brightness.dark,
|
||||
primary: Color(0xffa9c7ff),
|
||||
onPrimary: Color(0xff001b3d),
|
||||
primaryContainer: Color(0xff00468c),
|
||||
onPrimaryContainer: Color(0xffd6e3ff),
|
||||
secondary: Color(0xffd6e3ff),
|
||||
onSecondary: Color(0xff001b3d),
|
||||
secondaryContainer: Color(0xff003063),
|
||||
onSecondaryContainer: Color(0xffd6e3ff),
|
||||
tertiary: Color(0xffeab4f6),
|
||||
onTertiary: Color(0xff310540),
|
||||
tertiaryContainer: Color(0xff61356e),
|
||||
onTertiaryContainer: Color(0xfffad7ff),
|
||||
error: Color(0xffffb4ab),
|
||||
onError: Color(0xff410002),
|
||||
errorContainer: Color(0xff93000a),
|
||||
onErrorContainer: Color(0xffffb4ab),
|
||||
surface: Color(0xFF15181C),
|
||||
onSurface: Color(0xffe2e2e9),
|
||||
onSurfaceVariant: Color(0xffc2c6d2),
|
||||
surfaceContainer: Color(0xff1a1e22),
|
||||
surfaceContainerHighest: Color(0xff424852),
|
||||
outline: Color(0xff8c919c),
|
||||
outlineVariant: Color(0xff424751),
|
||||
shadow: Color(0xff000000),
|
||||
scrim: Color(0xff000000),
|
||||
inverseSurface: Color(0xffe1e1e9),
|
||||
onInverseSurface: Color(0xff2e3036),
|
||||
inversePrimary: Color(0xff005db7),
|
||||
surfaceTint: Color(0xffa9c7ff),
|
||||
);
|
||||
}
|
||||
@@ -1,89 +0,0 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:immich_mobile/presentation/modules/theme/models/app_colors.model.dart';
|
||||
import 'package:immich_mobile/utils/extensions/material_state.extension.dart';
|
||||
|
||||
enum AppTheme {
|
||||
blue._(AppColors.blueLight, AppColors.blueDark),
|
||||
// Fallback color for dynamic theme for non-supported platforms
|
||||
dynamic._(AppColors.blueLight, AppColors.blueDark);
|
||||
|
||||
final ColorScheme lightSchema;
|
||||
final ColorScheme darkSchema;
|
||||
|
||||
const AppTheme._(this.lightSchema, this.darkSchema);
|
||||
|
||||
static ThemeData generateThemeData(ColorScheme color) {
|
||||
return ThemeData(
|
||||
colorScheme: color,
|
||||
primaryColor: color.primary,
|
||||
iconTheme: const IconThemeData(weight: 500, opticalSize: 24),
|
||||
navigationBarTheme: NavigationBarThemeData(
|
||||
backgroundColor: color.surfaceContainer,
|
||||
indicatorColor: color.primary,
|
||||
iconTheme: WidgetStateProperty.resolveWith(
|
||||
(Set<WidgetState> states) {
|
||||
if (states.isSelected) {
|
||||
return IconThemeData(color: color.onPrimary);
|
||||
}
|
||||
return IconThemeData(color: color.onSurface.withAlpha(175));
|
||||
},
|
||||
),
|
||||
),
|
||||
scaffoldBackgroundColor: color.surface,
|
||||
navigationRailTheme: NavigationRailThemeData(
|
||||
backgroundColor: color.surfaceContainer,
|
||||
elevation: 3,
|
||||
indicatorColor: color.primary,
|
||||
selectedIconTheme:
|
||||
IconThemeData(weight: 500, opticalSize: 24, color: color.onPrimary),
|
||||
unselectedIconTheme: IconThemeData(
|
||||
weight: 500,
|
||||
opticalSize: 24,
|
||||
color: color.onSurface.withAlpha(175),
|
||||
),
|
||||
),
|
||||
inputDecorationTheme: InputDecorationTheme(
|
||||
focusedBorder: OutlineInputBorder(
|
||||
borderSide: BorderSide(color: color.primary),
|
||||
borderRadius: const BorderRadius.all(Radius.circular(15)),
|
||||
),
|
||||
enabledBorder: OutlineInputBorder(
|
||||
borderSide: BorderSide(color: color.outlineVariant),
|
||||
borderRadius: const BorderRadius.all(Radius.circular(15)),
|
||||
),
|
||||
errorBorder: OutlineInputBorder(
|
||||
borderRadius: const BorderRadius.all(Radius.circular(15)),
|
||||
borderSide: BorderSide(color: color.error),
|
||||
),
|
||||
focusedErrorBorder: OutlineInputBorder(
|
||||
borderRadius: const BorderRadius.all(Radius.circular(15)),
|
||||
borderSide: BorderSide(color: color.error),
|
||||
),
|
||||
hintStyle: const TextStyle(
|
||||
fontSize: 16.0,
|
||||
fontWeight: FontWeight.normal,
|
||||
),
|
||||
),
|
||||
textSelectionTheme: TextSelectionThemeData(cursorColor: color.primary),
|
||||
sliderTheme: SliderThemeData(
|
||||
valueIndicatorColor:
|
||||
Color.alphaBlend(color.primary.withAlpha(80), color.onSurface)
|
||||
.withAlpha(240),
|
||||
),
|
||||
snackBarTheme: SnackBarThemeData(
|
||||
elevation: 4,
|
||||
behavior: SnackBarBehavior.floating,
|
||||
shape: const RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.all(Radius.circular(4.0)),
|
||||
),
|
||||
insetPadding: const EdgeInsets.fromLTRB(20.0, 5.0, 20.0, 25.0),
|
||||
backgroundColor:
|
||||
Color.alphaBlend(color.primary.withAlpha(80), color.onSurface)
|
||||
.withAlpha(240),
|
||||
actionTextColor: color.inversePrimary,
|
||||
contentTextStyle: TextStyle(color: color.onInverseSurface),
|
||||
closeIconColor: color.onInverseSurface,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:immich_mobile/domain/models/app_setting.model.dart';
|
||||
import 'package:immich_mobile/domain/services/app_setting.service.dart';
|
||||
import 'package:immich_mobile/presentation/modules/theme/models/app_theme.model.dart';
|
||||
|
||||
class AppThemeCubit extends Cubit<AppTheme> {
|
||||
final AppSettingService _appSettings;
|
||||
late final StreamSubscription _appSettingSubscription;
|
||||
|
||||
AppThemeCubit(this._appSettings) : super(AppTheme.blue) {
|
||||
_appSettingSubscription =
|
||||
_appSettings.watch(AppSetting.appTheme).listen((theme) => emit(theme));
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> close() {
|
||||
_appSettingSubscription.cancel();
|
||||
return super.close();
|
||||
}
|
||||
}
|
||||
@@ -1,43 +0,0 @@
|
||||
import 'package:dynamic_color/dynamic_color.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:immich_mobile/presentation/modules/theme/models/app_theme.model.dart';
|
||||
|
||||
class AppThemeBuilder extends StatelessWidget {
|
||||
const AppThemeBuilder({
|
||||
super.key,
|
||||
required this.theme,
|
||||
required this.builder,
|
||||
});
|
||||
|
||||
/// Current app theme to switch the theme data used
|
||||
final AppTheme theme;
|
||||
|
||||
/// Builds the child widget of this widget, providing a light and dark [ThemeData] based on the
|
||||
/// [theme] passed.
|
||||
final Widget Function(
|
||||
BuildContext context,
|
||||
ThemeData lightTheme,
|
||||
ThemeData darkTheme,
|
||||
) builder;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
// Static colors
|
||||
if (theme != AppTheme.dynamic) {
|
||||
final lightTheme = AppTheme.generateThemeData(theme.lightSchema);
|
||||
final darkTheme = AppTheme.generateThemeData(theme.darkSchema);
|
||||
|
||||
return builder(context, lightTheme, darkTheme);
|
||||
}
|
||||
|
||||
// Dynamic color builder
|
||||
return DynamicColorBuilder(builder: (lightDynamic, darkDynamic) {
|
||||
final lightTheme =
|
||||
AppTheme.generateThemeData(lightDynamic ?? theme.lightSchema);
|
||||
final darkTheme =
|
||||
AppTheme.generateThemeData(darkDynamic ?? theme.darkSchema);
|
||||
|
||||
return builder(context, lightTheme, darkTheme);
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user