feat:更新个人主页模块

This commit is contained in:
2025-11-24 19:56:13 +08:00
parent 97e7a6f44b
commit 8cff5228ae
18 changed files with 443 additions and 197 deletions

View File

@@ -2,13 +2,16 @@ import 'package:flutter/material.dart';
import 'package:flutter_common/widget/common_widget.dart';
import 'package:food_hub_app/config/app_config.dart';
import 'package:food_hub_app/models/moment.dart';
import 'package:food_hub_app/provider/food_provider.dart';
import 'package:food_hub_app/widgets/common/image.dart';
import 'package:provider/provider.dart';
import 'package:tdesign_flutter/tdesign_flutter.dart';
class MomentCard extends StatelessWidget {
final Moment moment;
final bool isUser;
const MomentCard({super.key, required this.moment});
const MomentCard({super.key, required this.moment, required this.isUser});
@override
Widget build(BuildContext context) {
@@ -32,7 +35,7 @@ class MomentCard extends StatelessWidget {
const SizedBox(height: 10),
_buildTime(),
const SizedBox(height: 5),
_buildActionButtons(),
_buildActionButtons(context),
if (moment.commentList!.isNotEmpty) ...[
const SizedBox(height: 8),
_buildCommentList(),
@@ -52,7 +55,7 @@ class MomentCard extends StatelessWidget {
size: TDAvatarSize.medium,
type: TDAvatarType.customText,
shape: TDAvatarShape.circle,
backgroundColor: Theme.of(context).primaryColor,
backgroundColor: Theme.of(context).colorScheme.primary,
text: moment.username?[0],
);
} else {
@@ -126,10 +129,31 @@ class MomentCard extends StatelessWidget {
);
}
void _onTapEdit(BuildContext context) {
final provider = Provider.of<FoodProvider>(context, listen: false);
provider.isEditing = true;
provider.momentFormItem = moment;
Navigator.pushNamed(context, '/momentForm');
}
// 构建点赞和评论按钮
Widget _buildActionButtons() {
Widget _buildActionButtons(BuildContext context) {
return Row(
children: [
if (isUser)
SizedBox(
width: 42,
height: 36,
child: Stack(
alignment: Alignment.bottomLeft,
children: [
InkWell(
onTap: () => _onTapEdit(context),
child: Icon(Icons.edit),
),
],
),
),
SizedBox(
width: 42,
height: 36,
@@ -166,30 +190,6 @@ class MomentCard extends StatelessWidget {
],
),
),
// _buildActionButton(
// icon: Icons.thumb_up_alt_outlined,
// count: moment.likeList?.length ?? 0,
// ),
// const SizedBox(width: 20),
// _buildActionButton(
// icon: Icons.comment_outlined,
// count: moment.commentList?.length ?? 0,
// ),
],
);
}
// 构建带数字标记的动作按钮
Widget _buildActionButton({required IconData icon, required int count}) {
return Row(
children: [
Icon(icon, color: Colors.grey[500], size: 18),
const SizedBox(width: 4),
if (count > 0)
Text(
count.toString(),
style: TextStyle(fontSize: 12, color: Colors.grey[500]),
),
],
);
}