2025-07-03 09:45:15 +08:00
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:qhd_prevention/pages/home/scan_page.dart';
|
2025-07-07 16:49:05 +08:00
|
|
|
import 'package:qhd_prevention/pages/my_appbar.dart';
|
2025-07-03 09:45:15 +08:00
|
|
|
import 'home/home_page.dart';
|
|
|
|
import 'app/application_page.dart';
|
|
|
|
import 'mine/mine_page.dart';
|
|
|
|
import 'notif/notif_page.dart';
|
|
|
|
|
|
|
|
class MainPage extends StatefulWidget {
|
|
|
|
const MainPage({super.key});
|
|
|
|
|
|
|
|
@override
|
|
|
|
_MainPageState createState() => _MainPageState();
|
|
|
|
}
|
|
|
|
|
|
|
|
class _MainPageState extends State<MainPage> {
|
|
|
|
int _currentIndex = 0;
|
|
|
|
|
|
|
|
// 页面列表
|
|
|
|
final List<Widget> _pages = const [
|
|
|
|
HomePage(),
|
|
|
|
ApplicationPage(),
|
|
|
|
NotifPage(),
|
2025-07-07 16:49:05 +08:00
|
|
|
MinePage(),
|
2025-07-03 09:45:15 +08:00
|
|
|
];
|
|
|
|
|
|
|
|
// 页面标题
|
2025-07-07 16:49:05 +08:00
|
|
|
final List<String> _titles = ['首页', '应用中心', '通知公告', '我的'];
|
2025-07-03 09:45:15 +08:00
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return Scaffold(
|
2025-07-07 16:49:05 +08:00
|
|
|
appBar:
|
|
|
|
_currentIndex == 1
|
|
|
|
? null
|
|
|
|
: MyAppbar(
|
|
|
|
title: _currentIndex == 0 ? "泰盛安全首页" : _titles[_currentIndex],
|
|
|
|
backgroundColor: Colors.blue,
|
|
|
|
isBack: false,
|
|
|
|
actions: [
|
|
|
|
if (_currentIndex == 0)
|
|
|
|
IconButton(
|
|
|
|
onPressed: () {
|
|
|
|
Navigator.push(
|
|
|
|
context,
|
|
|
|
MaterialPageRoute(builder: (context) => ScanPage()),
|
|
|
|
);
|
|
|
|
},
|
|
|
|
icon: Image.asset(
|
|
|
|
"assets/images/scan.png",
|
|
|
|
width: 20,
|
|
|
|
height: 20,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
2025-07-03 09:45:15 +08:00
|
|
|
body: _pages[_currentIndex],
|
|
|
|
bottomNavigationBar: BottomNavigationBar(
|
|
|
|
currentIndex: _currentIndex,
|
2025-07-07 16:49:05 +08:00
|
|
|
type: BottomNavigationBarType.fixed,
|
|
|
|
// 保证超过3个图标不压缩
|
2025-07-03 09:45:15 +08:00
|
|
|
selectedItemColor: Colors.blue,
|
|
|
|
unselectedItemColor: Colors.grey,
|
|
|
|
onTap: (index) => setState(() => _currentIndex = index),
|
|
|
|
items: [
|
|
|
|
BottomNavigationBarItem(
|
2025-07-07 16:49:05 +08:00
|
|
|
icon: Image.asset(
|
|
|
|
'assets/tabbar/basics.png',
|
|
|
|
width: 24,
|
|
|
|
height: 24,
|
|
|
|
),
|
|
|
|
activeIcon: Image.asset(
|
|
|
|
'assets/tabbar/basics_cur.png',
|
|
|
|
width: 24,
|
|
|
|
height: 24,
|
|
|
|
),
|
2025-07-03 09:45:15 +08:00
|
|
|
label: '首页',
|
|
|
|
),
|
|
|
|
BottomNavigationBarItem(
|
2025-07-07 16:49:05 +08:00
|
|
|
icon: Image.asset(
|
|
|
|
'assets/tabbar/application.png',
|
|
|
|
width: 24,
|
|
|
|
height: 24,
|
|
|
|
),
|
|
|
|
activeIcon: Image.asset(
|
|
|
|
'assets/tabbar/application_cur.png',
|
|
|
|
width: 24,
|
|
|
|
height: 24,
|
|
|
|
),
|
2025-07-03 09:45:15 +08:00
|
|
|
label: '应用',
|
|
|
|
),
|
|
|
|
BottomNavigationBarItem(
|
|
|
|
icon: Image.asset('assets/tabbar/works.png', width: 24, height: 24),
|
2025-07-07 16:49:05 +08:00
|
|
|
activeIcon: Image.asset(
|
|
|
|
'assets/tabbar/works_cur.png',
|
|
|
|
width: 24,
|
|
|
|
height: 24,
|
|
|
|
),
|
2025-07-03 09:45:15 +08:00
|
|
|
label: '通知',
|
|
|
|
),
|
|
|
|
BottomNavigationBarItem(
|
|
|
|
icon: Image.asset('assets/tabbar/my.png', width: 24, height: 24),
|
2025-07-07 16:49:05 +08:00
|
|
|
activeIcon: Image.asset(
|
|
|
|
'assets/tabbar/my_cur.png',
|
|
|
|
width: 24,
|
|
|
|
height: 24,
|
|
|
|
),
|
2025-07-03 09:45:15 +08:00
|
|
|
label: '我的',
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|