From e387a8db038a15e37cb554c7585d1cac138a18f5 Mon Sep 17 00:00:00 2001 From: ddshi <8811906+ddshi@user.noreply.gitee.com> Date: Fri, 27 Dec 2024 13:56:59 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E5=AF=BC=E8=88=AA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/main.dart | 57 ++++++++++++++++++++++++++++++++-- lib/pages/home_page.dart | 1 - lib/pages/profile_page.dart | 17 ++++++++++ lib/pages/statistics_page.dart | 17 ++++++++++ 4 files changed, 88 insertions(+), 4 deletions(-) create mode 100644 lib/pages/profile_page.dart create mode 100644 lib/pages/statistics_page.dart diff --git a/lib/main.dart b/lib/main.dart index abea467..4cc1db6 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -1,5 +1,7 @@ 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()); @@ -10,14 +12,63 @@ class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { - // 移除debug标签 return MaterialApp( debugShowCheckedModeBanner: false, title: '记账本', theme: ThemeData( - primarySwatch: Colors.blue, + 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 createState() => _MainPageState(); +} + +class _MainPageState extends State { + int _currentIndex = 0; + + // 页面列表 + final List _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: '我的', + ), + ], ), - home: const HomePage(), ); } } diff --git a/lib/pages/home_page.dart b/lib/pages/home_page.dart index e4a28cd..316cad3 100644 --- a/lib/pages/home_page.dart +++ b/lib/pages/home_page.dart @@ -5,7 +5,6 @@ import 'dart:async'; import '../models/record.dart'; import './record_page.dart'; import '../widgets/record_list.dart'; -import '../data/mock_data.dart'; // 暂时使用模拟数据 import '../services/database_service.dart'; import '../widgets/weekly_spending_chart.dart'; import '../widgets/monthly_summary_card.dart'; diff --git a/lib/pages/profile_page.dart b/lib/pages/profile_page.dart new file mode 100644 index 0000000..83db124 --- /dev/null +++ b/lib/pages/profile_page.dart @@ -0,0 +1,17 @@ +import 'package:flutter/material.dart'; + +class ProfilePage extends StatelessWidget { + const ProfilePage({Key? key}) : super(key: key); + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar( + title: const Text('我的'), + ), + body: const Center( + child: Text('个人中心开发中...'), + ), + ); + } +} \ No newline at end of file diff --git a/lib/pages/statistics_page.dart b/lib/pages/statistics_page.dart new file mode 100644 index 0000000..76f62bb --- /dev/null +++ b/lib/pages/statistics_page.dart @@ -0,0 +1,17 @@ +import 'package:flutter/material.dart'; + +class StatisticsPage extends StatelessWidget { + const StatisticsPage({Key? key}) : super(key: key); + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar( + title: const Text('统计'), + ), + body: const Center( + child: Text('统计功能开发中...'), + ), + ); + } +} \ No newline at end of file