index_page.dart 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. import 'package:flutter/material.dart';
  2. import 'package:flutter_tracker/pages/home_page.dart';
  3. import 'package:flutter_tracker/pages/mine_page.dart';
  4. import 'package:flutter_tracker/pages/track_page.dart';
  5. /// Description:
  6. /// Time : 2021年12月03日 Friday
  7. /// Author : liuyuqi.gov@msncn
  8. class IndexPage extends StatefulWidget {
  9. const IndexPage({Key key}) : super(key: key);
  10. @override
  11. _IndexPageState createState() => _IndexPageState();
  12. }
  13. class _IndexPageState extends State<IndexPage> {
  14. int navIndex = 0;
  15. List<Widget> pages = [
  16. HomePage(url: "http://app.21jingji.com/html/2020yiqing/"),
  17. //https://xw.qq.com/act/qgfeiyan
  18. // https://www.ipe.org.cn/MapGZBD/XQMap.html
  19. //http://m.look.360.cn/subject/400?sign=360_6aa05217&stab=0
  20. const TrackPage(),
  21. MinePage(),
  22. ];
  23. Widget currentPage;
  24. @override
  25. void initState() {
  26. super.initState();
  27. currentPage = pages[navIndex];
  28. }
  29. @override
  30. Widget build(BuildContext context) {
  31. return Scaffold(
  32. backgroundColor: const Color(0xF1F6F9ff),
  33. body: currentPage,
  34. bottomNavigationBar: BottomNavigationBar(
  35. type: BottomNavigationBarType.fixed,
  36. currentIndex: navIndex,
  37. items: const [
  38. BottomNavigationBarItem(icon: Icon(Icons.home), label: "首页"),
  39. BottomNavigationBarItem(icon: Icon(Icons.art_track), label: "追踪"),
  40. BottomNavigationBarItem(icon: Icon(Icons.person), label: "我的"),
  41. ],
  42. onTap: (index) {
  43. setState(() {
  44. navIndex = index;
  45. currentPage = pages[navIndex];
  46. });
  47. },
  48. ),
  49. );
  50. }
  51. }