Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import 'package:flutter/material.dart';
- import 'package:smart_relay/theme.dart';
- import 'home_page.dart';
- class MainPage extends StatefulWidget {
- @override
- State<MainPage> createState() => _MainPageState();
- }
- class _MainPageState extends State<MainPage> {
- int currentIndex = 0;
- @override
- Widget build(BuildContext context) {
- Widget customBottomNav() {
- return ClipRRect(
- borderRadius: BorderRadius.vertical(
- top: Radius.circular(30),
- ),
- child: BottomAppBar(
- shape: CircularNotchedRectangle(),
- notchMargin: 12,
- clipBehavior: Clip.antiAlias,
- child: BottomNavigationBar(
- backgroundColor: backgroundColor4,
- currentIndex: currentIndex,
- onTap: (value) {
- setState(() {
- currentIndex = value;
- });
- },
- type: BottomNavigationBarType.fixed,
- items: [
- BottomNavigationBarItem(
- icon: Container(
- margin: const EdgeInsets.only(
- top: 20,
- bottom: 10,
- ),
- child: Image.asset(
- 'assets/icon_home.png',
- width: 21,
- color: currentIndex == 0 ? primaryColor : Color(0xff808191),
- ),
- ),
- label: '',
- ),
- BottomNavigationBarItem(
- icon: Container(
- margin: EdgeInsets.only(
- top: 20,
- bottom: 10,
- ),
- child: Image.asset(
- 'assets/icon_home.png',
- width: 18,
- color: currentIndex == 3 ? primaryColor : Color(0xff808191),
- ),
- ),
- label: '',
- ),
- ],
- ),
- ),
- );
- }
- Widget body() {
- switch (currentIndex) {
- case 0:
- return HomePage();
- // case 1:
- // return ChatPage();
- // case 2:
- // return WishlistPage();
- // case 3:
- // return ProfilePage();
- default:
- return HomePage();
- }
- ;
- }
- return Scaffold(
- backgroundColor: currentIndex == 0 ? backgroundColor1 : backgroundColor3,
- // floatingActionButton: cartButton(),
- floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked,
- bottomNavigationBar: customBottomNav(),
- body: body(),
- );
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement