feat:更新UI布局

This commit is contained in:
2025-12-03 11:49:50 +08:00
parent e2853483f7
commit e672442d6a
9 changed files with 196 additions and 189 deletions

View File

@@ -1,10 +1,8 @@
import 'package:fitnote/provider/health_provider.dart';
import 'package:fitnote/service/health_service.dart';
import 'package:fitnote/widget/record/record_calendar.dart';
import 'package:fitnote/widget/record/record_daily.dart';
import 'package:flutter/material.dart';
import 'package:flutter_common/widget/common_widget.dart';
import 'package:table_calendar/table_calendar.dart';
import 'package:provider/provider.dart';
class HistoryPage extends StatefulWidget {
const HistoryPage({super.key});
@@ -16,36 +14,13 @@ class HistoryPage extends StatefulWidget {
class _HistoryPageState extends State<HistoryPage> {
final HealthService service = HealthService();
TableCalendar _calendar() {
final provider = context.watch<HealthProvider>();
return TableCalendar(
locale: 'zh_CN',
headerStyle: const HeaderStyle(
headerPadding: EdgeInsets.symmetric(vertical: 0),
formatButtonVisible: false,
titleCentered: true,
),
firstDay: DateTime.utc(2010, 1, 1),
lastDay: DateTime.utc(2100, 12, 31),
focusedDay: provider.selectedDate,
selectedDayPredicate: (day) => isSameDay(provider.selectedDate, day),
onDaySelected: (selectedDay, focusedDay) {
if (!isSameDay(provider.selectedDate, selectedDay)) {
provider.updateSelectDate(selectedDay);
provider.updateRecord(service.getRecordByDate(provider.selectedDate));
}
}
);
}
@override
Widget build(BuildContext context) {
return SingleChildScrollView(
child: Column(
children: [
CommonCard(child: _calendar()),
const SizedBox(height: 24),
CommonCard(child: RecordCalendar()),
const SizedBox(height: 10),
RecordDaily(),
],
),

View File

@@ -1,8 +1,6 @@
import 'package:fitnote/widget/record/goal_progress.dart';
import 'package:fitnote/widget/record/record_daily.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});
@@ -12,98 +10,14 @@ class RecordPage extends StatefulWidget {
}
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), RecordDaily()],
),
);
}
// 顶部导航栏
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,
),
),
),
),
],
),
GoalProgress(),
const SizedBox(height: 10),
RecordDaily(),
],
),
);