more refactors and logs page handling

This commit is contained in:
shenlong-tanwen
2024-10-23 02:30:46 +05:30
parent 8f47645cdb
commit a0afea04d8
90 changed files with 2386 additions and 584 deletions
@@ -21,7 +21,6 @@ class SplashScreenWrapperPage extends AutoRouter implements AutoRouteWrapper {
}
@RoutePage()
// ignore: prefer-single-widget-per-file
class SplashScreenPage extends StatefulWidget {
const SplashScreenPage({super.key});
@@ -63,7 +62,7 @@ class _SplashScreenState extends State<SplashScreenPage>
future: di.allReady(),
builder: (_, snap) {
if (snap.hasData) {
_tryLogin();
unawaited(_tryLogin());
} else if (snap.hasError) {
log.wtf(
"Error while initializing the app",
@@ -75,7 +74,7 @@ class _SplashScreenState extends State<SplashScreenPage>
return Center(
child: RotationTransition(
turns: _animationController,
child: const ImLogo(width: 100),
child: const ImLogo(dimension: 100),
),
);
},
@@ -2,7 +2,14 @@ import 'package:auto_route/auto_route.dart';
import 'package:flutter/material.dart';
import 'package:flutter_adaptive_scaffold/flutter_adaptive_scaffold.dart';
import 'package:immich_mobile/i18n/strings.g.dart';
import 'package:immich_mobile/presentation/components/common/immich_navigation_rail.dart';
import 'package:immich_mobile/presentation/components/common/user_avatar.widget.dart';
import 'package:immich_mobile/presentation/components/image/immich_logo.widget.dart';
import 'package:immich_mobile/presentation/router/router.dart';
import 'package:immich_mobile/presentation/states/current_user.state.dart';
import 'package:immich_mobile/service_locator.dart';
import 'package:immich_mobile/utils/constants/size_constants.dart';
import 'package:immich_mobile/utils/extensions/build_context.extension.dart';
import 'package:material_symbols_icons/symbols.dart';
@RoutePage()
@@ -24,7 +31,7 @@ class TabControllerPage extends StatelessWidget {
return PopScope(
canPop: tabsRouter.activeIndex == 0,
onPopInvokedWithResult: (didPop, _) =>
!didPop ? tabsRouter.setActiveIndex(0) : null,
didPop ? null : tabsRouter.setActiveIndex(0),
child: _TabControllerAdaptiveScaffold(
body: (ctxx) => child,
selectedIndex: tabsRouter.activeIndex,
@@ -80,53 +87,117 @@ class _TabControllerAdaptiveScaffold extends StatelessWidget {
return Scaffold(
body: AdaptiveLayout(
// No animation on layout change
transitionDuration: Duration.zero,
primaryNavigation: SlotLayout(
config: <Breakpoint, SlotLayoutConfig>{
Breakpoints.mediumAndUp: SlotLayout.from(
key: const Key(
'_TabControllerAdaptiveScaffold Primary Navigation Medium',
),
builder: (_) => AdaptiveScaffold.standardNavigationRail(
selectedIndex: selectedIndex,
builder: (_) => _ImNavigationRailBuilder(
destinations: destinations
.map((NavigationDestination destination) =>
AdaptiveScaffold.toRailDestination(destination))
.toList(),
onDestinationSelected: onSelectedIndexChange,
selectedIndex: selectedIndex,
backgroundColor: navRailTheme.backgroundColor,
leading: ImUserAvatar(
user: di<CurrentUserProvider>().value,
dimension: SizeConstants.m,
radius: SizeConstants.m,
),
trailing: ImLogo(dimension: SizeConstants.xm),
onDestinationSelected: onSelectedIndexChange,
selectedIconTheme: navRailTheme.selectedIconTheme,
unselectedIconTheme: navRailTheme.unselectedIconTheme,
selectedLabelTextStyle: navRailTheme.selectedLabelTextStyle,
unSelectedLabelTextStyle: navRailTheme.unselectedLabelTextStyle,
),
key: const Key(
'_TabControllerAdaptiveScaffold Primary Navigation Medium',
),
),
},
),
body: SlotLayout(
config: {
Breakpoints.standard: SlotLayout.from(
key: const Key('_TabControllerAdaptiveScaffold Body'),
builder: body,
key: const Key('_TabControllerAdaptiveScaffold Body'),
),
},
),
// No animation on layout change
transitionDuration: Duration.zero,
),
bottomNavigationBar: SlotLayout(
config: <Breakpoint, SlotLayoutConfig>{
Breakpoints.small: SlotLayout.from(
builder: (_) => AdaptiveScaffold.standardBottomNavigationBar(
destinations: destinations,
currentIndex: selectedIndex,
onDestinationSelected: onSelectedIndexChange,
),
key: const Key(
'_TabControllerAdaptiveScaffold Bottom Navigation Small',
),
builder: (_) => AdaptiveScaffold.standardBottomNavigationBar(
currentIndex: selectedIndex,
destinations: destinations,
onDestinationSelected: onSelectedIndexChange,
),
),
},
),
);
}
}
class _ImNavigationRailBuilder extends StatelessWidget {
final List<NavigationRailDestination> destinations;
final int? selectedIndex;
final Color? backgroundColor;
final Function(int)? onDestinationSelected;
final IconThemeData? selectedIconTheme;
final IconThemeData? unselectedIconTheme;
final TextStyle? selectedLabelTextStyle;
final TextStyle? unSelectedLabelTextStyle;
final Widget? leading;
final Widget? trailing;
const _ImNavigationRailBuilder({
required this.destinations,
this.selectedIndex,
this.backgroundColor,
this.leading,
this.trailing,
this.onDestinationSelected,
this.selectedIconTheme,
this.unselectedIconTheme,
this.selectedLabelTextStyle,
this.unSelectedLabelTextStyle,
});
@override
Widget build(BuildContext context) {
return Builder(builder: (BuildContext _) {
return SizedBox(
width: 72,
height: context.height,
child: LayoutBuilder(
builder: (BuildContext _, BoxConstraints constraints) {
return ConstrainedBox(
constraints: BoxConstraints(minHeight: constraints.maxHeight),
child: IntrinsicHeight(
child: ImNavigationRail(
backgroundColor: backgroundColor,
leading: leading,
trailing: trailing,
destinations: destinations,
selectedIndex: selectedIndex,
onDestinationSelected: onDestinationSelected,
labelType: NavigationRailLabelType.none,
unselectedLabelTextStyle: unSelectedLabelTextStyle,
selectedLabelTextStyle: selectedLabelTextStyle,
unselectedIconTheme: unselectedIconTheme,
selectedIconTheme: selectedIconTheme,
),
),
);
},
),
);
});
}
}
@@ -2,7 +2,7 @@ import 'package:auto_route/auto_route.dart';
import 'package:immich_mobile/presentation/modules/home/pages/home.page.dart';
import 'package:immich_mobile/presentation/modules/library/pages/library.page.dart';
import 'package:immich_mobile/presentation/modules/login/pages/login.page.dart';
import 'package:immich_mobile/presentation/modules/logs/pages/log.page.dart';
import 'package:immich_mobile/presentation/modules/logs/pages/logs.page.dart';
import 'package:immich_mobile/presentation/modules/search/pages/search.page.dart';
import 'package:immich_mobile/presentation/modules/settings/pages/about_settings.page.dart';
import 'package:immich_mobile/presentation/modules/settings/pages/advance_settings.page.dart';
@@ -29,12 +29,15 @@ class AppRouter extends RootStackRouter {
List<AutoRoute> get routes => [
AutoRoute(
page: SplashScreenWrapperRoute.page,
initial: true,
children: [
AutoRoute(page: SplashScreenRoute.page, initial: true),
AutoRoute(page: LoginRoute.page),
],
initial: true,
),
AutoRoute(page: LogsWrapperRoute.page, children: [
AutoRoute(page: LogsRoute.page),
]),
AutoRoute(page: LogsRoute.page),
AutoRoute(page: TabControllerRoute.page, children: [
AutoRoute(page: HomeRoute.page),