gascom/lib/widgets/bottom_nav.dart
Abdullah Salah 216efb8a83 first commit
2024-12-25 11:09:55 +03:00

104 lines
3.0 KiB
Dart

import 'package:flutter/material.dart';
import 'package:flutter_svg/svg.dart';
import 'package:gascom/constants/app_theme.dart';
import 'package:gascom/screens/follow_order_screen.dart';
import 'package:gascom/screens/generator_info_screen.dart';
import 'package:gascom/screens/home_screen.dart';
import 'package:persistent_bottom_nav_bar_v2/persistent_bottom_nav_bar_v2.dart';
class BottomNav extends StatelessWidget {
const BottomNav({
super.key,
});
@override
Widget build(BuildContext context) {
return PersistentTabView(
controller: PersistentTabController(initialIndex: 0),
resizeToAvoidBottomInset: false,
navBarHeight: 70,
tabs: [
tabConfig(
context,
const HomeScreen(),
"home",
"assets/svgs/home_filled.svg",
"assets/svgs/home.svg",
"Home Active",
"Home Inactive",
"الرئيسية",
),
tabConfig(
context,
const GeneratorInfoScreen(),
"generator_info",
"assets/svgs/generator_filled.svg",
"assets/svgs/generator.svg",
"Generator Info Active",
"Generator Info Inactive",
"معلومات المولدة",
),
tabConfig(
context,
const FollowOrderScreen(),
"follow_order",
"assets/svgs/van_filled.svg",
"assets/svgs/van.svg",
"Follow Order Active",
"Follow Order Inactive",
"تتبع الطلب",
),
],
navBarBuilder: (navBarConfig) => Style6BottomNavBar(
navBarConfig: navBarConfig,
navBarDecoration: NavBarDecoration(
color: AppTheme.secondaryColor,
padding: EdgeInsets.all(10),
boxShadow: [
BoxShadow(
color: Colors.black.withOpacity(0.15),
blurRadius: 10,
spreadRadius: 1,
offset: const Offset(0, 0),
),
],
),
),
);
}
PersistentTabConfig tabConfig(
BuildContext context,
Widget screen,
String initialRoute,
String activeIcon,
String inactiveIcon,
String activeSemanticsLabel,
String inactiveSemanticsLabel,
String title,
) {
return PersistentTabConfig(
screen: screen,
navigatorConfig: NavigatorConfig(
initialRoute: initialRoute,
),
item: ItemConfig(
icon: Padding(
padding: const EdgeInsets.only(top: 4, left: 4, right: 4),
child: SvgPicture.asset(
activeIcon,
semanticsLabel: activeSemanticsLabel,
),
),
inactiveIcon: SvgPicture.asset(
inactiveIcon,
semanticsLabel: inactiveSemanticsLabel,
),
activeForegroundColor: AppTheme.primaryColor,
inactiveForegroundColor: AppTheme.primaryColor,
textStyle: Theme.of(context).textTheme.bodySmall ?? TextStyle(),
title: title,
)
);
}
}