refactor(class): 抽离攻克任务组件并优化样式与资源
1. 将ResolveProblemBox从class_update_widgets.dart抽离到公共组件目录 2. 替换静态渐变背景为CDN资源背景图,适配平板和手机端 3. 将点赞评论按钮的图标从内置Icons替换为本地png资源 4. 更新pubspec.yaml添加新的图片资源路径 5. 删除冗余的空行配置
This commit is contained in:
@@ -5,6 +5,7 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||
import 'package:new_learn/core/api/class/model.dart';
|
||||
import 'package:new_learn/core/components/image_preview_viewer.dart';
|
||||
import 'package:new_learn/core/components/resolve_problem_box.dart';
|
||||
import 'package:new_learn/core/components/user_circle_avatar.dart';
|
||||
import 'package:new_learn/core/utils/img_url.dart';
|
||||
|
||||
@@ -12,7 +13,8 @@ import 'package:new_learn/core/utils/img_url.dart';
|
||||
/// 【班级动态组件】由 class_update_view.dart 抽离的展示组件
|
||||
///
|
||||
/// PostCard(动态卡片,按 type 分发内容 + 相册 + 点赞评论栏)
|
||||
/// CardHeader / SubjectTag / ResolveProblemBox / AlbumDesc / AlbumGrid
|
||||
/// CardHeader / SubjectTag / AlbumDesc / AlbumGrid / LikeCommentBar / ...
|
||||
/// ResolveProblemBox 已抽离到 core/components/resolve_problem_box.dart
|
||||
/// LikeCommentBar / MetaButton / CommentPreview / CommentInput
|
||||
///
|
||||
/// 原为 class_update_view.dart 内的私有组件,重命名去下划线后放到本文件。
|
||||
@@ -263,65 +265,6 @@ class SubjectTag extends StatelessWidget {
|
||||
}
|
||||
}
|
||||
|
||||
/// 攻克任务卡(对标 ResolveProblem)
|
||||
class ResolveProblemBox extends StatelessWidget {
|
||||
const ResolveProblemBox({super.key, required this.desc});
|
||||
|
||||
final String desc;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
width: double.infinity,
|
||||
padding: EdgeInsets.fromLTRB(19.w, 25.h, 19.w, 11.h),
|
||||
decoration: BoxDecoration(
|
||||
gradient: const LinearGradient(
|
||||
begin: Alignment.topCenter,
|
||||
end: Alignment.bottomCenter,
|
||||
colors: [Color(0xFFEAF4FF), Color(0xFFFFFFFF)],
|
||||
),
|
||||
borderRadius: BorderRadius.circular(10.r),
|
||||
),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
const Text(
|
||||
'刚刚攻克了',
|
||||
style: TextStyle(
|
||||
fontSize: 15,
|
||||
fontWeight: FontWeight.w900,
|
||||
color: Color(0xFF1D2B47),
|
||||
),
|
||||
),
|
||||
SizedBox(height: 3.h),
|
||||
Text.rich(
|
||||
TextSpan(
|
||||
children: [
|
||||
TextSpan(
|
||||
text: '「$desc」',
|
||||
style: const TextStyle(
|
||||
fontSize: 13,
|
||||
fontWeight: FontWeight.w500,
|
||||
color: Color(0xFF1D2B47),
|
||||
),
|
||||
),
|
||||
const TextSpan(
|
||||
text: ' 的所有高难考点!',
|
||||
style: TextStyle(
|
||||
fontSize: 13,
|
||||
fontWeight: FontWeight.w500,
|
||||
color: Color(0xFF45597E),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// 纯文字笔记(album-desc,最多 2 行)
|
||||
class AlbumDesc extends StatelessWidget {
|
||||
const AlbumDesc({super.key, required this.text});
|
||||
@@ -441,15 +384,26 @@ class LikeCommentBar extends StatelessWidget {
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
children: [
|
||||
MetaButton(
|
||||
icon: post.userLikeStatus
|
||||
? Icons.favorite
|
||||
: Icons.favorite_border,
|
||||
icon: Image.asset(
|
||||
post.userLikeStatus
|
||||
? 'assets/img/class/like-check-icon.png'
|
||||
: 'assets/img/class/like-icon.png',
|
||||
width: 13.w,
|
||||
height: 13.w,
|
||||
),
|
||||
count: post.likeCount,
|
||||
active: post.userLikeStatus,
|
||||
onTap: onLike,
|
||||
),
|
||||
SizedBox(width: 8.w),
|
||||
MetaButton(icon: Icons.chat_bubble_outline, count: post.replyCount),
|
||||
MetaButton(
|
||||
icon: Image.asset(
|
||||
'assets/img/class/comment-icon.png',
|
||||
width: 13.w,
|
||||
height: 13.w,
|
||||
),
|
||||
count: post.replyCount,
|
||||
),
|
||||
],
|
||||
),
|
||||
if (showComposer) ...[
|
||||
@@ -474,7 +428,7 @@ class MetaButton extends StatelessWidget {
|
||||
this.onTap,
|
||||
});
|
||||
|
||||
final IconData icon;
|
||||
final Widget icon;
|
||||
final int count;
|
||||
final bool active;
|
||||
final VoidCallback? onTap;
|
||||
@@ -496,7 +450,7 @@ class MetaButton extends StatelessWidget {
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Icon(icon, size: 13.w, color: color),
|
||||
icon,
|
||||
SizedBox(width: 4.w),
|
||||
Text('$count', style: TextStyle(fontSize: 13, color: color)),
|
||||
],
|
||||
|
||||
Reference in New Issue
Block a user