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

@@ -0,0 +1,68 @@
import 'package:fitnote/provider/health_provider.dart';
import 'package:flutter/material.dart';
import 'package:flutter_common/widget/common_widget.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import 'package:intl/intl.dart';
import 'package:provider/provider.dart';
class Welcome extends StatefulWidget {
const Welcome({super.key});
@override
State<Welcome> createState() => _WelcomeState();
}
class _WelcomeState extends State<Welcome> {
@override
void initState() {
super.initState();
}
String _formatCurrentDate() {
final now = DateTime.now();
return "${DateFormat('yyyy年MM月dd日').format(now)} ${_getWeekday(now.weekday)}";
}
// 数字星期转中文
String _getWeekday(int weekday) {
const weekdays = ['周日', '周一', '周二', '周三', '周四', '周五', '周六'];
return weekdays[weekday - 1];
}
String getGreeting() {
int hour = DateTime.now().hour;
if (hour >= 5 && hour < 12) {
return '早上好';
} else if (hour >= 12 && hour < 18) {
return '下午好';
} else {
return '晚上好';
}
}
@override
Widget build(BuildContext context) {
return CommonCard(
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
getGreeting(),
style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold),
),
const SizedBox(height: 4),
Text(
'今天是 ${_formatCurrentDate()}',
style: const TextStyle(fontSize: 12, color: Colors.grey),
),
],
)
],
),
);
}
}