import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import '../utils/colors.dart';
class MobileScreenLayout extends StatefulWidget {
const MobileScreenLayout({super.key});
@override
State<MobileScreenLayout> createState() => _MobileScreenLayoutState();
}
class _MobileScreenLayoutState extends State<MobileScreenLayout> {
int _page = 0;
late PageController pageController;
@override
void initState() {
pageController = PageController();
super.initState();
}
@override
void dispose() {
pageController.dispose();
super.dispose();
}
void navigationTapped(int page) {
pageController.jumpToPage(page);
}
void onPageChanged(int page) {
setState(() {
_page = page;
});
}
@override
Widget build(BuildContext context) {
// ignore: prefer_const_constructors
return Scaffold(
body: PageView(
children: [
Text("data"),
Center(child: Text("data")),
Text("data"),
Text("data"),
Text("data"),
],
controller: pageController,
onPageChanged: onPageChanged,
),
bottomNavigationBar: CupertinoTabBar(
onTap: navigationTapped,
backgroundColor: mobileBackgroundColor,
items: [
BottomNavigationBarItem(
icon: Icon(
Icons.home,
color: _page == 0 ? maincolor : Colors.grey,
),
label: "",
backgroundColor: primaryColor,
),
BottomNavigationBarItem(
icon: Icon(
Icons.search,
color: _page == 1 ? maincolor : Colors.grey,
),
label: "",
backgroundColor: primaryColor,
),
BottomNavigationBarItem(
icon: Icon(
Icons.add_circle,
color: _page == 2 ? maincolor : Colors.grey,
),
label: "",
backgroundColor: primaryColor,
),
BottomNavigationBarItem(
icon: Icon(
Icons.notifications,
color: _page == 3 ? maincolor : Colors.grey,
),
label: "",
backgroundColor: primaryColor,
),
BottomNavigationBarItem(
icon: Icon(
Icons.person,
color: _page == 4 ? maincolor : Colors.grey,
),
label: "",
backgroundColor: primaryColor,
),
],
),
);
}
}
Comments
Post a Comment