|
|
|
|
@ -11,35 +11,58 @@ class TabControllerPage extends ConsumerWidget {
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
Widget build(BuildContext context, WidgetRef ref) {
|
|
|
|
|
final multiselectEnabled = ref.watch(multiselectProvider);
|
|
|
|
|
return AutoTabsRouter(
|
|
|
|
|
routes: [
|
|
|
|
|
const HomeRoute(),
|
|
|
|
|
SearchRoute(),
|
|
|
|
|
const SharingRoute(),
|
|
|
|
|
const LibraryRoute()
|
|
|
|
|
],
|
|
|
|
|
builder: (context, child, animation) {
|
|
|
|
|
final tabsRouter = AutoTabsRouter.of(context);
|
|
|
|
|
final appRouter = AutoRouter.of(context);
|
|
|
|
|
return WillPopScope(
|
|
|
|
|
onWillPop: () async {
|
|
|
|
|
bool atHomeTab = tabsRouter.activeIndex == 0;
|
|
|
|
|
if (!atHomeTab) {
|
|
|
|
|
tabsRouter.setActiveIndex(0);
|
|
|
|
|
} else {
|
|
|
|
|
appRouter.navigateBack();
|
|
|
|
|
}
|
|
|
|
|
return atHomeTab;
|
|
|
|
|
|
|
|
|
|
navigationRail(TabsRouter tabsRouter) {
|
|
|
|
|
return NavigationRail(
|
|
|
|
|
labelType: NavigationRailLabelType.all,
|
|
|
|
|
selectedIndex: tabsRouter.activeIndex,
|
|
|
|
|
onDestinationSelected: (index) {
|
|
|
|
|
HapticFeedback.selectionClick();
|
|
|
|
|
tabsRouter.setActiveIndex(index);
|
|
|
|
|
},
|
|
|
|
|
child: Scaffold(
|
|
|
|
|
body: FadeTransition(
|
|
|
|
|
opacity: animation,
|
|
|
|
|
child: child,
|
|
|
|
|
selectedIconTheme: IconThemeData(
|
|
|
|
|
color: Theme.of(context).primaryColor,
|
|
|
|
|
),
|
|
|
|
|
bottomNavigationBar: multiselectEnabled
|
|
|
|
|
? null
|
|
|
|
|
: BottomNavigationBar(
|
|
|
|
|
selectedLabelTextStyle: TextStyle(
|
|
|
|
|
color: Theme.of(context).primaryColor,
|
|
|
|
|
),
|
|
|
|
|
useIndicator: false,
|
|
|
|
|
destinations: [
|
|
|
|
|
NavigationRailDestination(
|
|
|
|
|
padding: EdgeInsets.only(
|
|
|
|
|
top: MediaQuery.of(context).padding.top + 4,
|
|
|
|
|
left: 4,
|
|
|
|
|
right: 4,
|
|
|
|
|
bottom: 4,
|
|
|
|
|
),
|
|
|
|
|
icon: const Icon(Icons.photo_outlined),
|
|
|
|
|
selectedIcon: const Icon(Icons.photo),
|
|
|
|
|
label: const Text('tab_controller_nav_photos').tr(),
|
|
|
|
|
),
|
|
|
|
|
NavigationRailDestination(
|
|
|
|
|
padding: const EdgeInsets.all(4),
|
|
|
|
|
icon: const Icon(Icons.search_rounded),
|
|
|
|
|
selectedIcon: const Icon(Icons.search),
|
|
|
|
|
label: const Text('tab_controller_nav_search').tr(),
|
|
|
|
|
),
|
|
|
|
|
NavigationRailDestination(
|
|
|
|
|
padding: const EdgeInsets.all(4),
|
|
|
|
|
icon: const Icon(Icons.share_rounded),
|
|
|
|
|
selectedIcon: const Icon(Icons.share),
|
|
|
|
|
label: const Text('tab_controller_nav_sharing').tr(),
|
|
|
|
|
),
|
|
|
|
|
NavigationRailDestination(
|
|
|
|
|
padding: const EdgeInsets.all(4),
|
|
|
|
|
icon: const Icon(Icons.photo_album_outlined),
|
|
|
|
|
selectedIcon: const Icon(Icons.photo_album),
|
|
|
|
|
label: const Text('tab_controller_nav_library').tr(),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bottomNavigationBar(TabsRouter tabsRouter) {
|
|
|
|
|
return BottomNavigationBar(
|
|
|
|
|
selectedLabelStyle: const TextStyle(
|
|
|
|
|
fontSize: 13,
|
|
|
|
|
fontWeight: FontWeight.w600,
|
|
|
|
|
@ -75,8 +98,63 @@ class TabControllerPage extends ConsumerWidget {
|
|
|
|
|
activeIcon: const Icon(Icons.photo_album_rounded),
|
|
|
|
|
)
|
|
|
|
|
],
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
final multiselectEnabled = ref.watch(multiselectProvider);
|
|
|
|
|
return AutoTabsRouter(
|
|
|
|
|
routes: [
|
|
|
|
|
const HomeRoute(),
|
|
|
|
|
SearchRoute(),
|
|
|
|
|
const SharingRoute(),
|
|
|
|
|
const LibraryRoute()
|
|
|
|
|
],
|
|
|
|
|
builder: (context, child, animation) {
|
|
|
|
|
final tabsRouter = AutoTabsRouter.of(context);
|
|
|
|
|
final appRouter = AutoRouter.of(context);
|
|
|
|
|
return WillPopScope(
|
|
|
|
|
onWillPop: () async {
|
|
|
|
|
bool atHomeTab = tabsRouter.activeIndex == 0;
|
|
|
|
|
if (!atHomeTab) {
|
|
|
|
|
tabsRouter.setActiveIndex(0);
|
|
|
|
|
} else {
|
|
|
|
|
appRouter.navigateBack();
|
|
|
|
|
}
|
|
|
|
|
return atHomeTab;
|
|
|
|
|
},
|
|
|
|
|
child: LayoutBuilder(
|
|
|
|
|
builder: (context, constraints) {
|
|
|
|
|
const medium = 600;
|
|
|
|
|
final Widget? bottom;
|
|
|
|
|
final Widget body;
|
|
|
|
|
if (constraints.maxWidth < medium) {
|
|
|
|
|
// Normal phone width
|
|
|
|
|
bottom = bottomNavigationBar(tabsRouter);
|
|
|
|
|
body = FadeTransition(
|
|
|
|
|
opacity: animation,
|
|
|
|
|
child: child,
|
|
|
|
|
);
|
|
|
|
|
} else {
|
|
|
|
|
// Medium tablet width
|
|
|
|
|
bottom = null;
|
|
|
|
|
body = Row(
|
|
|
|
|
children: [
|
|
|
|
|
navigationRail(tabsRouter),
|
|
|
|
|
Expanded(
|
|
|
|
|
child: FadeTransition(
|
|
|
|
|
opacity: animation,
|
|
|
|
|
child: child,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
);
|
|
|
|
|
} return Scaffold(
|
|
|
|
|
body: body,
|
|
|
|
|
bottomNavigationBar: multiselectEnabled
|
|
|
|
|
? null
|
|
|
|
|
: bottom,
|
|
|
|
|
);
|
|
|
|
|
},),
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
);
|
|
|
|
|
|