ui backbone
This commit is contained in:
parent
3e374d24f6
commit
b7045fc242
24 changed files with 918 additions and 73 deletions
|
@ -12,6 +12,8 @@ abstract class AppSetup {
|
|||
static Future<void> initialise() async {
|
||||
WidgetsFlutterBinding.ensureInitialized();
|
||||
|
||||
await _setupStrings();
|
||||
|
||||
await SystemChrome.setPreferredOrientations([
|
||||
DeviceOrientation.portraitUp,
|
||||
DeviceOrientation.portraitDown,
|
||||
|
@ -38,7 +40,7 @@ abstract class AppSetup {
|
|||
return supportedLocales.first;
|
||||
}
|
||||
|
||||
static Future<void> setupStrings() async {
|
||||
static Future<void> _setupStrings() async {
|
||||
await Strings.load(resolveLocale(WidgetsBinding.instance.window.locales, supportedLocales));
|
||||
}
|
||||
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/widgets.dart';
|
||||
import 'package:mc_gallery/features/core/services/logging_service.dart';
|
||||
import 'package:mc_gallery/l10n/generated/l10n.dart';
|
||||
|
||||
import '/l10n/generated/l10n.dart';
|
||||
import '../data/enums/view_model_state.dart';
|
||||
import '../services/logging_service.dart';
|
||||
|
||||
abstract class BaseViewModel<E extends Object?> extends ChangeNotifier {
|
||||
abstract class BaseViewModel<T extends Object?> extends ChangeNotifier {
|
||||
final ValueNotifier<bool> _isInitialised = ValueNotifier(false);
|
||||
ValueListenable<bool> get isInitialised => _isInitialised;
|
||||
|
||||
|
@ -23,12 +23,11 @@ abstract class BaseViewModel<E extends Object?> extends ChangeNotifier {
|
|||
String get errorMessage => _errorMessage ?? strings.somethingWentWrong;
|
||||
|
||||
@mustCallSuper
|
||||
void initialise(DisposableBuildContext disposableBuildContext, bool Function() mounted,
|
||||
[E? arguments]) {
|
||||
void initialise(bool Function() mounted, [T? arguments]) {
|
||||
_mounted = mounted;
|
||||
_isInitialised.value = true;
|
||||
_state.value = ViewModelState.isInitialised;
|
||||
_loggingService.successfulInit(location: runtimeType.runtimeType.toString());
|
||||
_loggingService.successfulInit(location: runtimeType.toString());
|
||||
}
|
||||
|
||||
void setBusy(bool isBusy) {
|
||||
|
@ -56,7 +55,7 @@ abstract class BaseViewModel<E extends Object?> extends ChangeNotifier {
|
|||
@override
|
||||
void dispose() {
|
||||
super.dispose();
|
||||
_loggingService.successfulDispose(location: runtimeType.runtimeType.toString());
|
||||
_loggingService.successfulDispose(location: runtimeType.toString());
|
||||
}
|
||||
|
||||
late final bool Function() _mounted;
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:mc_gallery/features/home/views/gallery/gallery_view.dart';
|
||||
import 'package:mc_gallery/features/home/views/image_carousel/image_carousel_view.dart';
|
||||
|
||||
import '../../views/error_page_view.dart';
|
||||
import 'routes.dart';
|
||||
|
@ -14,12 +15,21 @@ class McgRouter {
|
|||
key: state.pageKey,
|
||||
child: ErrorPageView(error: state.error),
|
||||
),
|
||||
// TODO Add Redirect
|
||||
//todo(mehul): Add Redirect
|
||||
routes: [
|
||||
GoRoute(
|
||||
path: Routes.home.routePath,
|
||||
name: Routes.home.routeName,
|
||||
builder: (context, _) => const GalleryView(),
|
||||
routes: [
|
||||
GoRoute(
|
||||
path: Routes.imageCarousel.routePath,
|
||||
name: Routes.imageCarousel.routeName,
|
||||
builder: (context, state) => ImageCarouselView(
|
||||
imageCarouselViewArguments: state.extra as ImageCarouselViewArguments,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
);
|
||||
|
|
|
@ -4,7 +4,7 @@ enum Routes {
|
|||
routeName: 'Home',
|
||||
)),
|
||||
imageCarousel(RoutesInfo(
|
||||
routePath: '/image_carousel',
|
||||
routePath: 'image_carousel',
|
||||
routeName: 'Image Carousel',
|
||||
));
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue