Files
linkding-ios/lib/widgets/layout.dart
Juan Gilsanz Polo f1e5e3ec71 Router changes
2024-02-23 13:06:53 +01:00

52 lines
1.6 KiB
Dart

import 'package:animations/animations.dart';
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:go_router/go_router.dart';
import 'package:linkdy/widgets/system_overlay_style.dart';
import 'package:linkdy/config/app_screens.dart';
import 'package:linkdy/providers/router_provider.dart';
class Layout extends ConsumerWidget {
final GoRouterState state;
final Widget child;
const Layout({
Key? key,
required this.state,
required this.child,
}) : super(key: key);
@override
Widget build(BuildContext context, WidgetRef ref) {
final screenIndex = appScreens.map((s) => s.route).toList().indexOf("/${state.matchedLocation.split("/")[1]}");
return OverlayStyle(
child: Scaffold(
body: PageTransitionSwitcher(
duration: const Duration(milliseconds: 200),
transitionBuilder: (child, primaryAnimation, secondaryAnimation) => FadeThroughTransition(
animation: primaryAnimation,
secondaryAnimation: secondaryAnimation,
child: child,
),
child: child,
),
bottomNavigationBar: NavigationBar(
onDestinationSelected: (s) => ref.watch(routerProvider).replace(appScreens[s].route),
selectedIndex: screenIndex,
destinations: appScreens
.map(
(screen) => NavigationDestination(
icon: Icon(screen.icon),
label: screen.name,
),
)
.toList(),
),
),
);
}
}