1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071 |
- import 'package:flutter/material.dart';
- import 'package:flutter/cupertino.dart';
- import 'home_page.dart';
- import 'Information_page.dart';
- import 'Mine_page.dart';
- import 'Orders_page.dart';
-
- class IndexPage extends StatefulWidget {
- _IndexPageState createState() => _IndexPageState();
- }
-
- class _IndexPageState extends State<IndexPage> {
-
-
- final List<BottomNavigationBarItem> bottomTabs = [
- BottomNavigationBarItem(
- icon: Icon(CupertinoIcons.home),
- title: Text('首页'),
- ),
- BottomNavigationBarItem(
- icon: Icon(CupertinoIcons.search),
- title: Text('资讯'),
-
- ),
- BottomNavigationBarItem(
- icon: Icon(CupertinoIcons.shopping_cart),
- title: Text('订单'),
-
- ),
- BottomNavigationBarItem(
- icon: Icon(CupertinoIcons.profile_circled),
- title: Text('我的'),
- ),
- ];
-
- final List tabBodies = [
- HomePage(),
- InformationPage(),
- OrdersPage(),
- MinePage(),
- ];
-
- int currentIndex = 0;
- var currentPage;
-
- @override
- void initState() {
- super.initState();
- currentPage = tabBodies[currentIndex];
- }
-
- @override
- Widget build(BuildContext context) {
- // TODO: implement build
- return Scaffold(
- backgroundColor: Color.fromRGBO(244, 245, 245, 1),
- bottomNavigationBar: BottomNavigationBar(
- type: BottomNavigationBarType.fixed,
- currentIndex: currentIndex,
- items: bottomTabs,
- onTap: (index){
- setState(() {
- currentIndex = index;
- currentPage = tabBodies[currentIndex];
- });
- },
- ),
- body: currentPage,
- );
- }
- }
|