import 'package:flutter/material.dart'; import '../../core/responsive.dart'; class ResponsiveScaffold extends StatelessWidget { final String? title; final List? actions; final Widget body; final Widget? drawer; final int? selectedIndex; final ValueChanged? onNavigationChanged; final List? 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, ); } }