import 'package:flutter/material.dart'; import 'entry_page.dart'; import 'message_page.dart'; import 'personal_page.dart'; import 'home_content_page.dart'; class HomePage extends StatefulWidget { const HomePage({super.key}); @override State createState() => _HomePageState(); } class _HomePageState extends State { int _currentIndex = 0; final List _pages = const [ HomeContentPage(), EntryPage(), MessagePage(), PersonalPage(), ]; @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: const Text('社區通'), actions: [ Row( children: [ const Text( '林小安 您好', style: TextStyle(fontWeight: FontWeight.bold), ), const SizedBox(width: 8), Stack( children: [ IconButton( icon: const Icon(Icons.notifications), onPressed: () { // TODO: 跳轉到通知頁 }, ), Positioned( right: 8, top: 8, child: Container( padding: const EdgeInsets.all(2), decoration: BoxDecoration( color: Colors.red, borderRadius: BorderRadius.circular(10), ), constraints: const BoxConstraints( minWidth: 16, minHeight: 16, ), child: const Text( '3', style: TextStyle(color: Colors.white, fontSize: 10), textAlign: TextAlign.center, ), ), ), ], ), ], ), ], ), body: _pages[_currentIndex], bottomNavigationBar: BottomNavigationBar( type: BottomNavigationBarType.fixed, currentIndex: _currentIndex, onTap: (index) { setState(() { _currentIndex = index; }); }, items: const [ BottomNavigationBarItem(icon: Icon(Icons.home), label: '首頁'), BottomNavigationBarItem( icon: Icon(Icons.door_front_door), label: '出入', ), BottomNavigationBarItem(icon: Icon(Icons.message), label: '訊息'), BottomNavigationBarItem(icon: Icon(Icons.person), label: '住戶'), ], ), ); } }