Files
abawo-bt-app/lib/widgets/app_shell.dart

69 lines
1.9 KiB
Dart

import 'package:flutter/material.dart';
import 'package:go_router/go_router.dart';
class AppShell extends StatelessWidget {
const AppShell({
required this.child,
required this.currentLocation,
super.key,
});
final Widget child;
final String currentLocation;
@override
Widget build(BuildContext context) {
final selectedIndex = currentLocation.startsWith('/settings') ? 1 : 0;
return Scaffold(
body: DecoratedBox(
decoration: BoxDecoration(
gradient: LinearGradient(
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
colors: [
Theme.of(context).scaffoldBackgroundColor,
Theme.of(context).colorScheme.surface,
],
),
),
child: SafeArea(bottom: false, child: child),
),
bottomNavigationBar: SafeArea(
top: false,
child: Padding(
padding: const EdgeInsets.fromLTRB(16, 0, 16, 16),
child: ClipRRect(
borderRadius: BorderRadius.circular(24),
child: NavigationBar(
selectedIndex: selectedIndex,
onDestinationSelected: (index) {
switch (index) {
case 0:
context.go('/devices');
break;
case 1:
context.go('/settings');
break;
}
},
destinations: const [
NavigationDestination(
icon: Icon(Icons.bluetooth_searching_outlined),
selectedIcon: Icon(Icons.bluetooth_searching),
label: 'Devices',
),
NavigationDestination(
icon: Icon(Icons.settings_outlined),
selectedIcon: Icon(Icons.settings),
label: 'Settings',
),
],
),
),
),
),
);
}
}