| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 |
- import 'package:flutter/material.dart';
- import '../../core/responsive.dart';
- class ResponsiveScaffold extends StatelessWidget {
- final String? title;
- final List<Widget>? actions;
- final Widget body;
- final Widget? drawer;
- final int? selectedIndex;
- final ValueChanged<int>? onNavigationChanged;
- final List<NavigationDestination>? navigationDestinations;
- const ResponsiveScaffold({
- super.key,
- this.title,
- this.actions,
- required this.body,
- this.drawer,
- this.selectedIndex,
- this.onNavigationChanged,
- this.navigationDestinations,
- });
- @override
- Widget build(BuildContext context) {
- if (ResponsiveBreakpoints.isDesktop(context)) {
- return Scaffold(
- appBar: AppBar(title: Text(title ?? ''), actions: actions),
- drawer: drawer is Drawer ? drawer as Drawer : null,
- body: Row(
- children: [
- if (navigationDestinations != null)
- NavigationRail(
- selectedIndex: selectedIndex ?? 0,
- onDestinationSelected: onNavigationChanged ?? (_) {},
- labelType: NavigationRailLabelType.all,
- destinations: navigationDestinations!.map((d) => NavigationRailDestination(
- icon: d.icon,
- selectedIcon: d.selectedIcon,
- label: Text(d.label ?? ''),
- )).toList(),
- ),
- Expanded(child: body),
- ],
- ),
- );
- }
- return Scaffold(
- appBar: AppBar(title: Text(title ?? ''), actions: actions),
- drawer: drawer,
- body: body,
- bottomNavigationBar: navigationDestinations != null && !ResponsiveBreakpoints.isDesktop(context)
- ? NavigationBar(
- selectedIndex: selectedIndex ?? 0,
- onDestinationSelected: onNavigationChanged ?? (_) {},
- destinations: navigationDestinations!,
- )
- : null,
- );
- }
- }
|