forked from eatvio/eatvio_app
go router + bottom nav bar
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import 'package:eatvio_app/core/app_export.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
|
||||
// ignore: must_be_immutable
|
||||
class CustomAppBar extends StatelessWidget implements PreferredSizeWidget {
|
||||
@@ -30,7 +31,10 @@ class CustomAppBar extends StatelessWidget implements PreferredSizeWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return AppBar(
|
||||
elevation: 0,
|
||||
systemOverlayStyle: SystemUiOverlayStyle(
|
||||
statusBarIconBrightness: Brightness.dark,
|
||||
statusBarBrightness: Brightness.light,
|
||||
),
|
||||
toolbarHeight: height ?? 56.v,
|
||||
automaticallyImplyLeading: false,
|
||||
backgroundColor: Colors.transparent,
|
||||
|
||||
@@ -2,6 +2,106 @@ import 'package:eatvio_app/core/app_export.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:eatvio_app/widgets/app_bar/appbar_title_circleimage.dart';
|
||||
import 'package:eatvio_app/widgets/custom_navigation_menu.dart';
|
||||
import 'package:flutter_svg/flutter_svg.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
|
||||
int currentBottomNavBarIndex = 0;
|
||||
|
||||
class BottomNavigationBarWidget extends StatefulWidget {
|
||||
final Widget child;
|
||||
|
||||
const BottomNavigationBarWidget({
|
||||
super.key,
|
||||
required this.child,
|
||||
});
|
||||
|
||||
@override
|
||||
State<BottomNavigationBarWidget> createState() => _BottomNavigationBarWidgetState();
|
||||
}
|
||||
|
||||
class _BottomNavigationBarWidgetState extends State<BottomNavigationBarWidget> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
body: widget.child,
|
||||
bottomNavigationBar: BottomNavigationBar(
|
||||
type: BottomNavigationBarType.fixed,
|
||||
onTap: (index) {
|
||||
if (currentBottomNavBarIndex != index) {
|
||||
setState(() {
|
||||
currentBottomNavBarIndex = index;
|
||||
});
|
||||
}
|
||||
switch (currentBottomNavBarIndex) {
|
||||
case 0:
|
||||
GoRouter.of(context).replace('/my-profile-screen');
|
||||
break;
|
||||
case 1:
|
||||
GoRouter.of(context).replace('/feed-screen');
|
||||
break;
|
||||
case 2:
|
||||
GoRouter.of(context).replace('/diary-screen');
|
||||
break;
|
||||
case 3:
|
||||
GoRouter.of(context).replace('/chat-select-screen');
|
||||
break;
|
||||
case 4:
|
||||
break;
|
||||
case 5:
|
||||
final RenderBox overlay = Overlay.of(context).context.findRenderObject() as RenderBox;
|
||||
final size = overlay.size;
|
||||
showMenu(
|
||||
context: context,
|
||||
color: Colors.white,
|
||||
shadowColor: Colors.white,
|
||||
surfaceTintColor: Colors.white,
|
||||
items: [
|
||||
PopupMenuItem(
|
||||
child: CustomNavigationMenu(),
|
||||
)
|
||||
],
|
||||
position: RelativeRect.fromLTRB(size.width, size.height, 0, 0),
|
||||
);
|
||||
break;
|
||||
}
|
||||
},
|
||||
selectedFontSize: 12,
|
||||
unselectedFontSize: 12,
|
||||
currentIndex: currentBottomNavBarIndex,
|
||||
items: [
|
||||
BottomNavigationBarItem(
|
||||
label: '',
|
||||
icon: SvgPicture.asset(ImageConstant.imgLogo),
|
||||
),
|
||||
BottomNavigationBarItem(
|
||||
label: 'Лента',
|
||||
icon: SvgPicture.asset(ImageConstant.imgFeed),
|
||||
),
|
||||
BottomNavigationBarItem(
|
||||
label: "diary".tr,
|
||||
icon: SvgPicture.asset(ImageConstant.imgDiary),
|
||||
),
|
||||
BottomNavigationBarItem(
|
||||
label: "chat".tr,
|
||||
icon: SvgPicture.asset(ImageConstant.imgChat),
|
||||
),
|
||||
BottomNavigationBarItem(
|
||||
label: '',
|
||||
icon: SvgPicture.asset(ImageConstant.imgBell),
|
||||
),
|
||||
BottomNavigationBarItem(
|
||||
label: '',
|
||||
icon: Image.asset(
|
||||
ImageConstant.imgEllipse1,
|
||||
width: 32,
|
||||
height: 32,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// ignore: must_be_immutable
|
||||
class CustomBottomBar extends StatefulWidget {
|
||||
@@ -18,33 +118,38 @@ class CustomBottomBarState extends State<CustomBottomBar> {
|
||||
|
||||
List<BottomMenuModel> bottomMenuList = [
|
||||
BottomMenuModel(
|
||||
icon: ImageConstant.imgLogo,
|
||||
activeIcon: ImageConstant.imgLogo,
|
||||
type: BottomBarEnum.tf,
|
||||
image: false),
|
||||
icon: ImageConstant.imgLogo,
|
||||
activeIcon: ImageConstant.imgLogo,
|
||||
type: BottomBarEnum.tf,
|
||||
image: false,
|
||||
),
|
||||
BottomMenuModel(
|
||||
icon: ImageConstant.imgFeed,
|
||||
activeIcon: ImageConstant.imgFeed,
|
||||
title: "Лента",
|
||||
type: BottomBarEnum.tf,
|
||||
image: false),
|
||||
icon: ImageConstant.imgFeed,
|
||||
activeIcon: ImageConstant.imgFeed,
|
||||
title: "Лента",
|
||||
type: BottomBarEnum.tf,
|
||||
image: false,
|
||||
),
|
||||
BottomMenuModel(
|
||||
icon: ImageConstant.imgDiary,
|
||||
activeIcon: ImageConstant.imgDiary,
|
||||
title: "diary".tr,
|
||||
type: BottomBarEnum.tf,
|
||||
image: false),
|
||||
icon: ImageConstant.imgDiary,
|
||||
activeIcon: ImageConstant.imgDiary,
|
||||
title: "diary".tr,
|
||||
type: BottomBarEnum.tf,
|
||||
image: false,
|
||||
),
|
||||
BottomMenuModel(
|
||||
icon: ImageConstant.imgChat,
|
||||
activeIcon: ImageConstant.imgChat,
|
||||
title: "chat".tr,
|
||||
type: BottomBarEnum.tf,
|
||||
image: false),
|
||||
icon: ImageConstant.imgChat,
|
||||
activeIcon: ImageConstant.imgChat,
|
||||
title: "chat".tr,
|
||||
type: BottomBarEnum.tf,
|
||||
image: false,
|
||||
),
|
||||
BottomMenuModel(
|
||||
icon: ImageConstant.imgBell,
|
||||
activeIcon: ImageConstant.imgBell,
|
||||
type: BottomBarEnum.tf,
|
||||
image: false),
|
||||
icon: ImageConstant.imgBell,
|
||||
activeIcon: ImageConstant.imgBell,
|
||||
type: BottomBarEnum.tf,
|
||||
image: false,
|
||||
),
|
||||
BottomMenuModel(
|
||||
icon: ImageConstant.imgEllipse1,
|
||||
activeIcon: ImageConstant.imgEllipse1,
|
||||
@@ -84,16 +189,16 @@ class CustomBottomBarState extends State<CustomBottomBar> {
|
||||
|
||||
switch (index) {
|
||||
case 0:
|
||||
Navigator.pushNamed(context, AppRoutes.myProfile);
|
||||
Navigator.pushReplacementNamed(context, AppRoutes.myProfile);
|
||||
break;
|
||||
case 1:
|
||||
Navigator.pushNamed(context, AppRoutes.feedScreen);
|
||||
Navigator.pushReplacementNamed(context, AppRoutes.feedScreen);
|
||||
break;
|
||||
case 2:
|
||||
Navigator.pushNamed(context, AppRoutes.diaryEdit);
|
||||
Navigator.pushReplacementNamed(context, AppRoutes.diaryEdit);
|
||||
break;
|
||||
case 3:
|
||||
Navigator.pushNamed(context, AppRoutes.chatSelectScreen);
|
||||
Navigator.pushReplacementNamed(context, AppRoutes.chatSelectScreen);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -131,8 +236,7 @@ class CustomBottomBarState extends State<CustomBottomBar> {
|
||||
imagePath: bottomMenuList[index].icon,
|
||||
height: iconHeight,
|
||||
width: iconWidth,
|
||||
color:
|
||||
isSelected ? theme.colorScheme.primary : appTheme.blueGray400,
|
||||
color: isSelected ? theme.colorScheme.primary : appTheme.blueGray400,
|
||||
),
|
||||
if (bottomMenuList[index].image)
|
||||
GestureDetector(
|
||||
@@ -143,16 +247,14 @@ class CustomBottomBarState extends State<CustomBottomBar> {
|
||||
surfaceTintColor: Colors.white,
|
||||
position: RelativeRect.fromLTRB(
|
||||
// Указываем позицию справа по центру
|
||||
MediaQuery.of(context).size.width -
|
||||
50, // Расположение от правого края
|
||||
MediaQuery.of(context).size.width - 50, // Расположение от правого края
|
||||
kToolbarHeight + 340, // Расположение от верхнего края
|
||||
0, // Не смещаем по горизонтали
|
||||
0, // Не смещаем по вертикали
|
||||
),
|
||||
items: [
|
||||
PopupMenuItem(
|
||||
child:
|
||||
CustomNavigationMenu(), // Используйте ваше меню здесь
|
||||
child: CustomNavigationMenu(), // Используйте ваше меню здесь
|
||||
)
|
||||
],
|
||||
),
|
||||
@@ -160,16 +262,13 @@ class CustomBottomBarState extends State<CustomBottomBar> {
|
||||
imagePath: ImageConstant.imgEllipse1,
|
||||
),
|
||||
),
|
||||
if (bottomMenuList[index].title !=
|
||||
null) // Проверяем, существует ли title
|
||||
if (bottomMenuList[index].title != null) // Проверяем, существует ли title
|
||||
Padding(
|
||||
padding: EdgeInsets.only(top: 8.v),
|
||||
child: Text(
|
||||
bottomMenuList[index].title!,
|
||||
style: CustomTextStyles.bodySmallMulishBluegray80012.copyWith(
|
||||
color: isSelected
|
||||
? theme.colorScheme.primary
|
||||
: appTheme.blueGray800,
|
||||
color: isSelected ? theme.colorScheme.primary : appTheme.blueGray800,
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user