ModelOfTheTime/lib/main.dart
2024-09-04 19:04:29 +08:00

81 lines
2.0 KiB
Dart

import 'package:flutter/material.dart';
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';
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(
title: '时代楷模',
theme: ThemeData(
colorScheme: ColorScheme.fromSeed(seedColor: Colors.white),
useMaterial3: true,
),
home: const MainPage(),
);
}
}
class MainPage extends StatefulWidget {
const MainPage({super.key});
@override
State<MainPage> createState() => _MainPageState();
}
class _MainPageState extends State<MainPage> {
int _nowPageIndex = 0;
final List<ViewInformation> _pages = [
ViewInformation(const HomeView(), "时代楷模")
];
@override
Widget build(BuildContext context) {
final page = _pages[_nowPageIndex];
return Scaffold(
appBar: AppBar(
title: Text(
page.title,
style: const TextStyle(
color: Colors.red
),
),
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: "数据分析"
),
]
),
);
}
}