refactor: asset grid
This commit is contained in:
@@ -1,6 +1,10 @@
|
||||
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/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 {
|
||||
@@ -8,6 +12,14 @@ class HomePage extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return const Scaffold(body: ImAssetGrid());
|
||||
return Scaffold(
|
||||
body: BlocProvider(
|
||||
create: (_) => ImmichAssetGridCubit(
|
||||
renderStream: di<IAssetRepository>().watchRenderList(),
|
||||
assetProvider: di<IAssetRepository>().fetchAssets,
|
||||
),
|
||||
child: const ImAssetGrid(),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,6 +53,12 @@ class _LoginPageState extends State<LoginPage>
|
||||
_passwordController.text = 'demo';
|
||||
}
|
||||
|
||||
void _onLoginPageStateChange(BuildContext context, LoginPageState state) {
|
||||
if (state.isLoginSuccessful) {
|
||||
context.replaceRoute(const TabControllerRoute());
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final PreferredSizeWidget? appBar;
|
||||
@@ -154,11 +160,7 @@ class _LoginPageState extends State<LoginPage>
|
||||
}
|
||||
|
||||
return BlocListener<LoginPageCubit, LoginPageState>(
|
||||
listener: (_, loginState) {
|
||||
if (loginState.isLoginSuccessful) {
|
||||
context.replaceRoute(const TabControllerRoute());
|
||||
}
|
||||
},
|
||||
listener: _onLoginPageStateChange,
|
||||
child: Scaffold(
|
||||
resizeToAvoidBottomInset: false,
|
||||
appBar: appBar,
|
||||
|
||||
@@ -49,15 +49,23 @@ class LoginForm extends StatelessWidget {
|
||||
}
|
||||
}
|
||||
|
||||
class _ServerForm extends StatelessWidget {
|
||||
class _ServerForm extends StatefulWidget {
|
||||
final TextEditingController controller;
|
||||
final GlobalKey<FormState> _formKey = GlobalKey();
|
||||
|
||||
_ServerForm({required this.controller});
|
||||
const _ServerForm({required this.controller});
|
||||
|
||||
@override
|
||||
State createState() => _ServerFormState();
|
||||
}
|
||||
|
||||
class _ServerFormState extends State<_ServerForm> {
|
||||
final GlobalKey<FormState> _formKey = GlobalKey();
|
||||
|
||||
Future<void> _validateForm(BuildContext context) async {
|
||||
if (_formKey.currentState?.validate() == true) {
|
||||
await context.read<LoginPageCubit>().validateServer(controller.text);
|
||||
await context
|
||||
.read<LoginPageCubit>()
|
||||
.validateServer(widget.controller.text);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -72,7 +80,7 @@ class _ServerForm extends StatelessWidget {
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
ImTextFormField(
|
||||
controller: controller,
|
||||
controller: widget.controller,
|
||||
label: context.t.login.label.endpoint,
|
||||
validator: context.read<LoginPageCubit>().validateServerUrl,
|
||||
autoFillHints: const [AutofillHints.url],
|
||||
|
||||
@@ -22,6 +22,7 @@ class SettingsWrapperPage extends StatelessWidget {
|
||||
}
|
||||
|
||||
@RoutePage()
|
||||
// ignore: prefer-single-widget-per-file
|
||||
class SettingsPage extends StatelessWidget {
|
||||
const SettingsPage({super.key});
|
||||
|
||||
@@ -35,9 +36,7 @@ class SettingsPage extends StatelessWidget {
|
||||
final section = SettingSection.values.elementAt(index);
|
||||
return ListTile(
|
||||
title: Text(context.t[section.labelKey]),
|
||||
onTap: () {
|
||||
context.navigateRoot(section.destination);
|
||||
},
|
||||
onTap: () => context.navigateRoot(section.destination),
|
||||
leading: Icon(section.icon),
|
||||
);
|
||||
},
|
||||
|
||||
@@ -7,7 +7,7 @@ import 'package:immich_mobile/presentation/modules/theme/models/app_theme.model.
|
||||
|
||||
class AppThemeCubit extends Cubit<AppTheme> {
|
||||
final AppSettingService _appSettings;
|
||||
StreamSubscription? _appSettingSubscription;
|
||||
late final StreamSubscription _appSettingSubscription;
|
||||
|
||||
AppThemeCubit(this._appSettings) : super(AppTheme.blue) {
|
||||
_appSettingSubscription = _appSettings
|
||||
@@ -17,7 +17,7 @@ class AppThemeCubit extends Cubit<AppTheme> {
|
||||
|
||||
@override
|
||||
Future<void> close() {
|
||||
_appSettingSubscription?.cancel();
|
||||
_appSettingSubscription.cancel();
|
||||
return super.close();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user