ModelOfTheTime/lib/main.dart

81 lines
2.0 KiB
Dart
Raw Normal View History

2024-09-03 16:50:16 +08:00
import 'package:flutter/material.dart';
2024-09-04 19:04:29 +08:00
import 'package:model_of_the_times/entities/ViewInformation.dart';
import 'package:model_of_the_times/icons/material_design_icons.dart';
import 'package:model_of_the_times/views/home.dart';
2024-09-03 16:50:16 +08:00
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
2024-09-04 19:04:29 +08:00
title: '时代楷模',
2024-09-03 16:50:16 +08:00
theme: ThemeData(
2024-09-04 19:04:29 +08:00
colorScheme: ColorScheme.fromSeed(seedColor: Colors.white),
2024-09-03 16:50:16 +08:00
useMaterial3: true,
),
2024-09-04 19:04:29 +08:00
home: const MainPage(),
2024-09-03 16:50:16 +08:00
);
}
}
2024-09-04 19:04:29 +08:00
class MainPage extends StatefulWidget {
const MainPage({super.key});
2024-09-03 16:50:16 +08:00
@override
2024-09-04 19:04:29 +08:00
State<MainPage> createState() => _MainPageState();
2024-09-03 16:50:16 +08:00
}
2024-09-04 19:04:29 +08:00
class _MainPageState extends State<MainPage> {
int _nowPageIndex = 0;
final List<ViewInformation> _pages = [
ViewInformation(const HomeView(), "时代楷模")
];
2024-09-03 16:50:16 +08:00
@override
Widget build(BuildContext context) {
2024-09-04 19:04:29 +08:00
final page = _pages[_nowPageIndex];
2024-09-03 16:50:16 +08:00
return Scaffold(
appBar: AppBar(
2024-09-04 19:04:29 +08:00
title: Text(
page.title,
style: const TextStyle(
color: Colors.red
),
2024-09-03 16:50:16 +08:00
),
2024-09-04 19:04:29 +08:00
centerTitle: true,
),
body: page.view,
bottomNavigationBar: BottomNavigationBar(
onTap: (newIndex){
setState(() {
_nowPageIndex = newIndex;
});
},
type: BottomNavigationBarType.fixed,
items: const [
BottomNavigationBarItem(
icon: Icon(MaterialDesign.home),
label: "首页"
),
BottomNavigationBarItem(
icon: Icon(MaterialDesign.feedback),
label: "公告"
),
BottomNavigationBarItem(
icon: Icon(MaterialDesign.favorite),
label: "心得"
),
BottomNavigationBarItem(
icon: Icon(MaterialDesign.view_stream),
label: "数据分析"
),
]
2024-09-03 16:50:16 +08:00
),
);
}
2024-09-04 19:04:29 +08:00
}