75 lines
1.7 KiB
Dart
75 lines
1.7 KiB
Dart
import 'package:flutter/material.dart';
|
|
import './pages/home_page.dart';
|
|
import './pages/statistics_page.dart';
|
|
import './pages/profile_page.dart';
|
|
|
|
void main() {
|
|
runApp(const MyApp());
|
|
}
|
|
|
|
class MyApp extends StatelessWidget {
|
|
const MyApp({Key? key}) : super(key: key);
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return MaterialApp(
|
|
debugShowCheckedModeBanner: false,
|
|
title: '记账本',
|
|
theme: ThemeData(
|
|
primaryColor: const Color(0xFF9FE2BF),
|
|
colorScheme: ColorScheme.fromSeed(
|
|
seedColor: const Color(0xFF9FE2BF),
|
|
),
|
|
),
|
|
home: const MainPage(),
|
|
);
|
|
}
|
|
}
|
|
|
|
class MainPage extends StatefulWidget {
|
|
const MainPage({Key? key}) : super(key: key);
|
|
|
|
@override
|
|
State<MainPage> createState() => _MainPageState();
|
|
}
|
|
|
|
class _MainPageState extends State<MainPage> {
|
|
int _currentIndex = 0;
|
|
|
|
// 页面列表
|
|
final List<Widget> _pages = [
|
|
const HomePage(),
|
|
const StatisticsPage(),
|
|
const ProfilePage(),
|
|
];
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Scaffold(
|
|
body: _pages[_currentIndex],
|
|
bottomNavigationBar: BottomNavigationBar(
|
|
currentIndex: _currentIndex,
|
|
onTap: (index) {
|
|
setState(() {
|
|
_currentIndex = index;
|
|
});
|
|
},
|
|
items: const [
|
|
BottomNavigationBarItem(
|
|
icon: Icon(Icons.account_balance_wallet),
|
|
label: '记账',
|
|
),
|
|
BottomNavigationBarItem(
|
|
icon: Icon(Icons.insert_chart),
|
|
label: '统计',
|
|
),
|
|
BottomNavigationBarItem(
|
|
icon: Icon(Icons.person),
|
|
label: '我的',
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
}
|