import 'package:flutter/material.dart'; import 'package:gowater/widget/buy-water.dart'; import 'package:gowater/widget/history.dart'; // // void main() { runApp(const GoWaterMyApp()); } class GoWaterMyApp extends StatelessWidget { const GoWaterMyApp({super.key}); @override Widget build(BuildContext context) { return MaterialApp( title: 'GoWater', theme: ThemeData( colorScheme: ColorScheme.fromSeed( seedColor: Colors.lightBlue), useMaterial3: true, ), home: const MyHomePage(title: '桶裝水自動配送系統'), ); } } class MyHomePage extends StatefulWidget { const MyHomePage({super.key, required this.title}); final String title; @override State<MyHomePage> createState() => _MyHomePageState(); } class _MyHomePageState extends State<MyHomePage> { late int _selectedIndex = 0; // 建立一組彩色的容器 // 建立一組彩色的容器 static List<Widget> pages = <Widget>[ //Container(color: Colors.red), const History(), // const MyButton(), // Container(color: Colors.blue) ]; //彩色容器結束 @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( backgroundColor: Theme.of(context).colorScheme.inversePrimary, title: Text(widget.title), ), body: SafeArea( //child: Container(),//原始安全容器主要內容 child: pages[_selectedIndex], ), //導航開始 bottomNavigationBar: BottomNavigationBar( selectedItemColor: Colors.lightBlue, currentIndex: _selectedIndex, onTap: (index) => setState(() { _selectedIndex = index; }), items: const [ BottomNavigationBarItem( icon: Icon(Icons.list), label: '歷史', ), BottomNavigationBarItem( icon: Icon(Icons.widgets), label: '訂水', ), BottomNavigationBarItem( icon: Icon(Icons.settings), label: '自己', ), ], ), //導航結束 ); } }