bottom navigation updated.
parent
8bc49929d4
commit
886825a4b9
@ -0,0 +1,43 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:hmg_patient_app_new/presentation/home/landing_page.dart';
|
||||||
|
import 'package:hmg_patient_app_new/presentation/medical_file/medical_file_page.dart';
|
||||||
|
import 'package:hmg_patient_app_new/widgets/bottom_navigation/bottom_navigation.dart';
|
||||||
|
|
||||||
|
class LandingNavigation extends StatefulWidget {
|
||||||
|
const LandingNavigation({super.key});
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<LandingNavigation> createState() => _LandingNavigationState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _LandingNavigationState extends State<LandingNavigation> {
|
||||||
|
int _currentIndex = 0;
|
||||||
|
final PageController _pageController = PageController();
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Scaffold(
|
||||||
|
body: PageView(
|
||||||
|
controller: _pageController,
|
||||||
|
physics: const NeverScrollableScrollPhysics(),
|
||||||
|
children: const [
|
||||||
|
LandingPage(),
|
||||||
|
MedicalFilePage(),
|
||||||
|
LandingPage(),
|
||||||
|
LandingPage(),
|
||||||
|
LandingPage(),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
bottomNavigationBar: BottomNavigation(
|
||||||
|
currentIndex: _currentIndex,
|
||||||
|
onTap: (index) {
|
||||||
|
setState(() => _currentIndex = index);
|
||||||
|
_pageController.animateToPage(
|
||||||
|
index,
|
||||||
|
duration: const Duration(milliseconds: 300),
|
||||||
|
curve: Curves.easeInOut);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,59 +1,103 @@
|
|||||||
import 'package:easy_localization/easy_localization.dart';
|
import 'package:easy_localization/easy_localization.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:hmg_patient_app_new/core/app_assets.dart';
|
import 'package:hmg_patient_app_new/core/app_assets.dart';
|
||||||
|
import 'package:hmg_patient_app_new/core/utils/size_utils.dart';
|
||||||
import 'package:hmg_patient_app_new/core/utils/utils.dart';
|
import 'package:hmg_patient_app_new/core/utils/utils.dart';
|
||||||
|
import 'package:hmg_patient_app_new/extensions/string_extensions.dart';
|
||||||
import 'package:hmg_patient_app_new/generated/locale_keys.g.dart';
|
import 'package:hmg_patient_app_new/generated/locale_keys.g.dart';
|
||||||
import 'package:hmg_patient_app_new/theme/colors.dart';
|
import 'package:hmg_patient_app_new/theme/colors.dart';
|
||||||
|
|
||||||
class BottomNavigation extends StatelessWidget {
|
class BottomNavigation extends StatelessWidget {
|
||||||
const BottomNavigation({super.key});
|
final int currentIndex;
|
||||||
|
final ValueChanged<int> onTap;
|
||||||
|
|
||||||
|
const BottomNavigation({
|
||||||
|
super.key,
|
||||||
|
required this.currentIndex,
|
||||||
|
required this.onTap,
|
||||||
|
});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Container(
|
final items = [
|
||||||
padding: const EdgeInsets.symmetric(vertical: 12),
|
BottomNavItem(icon: AppAssets.homeBottom, label: LocaleKeys.home.tr()),
|
||||||
decoration: const BoxDecoration(
|
BottomNavItem(icon: AppAssets.myFilesBottom, label: LocaleKeys.myFiles.tr()),
|
||||||
color: Colors.white,
|
BottomNavItem(
|
||||||
border: Border(
|
icon: AppAssets.bookAppoBottom,
|
||||||
top: BorderSide(color: AppColors.bottomNAVBorder, width: 0.5),
|
label: LocaleKeys.appointment.tr(),
|
||||||
),
|
iconSize: 27,
|
||||||
|
isSpecial: true,
|
||||||
),
|
),
|
||||||
|
BottomNavItem(icon: AppAssets.toDoBottom, label: LocaleKeys.todoList.tr()),
|
||||||
|
BottomNavItem(icon: AppAssets.servicesBottom, label: LocaleKeys.services2.tr()),
|
||||||
|
];
|
||||||
|
|
||||||
|
return Container(
|
||||||
|
decoration: _containerDecoration,
|
||||||
|
padding: _containerPadding,
|
||||||
child: Row(
|
child: Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||||
children: [
|
children: List.generate(
|
||||||
_buildNavItem(AppAssets.homeBottom, LocaleKeys.home.tr()),
|
items.length,
|
||||||
_buildNavItem(AppAssets.myFilesBottom, LocaleKeys.myFiles.tr()),
|
(index) => _buildNavItem(items[index], index),
|
||||||
_buildNavItem(AppAssets.bookAppoBottom, LocaleKeys.appointment.tr(), iconSize: 32),
|
),
|
||||||
_buildNavItem(AppAssets.toDoBottom, LocaleKeys.todoList.tr()),
|
|
||||||
_buildNavItem(AppAssets.servicesBottom, LocaleKeys.services2.tr()),
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildNavItem(String iconName, String label,{ double iconSize = 24}) {
|
Widget _buildNavItem(BottomNavItem item, int index) {
|
||||||
return Column(
|
final bool isSelected = currentIndex == index;
|
||||||
mainAxisSize: MainAxisSize.min,
|
|
||||||
children: [
|
return GestureDetector(
|
||||||
Container(
|
onTap: () => onTap(index),
|
||||||
padding: const EdgeInsets.all(10),
|
behavior: HitTestBehavior.opaque,
|
||||||
child: Utils.buildSvgWithAssets(
|
child: Column(
|
||||||
icon: iconName,
|
mainAxisSize: MainAxisSize.min,
|
||||||
height: iconSize,
|
children: [
|
||||||
width: iconSize
|
Center(
|
||||||
),
|
child: Utils.buildSvgWithAssets(
|
||||||
),
|
icon: item.icon,
|
||||||
// const SizedBox(height: 4),
|
height: item.iconSize.h,
|
||||||
Text(
|
width: item.iconSize.h,
|
||||||
label,
|
// iconColor: isSelected ? Colors.black87 : Colors.black87,
|
||||||
style: TextStyle(
|
),
|
||||||
fontSize: 13,
|
),
|
||||||
fontWeight: FontWeight.w500,
|
const SizedBox(height: 10),
|
||||||
color: Colors.black87,
|
item.label.toText12(
|
||||||
|
fontWeight:FontWeight.w500,
|
||||||
|
// color: Colors.black87,
|
||||||
|
// textAlign: TextAlign.center,
|
||||||
),
|
),
|
||||||
),
|
SizedBox(height: item.isSpecial ? 5:0 )
|
||||||
],
|
],
|
||||||
|
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class BottomNavItem {
|
||||||
|
final String icon;
|
||||||
|
final String label;
|
||||||
|
final double iconSize;
|
||||||
|
final bool isSpecial;
|
||||||
|
|
||||||
|
const BottomNavItem({
|
||||||
|
required this.icon,
|
||||||
|
required this.label,
|
||||||
|
this.iconSize = 21,
|
||||||
|
this.isSpecial = false,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Constants
|
||||||
|
const EdgeInsets _containerPadding = EdgeInsets.all(15);
|
||||||
|
const BoxDecoration _containerDecoration = BoxDecoration(
|
||||||
|
color: Colors.white,
|
||||||
|
border: Border(
|
||||||
|
top: BorderSide(
|
||||||
|
color: AppColors.bottomNAVBorder,
|
||||||
|
width: 0.5,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|||||||
Loading…
Reference in New Issue