feat:增加记录对话框内容

This commit is contained in:
2025-12-01 19:59:25 +08:00
parent 49502295e3
commit eb14cf1957
28 changed files with 1596 additions and 620 deletions

View File

@@ -0,0 +1,15 @@
import 'package:flutter/material.dart';
class HistoryPage extends StatefulWidget {
const HistoryPage({super.key});
@override
State<HistoryPage> createState() => _HistoryPageState();
}
class _HistoryPageState extends State<HistoryPage> {
@override
Widget build(BuildContext context) {
return Center(child: Text('历史记录'));
}
}

100
lib/pages/home_page.dart Normal file
View File

@@ -0,0 +1,100 @@
import 'package:fitnote/layout/app_navbar.dart';
import 'package:fitnote/modesl/menu.dart';
import 'package:flutter/material.dart';
class HomePage extends StatefulWidget {
const HomePage({super.key});
@override
_HomePageState createState() => _HomePageState();
}
class _HomePageState extends State<HomePage> {
int _currentPageIndex = 0;
late PageController _pageController;
@override
void initState() {
super.initState();
_pageController = PageController(initialPage: _currentPageIndex);
}
@override
void dispose() {
_pageController.dispose();
super.dispose();
}
Widget _buildLeading() {
return Builder(
builder:
(context) => IconButton(
icon: Icon(Icons.menu, color: Colors.white),
onPressed: () => Scaffold.of(context).openDrawer(),
),
);
}
Widget _buildAppBarTitle() {
return Text(
pages[_currentPageIndex].title,
style: TextStyle(color: Colors.white),
);
}
Widget _buildPageView() {
return PageView(
controller: _pageController,
onPageChanged: (index) {
setState(() {
_currentPageIndex = index;
});
},
children: pageWidgets,
);
}
void _onTapNavbarItem(int index) {
setState(() {
_currentPageIndex = index;
});
_pageController.animateToPage(
index,
duration: Duration(milliseconds: 300),
curve: Curves.easeInOut,
);
}
void onTapDrawerItem(int index) {
setState(() {
_currentPageIndex = index;
});
_pageController.animateToPage(
index,
duration: Duration(milliseconds: 300),
curve: Curves.easeInOut,
);
Navigator.pop(context);
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: _buildAppBarTitle(),
backgroundColor: Theme.of(context).colorScheme.primary,
elevation: 0,
leading: _buildLeading(),
),
// drawer: AppDrawer(
// currentPageIndex: _currentPageIndex,
// onTapDrawerItem: onTapDrawerItem,
// ),
body: Padding(padding: EdgeInsets.all(10), child: _buildPageView()),
bottomNavigationBar: AppNavbar(
currentPageIndex: _currentPageIndex,
onTapNavbarItem: _onTapNavbarItem,
),
);
}
}

111
lib/pages/record_page.dart Normal file
View File

@@ -0,0 +1,111 @@
import 'package:fitnote/widget/record/goal_progress.dart';
import 'package:fitnote/widget/record/today_record.dart';
import 'package:flutter/material.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import 'package:intl/intl.dart';
class RecordPage extends StatefulWidget {
const RecordPage({super.key});
@override
State<RecordPage> createState() => _RecordPageState();
}
class _RecordPageState extends State<RecordPage> {
// 格式化当前日期
String _formatCurrentDate() {
final now = DateTime.now();
// 格式2025年11月28日周五
return "${DateFormat('yyyy年MM月dd日').format(now)}${_getWeekday(now.weekday)}";
}
// 数字星期转中文
String _getWeekday(int weekday) {
const weekdays = ['周日', '周一', '周二', '周三', '周四', '周五', '周六'];
return weekdays[weekday - 1];
}
@override
Widget build(BuildContext context) {
return SingleChildScrollView(
child: Column(
children: [GoalProgress(), const SizedBox(height: 24), TodayRecord()],
),
);
}
// 顶部导航栏
Widget _buildHeader() {
return Container(
padding: const EdgeInsets.symmetric(horizontal: 24, vertical: 16),
color: Colors.white,
// boxShadow: const [
// BoxShadow(
// color: Color(0x0A000000),
// blurRadius: 4,
// offset: Offset(0, 2),
// ),
// ],
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const Text(
'早上好,用户',
style: TextStyle(
fontSize: 18,
fontWeight: FontWeight.bold,
color: Color(0xFF1E293B),
),
),
const SizedBox(height: 4),
Text(
'今天是 ${_formatCurrentDate()}',
style: const TextStyle(fontSize: 12, color: Color(0xFF64748B)),
),
],
),
Row(
children: [
// 通知按钮
Container(
width: 40,
height: 40,
decoration: BoxDecoration(
color: const Color(0xFFF1F5F9),
borderRadius: BorderRadius.circular(20),
),
child: Icon(
FontAwesomeIcons.bell,
color: const Color(0xFF64748B),
size: 18,
),
),
// 用户头像
Container(
width: 40,
height: 40,
decoration: BoxDecoration(
color: const Color(0xFFE0F2FE), // 主色浅背景
borderRadius: BorderRadius.circular(20),
),
child: const Center(
child: Text(
'U',
style: TextStyle(
color: Color(0xFF38BDF8),
fontWeight: FontWeight.bold,
fontSize: 16,
),
),
),
),
],
),
],
),
);
}
}

View File

@@ -0,0 +1,15 @@
import 'package:flutter/material.dart';
class SettingPage extends StatefulWidget {
const SettingPage({super.key});
@override
State<SettingPage> createState() => _SettingPageState();
}
class _SettingPageState extends State<SettingPage> {
@override
Widget build(BuildContext context) {
return Center(child: Text('设置'));
}
}

15
lib/pages/stats_page.dart Normal file
View File

@@ -0,0 +1,15 @@
import 'package:flutter/material.dart';
class StatsPage extends StatefulWidget {
const StatsPage({super.key});
@override
State<StatsPage> createState() => _StatsPageState();
}
class _StatsPageState extends State<StatsPage> {
@override
Widget build(BuildContext context) {
return Center(child: Text('统计'));
}
}