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
@@ -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,
),
),
);
},
),
);
});
}
}