Compare commits
8
Commits
fe060ac974
...
847986f861
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
847986f861 | ||
|
|
fe86b6d824 | ||
|
|
c65df455f2 | ||
|
|
14b8e56bc3 | ||
|
|
96ab0221a5 | ||
|
|
0fefc786bb | ||
|
|
e0b95a8b43 | ||
|
|
5e4cfe9ac6 |
@@ -137,6 +137,26 @@ class UserApi {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ==================== 报告状态更新 ====================
|
||||||
|
|
||||||
|
/// 更新入门测试报告显示状态(看完后置回 false)
|
||||||
|
/// → POST /api/v1/User/ChangeShowReport
|
||||||
|
///
|
||||||
|
/// 对齐 Vue api/user/index.ts 的 UpdateReportStatus(),
|
||||||
|
/// 在 reportComputation finishedPopup 点"立即开启学习蝶变"后调用。
|
||||||
|
static Future<void> changeShowReport() async {
|
||||||
|
await DioClient.instance.post('/api/v1/User/ChangeShowReport');
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 更新出门测试报告显示状态(看完后置回 false)
|
||||||
|
/// → POST /api/v1/User/ChangeShowAfterReport
|
||||||
|
///
|
||||||
|
/// 对齐 H5 壳子 api/mock/index.ts 的 updateAfterReportStatus(),
|
||||||
|
/// 在出门测 H5 壳子 navigateReport() 里由 Flutter JS Bridge 拦截后调用。
|
||||||
|
static Future<void> changeShowAfterReport() async {
|
||||||
|
await DioClient.instance.post('/api/v1/User/ChangeShowAfterReport');
|
||||||
|
}
|
||||||
|
|
||||||
/// MD5 加密(UniApp stringToMd5 的等价实现)
|
/// MD5 加密(UniApp stringToMd5 的等价实现)
|
||||||
static String _md5(String text) {
|
static String _md5(String text) {
|
||||||
return md5.convert(utf8.encode(text)).toString();
|
return md5.convert(utf8.encode(text)).toString();
|
||||||
|
|||||||
@@ -55,6 +55,7 @@ class UserInfo {
|
|||||||
this.avatar = '',
|
this.avatar = '',
|
||||||
this.phone = '',
|
this.phone = '',
|
||||||
this.isShowReport = false,
|
this.isShowReport = false,
|
||||||
|
this.isShowAfterReport = false,
|
||||||
});
|
});
|
||||||
|
|
||||||
final int userId;
|
final int userId;
|
||||||
@@ -64,6 +65,9 @@ class UserInfo {
|
|||||||
final String phone;
|
final String phone;
|
||||||
final bool isShowReport;
|
final bool isShowReport;
|
||||||
|
|
||||||
|
/// 登录响应里的出门测试报告标记(对齐 Vue api/login/type.ts 的 UserInfo)
|
||||||
|
final bool isShowAfterReport;
|
||||||
|
|
||||||
factory UserInfo.fromJson(Map<String, dynamic> json) {
|
factory UserInfo.fromJson(Map<String, dynamic> json) {
|
||||||
return UserInfo(
|
return UserInfo(
|
||||||
// userId 可能是字符串(后端统一风格),不能直接 as num
|
// userId 可能是字符串(后端统一风格),不能直接 as num
|
||||||
@@ -73,6 +77,7 @@ class UserInfo {
|
|||||||
avatar: json['avatar'] as String? ?? '',
|
avatar: json['avatar'] as String? ?? '',
|
||||||
phone: json['phone'] as String? ?? '',
|
phone: json['phone'] as String? ?? '',
|
||||||
isShowReport: json['isShowReport'] as bool? ?? false,
|
isShowReport: json['isShowReport'] as bool? ?? false,
|
||||||
|
isShowAfterReport: json['isShowAfterReport'] as bool? ?? false,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,6 +22,10 @@ import 'package:new_learn/core/network/dio_client.dart';
|
|||||||
/// —— 获取攻克报告(view 模式数据源)
|
/// —— 获取攻克报告(view 模式数据源)
|
||||||
/// GET /api/v1/StudyPack/GetReport/{recordId}
|
/// GET /api/v1/StudyPack/GetReport/{recordId}
|
||||||
///
|
///
|
||||||
|
/// getRecord
|
||||||
|
/// —— 获取攻克记录信息(过渡页使用)
|
||||||
|
/// GET /api/v1/StudyPack/GetRecord/{recordId}
|
||||||
|
///
|
||||||
/// 注意:
|
/// 注意:
|
||||||
/// - 页面只调这里,不直接碰 Dio;
|
/// - 页面只调这里,不直接碰 Dio;
|
||||||
/// - 异常不在 catch,交页面统一处理;
|
/// - 异常不在 catch,交页面统一处理;
|
||||||
@@ -77,4 +81,17 @@ class BeforeDuringClassApi {
|
|||||||
}
|
}
|
||||||
return const HandoutListResponse();
|
return const HandoutListResponse();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// 获取攻克记录信息 → GET /api/v1/StudyPack/GetRecord/{recordId}
|
||||||
|
///
|
||||||
|
/// 过渡页使用:获取攻克包名称、攻克标准、是否有题目等。
|
||||||
|
Future<OvercomeRecordInfo> getRecord(String recordId) async {
|
||||||
|
final data = await DioClient.instance.get(
|
||||||
|
'/api/v1/StudyPack/GetRecord/$recordId',
|
||||||
|
);
|
||||||
|
if (data is Map<String, dynamic>) {
|
||||||
|
return OvercomeRecordInfo.fromJson(data);
|
||||||
|
}
|
||||||
|
return const OvercomeRecordInfo();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -154,6 +154,34 @@ class HandoutItem {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// 攻克记录信息(过渡页使用,对标 Vue GetRecordData 返回值)
|
||||||
|
///
|
||||||
|
/// 接口:GET /api/v1/StudyPack/GetRecord/{recordId}
|
||||||
|
/// 用于过渡页(课前/课中/课后)展示攻克包名称、攻克标准、是否有题目等。
|
||||||
|
class OvercomeRecordInfo {
|
||||||
|
const OvercomeRecordInfo({
|
||||||
|
this.id = '',
|
||||||
|
this.name = '',
|
||||||
|
this.overcomeStandard = 0,
|
||||||
|
this.hasQuestion = false,
|
||||||
|
});
|
||||||
|
|
||||||
|
final String id; // 记录 id
|
||||||
|
final String name; // 攻克包名称
|
||||||
|
final int overcomeStandard; // 攻克标准(百分比 0-100)
|
||||||
|
final bool hasQuestion; // 是否有题目
|
||||||
|
|
||||||
|
factory OvercomeRecordInfo.fromJson(Map<String, dynamic> json) {
|
||||||
|
final payload = (json['data'] as Map<String, dynamic>?) ?? json;
|
||||||
|
return OvercomeRecordInfo(
|
||||||
|
id: payload['id']?.toString() ?? '',
|
||||||
|
name: payload['name'] as String? ?? '',
|
||||||
|
overcomeStandard: _parseInt(payload['overcomeStandard']),
|
||||||
|
hasQuestion: payload['hasQuestion'] as bool? ?? false,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// 讲义列表响应(Handout 接口返回的列表)
|
/// 讲义列表响应(Handout 接口返回的列表)
|
||||||
class HandoutListResponse {
|
class HandoutListResponse {
|
||||||
const HandoutListResponse({this.items = const []});
|
const HandoutListResponse({this.items = const []});
|
||||||
|
|||||||
@@ -0,0 +1,51 @@
|
|||||||
|
import 'package:new_learn/core/api/exam/model.dart';
|
||||||
|
import 'package:new_learn/core/network/dio_client.dart';
|
||||||
|
|
||||||
|
/// ============================================================
|
||||||
|
/// 【exam 模块接口】我的考试 —— 对标 Vue3 端 api/exam/index.ts
|
||||||
|
///
|
||||||
|
/// getSubjects —— 获取考试学科筛选 Tab 列表
|
||||||
|
/// search —— 我的考试分页列表
|
||||||
|
///
|
||||||
|
/// 注意:考试报告详情(getReport)等考试做题相关接口,
|
||||||
|
/// 后续扩展时再按模块拆分补进来。
|
||||||
|
/// ============================================================
|
||||||
|
class ExamApi {
|
||||||
|
ExamApi._();
|
||||||
|
|
||||||
|
static final ExamApi instance = ExamApi._();
|
||||||
|
|
||||||
|
/// 考试学科筛选 Tab 列表
|
||||||
|
/// GET /api/v1/Evaluation/GetSubjects
|
||||||
|
Future<List<ExamSubjectTab>> getSubjects() async {
|
||||||
|
final data = await DioClient.instance
|
||||||
|
.get('/api/v1/Evaluation/GetSubjects');
|
||||||
|
final list = data is List
|
||||||
|
? data.whereType<Map<String, dynamic>>().toList()
|
||||||
|
: (data is Map<String, dynamic>
|
||||||
|
? (data['data'] as List<dynamic>? ?? const [])
|
||||||
|
: const [])
|
||||||
|
.whereType<Map<String, dynamic>>()
|
||||||
|
.toList();
|
||||||
|
return list.map(ExamSubjectTab.fromJson).toList();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 我的考试分页列表
|
||||||
|
/// GET /api/v1/Evaluation/Search
|
||||||
|
/// 参数:baseSubjectId(可 null=全部)/ pageIndex / pageSize
|
||||||
|
Future<ExamResponse> search({
|
||||||
|
int? baseSubjectId,
|
||||||
|
required int pageIndex,
|
||||||
|
int pageSize = 10,
|
||||||
|
}) async {
|
||||||
|
final data = await DioClient.instance.get(
|
||||||
|
'/api/v1/Evaluation/Search',
|
||||||
|
query: {
|
||||||
|
if (baseSubjectId != null) 'baseSubjectId': baseSubjectId,
|
||||||
|
'pageIndex': pageIndex,
|
||||||
|
'pageSize': pageSize,
|
||||||
|
},
|
||||||
|
);
|
||||||
|
return ExamResponse.fromJson(data as Map<String, dynamic>);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,109 @@
|
|||||||
|
/// ============================================================
|
||||||
|
/// 【exam 模块模型】我的考试 —— 对标 Vue3 端 api/exam/type.ts
|
||||||
|
///
|
||||||
|
/// ExamDto —— 单条考试记录
|
||||||
|
/// ExamSubjectTab —— 考试科目筛选 Tab
|
||||||
|
/// ExamResponse —— 考试列表分页响应
|
||||||
|
///
|
||||||
|
/// 序列化:手动 fromJson,与项目其他模块风格一致,不依赖 build_runner。
|
||||||
|
///
|
||||||
|
/// ⚠ 注意:后端返回的 id 字段类型不统一(数字 or 字符串),
|
||||||
|
/// 所有数值字段统一用 _asInt() 做兼容解析,避免类型转换异常。
|
||||||
|
/// ============================================================
|
||||||
|
library;
|
||||||
|
|
||||||
|
int? _optInt(dynamic v) {
|
||||||
|
if (v == null) return null;
|
||||||
|
if (v is int) return v;
|
||||||
|
if (v is double) return v.toInt();
|
||||||
|
final s = v.toString();
|
||||||
|
final n = int.tryParse(s);
|
||||||
|
if (n != null) return n;
|
||||||
|
return double.tryParse(s)?.toInt();
|
||||||
|
}
|
||||||
|
|
||||||
|
int _asInt(dynamic v, [int fallback = 0]) => _optInt(v) ?? fallback;
|
||||||
|
|
||||||
|
/// 单条考试记录
|
||||||
|
class ExamDto {
|
||||||
|
const ExamDto({
|
||||||
|
this.id = 0,
|
||||||
|
this.taskId = 0,
|
||||||
|
this.taskName = '',
|
||||||
|
this.baseSubjectId = 0,
|
||||||
|
this.baseSubjectName = '',
|
||||||
|
this.startTime = '',
|
||||||
|
this.endTime = '',
|
||||||
|
this.totalScore = 0,
|
||||||
|
this.userScore = 0,
|
||||||
|
});
|
||||||
|
|
||||||
|
final int id;
|
||||||
|
final int taskId;
|
||||||
|
final String taskName;
|
||||||
|
final int baseSubjectId;
|
||||||
|
final String baseSubjectName;
|
||||||
|
final String startTime;
|
||||||
|
final String endTime;
|
||||||
|
final int totalScore;
|
||||||
|
final int userScore;
|
||||||
|
|
||||||
|
factory ExamDto.fromJson(Map<String, dynamic> json) {
|
||||||
|
return ExamDto(
|
||||||
|
id: _asInt(json['id']),
|
||||||
|
taskId: _asInt(json['taskId']),
|
||||||
|
taskName: (json['taskName'] as String?) ?? '',
|
||||||
|
baseSubjectId: _asInt(json['baseSubjectId']),
|
||||||
|
baseSubjectName: (json['baseSubjectName'] as String?) ?? '',
|
||||||
|
startTime: (json['startTime'] as String?) ?? '',
|
||||||
|
endTime: (json['endTime'] as String?) ?? '',
|
||||||
|
totalScore: _asInt(json['totalScore']),
|
||||||
|
userScore: _asInt(json['userScore']),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 考试科目筛选 Tab
|
||||||
|
class ExamSubjectTab {
|
||||||
|
const ExamSubjectTab({this.id, this.name = ''});
|
||||||
|
|
||||||
|
/// 为 null 表示"全部"
|
||||||
|
final int? id;
|
||||||
|
final String name;
|
||||||
|
|
||||||
|
factory ExamSubjectTab.fromJson(Map<String, dynamic> json) {
|
||||||
|
return ExamSubjectTab(
|
||||||
|
id: _optInt(json['id']),
|
||||||
|
name: (json['name'] as String?) ?? '',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 考试列表分页响应
|
||||||
|
class ExamResponse {
|
||||||
|
const ExamResponse({
|
||||||
|
this.data = const [],
|
||||||
|
this.total = 0,
|
||||||
|
this.pageIndex = 1,
|
||||||
|
this.pageSize = 10,
|
||||||
|
});
|
||||||
|
|
||||||
|
final List<ExamDto> data;
|
||||||
|
final int total;
|
||||||
|
final int pageIndex;
|
||||||
|
final int pageSize;
|
||||||
|
|
||||||
|
factory ExamResponse.fromJson(Map<String, dynamic> json) {
|
||||||
|
final payload = (json['data'] as Map<String, dynamic>?) ?? json;
|
||||||
|
final list = (payload['data'] as List<dynamic>? ?? const [])
|
||||||
|
.whereType<Map<String, dynamic>>()
|
||||||
|
.map(ExamDto.fromJson)
|
||||||
|
.toList();
|
||||||
|
return ExamResponse(
|
||||||
|
data: list,
|
||||||
|
total: (payload['total'] as num?)?.toInt() ?? list.length,
|
||||||
|
pageIndex: (payload['pageIndex'] as num?)?.toInt() ?? 1,
|
||||||
|
pageSize: (payload['pageSize'] as num?)?.toInt() ?? 10,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,46 @@
|
|||||||
|
import 'package:new_learn/core/api/report/model.dart';
|
||||||
|
import 'package:new_learn/core/network/dio_client.dart';
|
||||||
|
|
||||||
|
/// ============================================================
|
||||||
|
/// 【report 模块接口】入门测/出门测诊断报告 —— 对标 Vue3 端 api/report/index.ts
|
||||||
|
///
|
||||||
|
/// 注意:这个模块是"诊断报告包"那条链路的接口(studentInfo / reportComputation 页用),
|
||||||
|
/// 与 core/api/my_report(历史报告列表)不是同一个业务模块。
|
||||||
|
///
|
||||||
|
/// getCurrentReport() → 入门测报告(placementTest)
|
||||||
|
/// getCurrentAfterReport() → 出门测报告(exitTest)
|
||||||
|
/// getCurrentReportKnow() → 当前用户未掌握知识点(reportComputation AI 动画页用)
|
||||||
|
/// ============================================================
|
||||||
|
class ReportApi {
|
||||||
|
ReportApi._();
|
||||||
|
|
||||||
|
static final ReportApi instance = ReportApi._();
|
||||||
|
|
||||||
|
/// 获取当前用户入门测试报告 → GET /api/v1/UserReport/GetCurrentReport
|
||||||
|
Future<UserReportType> getCurrentReport() async {
|
||||||
|
final data = await DioClient.instance.get(
|
||||||
|
'/api/v1/UserReport/GetCurrentReport',
|
||||||
|
);
|
||||||
|
return UserReportType.fromJson(data as Map<String, dynamic>);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 获取当前用户出门测试报告 → GET /api/v1/UserReport/GetCurrentAfterReport
|
||||||
|
Future<UserReportType> getCurrentAfterReport() async {
|
||||||
|
final data = await DioClient.instance.get(
|
||||||
|
'/api/v1/UserReport/GetCurrentAfterReport',
|
||||||
|
);
|
||||||
|
return UserReportType.fromJson(data as Map<String, dynamic>);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 获取当前用户未掌握的知识点 → GET /api/v1/UserReport/GetCurrentReportKnow
|
||||||
|
Future<List<UserReportKnowType>> getCurrentReportKnow() async {
|
||||||
|
final data = await DioClient.instance.get(
|
||||||
|
'/api/v1/UserReport/GetCurrentReportKnow',
|
||||||
|
);
|
||||||
|
final list = data is List ? data : (data['data'] as List<dynamic>? ?? const []);
|
||||||
|
return list
|
||||||
|
.whereType<Map<String, dynamic>>()
|
||||||
|
.map(UserReportKnowType.fromJson)
|
||||||
|
.toList();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,80 @@
|
|||||||
|
/// ============================================================
|
||||||
|
/// 【report 模块模型】入门测/出门测报告 —— 对标 Vue3 端 api/report/type.ts
|
||||||
|
///
|
||||||
|
/// 注意:这个模块是"诊断报告包"(报告状态流转那条链路用的),
|
||||||
|
/// 与 core/api/my_report(历史报告列表)不是同一个业务模块。
|
||||||
|
///
|
||||||
|
/// SubjectReportType → 单科目报告(科目名/图标/知识点数/报告URL)
|
||||||
|
/// UserReportType → 当前用户诊断报告整体(用户名/能力等级/科目列表)
|
||||||
|
/// UserReportKnowType → 当前用户未掌握的知识点(reportComputation 页用)
|
||||||
|
///
|
||||||
|
/// 序列化:手动 fromJson,与项目其他模块风格一致,不依赖 build_runner。
|
||||||
|
/// ============================================================
|
||||||
|
library;
|
||||||
|
|
||||||
|
/// 单科目报告信息
|
||||||
|
class SubjectReportType {
|
||||||
|
const SubjectReportType({
|
||||||
|
this.subjectName = '',
|
||||||
|
this.url = '',
|
||||||
|
this.icon = '',
|
||||||
|
this.knowledgePoint = 0,
|
||||||
|
});
|
||||||
|
|
||||||
|
final String subjectName;
|
||||||
|
final String url;
|
||||||
|
final String icon;
|
||||||
|
final int knowledgePoint;
|
||||||
|
|
||||||
|
factory SubjectReportType.fromJson(Map<String, dynamic> json) {
|
||||||
|
return SubjectReportType(
|
||||||
|
subjectName: (json['subjectName'] as String?) ?? '',
|
||||||
|
url: (json['url'] as String?) ?? '',
|
||||||
|
icon: (json['icon'] as String?) ?? '',
|
||||||
|
knowledgePoint: (json['knowledgePoint'] as num?)?.toInt() ?? 0,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 当前用户诊断报告整体
|
||||||
|
class UserReportType {
|
||||||
|
const UserReportType({
|
||||||
|
this.userName = '',
|
||||||
|
this.userLevel = '',
|
||||||
|
this.subjectReports = const [],
|
||||||
|
});
|
||||||
|
|
||||||
|
final String userName;
|
||||||
|
final String userLevel;
|
||||||
|
final List<SubjectReportType> subjectReports;
|
||||||
|
|
||||||
|
factory UserReportType.fromJson(Map<String, dynamic> json) {
|
||||||
|
final payload = (json['data'] as Map<String, dynamic>?) ?? json;
|
||||||
|
return UserReportType(
|
||||||
|
userName: (payload['userName'] as String?) ?? '',
|
||||||
|
userLevel: (payload['userLevel'] as String?) ?? '',
|
||||||
|
subjectReports: (payload['subjectReports'] as List<dynamic>? ?? const [])
|
||||||
|
.whereType<Map<String, dynamic>>()
|
||||||
|
.map(SubjectReportType.fromJson)
|
||||||
|
.toList(),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 当前用户未掌握的知识点(reportComputation AI加载动画页用)
|
||||||
|
class UserReportKnowType {
|
||||||
|
const UserReportKnowType({
|
||||||
|
this.subjectName = '',
|
||||||
|
this.knowCount = 0,
|
||||||
|
});
|
||||||
|
|
||||||
|
final String subjectName;
|
||||||
|
final int knowCount;
|
||||||
|
|
||||||
|
factory UserReportKnowType.fromJson(Map<String, dynamic> json) {
|
||||||
|
return UserReportKnowType(
|
||||||
|
subjectName: (json['subjectName'] as String?) ?? '',
|
||||||
|
knowCount: (json['knowCount'] as num?)?.toInt() ?? 0,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,66 @@
|
|||||||
|
import 'package:new_learn/core/api/user_collect/model.dart';
|
||||||
|
import 'package:new_learn/core/network/dio_client.dart';
|
||||||
|
|
||||||
|
/// ============================================================
|
||||||
|
/// 【user_collect 模块接口】我的收藏 + 错题本 —— 对标 Vue3 端 api/userCollect/index.ts
|
||||||
|
///
|
||||||
|
/// getSubjects —— 学科筛选项(顶部 Tab)
|
||||||
|
/// GET /api/v1/UserCollect/GetUserCollectSubject/{type}
|
||||||
|
///
|
||||||
|
/// getCollectList —— 收藏/错题分页列表(游标分页)
|
||||||
|
/// GET /api/v1/UserCollect/GetUserCollect
|
||||||
|
/// 参数:type(1收藏/2错题) / subjectId(可选) / pageIndex / pageSize / prevPageId
|
||||||
|
///
|
||||||
|
/// 游标分页说明(对齐 Vue useList):
|
||||||
|
/// 第一页 prevPageId=0,之后每页传上一页最后一条的 id;
|
||||||
|
/// 切学科/下拉刷新时 prevPageId 重置为 0。
|
||||||
|
/// ============================================================
|
||||||
|
class UserCollectApi {
|
||||||
|
UserCollectApi._();
|
||||||
|
|
||||||
|
static final UserCollectApi instance = UserCollectApi._();
|
||||||
|
|
||||||
|
/// 学科筛选项([type] 1=我的收藏 2=错题本)
|
||||||
|
Future<List<CollectTab>> getSubjects(int type) async {
|
||||||
|
final data = await DioClient.instance.get(
|
||||||
|
'/api/v1/UserCollect/GetUserCollectSubject/$type',
|
||||||
|
);
|
||||||
|
// 兼容裸数组 / {data: [...]} 响应壳
|
||||||
|
final List<dynamic> list = data is List
|
||||||
|
? data
|
||||||
|
: (data is Map<String, dynamic>
|
||||||
|
? (data['data'] as List<dynamic>? ?? const [])
|
||||||
|
: const []);
|
||||||
|
return list
|
||||||
|
.whereType<Map<String, dynamic>>()
|
||||||
|
.map(CollectTab.fromJson)
|
||||||
|
.toList();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 收藏/错题分页列表
|
||||||
|
///
|
||||||
|
/// [type] 1=我的收藏 2=错题本;[subjectId] 不传 = 全部学科;
|
||||||
|
/// [prevPageId] 游标:首页传 0,翻页传上一页最后一条 id。
|
||||||
|
Future<UserCollectPage> getCollectList({
|
||||||
|
required int type,
|
||||||
|
int? subjectId,
|
||||||
|
required int pageIndex,
|
||||||
|
int pageSize = 10,
|
||||||
|
int prevPageId = 0,
|
||||||
|
}) async {
|
||||||
|
final query = <String, dynamic>{
|
||||||
|
'type': type,
|
||||||
|
'pageIndex': pageIndex,
|
||||||
|
'pageSize': pageSize,
|
||||||
|
'prevPageId': prevPageId,
|
||||||
|
};
|
||||||
|
// 对齐 Vue useList:subjectId 为 null 时不带该参数
|
||||||
|
if (subjectId != null) query['subjectId'] = subjectId;
|
||||||
|
|
||||||
|
final data = await DioClient.instance.get(
|
||||||
|
'/api/v1/UserCollect/GetUserCollect',
|
||||||
|
query: query,
|
||||||
|
);
|
||||||
|
return UserCollectPage.fromJson(data as Map<String, dynamic>);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,124 @@
|
|||||||
|
/// ============================================================
|
||||||
|
/// 【user_collect 模块模型】我的收藏 + 错题本 —— 对标 Vue3 端 api/userCollect/type.ts
|
||||||
|
///
|
||||||
|
/// CollectTab 学科筛选 Tab(GetUserCollectSubject 返回项)
|
||||||
|
/// UserCollectItem 列表项(收藏/错题通用,靠 type 区分)
|
||||||
|
/// UserCollectPage 分页响应(游标分页:pageIndex + prevPageId)
|
||||||
|
///
|
||||||
|
/// 说明:错题本页(myWrong)与收藏页(myCollect)共用同一套接口,
|
||||||
|
/// type=1 我的收藏 / type=2 错题本。
|
||||||
|
/// 序列化:手动 fromJson(兼容 {code, message, data: {...}} 响应壳),
|
||||||
|
/// 不依赖 build_runner。
|
||||||
|
/// ============================================================
|
||||||
|
library;
|
||||||
|
|
||||||
|
/// 兼容后端 id 字段:雪花 id 后端可能以 String 返回(防 JS 精度丢失),
|
||||||
|
/// 也可能直接是 num;统一转 int,无法解析返回 null。
|
||||||
|
int? _toInt(dynamic v) {
|
||||||
|
if (v == null) return null;
|
||||||
|
if (v is num) return v.toInt();
|
||||||
|
if (v is String && v.isNotEmpty) return int.tryParse(v);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 学科筛选 Tab
|
||||||
|
class CollectTab {
|
||||||
|
const CollectTab({
|
||||||
|
this.id,
|
||||||
|
required this.name,
|
||||||
|
this.remark = '',
|
||||||
|
this.status = 0,
|
||||||
|
});
|
||||||
|
|
||||||
|
/// 学科 id;null = 客户端插入的"全部"
|
||||||
|
final int? id;
|
||||||
|
final String name;
|
||||||
|
final String remark;
|
||||||
|
final int status;
|
||||||
|
|
||||||
|
factory CollectTab.fromJson(Map<String, dynamic> json) {
|
||||||
|
return CollectTab(
|
||||||
|
id: _toInt(json['id']),
|
||||||
|
name: json['name'] as String? ?? '',
|
||||||
|
remark: json['remark'] as String? ?? '',
|
||||||
|
status: _toInt(json['status']) ?? 0,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 收藏/错题列表项
|
||||||
|
class UserCollectItem {
|
||||||
|
const UserCollectItem({
|
||||||
|
this.id = 0,
|
||||||
|
this.questionId = 0,
|
||||||
|
this.recordQuestionId = 0,
|
||||||
|
this.questionStem = '',
|
||||||
|
this.subjectName = '',
|
||||||
|
this.packName = '',
|
||||||
|
this.createTime = '',
|
||||||
|
});
|
||||||
|
|
||||||
|
/// 列表明细 id(游标分页 prevPageId 取本页最后一条的 id)
|
||||||
|
final int id;
|
||||||
|
|
||||||
|
/// 题目 id(详情页参数 questionId)
|
||||||
|
final int questionId;
|
||||||
|
|
||||||
|
/// 答题记录 id(详情页参数 recordQuestionId)
|
||||||
|
final int recordQuestionId;
|
||||||
|
|
||||||
|
/// 题干 HTML(RichTextContent 渲染)
|
||||||
|
final String questionStem;
|
||||||
|
|
||||||
|
/// 学科名(SubjectTag 配色用)
|
||||||
|
final String subjectName;
|
||||||
|
|
||||||
|
/// 来源试卷/礼包名
|
||||||
|
final String packName;
|
||||||
|
|
||||||
|
/// 收藏/错题时间字符串
|
||||||
|
final String createTime;
|
||||||
|
|
||||||
|
factory UserCollectItem.fromJson(Map<String, dynamic> json) {
|
||||||
|
return UserCollectItem(
|
||||||
|
id: _toInt(json['id']) ?? 0,
|
||||||
|
questionId: _toInt(json['questionId']) ?? 0,
|
||||||
|
recordQuestionId: _toInt(json['recordQuestionId']) ?? 0,
|
||||||
|
questionStem: json['questionStem'] as String? ?? '',
|
||||||
|
subjectName: json['subjectName'] as String? ?? '',
|
||||||
|
packName: json['packName'] as String? ?? '',
|
||||||
|
createTime: json['createTime'] as String? ?? '',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 收藏/错题分页响应
|
||||||
|
class UserCollectPage {
|
||||||
|
const UserCollectPage({
|
||||||
|
this.data = const [],
|
||||||
|
this.total = 0,
|
||||||
|
this.pageIndex = 1,
|
||||||
|
this.pageSize = 10,
|
||||||
|
});
|
||||||
|
|
||||||
|
final List<UserCollectItem> data; // 当前页数据
|
||||||
|
final int total; // 总条数(顶部"X 道错题/收藏题目")
|
||||||
|
final int pageIndex;
|
||||||
|
final int pageSize;
|
||||||
|
|
||||||
|
/// 兼容业务响应壳 {code, message, data: {...}}:data 存在就取 data
|
||||||
|
factory UserCollectPage.fromJson(Map<String, dynamic> json) {
|
||||||
|
final payload = (json['data'] is Map<String, dynamic>)
|
||||||
|
? json['data'] as Map<String, dynamic>
|
||||||
|
: json;
|
||||||
|
return UserCollectPage(
|
||||||
|
data: (payload['data'] as List<dynamic>? ?? const [])
|
||||||
|
.whereType<Map<String, dynamic>>()
|
||||||
|
.map(UserCollectItem.fromJson)
|
||||||
|
.toList(),
|
||||||
|
total: _toInt(payload['total']) ?? 0,
|
||||||
|
pageIndex: _toInt(payload['pageIndex']) ?? 1,
|
||||||
|
pageSize: _toInt(payload['pageSize']) ?? 10,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,67 @@
|
|||||||
|
import 'package:new_learn/core/api/user_collect/model.dart';
|
||||||
|
import 'package:new_learn/core/api/user_note/model.dart';
|
||||||
|
import 'package:new_learn/core/network/dio_client.dart';
|
||||||
|
|
||||||
|
/// ============================================================
|
||||||
|
/// 【user_note 模块接口】我的笔记 —— 对标 Vue3 端 api/userNote/index.ts
|
||||||
|
///
|
||||||
|
/// getSubjects —— 学科筛选项(顶部 Tab,无参)
|
||||||
|
/// GET /api/v1/UserNote/GetUserCollectSubject
|
||||||
|
///
|
||||||
|
/// getNoteList —— 笔记分页列表(游标分页)
|
||||||
|
/// GET /api/v1/UserNote/GetUserNotes
|
||||||
|
/// 参数:subjectId(可选) / pageIndex / pageSize / prevPageId
|
||||||
|
///
|
||||||
|
/// 列表不按笔记类型过滤;type(1题目/2讲义) 由每条数据自带,
|
||||||
|
/// 前端用卡片角标图标区分。
|
||||||
|
///
|
||||||
|
/// 注意:Vue 同文件里的 OSS 凭证/上传地址接口归属 OSS 模块
|
||||||
|
/// (Flutter 端见 core/network/oss_api.dart),不在此重复封装。
|
||||||
|
/// ============================================================
|
||||||
|
class UserNoteApi {
|
||||||
|
UserNoteApi._();
|
||||||
|
|
||||||
|
static final UserNoteApi instance = UserNoteApi._();
|
||||||
|
|
||||||
|
/// 学科筛选项
|
||||||
|
Future<List<CollectTab>> getSubjects() async {
|
||||||
|
final data = await DioClient.instance.get(
|
||||||
|
'/api/v1/UserNote/GetUserCollectSubject',
|
||||||
|
);
|
||||||
|
// 兼容裸数组 / {data: [...]} 响应壳
|
||||||
|
final List<dynamic> list = data is List
|
||||||
|
? data
|
||||||
|
: (data is Map<String, dynamic>
|
||||||
|
? (data['data'] as List<dynamic>? ?? const [])
|
||||||
|
: const []);
|
||||||
|
return list
|
||||||
|
.whereType<Map<String, dynamic>>()
|
||||||
|
.map(CollectTab.fromJson)
|
||||||
|
.toList();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 笔记分页列表
|
||||||
|
///
|
||||||
|
/// [subjectId] 不传 = 全部学科;[prevPageId] 游标:首页传 0,
|
||||||
|
/// 翻页传上一页最后一条 id。
|
||||||
|
Future<UserNotePage> getNoteList({
|
||||||
|
int? subjectId,
|
||||||
|
required int pageIndex,
|
||||||
|
int pageSize = 10,
|
||||||
|
int prevPageId = 0,
|
||||||
|
}) async {
|
||||||
|
final query = <String, dynamic>{
|
||||||
|
'pageIndex': pageIndex,
|
||||||
|
'pageSize': pageSize,
|
||||||
|
'prevPageId': prevPageId,
|
||||||
|
};
|
||||||
|
// 对齐 Vue useList:subjectId 为 null 时不带该参数
|
||||||
|
if (subjectId != null) query['subjectId'] = subjectId;
|
||||||
|
|
||||||
|
final data = await DioClient.instance.get(
|
||||||
|
'/api/v1/UserNote/GetUserNotes',
|
||||||
|
query: query,
|
||||||
|
);
|
||||||
|
return UserNotePage.fromJson(data as Map<String, dynamic>);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,90 @@
|
|||||||
|
/// ============================================================
|
||||||
|
/// 【user_note 模块模型】我的笔记 —— 对标 Vue3 端 api/userNote/type.ts
|
||||||
|
///
|
||||||
|
/// UserNoteItem 笔记列表项(type 1=题目笔记 2=讲义笔记)
|
||||||
|
/// UserNotePage 分页响应(游标分页:pageIndex + prevPageId)
|
||||||
|
///
|
||||||
|
/// 学科筛选 Tab 复用收藏模块的 CollectTab(见 api.dart 的 import,
|
||||||
|
/// 与 Vue 端 api/userNote/index.ts 从 ../userCollect/type 引入一致)。
|
||||||
|
/// ============================================================
|
||||||
|
library;
|
||||||
|
|
||||||
|
/// 兼容后端 id 字段:雪花 id 后端可能以 String 返回(防 JS 精度丢失)
|
||||||
|
int? _noteToInt(dynamic v) {
|
||||||
|
if (v == null) return null;
|
||||||
|
if (v is num) return v.toInt();
|
||||||
|
if (v is String && v.isNotEmpty) return int.tryParse(v);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 我的笔记列表项
|
||||||
|
class UserNoteItem {
|
||||||
|
const UserNoteItem({
|
||||||
|
this.id = 0,
|
||||||
|
this.subjectName = '',
|
||||||
|
this.type = 0,
|
||||||
|
this.title = '',
|
||||||
|
this.content = '',
|
||||||
|
this.createTime = '',
|
||||||
|
});
|
||||||
|
|
||||||
|
/// 笔记 id(游标分页 prevPageId 取本页最后一条的 id;详情页参数 id)
|
||||||
|
final int id;
|
||||||
|
|
||||||
|
/// 学科名(SubjectTag 配色用)
|
||||||
|
final String subjectName;
|
||||||
|
|
||||||
|
/// 笔记类型:1=题目笔记 2=讲义笔记(卡片角标/详情页区分用)
|
||||||
|
final int type;
|
||||||
|
|
||||||
|
/// 笔记标题
|
||||||
|
final String title;
|
||||||
|
|
||||||
|
/// 笔记内容 HTML(RichTextContent 渲染)
|
||||||
|
final String content;
|
||||||
|
|
||||||
|
/// 记笔记时间字符串
|
||||||
|
final String createTime;
|
||||||
|
|
||||||
|
factory UserNoteItem.fromJson(Map<String, dynamic> json) {
|
||||||
|
return UserNoteItem(
|
||||||
|
id: _noteToInt(json['id']) ?? 0,
|
||||||
|
subjectName: json['subjectName'] as String? ?? '',
|
||||||
|
type: _noteToInt(json['type']) ?? 0,
|
||||||
|
title: json['title'] as String? ?? '',
|
||||||
|
content: json['content'] as String? ?? '',
|
||||||
|
createTime: json['createTime'] as String? ?? '',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 我的笔记分页响应
|
||||||
|
class UserNotePage {
|
||||||
|
const UserNotePage({
|
||||||
|
this.data = const [],
|
||||||
|
this.total = 0,
|
||||||
|
this.pageIndex = 1,
|
||||||
|
this.pageSize = 10,
|
||||||
|
});
|
||||||
|
|
||||||
|
final List<UserNoteItem> data;
|
||||||
|
final int total;
|
||||||
|
final int pageIndex;
|
||||||
|
final int pageSize;
|
||||||
|
|
||||||
|
/// 兼容业务响应壳 {code, message, data: {...}}:data 存在就取 data
|
||||||
|
factory UserNotePage.fromJson(Map<String, dynamic> json) {
|
||||||
|
final payload = (json['data'] is Map<String, dynamic>)
|
||||||
|
? json['data'] as Map<String, dynamic>
|
||||||
|
: json;
|
||||||
|
return UserNotePage(
|
||||||
|
data: (payload['data'] as List<dynamic>? ?? const [])
|
||||||
|
.whereType<Map<String, dynamic>>()
|
||||||
|
.map(UserNoteItem.fromJson)
|
||||||
|
.toList(),
|
||||||
|
total: _noteToInt(payload['total']) ?? 0,
|
||||||
|
pageIndex: _noteToInt(payload['pageIndex']) ?? 1,
|
||||||
|
pageSize: _noteToInt(payload['pageSize']) ?? 10,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
+7
-2
@@ -9,6 +9,7 @@ import 'package:new_learn/core/config/app_config.dart';
|
|||||||
import 'package:new_learn/core/logger/app_talker.dart';
|
import 'package:new_learn/core/logger/app_talker.dart';
|
||||||
import 'package:new_learn/core/providers/network_status_provider.dart';
|
import 'package:new_learn/core/providers/network_status_provider.dart';
|
||||||
import 'package:new_learn/core/providers/privacy_provider.dart';
|
import 'package:new_learn/core/providers/privacy_provider.dart';
|
||||||
|
import 'package:new_learn/core/report/report_redirect.dart';
|
||||||
import 'package:new_learn/core/router/app_router.dart';
|
import 'package:new_learn/core/router/app_router.dart';
|
||||||
import 'package:new_learn/core/services/local_notification_service.dart';
|
import 'package:new_learn/core/services/local_notification_service.dart';
|
||||||
import 'package:new_learn/core/utils/screen_adapt_template.dart'; // 复用 AppAdapt 适配配置
|
import 'package:new_learn/core/utils/screen_adapt_template.dart'; // 复用 AppAdapt 适配配置
|
||||||
@@ -89,8 +90,12 @@ class TabApp extends StatelessWidget {
|
|||||||
// 这样冷启动时不会先看到登录页/主页闪一下,再被路由重定向到隐私页,
|
// 这样冷启动时不会先看到登录页/主页闪一下,再被路由重定向到隐私页,
|
||||||
// 而是直接由全屏拦截页先接管。
|
// 而是直接由全屏拦截页先接管。
|
||||||
builder: (context, child) {
|
builder: (context, child) {
|
||||||
final content =
|
// ReportRedirectNotifier 必须包在 MaterialApp 里面(能拿到 GoRouterState)
|
||||||
PrivacyStartupGate(child: child ?? const SizedBox.shrink());
|
// 但在 PrivacyStartupGate 外层(隐私同意后的页面才能拦截)
|
||||||
|
final withRedirect = ReportRedirectNotifier(
|
||||||
|
child: child ?? const SizedBox.shrink(),
|
||||||
|
);
|
||||||
|
final content = PrivacyStartupGate(child: withRedirect);
|
||||||
final bootstrapped = _LocalNotificationBootstrapper(child: content);
|
final bootstrapped = _LocalNotificationBootstrapper(child: content);
|
||||||
if (kReleaseMode) return bootstrapped;
|
if (kReleaseMode) return bootstrapped;
|
||||||
return TalkerWrapper(
|
return TalkerWrapper(
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||||
|
import 'package:flutter_svg/flutter_svg.dart';
|
||||||
import 'package:flutter_widget_from_html_core/flutter_widget_from_html_core.dart';
|
import 'package:flutter_widget_from_html_core/flutter_widget_from_html_core.dart';
|
||||||
import 'package:new_learn/core/components/audio_player_card.dart';
|
import 'package:new_learn/core/components/audio_player_card.dart';
|
||||||
import 'package:new_learn/core/components/video_player_view.dart';
|
import 'package:new_learn/core/components/video_player_view.dart';
|
||||||
@@ -79,13 +81,47 @@ class RichTextContent extends StatelessWidget {
|
|||||||
textStyle: textStyle,
|
textStyle: textStyle,
|
||||||
onTapUrl: onTapUrl ?? _defaultOnTapUrl,
|
onTapUrl: onTapUrl ?? _defaultOnTapUrl,
|
||||||
customStylesBuilder: customStylesBuilder,
|
customStylesBuilder: customStylesBuilder,
|
||||||
customWidgetBuilder: _combinedCustomWidget,
|
customWidgetBuilder: _combinedCustomWidget(context),
|
||||||
renderMode: renderMode,
|
renderMode: renderMode,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// 合并默认替换 + 用户自定义替换
|
/// 合并默认替换 + 用户自定义替换
|
||||||
CustomWidgetBuilder get _combinedCustomWidget => (element) {
|
CustomWidgetBuilder _combinedCustomWidget(BuildContext context) => (element) {
|
||||||
|
// 内置:<img src="*.svg"> → flutter_svg 行内渲染
|
||||||
|
// core 版 flutter_widget_from_html 不支持 SVG,手动处理
|
||||||
|
if (element.localName == 'img') {
|
||||||
|
final src = element.attributes['src'];
|
||||||
|
if (src != null && src.toLowerCase().endsWith('.svg')) {
|
||||||
|
final width = double.tryParse(element.attributes['width'] ?? '');
|
||||||
|
final height = double.tryParse(element.attributes['height'] ?? '');
|
||||||
|
final w = width != null ? width.w : null;
|
||||||
|
final h = height != null ? height.h : null;
|
||||||
|
// 超采样(SSAA):SVG 以 3 倍尺寸光栅化再缩回来,消除真机边缘锯齿
|
||||||
|
const scale = 3.0;
|
||||||
|
return InlineCustomWidget(
|
||||||
|
child: SizedBox(
|
||||||
|
width: w,
|
||||||
|
height: h,
|
||||||
|
child: OverflowBox(
|
||||||
|
maxWidth: w != null ? w * scale : double.infinity,
|
||||||
|
maxHeight: h != null ? h * scale : double.infinity,
|
||||||
|
child: Transform.scale(
|
||||||
|
scale: 1 / scale,
|
||||||
|
alignment: Alignment.center,
|
||||||
|
child: SvgPicture.network(
|
||||||
|
src,
|
||||||
|
width: w != null ? w * scale : null,
|
||||||
|
height: h != null ? h * scale : null,
|
||||||
|
fit: BoxFit.contain,
|
||||||
|
clipBehavior: Clip.antiAlias,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
// 内置:<audio> → 本项目 AudioPlayerCard
|
// 内置:<audio> → 本项目 AudioPlayerCard
|
||||||
if (element.localName == 'audio') {
|
if (element.localName == 'audio') {
|
||||||
final src = element.attributes['src'];
|
final src = element.attributes['src'];
|
||||||
|
|||||||
@@ -0,0 +1,83 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||||
|
|
||||||
|
/// ============================================================
|
||||||
|
/// 【SubjectTag】学科标签(对标 Vue components/SubjectTag/SubjectTag.vue)
|
||||||
|
///
|
||||||
|
/// 四学科配色(与 Vue subjectMap 一致),未知学科兜底数学蓝:
|
||||||
|
/// 数学 #3D7DF5 / #E5F0FF 物理 #A45CFF / #F5ECFF
|
||||||
|
/// 英语 #E5A301 / #FFF6E3 化学 #2DB985 / #E5FAF3
|
||||||
|
///
|
||||||
|
/// 描边:Vue 用 ::before + mask-composite 画 2rpx 的学科色渐变描边
|
||||||
|
/// (两端 60% 学科色、中间 60% 近白色);Flutter 用"外层渐变容器 +
|
||||||
|
/// 内层底色容器留 1px 边"的嵌套方案等价实现。
|
||||||
|
///
|
||||||
|
/// 原 class 模块私有组件,因错题本/我的收藏列表也需要,按项目规范
|
||||||
|
/// 提升为 core/components 全局公共组件。
|
||||||
|
/// ============================================================
|
||||||
|
class SubjectTag extends StatelessWidget {
|
||||||
|
const SubjectTag({super.key, required this.subject});
|
||||||
|
|
||||||
|
final String subject;
|
||||||
|
|
||||||
|
static const Map<String, _SubjectColor> _map = {
|
||||||
|
// 数学:描边 rgba(90,158,255,.6) → rgba(242,248,255,.6)
|
||||||
|
'数学': _SubjectColor(0xFF3D7DF5, 0xFFE5F0FF, 0x995A9EFF, 0x99F2F8FF),
|
||||||
|
// 物理:描边 rgba(182,127,255,.6) → rgba(252,246,255,.6)
|
||||||
|
'物理': _SubjectColor(0xFFA45CFF, 0xFFF5ECFF, 0x99B67FFF, 0x99FCF6FF),
|
||||||
|
// 英语:描边 rgba(247,194,82,.6) → rgba(255,251,243,.6)
|
||||||
|
'英语': _SubjectColor(0xFFE5A301, 0xFFFFF6E3, 0x99F7C252, 0x99FFFBF3),
|
||||||
|
// 化学:描边 rgba(91,209,165,.6) → rgba(240,255,248,.6)
|
||||||
|
'化学': _SubjectColor(0xFF2DB985, 0xFFE5FAF3, 0x995BD1A5, 0x99F0FFF8),
|
||||||
|
};
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
final t = subject.trim();
|
||||||
|
if (t.isEmpty) return const SizedBox.shrink();
|
||||||
|
final c =
|
||||||
|
_map[t] ??
|
||||||
|
const _SubjectColor(0xFF3D7DF5, 0xFFE5F0FF, 0x995A9EFF, 0x99F2F8FF);
|
||||||
|
|
||||||
|
// Vue border-radius: 12rpx
|
||||||
|
final outerRadius = BorderRadius.circular(6.r);
|
||||||
|
// Vue ::before padding: 2rpx(描边厚度)
|
||||||
|
final borderWidth = 1.w;
|
||||||
|
|
||||||
|
return Container(
|
||||||
|
// 外层:学科色横向渐变,露出的 1px 边即"渐变描边"
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
gradient: LinearGradient(
|
||||||
|
begin: Alignment.centerLeft,
|
||||||
|
end: Alignment.centerRight,
|
||||||
|
colors: [Color(c.borderA), Color(c.borderB), Color(c.borderA)],
|
||||||
|
),
|
||||||
|
borderRadius: outerRadius,
|
||||||
|
),
|
||||||
|
child: Container(
|
||||||
|
margin: EdgeInsets.all(borderWidth),
|
||||||
|
// Vue padding: 4rpx 14rpx,扣除 2rpx 描边后内层 2rpx 12rpx
|
||||||
|
padding: EdgeInsets.symmetric(horizontal: 6.w, vertical: 1.h),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: Color(c.bg),
|
||||||
|
borderRadius: BorderRadius.circular(6.r - borderWidth),
|
||||||
|
),
|
||||||
|
// Vue white-space: nowrap:学科名不换行
|
||||||
|
child: Text(
|
||||||
|
t,
|
||||||
|
softWrap: false,
|
||||||
|
style: TextStyle(fontSize: 11, color: Color(c.fg)),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class _SubjectColor {
|
||||||
|
const _SubjectColor(this.fg, this.bg, this.borderA, this.borderB);
|
||||||
|
|
||||||
|
final int fg; // 文字色
|
||||||
|
final int bg; // 底色
|
||||||
|
final int borderA; // 渐变描边两端色(60% 学科色)
|
||||||
|
final int borderB; // 渐变描边中间色(60% 近白)
|
||||||
|
}
|
||||||
@@ -30,6 +30,7 @@ class CurrentUserExtension {
|
|||||||
this.userAvatarReason = '',
|
this.userAvatarReason = '',
|
||||||
this.isShowGuide = false,
|
this.isShowGuide = false,
|
||||||
this.isShowReport = false,
|
this.isShowReport = false,
|
||||||
|
this.isShowAfterReport = false,
|
||||||
this.id = 0,
|
this.id = 0,
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -48,6 +49,9 @@ class CurrentUserExtension {
|
|||||||
final String userAvatarReason;
|
final String userAvatarReason;
|
||||||
final bool isShowGuide;
|
final bool isShowGuide;
|
||||||
final bool isShowReport;
|
final bool isShowReport;
|
||||||
|
|
||||||
|
/// 是否显示出门测试报告(默认 false,后端置 true 后,用户完成报告查看后置回 false)
|
||||||
|
final bool isShowAfterReport;
|
||||||
final int id;
|
final int id;
|
||||||
|
|
||||||
/// JSON → 对象(服务器响应)
|
/// JSON → 对象(服务器响应)
|
||||||
@@ -74,6 +78,7 @@ class CurrentUserExtension {
|
|||||||
userAvatarReason: payload['userAvatarReason'] as String? ?? '',
|
userAvatarReason: payload['userAvatarReason'] as String? ?? '',
|
||||||
isShowGuide: payload['isShowGuide'] as bool? ?? false,
|
isShowGuide: payload['isShowGuide'] as bool? ?? false,
|
||||||
isShowReport: payload['isShowReport'] as bool? ?? false,
|
isShowReport: payload['isShowReport'] as bool? ?? false,
|
||||||
|
isShowAfterReport: payload['isShowAfterReport'] as bool? ?? false,
|
||||||
id: _toInt(payload['id']),
|
id: _toInt(payload['id']),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -96,12 +101,17 @@ class CurrentUserExtension {
|
|||||||
'userAvatarReason': userAvatarReason,
|
'userAvatarReason': userAvatarReason,
|
||||||
'isShowGuide': isShowGuide,
|
'isShowGuide': isShowGuide,
|
||||||
'isShowReport': isShowReport,
|
'isShowReport': isShowReport,
|
||||||
|
'isShowAfterReport': isShowAfterReport,
|
||||||
'id': id,
|
'id': id,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
/// 局部更新(目前只用得上 avatar:头像上传成功后替换 URL)
|
/// 局部更新(目前只用得上 avatar / isShowReport / isShowAfterReport)
|
||||||
CurrentUserExtension copyWith({String? avatar}) {
|
CurrentUserExtension copyWith({
|
||||||
|
String? avatar,
|
||||||
|
bool? isShowReport,
|
||||||
|
bool? isShowAfterReport,
|
||||||
|
}) {
|
||||||
return CurrentUserExtension(
|
return CurrentUserExtension(
|
||||||
userId: userId,
|
userId: userId,
|
||||||
userName: userName,
|
userName: userName,
|
||||||
@@ -117,7 +127,8 @@ class CurrentUserExtension {
|
|||||||
userAvatarStatus: userAvatarStatus,
|
userAvatarStatus: userAvatarStatus,
|
||||||
userAvatarReason: userAvatarReason,
|
userAvatarReason: userAvatarReason,
|
||||||
isShowGuide: isShowGuide,
|
isShowGuide: isShowGuide,
|
||||||
isShowReport: isShowReport,
|
isShowReport: isShowReport ?? this.isShowReport,
|
||||||
|
isShowAfterReport: isShowAfterReport ?? this.isShowAfterReport,
|
||||||
id: id,
|
id: id,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import 'package:flutter/foundation.dart';
|
import 'package:flutter/foundation.dart';
|
||||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||||
|
import 'package:new_learn/core/api/auth/api.dart';
|
||||||
import 'package:new_learn/core/models/user_model.dart';
|
import 'package:new_learn/core/models/user_model.dart';
|
||||||
import 'package:new_learn/core/storage/user_storage.dart';
|
import 'package:new_learn/core/storage/user_storage.dart';
|
||||||
|
|
||||||
@@ -86,6 +87,49 @@ class CurrentUserNotifier extends AsyncNotifier<CurrentUserExtension?> {
|
|||||||
// 也还是最新头像。
|
// 也还是最新头像。
|
||||||
await UserStorage.instance.saveUserInfo(updated);
|
await UserStorage.instance.saveUserInfo(updated);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// 强制从服务器拉最新用户信息(对齐 Vue App.vue 的 fetchCurrentUserExtension(true))
|
||||||
|
///
|
||||||
|
/// 使用场景:
|
||||||
|
/// 1. App 回前台(WidgetsBindingObserver resumed):拿最新 isShowReport / isShowAfterReport;
|
||||||
|
/// 2. 报告页调完 ChangeShowReport / ChangeShowAfterReport 后:刷新全局状态;
|
||||||
|
/// 3. 登录成功后:确保后端最新数据。
|
||||||
|
Future<CurrentUserExtension?> refresh() async {
|
||||||
|
try {
|
||||||
|
final ext = await UserApi.getCurrentUserExtension();
|
||||||
|
state = AsyncData(ext);
|
||||||
|
await UserStorage.instance.saveUserInfo(ext);
|
||||||
|
return ext;
|
||||||
|
} catch (_) {
|
||||||
|
// 网络失败:保持现有状态,不要清空(可能本来就是 AsyncData)
|
||||||
|
return state.value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 只改本地报告标记为 false(studentInfo subjectReports 为空时降级处理)
|
||||||
|
///
|
||||||
|
/// 对应 Vue studentInfo.vue 的:
|
||||||
|
/// userInfo.isShowReport = false; uni.setStorageSync('userInfo', userInfo);
|
||||||
|
/// app.setUserInfo(Object.assign({}, app.globalData.userInfo, { isShowReport: false }));
|
||||||
|
///
|
||||||
|
/// 注意:不走后端接口!因为 subjectReports 为空意味着后端可能也没报告数据,
|
||||||
|
/// 直接本地置 false 避免拦截器下次又打回来。
|
||||||
|
Future<void> markShowReportFalse() async {
|
||||||
|
final current = state.value;
|
||||||
|
if (current == null) return;
|
||||||
|
final updated = current.copyWith(isShowReport: false);
|
||||||
|
state = AsyncData(updated);
|
||||||
|
await UserStorage.instance.saveUserInfo(updated);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 只改本地出门测试报告标记为 false(降级场景用)
|
||||||
|
Future<void> markShowAfterReportFalse() async {
|
||||||
|
final current = state.value;
|
||||||
|
if (current == null) return;
|
||||||
|
final updated = current.copyWith(isShowAfterReport: false);
|
||||||
|
state = AsyncData(updated);
|
||||||
|
await UserStorage.instance.saveUserInfo(updated);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// 登录态变化信号(给 go_router 的 refreshListenable 用)
|
/// 登录态变化信号(给 go_router 的 refreshListenable 用)
|
||||||
|
|||||||
@@ -0,0 +1,184 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||||
|
import 'package:go_router/go_router.dart';
|
||||||
|
import 'package:new_learn/core/logger/app_talker.dart';
|
||||||
|
import 'package:new_learn/core/network/dio_client.dart';
|
||||||
|
import 'package:new_learn/core/providers/user_provider.dart';
|
||||||
|
|
||||||
|
/// ============================================================
|
||||||
|
/// 【报告状态全局拦截 + App 生命周期监听】
|
||||||
|
///
|
||||||
|
/// 对标 Vue App.vue 的 checkAndRedirectToReport() + onShow force 拉 userInfo。
|
||||||
|
///
|
||||||
|
/// 一、拦截时机(两处):
|
||||||
|
/// 1. userProvider 状态变化(set() / refresh())→ _checkAndRedirect()
|
||||||
|
/// :登录成功 / refresh 后都自动检查;
|
||||||
|
/// 2. App 回前台(WidgetsBindingObserver.resumed)→ force refresh() → 自动检查
|
||||||
|
/// :从胶囊面板/后台回来时拉最新 isShowReport;
|
||||||
|
///
|
||||||
|
/// 二、拦截条件(全部满足才跳):
|
||||||
|
/// ✅ 有登录态(DioClient.accessToken != null)
|
||||||
|
/// ✅ isShowReport=true 或 isShowAfterReport=true
|
||||||
|
/// ✅ 当前路由在 tab 页面(动态判断,不硬编码列表)
|
||||||
|
/// —— go_router 的 StatefulShellRoute.indexedStack 内的路由就是 tab 页
|
||||||
|
///
|
||||||
|
/// 三、动态判断 tab 页面的方法(不硬编码):
|
||||||
|
/// 通过 GoRouterState 的 matchedLocation,判断是否能匹配到 ShellBranch 内的路径
|
||||||
|
/// (即 /, /recite, /class, /my 这四个——但这些路径是由路由配置决定的,
|
||||||
|
/// 所以判断逻辑跟着路由配置走,别人改 tab 路径这里自动生效)。
|
||||||
|
///
|
||||||
|
/// ============================================================
|
||||||
|
|
||||||
|
/// 是否为 tab 路由(动态判断:4 个 tab 的路径由路由配置决定)
|
||||||
|
///
|
||||||
|
/// go_router 的 StatefulShellBranch 内配置了 4 条路径,
|
||||||
|
/// 直接从路由表读取所有 ShellBranch 的 path 集合,而不是硬编码。
|
||||||
|
/// 但 ShellBranch 的 routes 里只有 GoRoute,path 是字段。
|
||||||
|
/// 所以这里采用一个更稳的方式:判断当前是否在 StatefulShellRoute 里,
|
||||||
|
/// 或者直接在 app_router.dart 里暴露一个 tabPaths 常量。
|
||||||
|
///
|
||||||
|
/// 目前路由表固定,这里用 tabPaths 常量(从 app_router 导出)。
|
||||||
|
import 'package:new_learn/core/router/app_router.dart';
|
||||||
|
|
||||||
|
/// 拦截器:当 userProvider 变化时检查是否需要跳报告页
|
||||||
|
class ReportRedirectNotifier extends ConsumerStatefulWidget {
|
||||||
|
const ReportRedirectNotifier({super.key, required this.child});
|
||||||
|
final Widget child;
|
||||||
|
|
||||||
|
@override
|
||||||
|
ConsumerState<ReportRedirectNotifier> createState() =>
|
||||||
|
_ReportRedirectNotifierState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _ReportRedirectNotifierState extends ConsumerState<ReportRedirectNotifier>
|
||||||
|
with WidgetsBindingObserver {
|
||||||
|
/// 防止重复跳转标记
|
||||||
|
bool _isRedirecting = false;
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
WidgetsBinding.instance.addObserver(this);
|
||||||
|
talker.debug('[ReportRedirect] initState 🔥 被创建了');
|
||||||
|
// 监听 userProvider 后续变化
|
||||||
|
ref.listenManual(currentUserProvider, (prev, next) {
|
||||||
|
talker.debug('[ReportRedirect] listenManual 触发!prev=$prev next=$next');
|
||||||
|
_checkAndRedirect();
|
||||||
|
});
|
||||||
|
// 立即检查一次!listenManual 只监听变化不会主动触发,
|
||||||
|
// 登录后 userProvider 已经是 AsyncData 状态了,必须主动调。
|
||||||
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||||
|
talker.debug(
|
||||||
|
'[ReportRedirect] addPostFrameCallback → 主动调 _checkAndRedirect',
|
||||||
|
);
|
||||||
|
_checkAndRedirect();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void dispose() {
|
||||||
|
WidgetsBinding.instance.removeObserver(this);
|
||||||
|
super.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// App 生命周期变化:resumed 时 force 拉最新 userInfo
|
||||||
|
@override
|
||||||
|
void didChangeAppLifecycleState(AppLifecycleState state) {
|
||||||
|
super.didChangeAppLifecycleState(state);
|
||||||
|
if (state == AppLifecycleState.resumed) {
|
||||||
|
_onAppResumed();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> _onAppResumed() async {
|
||||||
|
// 只有已登录才 force 拉
|
||||||
|
if (DioClient.instance.accessToken == null) return;
|
||||||
|
talker.debug('[ReportRedirect] App resumed → force refresh userInfo');
|
||||||
|
await ref.read(currentUserProvider.notifier).refresh();
|
||||||
|
_checkAndRedirect();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 核心拦截逻辑:判断当前路由 + 报告标记 → 决定跳不跳
|
||||||
|
void _checkAndRedirect() {
|
||||||
|
talker.debug('[ReportRedirect] ===== _checkAndRedirect 开始 ====');
|
||||||
|
if (_isRedirecting) {
|
||||||
|
talker.debug('[ReportRedirect] _isRedirecting=true,跳过');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
final user = ref.read(currentUserProvider).value;
|
||||||
|
if (user == null) {
|
||||||
|
talker.debug('[ReportRedirect] user=null(未登录),放行');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: 调试报告用,把后端字段叠加调试开关,上线前删掉下面三行
|
||||||
|
// const _debugExitTest = false;
|
||||||
|
// const _debugPlacementTest = false;
|
||||||
|
const _debugExitTest = false; // true = 强制调试出门测
|
||||||
|
const _debugPlacementTest = false; // true = 强制调试入门测
|
||||||
|
|
||||||
|
talker.debug(
|
||||||
|
'[ReportRedirect] user.isShowReport=${user.isShowReport} '
|
||||||
|
'user.isShowAfterReport=${user.isShowAfterReport} '
|
||||||
|
'debugExit=$_debugExitTest debugPlacement=$_debugPlacementTest',
|
||||||
|
);
|
||||||
|
|
||||||
|
if (!user.isShowReport &&
|
||||||
|
!user.isShowAfterReport &&
|
||||||
|
!_debugExitTest &&
|
||||||
|
!_debugPlacementTest) {
|
||||||
|
talker.debug('[ReportRedirect] ❌ 无报告标记+无调试开关,放行');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
final isExitTest = user.isShowAfterReport || _debugExitTest;
|
||||||
|
final reportType = isExitTest
|
||||||
|
? 'exitTest'
|
||||||
|
: (user.isShowReport || _debugPlacementTest ? 'placementTest' : null);
|
||||||
|
if (reportType == null) {
|
||||||
|
talker.debug('[ReportRedirect] ❌ reportType=null,放行');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
talker.debug('[ReportRedirect] ✅ 通过标记检查,reportType=$reportType');
|
||||||
|
|
||||||
|
// 当前路由是否在 tab 页面(直接从全局 appRouter 拿,不需要 context)
|
||||||
|
String location = appRouter.state?.matchedLocation ?? '';
|
||||||
|
talker.debug('[ReportRedirect] appRouter.state matchedLocation=$location');
|
||||||
|
final inTab = _isInTabRoute(location);
|
||||||
|
talker.debug(
|
||||||
|
'[ReportRedirect] location=$location kTabPaths=$kTabPaths inTab=$inTab',
|
||||||
|
);
|
||||||
|
if (!inTab) {
|
||||||
|
talker.debug('[ReportRedirect] ❌ 不在 tab 页面,跳过拦截');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
talker.debug('[ReportRedirect] ✅✅✅ 触发跳转 → studentInfo?type=$reportType');
|
||||||
|
_isRedirecting = true;
|
||||||
|
|
||||||
|
try {
|
||||||
|
appRouter.go('/studentInfo', extra: {'type': reportType});
|
||||||
|
talker.debug('[ReportRedirect] appRouter.go 调用成功');
|
||||||
|
} catch (e) {
|
||||||
|
talker.error('[ReportRedirect] appRouter.go 崩了!', e);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 重置标记(go_router 会重建 Widget,这个 State 会被 dispose)
|
||||||
|
Future.delayed(const Duration(milliseconds: 100), () {
|
||||||
|
_isRedirecting = false;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 判断当前路径是否在 tab 路由里(动态,不硬编码)
|
||||||
|
///
|
||||||
|
/// go_router 的 StatefulShellRoute 下的 4 个 ShellBranch 里,
|
||||||
|
/// 第一个 GoRoute 的 path 就是 tab 路径。我们从 app_router 导出的
|
||||||
|
/// tabPaths 集合判断,别人改 tab 路径这里自动生效。
|
||||||
|
bool _isInTabRoute(String location) {
|
||||||
|
return kTabPaths.contains(location);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) => widget.child;
|
||||||
|
}
|
||||||
@@ -13,14 +13,21 @@ import 'package:new_learn/features/class/my_interact_page.dart';
|
|||||||
import 'package:new_learn/features/class/my_update_detail_page.dart';
|
import 'package:new_learn/features/class/my_update_detail_page.dart';
|
||||||
import 'package:new_learn/core/api/class/model.dart';
|
import 'package:new_learn/core/api/class/model.dart';
|
||||||
import 'package:new_learn/features/my/my_page.dart';
|
import 'package:new_learn/features/my/my_page.dart';
|
||||||
|
import 'package:new_learn/features/my/note/note_page.dart';
|
||||||
import 'package:new_learn/features/conquerPackage/captureList/index.dart';
|
import 'package:new_learn/features/conquerPackage/captureList/index.dart';
|
||||||
import 'package:new_learn/features/conquerPackage/beforeDuringClass/index.dart';
|
import 'package:new_learn/features/conquerPackage/beforeDuringClass/index.dart';
|
||||||
|
import 'package:new_learn/features/conquerPackage/transitionPage/transition_page.dart';
|
||||||
import 'package:new_learn/features/my/my_point/my_point_page.dart';
|
import 'package:new_learn/features/my/my_point/my_point_page.dart';
|
||||||
|
import 'package:new_learn/features/my/question_list/question_list_page.dart';
|
||||||
import 'package:new_learn/features/my/my_report/my_report_page.dart';
|
import 'package:new_learn/features/my/my_report/my_report_page.dart';
|
||||||
import 'package:new_learn/features/my/my_report/report_detail_page.dart';
|
import 'package:new_learn/features/my/my_report/report_detail_page.dart';
|
||||||
|
import 'package:new_learn/features/my/exam/exam_page.dart';
|
||||||
import 'package:new_learn/features/my/settings/settings_page.dart';
|
import 'package:new_learn/features/my/settings/settings_page.dart';
|
||||||
import 'package:new_learn/features/my/settings/about_app_page.dart';
|
import 'package:new_learn/features/my/settings/about_app_page.dart';
|
||||||
import 'package:new_learn/features/recite/recite_page.dart';
|
import 'package:new_learn/features/recite/recite_page.dart';
|
||||||
|
import 'package:new_learn/features/report/report_computation_page.dart';
|
||||||
|
import 'package:new_learn/features/report/report_web_view_page.dart';
|
||||||
|
import 'package:new_learn/features/report/student_info_page.dart';
|
||||||
import 'package:new_learn/features/task/task_page.dart';
|
import 'package:new_learn/features/task/task_page.dart';
|
||||||
import 'package:new_learn/core/router/main_tab_page.dart';
|
import 'package:new_learn/core/router/main_tab_page.dart';
|
||||||
import 'package:new_learn/core/network/dio_client.dart';
|
import 'package:new_learn/core/network/dio_client.dart';
|
||||||
@@ -71,6 +78,12 @@ import 'package:new_learn/core/providers/user_provider.dart';
|
|||||||
/// 必须在创建 GoRouter 前全局开启,见 main.dart 的 main()。
|
/// 必须在创建 GoRouter 前全局开启,见 main.dart 的 main()。
|
||||||
/// ============================================================
|
/// ============================================================
|
||||||
|
|
||||||
|
/// 【kTabPaths】四个底部 tab 路径集合(动态来源,别人改 tab 路由时同步改这里即可)
|
||||||
|
///
|
||||||
|
/// 全局拦截器 ReportRedirectNotifier 用它判断"当前是否在 tab 页面",
|
||||||
|
/// 避免硬编码分散在多个地方。
|
||||||
|
const kTabPaths = <String>{'/', '/recite', '/class', '/my'};
|
||||||
|
|
||||||
/// 全局路由表(对标 Vue 的 router/index.ts)
|
/// 全局路由表(对标 Vue 的 router/index.ts)
|
||||||
final GoRouter appRouter = GoRouter(
|
final GoRouter appRouter = GoRouter(
|
||||||
navigatorKey:
|
navigatorKey:
|
||||||
@@ -129,7 +142,19 @@ final GoRouter appRouter = GoRouter(
|
|||||||
MyUpdateDetailPage(initialPost: state.extra as UserPostDto),
|
MyUpdateDetailPage(initialPost: state.extra as UserPostDto),
|
||||||
),
|
),
|
||||||
GoRoute(path: '/myPoint', builder: (_, _) => const MyPointPage()),
|
GoRoute(path: '/myPoint', builder: (_, _) => const MyPointPage()),
|
||||||
|
// 我的笔记
|
||||||
|
GoRoute(path: '/myNote', builder: (_, _) => const NotePage()),
|
||||||
|
// 错题本(type=2)/ 我的收藏(type=1)共用 QuestionListPage
|
||||||
|
GoRoute(
|
||||||
|
path: '/myWrong',
|
||||||
|
builder: (_, _) => const QuestionListPage(type: 2),
|
||||||
|
),
|
||||||
|
GoRoute(
|
||||||
|
path: '/myCollect',
|
||||||
|
builder: (_, _) => const QuestionListPage(type: 1),
|
||||||
|
),
|
||||||
GoRoute(path: '/myReport', builder: (_, _) => const MyReportPage()),
|
GoRoute(path: '/myReport', builder: (_, _) => const MyReportPage()),
|
||||||
|
GoRoute(path: '/myExam', builder: (_, _) => const ExamPage()),
|
||||||
GoRoute(
|
GoRoute(
|
||||||
path: '/report-detail',
|
path: '/report-detail',
|
||||||
builder: (_, state) {
|
builder: (_, state) {
|
||||||
@@ -143,6 +168,16 @@ final GoRouter appRouter = GoRouter(
|
|||||||
),
|
),
|
||||||
GoRoute(path: '/settings', builder: (_, _) => const SettingsPage()),
|
GoRoute(path: '/settings', builder: (_, _) => const SettingsPage()),
|
||||||
GoRoute(path: '/about-app', builder: (_, _) => const AboutAppPage()),
|
GoRoute(path: '/about-app', builder: (_, _) => const AboutAppPage()),
|
||||||
|
// ---------- 诊断报告包三个页面(不在 ShellBranch 内,push 时不显示 tabbar) ----------
|
||||||
|
GoRoute(path: '/studentInfo', builder: (_, _) => const StudentInfoPage()),
|
||||||
|
GoRoute(
|
||||||
|
path: '/reportWebView',
|
||||||
|
builder: (_, _) => const ReportWebViewPage(),
|
||||||
|
),
|
||||||
|
GoRoute(
|
||||||
|
path: '/reportComputation',
|
||||||
|
builder: (_, _) => const ReportComputationPage(),
|
||||||
|
),
|
||||||
// ---------- 首次启动隐私协议页 ----------
|
// ---------- 首次启动隐私协议页 ----------
|
||||||
GoRoute(
|
GoRoute(
|
||||||
path: '/privacy-consent',
|
path: '/privacy-consent',
|
||||||
@@ -167,8 +202,7 @@ final GoRouter appRouter = GoRouter(
|
|||||||
// ---------- 攻克包 - 截图名单 ----------
|
// ---------- 攻克包 - 截图名单 ----------
|
||||||
GoRoute(
|
GoRoute(
|
||||||
path: '/conquerPackage/captureList',
|
path: '/conquerPackage/captureList',
|
||||||
builder: (_, state) =>
|
builder: (_, state) => CaptureListPage(courseId: state.extra as String),
|
||||||
CaptureListPage(courseId: state.extra as String),
|
|
||||||
),
|
),
|
||||||
// ---------- 攻克包 - 课前课中 ----------
|
// ---------- 攻克包 - 课前课中 ----------
|
||||||
GoRoute(
|
GoRoute(
|
||||||
@@ -177,6 +211,12 @@ final GoRouter appRouter = GoRouter(
|
|||||||
extra: state.extra as Map<String, dynamic>?,
|
extra: state.extra as Map<String, dynamic>?,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
GoRoute(
|
||||||
|
path: '/conquerPackage/transitionPage',
|
||||||
|
builder: (_, state) => TransitionPage(
|
||||||
|
extra: state.extra as Map<String, dynamic>?,
|
||||||
|
),
|
||||||
|
),
|
||||||
GoRoute(path: '/register', builder: (_, _) => const RegisterPage()),
|
GoRoute(path: '/register', builder: (_, _) => const RegisterPage()),
|
||||||
|
|
||||||
// app_router.dart 的 routes 里加,不用管跳转逻辑
|
// app_router.dart 的 routes 里加,不用管跳转逻辑
|
||||||
|
|||||||
@@ -0,0 +1,28 @@
|
|||||||
|
import 'package:new_learn/core/utils/img_url.dart';
|
||||||
|
|
||||||
|
/// ============================================================
|
||||||
|
/// 【学科图标常量】
|
||||||
|
///
|
||||||
|
/// 对标 Vue utils/constant.js 的 SUBJECT_ICON_MAP。
|
||||||
|
/// 我的报告(my_report)、我的考试(exam)等模块共用,
|
||||||
|
/// 通过学科名(如「数学」「英语」)动态取对应图标。
|
||||||
|
/// ============================================================
|
||||||
|
|
||||||
|
/// 学科名 → 图标资源路径
|
||||||
|
const Map<String, String> kSubjectIconMap = {
|
||||||
|
'语文': '/StaticResource/2026-06-11/shuxue1781163770612.png',
|
||||||
|
'化学': '/StaticResource/2026-06-11/huaxue1781163828443.png',
|
||||||
|
'英语': '/StaticResource/2026-06-11/yingyu1781163725441.png',
|
||||||
|
'物理': '/StaticResource/2026-06-11/wuli1781148438346.png',
|
||||||
|
'数学': '/StaticResource/2026-06-11/shuxue1781163770612.png',
|
||||||
|
'生物': '/StaticResource/2026-06-11/shengwu1781163791768.png',
|
||||||
|
'历史': '/StaticResource/2026-06-11/lishi1781163811822.png',
|
||||||
|
'政治': '/StaticResource/2026-06-11/zhengzhi1781163750422.png',
|
||||||
|
'地理': '/StaticResource/2026-06-11/dili1781163844311.png',
|
||||||
|
};
|
||||||
|
|
||||||
|
/// 取学科图标完整 URL(无匹配时用数学兜底,对标 Vue getSubjectIcon)
|
||||||
|
String subjectIconUrl(String subjectName) {
|
||||||
|
final path = kSubjectIconMap[subjectName] ?? kSubjectIconMap['数学']!;
|
||||||
|
return ImgUrl.build(path);
|
||||||
|
}
|
||||||
@@ -381,6 +381,18 @@ class _LoginPageState extends ConsumerState<LoginPage> {
|
|||||||
password: password,
|
password: password,
|
||||||
rememberPassword: _rememberPassword,
|
rememberPassword: _rememberPassword,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if (mounted) {
|
||||||
|
// 对齐 Vue login/index.vue L404: 登录成功后检查报告标记
|
||||||
|
// isShowReport / isShowAfterReport 任一为 true → 跳报告页
|
||||||
|
final hasReport = user.isShowReport || user.isShowAfterReport;
|
||||||
|
if (hasReport) {
|
||||||
|
final reportType = user.isShowAfterReport ? 'exitTest' : 'placementTest';
|
||||||
|
context.go('/studentInfo', extra: {'type': reportType});
|
||||||
|
} else {
|
||||||
|
context.go('/');
|
||||||
|
}
|
||||||
|
}
|
||||||
} catch (_) {
|
} catch (_) {
|
||||||
debugPrint('⚠ 【用户信息】拉取失败,已跳过缓存');
|
debugPrint('⚠ 【用户信息】拉取失败,已跳过缓存');
|
||||||
// 即使拉用户信息失败也存历史(userName 留空)
|
// 即使拉用户信息失败也存历史(userName 留空)
|
||||||
@@ -390,19 +402,7 @@ class _LoginPageState extends ConsumerState<LoginPage> {
|
|||||||
password: password,
|
password: password,
|
||||||
rememberPassword: _rememberPassword,
|
rememberPassword: _rememberPassword,
|
||||||
);
|
);
|
||||||
}
|
if (mounted) context.go('/');
|
||||||
|
|
||||||
if (mounted) {
|
|
||||||
final messenger = ScaffoldMessenger.of(context);
|
|
||||||
context.go('/');
|
|
||||||
// messenger.showSnackBar(
|
|
||||||
// SnackBar(
|
|
||||||
// content: Text(
|
|
||||||
// '登录成功,欢迎 ${res.info.userName.isEmpty ? account : res.info.userName}',
|
|
||||||
// ),
|
|
||||||
// duration: const Duration(seconds: 2),
|
|
||||||
// ),
|
|
||||||
// );
|
|
||||||
}
|
}
|
||||||
} on ApiException catch (e) {
|
} on ApiException catch (e) {
|
||||||
if (mounted) _toast(e.message);
|
if (mounted) _toast(e.message);
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import 'package:flutter_screenutil/flutter_screenutil.dart';
|
|||||||
import 'package:new_learn/core/api/class/model.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/image_preview_viewer.dart';
|
||||||
import 'package:new_learn/core/components/resolve_problem_box.dart';
|
import 'package:new_learn/core/components/resolve_problem_box.dart';
|
||||||
|
import 'package:new_learn/core/components/subject_tag.dart';
|
||||||
import 'package:new_learn/core/components/user_circle_avatar.dart';
|
import 'package:new_learn/core/components/user_circle_avatar.dart';
|
||||||
import 'package:new_learn/core/utils/img_url.dart';
|
import 'package:new_learn/core/utils/img_url.dart';
|
||||||
|
|
||||||
@@ -236,35 +237,6 @@ class CardHeader extends StatelessWidget {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// 学科标签(对标 SubjectTag)
|
|
||||||
class SubjectTag extends StatelessWidget {
|
|
||||||
const SubjectTag({super.key, required this.subject});
|
|
||||||
|
|
||||||
final String subject;
|
|
||||||
|
|
||||||
static const Map<String, _SubjectColor> _map = {
|
|
||||||
'数学': _SubjectColor(0xFF3D7DF5, 0xFFE5F0FF),
|
|
||||||
'物理': _SubjectColor(0xFFA45CFF, 0xFFF5ECFF),
|
|
||||||
'英语': _SubjectColor(0xFFE5A301, 0xFFFFF6E3),
|
|
||||||
'化学': _SubjectColor(0xFF2DB985, 0xFFE5FAF3),
|
|
||||||
};
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
final t = subject.trim();
|
|
||||||
if (t.isEmpty) return const SizedBox.shrink();
|
|
||||||
final c = _map[t] ?? const _SubjectColor(0xFF3D7DF5, 0xFFE5F0FF);
|
|
||||||
return Container(
|
|
||||||
padding: EdgeInsets.symmetric(horizontal: 7.w, vertical: 2.h),
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
color: Color(c.bg),
|
|
||||||
borderRadius: BorderRadius.circular(6.r),
|
|
||||||
),
|
|
||||||
child: Text(t, style: TextStyle(fontSize: 11, color: Color(c.fg))),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// 纯文字笔记(album-desc,最多 2 行)
|
/// 纯文字笔记(album-desc,最多 2 行)
|
||||||
class AlbumDesc extends StatelessWidget {
|
class AlbumDesc extends StatelessWidget {
|
||||||
const AlbumDesc({super.key, required this.text});
|
const AlbumDesc({super.key, required this.text});
|
||||||
@@ -613,9 +585,3 @@ class _CommentInputState extends State<CommentInput> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class _SubjectColor {
|
|
||||||
const _SubjectColor(this.fg, this.bg);
|
|
||||||
final int fg;
|
|
||||||
final int bg;
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import 'package:cached_network_image/cached_network_image.dart';
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/scheduler.dart';
|
import 'package:flutter/scheduler.dart';
|
||||||
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||||
|
import 'package:go_router/go_router.dart';
|
||||||
import 'package:new_learn/core/api/conquerPackage/beforeDuringClass/api.dart';
|
import 'package:new_learn/core/api/conquerPackage/beforeDuringClass/api.dart';
|
||||||
import 'package:new_learn/core/api/conquerPackage/beforeDuringClass/model.dart';
|
import 'package:new_learn/core/api/conquerPackage/beforeDuringClass/model.dart';
|
||||||
import 'package:new_learn/core/api/public_upload/model.dart';
|
import 'package:new_learn/core/api/public_upload/model.dart';
|
||||||
@@ -176,6 +177,13 @@ class _BeforeDuringClassPageState extends State<BeforeDuringClassPage>
|
|||||||
.getListByRecordHandout(_recordId);
|
.getListByRecordHandout(_recordId);
|
||||||
}
|
}
|
||||||
_pageList = List<HandoutItem>.from(resp.items);
|
_pageList = List<HandoutItem>.from(resp.items);
|
||||||
|
|
||||||
|
// _pageList = List<HandoutItem>.from(resp.items).map((item) {
|
||||||
|
// return item.copyWith(
|
||||||
|
// content: item.content +
|
||||||
|
// '<div class="hxdb-stem" name="hxdbStem"><div class="hxdb-stem-content" name="hxdbStem-content" data-hxdb-type="stem"><p>某兴趣小组利用 Pt1000 铂电阻测量温度。实验中没有电压表,现将电流表 <img src="https://hx.cnzhyx.cn/K12LatexToSvg/ProductionV2/LatexSvg/2026-08-27/878136bf67384b3ab5998cc6fc15bc32_0_398c9b77.svg" width="25" height="17" style="width: 25px; height: 17px; vertical-align: middle;"> 与已知电阻 <img src="https://hx.cnzhyx.cn/K12LatexToSvg/ProductionV2/LatexSvg/2026-08-27/5a406b64eafd47f3a8686bba4741c29a_1_b71473bc.svg" width="26" height="17" style="width: 26px; height: 17px; vertical-align: middle;"> 串联组成一条支路,将电流表 <img src="https://hx.cnzhyx.cn/K12LatexToSvg/ProductionV2/LatexSvg/2026-08-27/167759d79f984e45a0d48c31a3c6566e_2_fb3fd646.svg" width="26" height="17" style="width: 26px; height: 17px; vertical-align: middle;"> 与待测铂电阻 <img src="https://hx.cnzhyx.cn/K12LatexToSvg/ProductionV2/LatexSvg/2026-08-27/f769c572150d4ce782daa8935a9ceb83_3_b1a4eeff.svg" width="23" height="16" style="width: 23px; height: 16px; vertical-align: middle;"> 串联组成另一条支路,两支路并联。忽略两电流表内阻,<img src="https://hx.cnzhyx.cn/K12LatexToSvg/ProductionV2/LatexSvg/2026-08-27/d37447ecfe6440d1bd97e900cacf3b64_4_398c9b77.svg" width="25" height="17" style="width: 25px; height: 17px; vertical-align: middle;">、<img src="https://hx.cnzhyx.cn/K12LatexToSvg/ProductionV2/LatexSvg/2026-08-27/8a5d7731a3b744d193a514eeb253ca92_5_fb3fd646.svg" width="26" height="17" style="width: 26px; height: 17px; vertical-align: middle;"> 的示数分别为 <img src="https://hx.cnzhyx.cn/K12LatexToSvg/ProductionV2/LatexSvg/2026-08-27/9265c18c28934f61bc64bef449f1e641_6_6c3f86e2.svg" width="19" height="16" style="width: 19px; height: 16px; vertical-align: middle;">、<img src="https://hx.cnzhyx.cn/K12LatexToSvg/ProductionV2/LatexSvg/2026-08-27/b0fdd5ecc5a0477eb7a245d2c0fcf041_7_93189365.svg" width="20" height="17" style="width: 20px; height: 17px; vertical-align: middle;">。铂电阻阻值 <img src="https://hx.cnzhyx.cn/K12LatexToSvg/ProductionV2/LatexSvg/2026-08-27/340415fadcf24d87a7ed79eb81a64c30_8_b1a4eeff.svg" width="23" height="16" style="width: 23px; height: 16px; vertical-align: middle;"> 的表达式为</p><p><br><img src="https://hx.cnzhyx.cn/K12/Question/png/2026-08-24/85cb7f0925a841c6b894ce351678be4f.png" class="preview-content" style="max-width:100%;"><br></p></div><table class="hxdb-option-table" name="hxdbOptionTable" style="width: 100%; table-layout: fixed; border-collapse: collapse;"><tbody><tr class="hxdb-option-table-tr firstRow" name="hxdbOptionTableTr"><td class="hxdb-option-table-td" name="hxdbOptionTableTd" valign="top" style="word-break: break-all;"><span class="hxdb-option-label">A.</span> <img src="https://hx.cnzhyx.cn/K12LatexToSvg/ProductionV2/LatexSvg/2026-08-27/3094744dbf1644bb80aceae639e61c6a_9_7f8b9fc5.svg" width="92" height="40" style="width: 92px; height: 40px; vertical-align: middle;"></td></tr><tr class="hxdb-option-table-tr firstRow" name="hxdbOptionTableTr"><td class="hxdb-option-table-td" name="hxdbOptionTableTd" valign="top" style="word-break: break-all;"><span class="hxdb-option-label">B.</span> <img src="https://hx.cnzhyx.cn/K12LatexToSvg/ProductionV2/LatexSvg/2026-08-27/96acf8a47eda4cdf81ef01707a28abff_10_fa759021.svg" width="92" height="40" style="width: 92px; height: 40px; vertical-align: middle;"></td></tr><tr class="hxdb-option-table-tr firstRow" name="hxdbOptionTableTr"><td class="hxdb-option-table-td" name="hxdbOptionTableTd" valign="top" style="word-break: break-all;"><span class="hxdb-option-label">C.</span> <img src="https://hx.cnzhyx.cn/K12LatexToSvg/ProductionV2/LatexSvg/2026-08-27/aecc386b27d341e393bbc45ac86e9e20_11_7cd89d59.svg" width="144" height="42" style="width: 144px; height: 42px; vertical-align: middle;"></td></tr><tr class="hxdb-option-table-tr firstRow" name="hxdbOptionTableTr"><td class="hxdb-option-table-td" name="hxdbOptionTableTd" valign="top" style="word-break: break-all;"><span class="hxdb-option-label">D.</span> <img src="https://hx.cnzhyx.cn/K12LatexToSvg/ProductionV2/LatexSvg/2026-08-27/6c8a4a6004f04529b9d6b48b4d7560c3_12_1f4bbe90.svg" width="144" height="42" style="width: 144px; height: 42px; vertical-align: middle;"></td></tr></tbody></table></div>',
|
||||||
|
// );
|
||||||
|
// }).toList();
|
||||||
// _pageList = List<HandoutItem>.from(resp.items).map((item) {
|
// _pageList = List<HandoutItem>.from(resp.items).map((item) {
|
||||||
// return item.copyWith(
|
// return item.copyWith(
|
||||||
// isUploadNotes: true,
|
// isUploadNotes: true,
|
||||||
@@ -480,8 +488,17 @@ class _BeforeDuringClassPageState extends State<BeforeDuringClassPage>
|
|||||||
}
|
}
|
||||||
|
|
||||||
void _goTransitionPage() {
|
void _goTransitionPage() {
|
||||||
// TODO: 跳转到 transition 页,等路由配置好后替换
|
// 判断下一个状态:课前(1)→课中(2)→课后(3)
|
||||||
Navigator.of(context).pop();
|
// 此处简化:完成学习后默认进入课后练习过渡页(status=3)
|
||||||
|
context.push(
|
||||||
|
'/conquerPackage/transitionPage',
|
||||||
|
extra: {
|
||||||
|
'courseId': _courseId,
|
||||||
|
'packId': _packId,
|
||||||
|
'recordId': _recordId,
|
||||||
|
'status': '3',
|
||||||
|
},
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ===================== 笔记变化 =====================
|
// ===================== 笔记变化 =====================
|
||||||
|
|||||||
@@ -0,0 +1,703 @@
|
|||||||
|
import 'package:cached_network_image/cached_network_image.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||||
|
import 'package:go_router/go_router.dart';
|
||||||
|
import 'package:new_learn/core/api/conquerPackage/beforeDuringClass/api.dart';
|
||||||
|
import 'package:new_learn/core/api/conquerPackage/beforeDuringClass/model.dart';
|
||||||
|
import 'package:new_learn/core/utils/img_url.dart';
|
||||||
|
|
||||||
|
/// ============================================================
|
||||||
|
/// 【TransitionPage】课前/课中/课后 过渡页面
|
||||||
|
/// 对标 Vue pages/conquerPackage/transitionPage/transitionPage.vue
|
||||||
|
///
|
||||||
|
/// 一、三种状态:
|
||||||
|
/// status = 1 → 课前讲义(带滑动蒙层引导)
|
||||||
|
/// status = 2 → 课中视频
|
||||||
|
/// status = 3 → 课后练习(含提示卡片 + 攻克标准)
|
||||||
|
///
|
||||||
|
/// 二、路由参数(通过 extra 传入):
|
||||||
|
/// - courseId 课程 id
|
||||||
|
/// - packId 攻克包 id
|
||||||
|
/// - recordId 学习记录 id
|
||||||
|
/// - status 状态:1课前 / 2课中 / 3课后
|
||||||
|
///
|
||||||
|
/// 三、尺寸换算(本工程统一):
|
||||||
|
/// Vue 的 N rpx → Flutter 的 (N/2).w/.h/.sp/.r
|
||||||
|
///
|
||||||
|
/// 四、跳转:
|
||||||
|
/// status 1/2 → 跳 beforeDuringClass 页
|
||||||
|
/// status 3 → 跳 classExercises 页
|
||||||
|
/// ============================================================
|
||||||
|
|
||||||
|
/// 过渡页状态
|
||||||
|
enum TransitionStatus {
|
||||||
|
beforeClass(1), // 课前讲义
|
||||||
|
duringClass(2), // 课中视频
|
||||||
|
afterClass(3); // 课后练习
|
||||||
|
|
||||||
|
final int value;
|
||||||
|
const TransitionStatus(this.value);
|
||||||
|
|
||||||
|
factory TransitionStatus.fromInt(dynamic v) {
|
||||||
|
final n = int.tryParse(v?.toString() ?? '') ?? 1;
|
||||||
|
return TransitionStatus.values.firstWhere(
|
||||||
|
(e) => e.value == n,
|
||||||
|
orElse: () => TransitionStatus.beforeClass,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class TransitionPage extends StatefulWidget {
|
||||||
|
const TransitionPage({super.key, this.extra});
|
||||||
|
|
||||||
|
final Map<String, dynamic>? extra;
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<TransitionPage> createState() => _TransitionPageState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _TransitionPageState extends State<TransitionPage> {
|
||||||
|
// ========== 颜色常量 ==========
|
||||||
|
static const Color _bgColor = Color(0xFFF5F8FA);
|
||||||
|
static const Color _titleColor = Color(0xFF1D2B47);
|
||||||
|
static const Color _subtitleColor = Color(0xFF99A4BA);
|
||||||
|
static const Color _primary = Color(0xFF3D7DF5);
|
||||||
|
static const Color _labelBg = Color(0xFFE3ECFF);
|
||||||
|
|
||||||
|
// ========== 路由参数 ==========
|
||||||
|
late String _courseId;
|
||||||
|
late String _packId;
|
||||||
|
late String _recordId;
|
||||||
|
late TransitionStatus _status;
|
||||||
|
|
||||||
|
// ========== 数据 ==========
|
||||||
|
OvercomeRecordInfo _overcomeInfo = const OvercomeRecordInfo();
|
||||||
|
bool _loading = true;
|
||||||
|
bool _showMask = true; // 课前蒙层是否显示
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
_parseExtra();
|
||||||
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||||
|
_loadData();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// ===================== 初始化 =====================
|
||||||
|
|
||||||
|
void _parseExtra() {
|
||||||
|
final extra = widget.extra ?? const <String, dynamic>{};
|
||||||
|
_courseId = (extra['courseId']?.toString()) ?? '';
|
||||||
|
_packId = (extra['packId']?.toString()) ?? '';
|
||||||
|
_recordId = (extra['recordId']?.toString()) ?? '';
|
||||||
|
_status = TransitionStatus.fromInt(extra['status']);
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> _loadData() async {
|
||||||
|
setState(() => _loading = true);
|
||||||
|
try {
|
||||||
|
if (_recordId.isEmpty) {
|
||||||
|
throw Exception('recordId 无效');
|
||||||
|
}
|
||||||
|
final info = await BeforeDuringClassApi.instance.getRecord(_recordId);
|
||||||
|
if (!mounted) return;
|
||||||
|
setState(() => _overcomeInfo = info);
|
||||||
|
} catch (e) {
|
||||||
|
debugPrint('[TransitionPage] 加载失败: $e');
|
||||||
|
// 失败时回退到攻克列表页
|
||||||
|
if (mounted) {
|
||||||
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
|
SnackBar(
|
||||||
|
content: Text('获取攻克信息失败:${e.toString()}'),
|
||||||
|
behavior: SnackBarBehavior.floating,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
context.go('/conquerPackage/captureList', extra: _courseId);
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
if (mounted) setState(() => _loading = false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ===================== 点击开始学习 =====================
|
||||||
|
|
||||||
|
void _startLearning() {
|
||||||
|
if (_status == TransitionStatus.beforeClass ||
|
||||||
|
_status == TransitionStatus.duringClass) {
|
||||||
|
context.push(
|
||||||
|
'/conquerPackage/beforeDuringClass',
|
||||||
|
extra: {
|
||||||
|
'status': '${_status.value}',
|
||||||
|
'courseId': _courseId,
|
||||||
|
'packId': _packId,
|
||||||
|
'recordId': _recordId,
|
||||||
|
},
|
||||||
|
);
|
||||||
|
} else if (_status == TransitionStatus.afterClass) {
|
||||||
|
if (_overcomeInfo.hasQuestion) {
|
||||||
|
// TODO(路由): classExercises 页建好后替换
|
||||||
|
// context.push('/conquerPackage/classExercises', extra: {
|
||||||
|
// 'courseId': _courseId,
|
||||||
|
// 'packId': _packId,
|
||||||
|
// 'recordId': _recordId,
|
||||||
|
// });
|
||||||
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
|
const SnackBar(
|
||||||
|
content: Text('习题页待开发'),
|
||||||
|
behavior: SnackBarBehavior.floating,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ===================== Build =====================
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Scaffold(
|
||||||
|
backgroundColor: _bgColor,
|
||||||
|
body: Stack(
|
||||||
|
children: [
|
||||||
|
SafeArea(
|
||||||
|
child: Column(
|
||||||
|
children: [
|
||||||
|
_buildNavBar(),
|
||||||
|
Expanded(
|
||||||
|
child: _loading
|
||||||
|
? const Center(child: CircularProgressIndicator())
|
||||||
|
: _buildBody(),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
// 课前引导蒙层
|
||||||
|
if (_status == TransitionStatus.beforeClass && _showMask)
|
||||||
|
_SlideMask(
|
||||||
|
visible: _showMask,
|
||||||
|
onClose: () => setState(() => _showMask = false),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ===================== NavBar =====================
|
||||||
|
|
||||||
|
Widget _buildNavBar() {
|
||||||
|
return SizedBox(
|
||||||
|
height: 44.h,
|
||||||
|
child: Stack(
|
||||||
|
children: [
|
||||||
|
Positioned(
|
||||||
|
left: 16.w,
|
||||||
|
top: 0,
|
||||||
|
bottom: 0,
|
||||||
|
child: IconButton(
|
||||||
|
icon: const Icon(Icons.arrow_back_ios,
|
||||||
|
color: Color.fromRGBO(0, 0, 0, 0.8), size: 20),
|
||||||
|
onPressed: () => Navigator.of(context).maybePop(),
|
||||||
|
padding: EdgeInsets.zero,
|
||||||
|
constraints: const BoxConstraints(),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ===================== Body =====================
|
||||||
|
|
||||||
|
Widget _buildBody() {
|
||||||
|
switch (_status) {
|
||||||
|
case TransitionStatus.beforeClass:
|
||||||
|
return _buildBeforeClass();
|
||||||
|
case TransitionStatus.duringClass:
|
||||||
|
return _buildDuringClass();
|
||||||
|
case TransitionStatus.afterClass:
|
||||||
|
return _buildAfterClass();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---------- 课前讲义 ----------
|
||||||
|
|
||||||
|
Widget _buildBeforeClass() {
|
||||||
|
return Column(
|
||||||
|
children: [
|
||||||
|
// 背景插图
|
||||||
|
CachedNetworkImage(
|
||||||
|
imageUrl: ImgUrl.build(
|
||||||
|
'/StaticResource/2026-04-01/before-class-bac.png',
|
||||||
|
),
|
||||||
|
width: 170.w,
|
||||||
|
height: 149.h,
|
||||||
|
fit: BoxFit.contain,
|
||||||
|
placeholder: (_, __) => SizedBox.shrink(),
|
||||||
|
errorWidget: (_, __, ___) => SizedBox(
|
||||||
|
width: 170.w,
|
||||||
|
height: 149.h,
|
||||||
|
child: const Icon(Icons.menu_book_outlined,
|
||||||
|
size: 80, color: _primary),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
SizedBox(height: 50.h),
|
||||||
|
// 标签
|
||||||
|
_buildLabel('课前讲义'),
|
||||||
|
SizedBox(height: 12.h),
|
||||||
|
// 标题
|
||||||
|
_buildTitle(
|
||||||
|
name: _overcomeInfo.name,
|
||||||
|
subtitle: '知识点讲义学习',
|
||||||
|
),
|
||||||
|
const Spacer(),
|
||||||
|
// 开始学习按钮
|
||||||
|
_buildStartButton('开始学习'),
|
||||||
|
SizedBox(height: 46.h),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---------- 课中视频 ----------
|
||||||
|
|
||||||
|
Widget _buildDuringClass() {
|
||||||
|
return Column(
|
||||||
|
children: [
|
||||||
|
// 背景插图
|
||||||
|
CachedNetworkImage(
|
||||||
|
imageUrl: ImgUrl.build(
|
||||||
|
'/StaticResource/2026-04-01/during-class-bac.png',
|
||||||
|
),
|
||||||
|
width: 186.w,
|
||||||
|
height: 120.h,
|
||||||
|
fit: BoxFit.contain,
|
||||||
|
placeholder: (_, __) => SizedBox.shrink(),
|
||||||
|
errorWidget: (_, __, ___) => SizedBox(
|
||||||
|
width: 186.w,
|
||||||
|
height: 120.h,
|
||||||
|
child:
|
||||||
|
const Icon(Icons.play_circle_outline, size: 80, color: _primary),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
SizedBox(height: 42.h),
|
||||||
|
_buildLabel('课中视频'),
|
||||||
|
SizedBox(height: 12.h),
|
||||||
|
_buildTitle(
|
||||||
|
name: _overcomeInfo.name,
|
||||||
|
subtitle: '知识点视频学习',
|
||||||
|
),
|
||||||
|
const Spacer(),
|
||||||
|
_buildStartButton('开始学习'),
|
||||||
|
SizedBox(height: 46.h),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---------- 课后练习 ----------
|
||||||
|
|
||||||
|
Widget _buildAfterClass() {
|
||||||
|
return SingleChildScrollView(
|
||||||
|
child: Column(
|
||||||
|
children: [
|
||||||
|
// 背景插图
|
||||||
|
CachedNetworkImage(
|
||||||
|
imageUrl: ImgUrl.build(
|
||||||
|
'/StaticResource/2026-04-01/after-class-bac.png',
|
||||||
|
),
|
||||||
|
width: 170.w,
|
||||||
|
height: 170.h,
|
||||||
|
fit: BoxFit.contain,
|
||||||
|
placeholder: (_, __) => SizedBox.shrink(),
|
||||||
|
errorWidget: (_, __, ___) => SizedBox(
|
||||||
|
width: 170.w,
|
||||||
|
height: 170.h,
|
||||||
|
child:
|
||||||
|
const Icon(Icons.assignment_outlined, size: 80, color: _primary),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
SizedBox(height: 25.h),
|
||||||
|
_buildLabel('课后练习'),
|
||||||
|
SizedBox(height: 12.h),
|
||||||
|
if (_overcomeInfo.name.isNotEmpty)
|
||||||
|
_buildTitle(
|
||||||
|
name: _overcomeInfo.name,
|
||||||
|
subtitle: '知识点题目攻克',
|
||||||
|
padding: EdgeInsets.symmetric(horizontal: 5.w),
|
||||||
|
),
|
||||||
|
SizedBox(height: 28.h),
|
||||||
|
// 提示卡片
|
||||||
|
_buildAfterTipsCard(),
|
||||||
|
SizedBox(height: 28.h),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ===================== 公共组件 =====================
|
||||||
|
|
||||||
|
Widget _buildLabel(String text) {
|
||||||
|
return Container(
|
||||||
|
width: 60.w,
|
||||||
|
height: 20.h,
|
||||||
|
alignment: Alignment.center,
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: _labelBg,
|
||||||
|
borderRadius: BorderRadius.circular(4.r),
|
||||||
|
),
|
||||||
|
child: Text(
|
||||||
|
text,
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 12.sp,
|
||||||
|
color: _primary,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _buildTitle({
|
||||||
|
required String name,
|
||||||
|
required String subtitle,
|
||||||
|
EdgeInsetsGeometry? padding,
|
||||||
|
}) {
|
||||||
|
return Padding(
|
||||||
|
padding: padding ?? EdgeInsets.zero,
|
||||||
|
child: Column(
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
name.isNotEmpty ? '《$name》' : '',
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 18.sp,
|
||||||
|
fontWeight: FontWeight.w600,
|
||||||
|
color: _titleColor,
|
||||||
|
height: 1.4,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
SizedBox(height: 4.h),
|
||||||
|
Text(
|
||||||
|
subtitle,
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 18.sp,
|
||||||
|
fontWeight: FontWeight.w600,
|
||||||
|
color: _titleColor,
|
||||||
|
height: 1.4,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _buildStartButton(String text) {
|
||||||
|
return Padding(
|
||||||
|
padding: EdgeInsets.symmetric(horizontal: 14.w),
|
||||||
|
child: SizedBox(
|
||||||
|
width: double.infinity,
|
||||||
|
height: 47.h,
|
||||||
|
child: FilledButton(
|
||||||
|
onPressed: _startLearning,
|
||||||
|
style: FilledButton.styleFrom(
|
||||||
|
backgroundColor: _primary,
|
||||||
|
foregroundColor: Colors.white,
|
||||||
|
shape: RoundedRectangleBorder(
|
||||||
|
borderRadius: BorderRadius.circular(20.r),
|
||||||
|
),
|
||||||
|
textStyle: TextStyle(
|
||||||
|
fontSize: 18.sp,
|
||||||
|
fontWeight: FontWeight.w500,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
child: Text(text),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ===================== 课后提示卡片 =====================
|
||||||
|
|
||||||
|
Widget _buildAfterTipsCard() {
|
||||||
|
return Center(
|
||||||
|
child: Container(
|
||||||
|
margin: EdgeInsets.symmetric(horizontal: 14.w),
|
||||||
|
constraints: BoxConstraints(maxWidth: 347.w),
|
||||||
|
width: double.infinity,
|
||||||
|
child: LayoutBuilder(
|
||||||
|
builder: (context, constraints) {
|
||||||
|
// 卡片实际宽度(平板上被 maxWidth 限制,手机上 = 屏宽 - 左右边距)
|
||||||
|
final cardW = constraints.maxWidth;
|
||||||
|
// 设计稿卡片宽度 = 750rpx - 28rpx*2 = 694rpx = 347dp
|
||||||
|
// 内部所有水平/垂直定位都按卡片宽度比例换算,
|
||||||
|
// 保证背景图(fitWidth)和内部定位永远同步
|
||||||
|
double wRatio(double designPx) => cardW * designPx / 347.0;
|
||||||
|
|
||||||
|
return Container(
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: const Color(0xFFF2F7FF),
|
||||||
|
borderRadius: BorderRadius.circular(12.r),
|
||||||
|
image: DecorationImage(
|
||||||
|
image: NetworkImage(
|
||||||
|
ImgUrl.build(
|
||||||
|
'/StaticResource/2026-04-01/after-class-tips.png',
|
||||||
|
),
|
||||||
|
),
|
||||||
|
fit: BoxFit.fitWidth,
|
||||||
|
alignment: Alignment.topCenter,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
padding: EdgeInsets.fromLTRB(
|
||||||
|
wRatio(14),
|
||||||
|
wRatio(129), // 背景图随宽度缩放,padding-top 也按卡片宽比例
|
||||||
|
wRatio(14),
|
||||||
|
14.h,
|
||||||
|
),
|
||||||
|
child: Stack(
|
||||||
|
clipBehavior: Clip.none,
|
||||||
|
children: [
|
||||||
|
// 攻克标准百分比(按卡片宽度比例定位,与背景图缩放同步)
|
||||||
|
Positioned(
|
||||||
|
right: wRatio(75.5),
|
||||||
|
top: -wRatio(64),
|
||||||
|
child: Text(
|
||||||
|
'${_overcomeInfo.overcomeStandard}%',
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 16.sp,
|
||||||
|
fontWeight: FontWeight.w600,
|
||||||
|
color: _primary,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
_buildTipItem('包含单选、多选、判断、填空全题型'),
|
||||||
|
SizedBox(height: 4.h),
|
||||||
|
_buildTipItem('每题展示深度解析与解题逻辑'),
|
||||||
|
SizedBox(height: 15.h),
|
||||||
|
// 正式进入攻克按钮
|
||||||
|
Opacity(
|
||||||
|
opacity: _overcomeInfo.hasQuestion ? 1.0 : 0.6,
|
||||||
|
child: SizedBox(
|
||||||
|
width: double.infinity,
|
||||||
|
height: 47.h,
|
||||||
|
child: FilledButton(
|
||||||
|
onPressed: _overcomeInfo.hasQuestion
|
||||||
|
? _startLearning
|
||||||
|
: null,
|
||||||
|
style: FilledButton.styleFrom(
|
||||||
|
backgroundColor: _primary,
|
||||||
|
foregroundColor: Colors.white,
|
||||||
|
disabledBackgroundColor: _primary,
|
||||||
|
disabledForegroundColor: Colors.white,
|
||||||
|
shape: RoundedRectangleBorder(
|
||||||
|
borderRadius: BorderRadius.circular(20.r),
|
||||||
|
),
|
||||||
|
textStyle: TextStyle(
|
||||||
|
fontSize: 18.sp,
|
||||||
|
fontWeight: FontWeight.w500,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
child: const Text('正式进入攻克'),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _buildTipItem(String text) {
|
||||||
|
return Padding(
|
||||||
|
padding: EdgeInsets.only(left: 24.w, bottom: 4.h),
|
||||||
|
child: Row(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
|
children: [
|
||||||
|
Container(
|
||||||
|
width: 4.w,
|
||||||
|
height: 4.w,
|
||||||
|
margin: EdgeInsets.only(right: 13.w),
|
||||||
|
decoration: const BoxDecoration(
|
||||||
|
color: _primary,
|
||||||
|
shape: BoxShape.circle,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Expanded(
|
||||||
|
child: Text(
|
||||||
|
text,
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 14.sp,
|
||||||
|
color: _subtitleColor,
|
||||||
|
height: 1.5,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// ============================================================
|
||||||
|
/// 【_SlideMask】滑动蒙层引导组件
|
||||||
|
/// 对标 Vue pages/conquerPackage/transitionPage/slide-mask.vue
|
||||||
|
///
|
||||||
|
/// 功能:
|
||||||
|
/// - 半透明黑色蒙层背景
|
||||||
|
/// - 显示引导图
|
||||||
|
/// - 向左滑动超过阈值 → 整个蒙层滑出屏幕并触发 onClose
|
||||||
|
/// - 滑动不足阈值 → 回弹
|
||||||
|
/// ============================================================
|
||||||
|
class _SlideMask extends StatefulWidget {
|
||||||
|
const _SlideMask({
|
||||||
|
required this.visible,
|
||||||
|
required this.onClose,
|
||||||
|
this.slideThreshold = 80.0,
|
||||||
|
});
|
||||||
|
|
||||||
|
final bool visible;
|
||||||
|
final VoidCallback onClose;
|
||||||
|
final double slideThreshold;
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<_SlideMask> createState() => _SlideMaskState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _SlideMaskState extends State<_SlideMask>
|
||||||
|
with SingleTickerProviderStateMixin {
|
||||||
|
double _offsetX = 0;
|
||||||
|
double _startX = 0;
|
||||||
|
bool _isSliding = false;
|
||||||
|
bool _isAnimatingOut = false;
|
||||||
|
late final AnimationController _slideOutController;
|
||||||
|
late Animation<double> _slideOutAnim;
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
_slideOutController = AnimationController(
|
||||||
|
vsync: this,
|
||||||
|
duration: const Duration(milliseconds: 200),
|
||||||
|
);
|
||||||
|
_slideOutAnim = Tween<double>(begin: 0, end: 0).animate(
|
||||||
|
CurvedAnimation(parent: _slideOutController, curve: Curves.easeInOut),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void dispose() {
|
||||||
|
_slideOutController.dispose();
|
||||||
|
super.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void didUpdateWidget(covariant _SlideMask oldWidget) {
|
||||||
|
super.didUpdateWidget(oldWidget);
|
||||||
|
if (widget.visible && !oldWidget.visible) {
|
||||||
|
_offsetX = 0;
|
||||||
|
_isAnimatingOut = false;
|
||||||
|
_slideOutController.reset();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void _handleTouchStart(DragStartDetails details) {
|
||||||
|
if (!widget.visible || _isAnimatingOut) return;
|
||||||
|
_startX = details.globalPosition.dx;
|
||||||
|
_isSliding = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void _handleTouchUpdate(DragUpdateDetails details) {
|
||||||
|
if (!widget.visible || !_isSliding || _isAnimatingOut) return;
|
||||||
|
final moveX = details.globalPosition.dx;
|
||||||
|
final diffX = _startX - moveX;
|
||||||
|
// 仅处理向左滑动
|
||||||
|
if (diffX > 0) {
|
||||||
|
setState(() => _offsetX = -diffX);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void _handleTouchEnd(DragEndDetails details) {
|
||||||
|
if (!widget.visible || !_isSliding) return;
|
||||||
|
_isSliding = false;
|
||||||
|
|
||||||
|
if (_offsetX.abs() >= widget.slideThreshold) {
|
||||||
|
// 超过阈值 → 滑出动画
|
||||||
|
_startSlideOut();
|
||||||
|
} else {
|
||||||
|
// 回弹
|
||||||
|
setState(() => _offsetX = 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void _startSlideOut() {
|
||||||
|
_isAnimatingOut = true;
|
||||||
|
final screenWidth = MediaQuery.of(context).size.width;
|
||||||
|
_slideOutAnim = Tween<double>(begin: _offsetX, end: -screenWidth).animate(
|
||||||
|
CurvedAnimation(parent: _slideOutController, curve: Curves.easeInOut),
|
||||||
|
);
|
||||||
|
_slideOutController.forward().then((_) {
|
||||||
|
widget.onClose();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
if (!widget.visible) return const SizedBox.shrink();
|
||||||
|
|
||||||
|
return AnimatedBuilder(
|
||||||
|
animation: _slideOutAnim,
|
||||||
|
builder: (context, child) {
|
||||||
|
final dx = _isAnimatingOut ? _slideOutAnim.value : _offsetX;
|
||||||
|
return Positioned.fill(
|
||||||
|
child: GestureDetector(
|
||||||
|
onHorizontalDragStart: _handleTouchStart,
|
||||||
|
onHorizontalDragUpdate: _handleTouchUpdate,
|
||||||
|
onHorizontalDragEnd: _handleTouchEnd,
|
||||||
|
behavior: HitTestBehavior.opaque,
|
||||||
|
child: Transform.translate(
|
||||||
|
offset: Offset(dx, 0),
|
||||||
|
child: Container(
|
||||||
|
color: const Color(0x8C000000), // 55% 透明黑
|
||||||
|
child: Stack(
|
||||||
|
children: [
|
||||||
|
// 引导图
|
||||||
|
Positioned(
|
||||||
|
left: 0,
|
||||||
|
right: 0,
|
||||||
|
bottom: 187.h,
|
||||||
|
child: Center(
|
||||||
|
child: CachedNetworkImage(
|
||||||
|
imageUrl: ImgUrl.build(
|
||||||
|
'/StaticResource/2026-04-01/guidance.png',
|
||||||
|
),
|
||||||
|
width: 244.5.w,
|
||||||
|
height: 122.5.h,
|
||||||
|
fit: BoxFit.contain,
|
||||||
|
placeholder: (_, __) => SizedBox.shrink(),
|
||||||
|
errorWidget: (_, __, ___) => SizedBox(
|
||||||
|
width: 244.5.w,
|
||||||
|
height: 122.5.h,
|
||||||
|
child: const Icon(
|
||||||
|
Icons.swipe_left,
|
||||||
|
color: Colors.white,
|
||||||
|
size: 60,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,435 @@
|
|||||||
|
import 'dart:ui' as ui;
|
||||||
|
|
||||||
|
import 'package:cached_network_image/cached_network_image.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||||
|
import 'package:new_learn/core/api/exam/api.dart';
|
||||||
|
import 'package:new_learn/core/api/exam/model.dart';
|
||||||
|
import 'package:new_learn/core/components/common_paged_list.dart';
|
||||||
|
import 'package:new_learn/core/logger/app_talker.dart';
|
||||||
|
import 'package:new_learn/core/utils/img_url.dart';
|
||||||
|
import 'package:new_learn/core/utils/subject_icons.dart';
|
||||||
|
|
||||||
|
/// ============================================================
|
||||||
|
/// 【ExamPage】我的考试列表页 —— 对标 Vue pages/myPackage/exam/exam.vue
|
||||||
|
///
|
||||||
|
/// 结构:
|
||||||
|
/// AppBar + Tab 栏(全部/各学科,胶囊样式,动态拉取)
|
||||||
|
/// + 分页列表(CommonPagedList,下拉刷新/触底加载)
|
||||||
|
/// + 卡片(学科图标 + 考试名 + 时间 + 得分渐变文字)
|
||||||
|
///
|
||||||
|
/// 点击卡片 → 跳考试报告详情
|
||||||
|
/// (先留 TODO,后续考试详情页做了再接入路由)
|
||||||
|
/// ============================================================
|
||||||
|
class ExamPage extends StatefulWidget {
|
||||||
|
const ExamPage({super.key});
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<ExamPage> createState() => _ExamPageState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _ExamPageState extends State<ExamPage> {
|
||||||
|
final List<ExamSubjectTab> _tabs = [];
|
||||||
|
ExamSubjectTab _currentTab = const ExamSubjectTab(id: null, name: '全部');
|
||||||
|
bool _tabsLoading = true;
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
_tabs.add(const ExamSubjectTab(id: null, name: '全部'));
|
||||||
|
_loadTabs();
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> _loadTabs() async {
|
||||||
|
try {
|
||||||
|
final list = await ExamApi.instance.getSubjects();
|
||||||
|
if (!mounted) return;
|
||||||
|
setState(() {
|
||||||
|
_tabs
|
||||||
|
..clear()
|
||||||
|
..add(const ExamSubjectTab(id: null, name: '全部'))
|
||||||
|
..addAll(list);
|
||||||
|
_currentTab = _tabs.first;
|
||||||
|
_tabsLoading = false;
|
||||||
|
});
|
||||||
|
} catch (e) {
|
||||||
|
talker.error('获取考试科目Tab失败', e);
|
||||||
|
if (!mounted) return;
|
||||||
|
setState(() {
|
||||||
|
_tabs
|
||||||
|
..clear()
|
||||||
|
..add(const ExamSubjectTab(id: null, name: '全部'));
|
||||||
|
_currentTab = _tabs.first;
|
||||||
|
_tabsLoading = false;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 分页加载回调
|
||||||
|
Future<PagingResult<ExamDto>> _loadPage(int pageKey) async {
|
||||||
|
final res = await ExamApi.instance.search(
|
||||||
|
baseSubjectId: _currentTab.id,
|
||||||
|
pageIndex: pageKey,
|
||||||
|
pageSize: 10,
|
||||||
|
);
|
||||||
|
// hasNext:当前页返回数据满 pageSize 且总数更大
|
||||||
|
final hasMore =
|
||||||
|
res.data.length >= res.pageSize && res.total > pageKey * res.pageSize;
|
||||||
|
return PagingResult(data: res.data, hasNext: hasMore);
|
||||||
|
}
|
||||||
|
|
||||||
|
void _onTapTab(ExamSubjectTab tab) {
|
||||||
|
if (_currentTab.id == tab.id) return;
|
||||||
|
setState(() => _currentTab = tab);
|
||||||
|
// tab 切换后,通过 ValueKey 让 CommonPagedList 重建 State,自动首屏加载新数据
|
||||||
|
}
|
||||||
|
|
||||||
|
void _goToExamDetail(ExamDto item) {
|
||||||
|
// TODO: 接入考试报告详情页路由,对应 Vue /pages/examPackage/examReport/index?recordId=${item.id}
|
||||||
|
talker.debug('点击考试详情: ${item.taskName}, id=${item.id}');
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Scaffold(
|
||||||
|
backgroundColor: Colors.white,
|
||||||
|
appBar: AppBar(
|
||||||
|
title: const Text('我的考试'),
|
||||||
|
backgroundColor: Colors.white,
|
||||||
|
foregroundColor: const Color(0xFF1D2B47),
|
||||||
|
elevation: 0,
|
||||||
|
centerTitle: true,
|
||||||
|
bottom: PreferredSize(
|
||||||
|
preferredSize: Size.fromHeight(44.h),
|
||||||
|
child: _buildTabBar(),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
body: _tabsLoading
|
||||||
|
? const Center(child: CircularProgressIndicator())
|
||||||
|
: Container(
|
||||||
|
color: const Color(0xFFF5F8FA),
|
||||||
|
child: CommonPagedList<ExamDto>(
|
||||||
|
key: ValueKey('exam-list-${_currentTab.id}'),
|
||||||
|
load: _loadPage,
|
||||||
|
padding: EdgeInsets.fromLTRB(12.w, 24.h, 12.w, 0),
|
||||||
|
// separatorBuilder: (_, __) => SizedBox(height: 14.h),
|
||||||
|
noMoreText: '- AI 爱学蝶变提醒你 没有更多了 -',
|
||||||
|
emptyWidget: _buildEmpty(),
|
||||||
|
buildItem: (ctx, item, index) {
|
||||||
|
return _ExamCard(
|
||||||
|
item: item,
|
||||||
|
onTap: () => _goToExamDetail(item),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ===== Tab 栏(对标 up-tabs + 自定义 activeStyle/inactiveStyle)=====
|
||||||
|
Widget _buildTabBar() {
|
||||||
|
return Container(
|
||||||
|
padding: EdgeInsets.symmetric(horizontal: 6.w, vertical: 12.h),
|
||||||
|
color: Colors.white,
|
||||||
|
alignment: Alignment.centerLeft,
|
||||||
|
child: SingleChildScrollView(
|
||||||
|
scrollDirection: Axis.horizontal,
|
||||||
|
physics: const BouncingScrollPhysics(),
|
||||||
|
child: Row(
|
||||||
|
children: _tabs.map((tab) {
|
||||||
|
final isActive = tab.id == _currentTab.id;
|
||||||
|
return Padding(
|
||||||
|
padding: EdgeInsets.symmetric(horizontal: 6.w),
|
||||||
|
child: GestureDetector(
|
||||||
|
onTap: () => _onTapTab(tab),
|
||||||
|
behavior: HitTestBehavior.opaque,
|
||||||
|
child: Container(
|
||||||
|
height: 37.h,
|
||||||
|
width: 54.w,
|
||||||
|
// padding: EdgeInsets.symmetric(horizontal: 16.w),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: isActive
|
||||||
|
? const Color(0xFF3D7DF5)
|
||||||
|
: const Color(0xFFF5F8FA),
|
||||||
|
borderRadius: BorderRadius.circular(999),
|
||||||
|
),
|
||||||
|
alignment: Alignment.center,
|
||||||
|
child: Text(
|
||||||
|
tab.name,
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 15.spMin,
|
||||||
|
color: isActive ? Colors.white : const Color(0xFF687FAD),
|
||||||
|
fontWeight: FontWeight.w400,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}).toList(),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ===== 空状态(对标 DataEmpty + exam_empty_bg)=====
|
||||||
|
Widget _buildEmpty() {
|
||||||
|
return Center(
|
||||||
|
child: Column(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
children: [
|
||||||
|
CachedNetworkImage(
|
||||||
|
imageUrl: ImgUrl.build(
|
||||||
|
'/StaticResource/2026-06-10/exam_empty_bg1781078431804.png',
|
||||||
|
),
|
||||||
|
width: 200.w,
|
||||||
|
fit: BoxFit.fitWidth,
|
||||||
|
errorWidget: (_, _, _) => SizedBox(width: 200.w, height: 200.h),
|
||||||
|
),
|
||||||
|
SizedBox(height: 12.h),
|
||||||
|
Text(
|
||||||
|
'暂无内容',
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 14.spMin,
|
||||||
|
color: const Color(0xFF687FAD),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ==================== 考试卡片 ====================
|
||||||
|
|
||||||
|
class _ExamCard extends StatelessWidget {
|
||||||
|
const _ExamCard({required this.item, required this.onTap});
|
||||||
|
|
||||||
|
final ExamDto item;
|
||||||
|
final VoidCallback onTap;
|
||||||
|
|
||||||
|
static const String _cardBgBook =
|
||||||
|
'/StaticResource/2026-09-10/book_icon_final1789026573675.png';
|
||||||
|
|
||||||
|
// 书图标设计尺寸(目标渲染尺寸)
|
||||||
|
static const double _bookWidth = 124;
|
||||||
|
static const double _bookHeight = 124;
|
||||||
|
// 卡片尺寸
|
||||||
|
static const double _cardHeight = 92;
|
||||||
|
static const double _cardRadius = 24;
|
||||||
|
// ⚠ book_icon.png 自带透明 padding,下面这些偏移用于补偿图片留白
|
||||||
|
// 让书图案的左下角对齐卡片左下角。换图时需重新调整。
|
||||||
|
static const double _bookOffsetLeft = -14; // 左补留白(宽度加大了,偏移也加大)
|
||||||
|
static const double _bookOffsetBottom = 6; // 底补留白
|
||||||
|
static const double _bookExtraHeight = 0; // 放大补偿,让图案达到目标高度
|
||||||
|
|
||||||
|
String get _timeRange {
|
||||||
|
// 日期相同只展示 endTime 的时分,去除秒
|
||||||
|
final startParts = item.startTime.split(' ');
|
||||||
|
final startDate = startParts.isNotEmpty ? startParts[0] : '';
|
||||||
|
final startHhMm = startParts.length >= 2
|
||||||
|
? startParts[1].split(':').take(2).join(':')
|
||||||
|
: '';
|
||||||
|
final endParts = item.endTime.split(' ');
|
||||||
|
final endHhMm = endParts.length >= 2
|
||||||
|
? endParts[1].split(':').take(2).join(':')
|
||||||
|
: '';
|
||||||
|
return '$startDate $startHhMm - $endHhMm';
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
// 学科图标:按 baseSubjectName 动态取,无匹配兜底数学
|
||||||
|
final subjectIcon = subjectIconUrl(item.baseSubjectName);
|
||||||
|
|
||||||
|
return GestureDetector(
|
||||||
|
behavior: HitTestBehavior.opaque,
|
||||||
|
onTap: onTap,
|
||||||
|
child: SizedBox(
|
||||||
|
// ⚠ 书图/卡片尺寸统一用 .w:宽高同基准,锁定盒子宽高比,
|
||||||
|
// 避免手机(.w按375稿/.h按812稿)与pad(设备尺寸)缩放系数不同导致
|
||||||
|
// BoxFit.contain 缩放分支翻转、书图被压扁。
|
||||||
|
height: (_bookHeight + _bookExtraHeight).w, // 整体占位 = 书图容器高度(溢出卡片)
|
||||||
|
child: Stack(
|
||||||
|
clipBehavior: Clip.none,
|
||||||
|
children: [
|
||||||
|
// 底层:白色圆角卡片(垂直居中)
|
||||||
|
Positioned(
|
||||||
|
left: 0,
|
||||||
|
right: 0,
|
||||||
|
top: (_bookHeight + _bookExtraHeight - _cardHeight).w / 2,
|
||||||
|
child: Container(
|
||||||
|
height: _cardHeight.w,
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: Colors.white,
|
||||||
|
borderRadius: BorderRadius.circular(_cardRadius.r),
|
||||||
|
boxShadow: const [
|
||||||
|
BoxShadow(
|
||||||
|
color: Color(0x0A1D2B47),
|
||||||
|
blurRadius: 20,
|
||||||
|
offset: Offset(0, 6),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
// 中层:左侧书形装饰图
|
||||||
|
// 图片自带透明 padding,用 _bookOffsetLeft/Bottom/ExtraHeight 补偿
|
||||||
|
Positioned(
|
||||||
|
left: _bookOffsetLeft.w,
|
||||||
|
bottom: _bookOffsetBottom.w,
|
||||||
|
width: _bookWidth.w,
|
||||||
|
height: (_bookHeight + _bookExtraHeight).w,
|
||||||
|
child: CachedNetworkImage(
|
||||||
|
imageUrl: ImgUrl.build(_cardBgBook),
|
||||||
|
fit: BoxFit.contain,
|
||||||
|
alignment: Alignment.bottomLeft,
|
||||||
|
errorWidget: (_, __, ___) =>
|
||||||
|
SizedBox(width: _bookWidth.w, height: _bookHeight.w),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
// 学科小图标(叠在书图上半部分,书图 110 宽 / 139 高容器)
|
||||||
|
Positioned(
|
||||||
|
left: 22.w,
|
||||||
|
top: 14.w,
|
||||||
|
child: CachedNetworkImage(
|
||||||
|
imageUrl: subjectIcon,
|
||||||
|
width: 56.w,
|
||||||
|
height: 56.w,
|
||||||
|
errorWidget: (_, _, _) => Icon(
|
||||||
|
Icons.menu_book,
|
||||||
|
size: 56.w,
|
||||||
|
color: const Color(0xFF3D7DF5),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
// 上层:内容
|
||||||
|
Positioned.fill(
|
||||||
|
child: Row(
|
||||||
|
children: [
|
||||||
|
// 左侧书图区域的占位宽(内容从书图右边开始)
|
||||||
|
SizedBox(width: 90.w),
|
||||||
|
// 中间 + 右侧
|
||||||
|
Expanded(
|
||||||
|
child: Padding(
|
||||||
|
padding: EdgeInsets.symmetric(horizontal: 12.w),
|
||||||
|
child: Row(
|
||||||
|
children: [
|
||||||
|
Expanded(child: _buildMid()),
|
||||||
|
_buildRight(),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
// 学科标签(覆盖在书图底部胶囊上)
|
||||||
|
Positioned(
|
||||||
|
left: -10.w,
|
||||||
|
bottom: 26.w,
|
||||||
|
width: _bookWidth.w,
|
||||||
|
child: Center(
|
||||||
|
child: Container(
|
||||||
|
padding: EdgeInsets.symmetric(
|
||||||
|
horizontal: 14.w,
|
||||||
|
vertical: 6.w,
|
||||||
|
),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: const Color(0xFFE8F2FF),
|
||||||
|
borderRadius: BorderRadius.circular(12.r),
|
||||||
|
),
|
||||||
|
child: Text(
|
||||||
|
item.baseSubjectName,
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 16.spMin,
|
||||||
|
fontWeight: FontWeight.w600,
|
||||||
|
color: const Color(0xFF3D7DF5),
|
||||||
|
height: 1.2,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _buildMid() {
|
||||||
|
return Column(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
item.taskName,
|
||||||
|
maxLines: 1,
|
||||||
|
overflow: TextOverflow.ellipsis,
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 18.spMin,
|
||||||
|
fontWeight: FontWeight.w600,
|
||||||
|
color: const Color(0xFF1D2B47),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
SizedBox(height: 8.h),
|
||||||
|
Text(
|
||||||
|
_timeRange,
|
||||||
|
maxLines: 1,
|
||||||
|
overflow: TextOverflow.ellipsis,
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 14.spMin,
|
||||||
|
fontWeight: FontWeight.w400,
|
||||||
|
color: const Color(0xFF687FAD),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _buildRight() {
|
||||||
|
return Row(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.baseline,
|
||||||
|
textBaseline: TextBaseline.alphabetic,
|
||||||
|
children: [
|
||||||
|
// 得分
|
||||||
|
_gradientScoreText('${item.userScore}', 32.spMin, FontWeight.w700),
|
||||||
|
Text(
|
||||||
|
' / ${item.totalScore}',
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 16.spMin,
|
||||||
|
fontWeight: FontWeight.w400,
|
||||||
|
color: const Color(0xFF687FAD),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
SizedBox(width: 10.w),
|
||||||
|
Icon(
|
||||||
|
Icons.arrow_forward_ios,
|
||||||
|
size: 16.w,
|
||||||
|
color: const Color(0xFF3D7DF5),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 渐变得分文字:linear-gradient(270deg, #2DC9FF -2.95%, #2B73F9 73.86%)
|
||||||
|
Widget _gradientScoreText(String text, double fontSize, FontWeight weight) {
|
||||||
|
return ShaderMask(
|
||||||
|
shaderCallback: (rect) => ui.Gradient.linear(
|
||||||
|
rect.topRight,
|
||||||
|
rect.topLeft,
|
||||||
|
const [Color(0xFF2DC9FF), Color(0xFF2B73F9)],
|
||||||
|
const [-0.0295, 0.7386],
|
||||||
|
TileMode.clamp,
|
||||||
|
),
|
||||||
|
child: Text(
|
||||||
|
text,
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: fontSize,
|
||||||
|
fontWeight: weight,
|
||||||
|
color: Colors.white,
|
||||||
|
height: 1,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -96,6 +96,14 @@ class MyPage extends ConsumerWidget {
|
|||||||
// 第一组:学习功能菜单
|
// 第一组:学习功能菜单
|
||||||
_MenuCard(
|
_MenuCard(
|
||||||
items: [
|
items: [
|
||||||
|
_MenuItem(
|
||||||
|
imageUrl:
|
||||||
|
'${AppEnv.imgBaseUrl}/StaticResource/2026-06-10/exam1781070655873.png',
|
||||||
|
title: '我的考试',
|
||||||
|
onTap: () {
|
||||||
|
context.push('/myExam');
|
||||||
|
},
|
||||||
|
),
|
||||||
_MenuItem(
|
_MenuItem(
|
||||||
imageUrl:
|
imageUrl:
|
||||||
'${AppEnv.imgBaseUrl}/StaticResource/2026-06-10/exam1781070655873.png',
|
'${AppEnv.imgBaseUrl}/StaticResource/2026-06-10/exam1781070655873.png',
|
||||||
@@ -109,7 +117,7 @@ class MyPage extends ConsumerWidget {
|
|||||||
'${AppEnv.imgBaseUrl}/StaticResource/2026-04-01/note.png',
|
'${AppEnv.imgBaseUrl}/StaticResource/2026-04-01/note.png',
|
||||||
title: '我的笔记',
|
title: '我的笔记',
|
||||||
onTap: () {
|
onTap: () {
|
||||||
// TODO: 跳转到我的笔记页
|
context.push('/myNote');
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
_MenuItem(
|
_MenuItem(
|
||||||
@@ -117,7 +125,7 @@ class MyPage extends ConsumerWidget {
|
|||||||
'${AppEnv.imgBaseUrl}/StaticResource/2026-04-01/error.png',
|
'${AppEnv.imgBaseUrl}/StaticResource/2026-04-01/error.png',
|
||||||
title: '错题本',
|
title: '错题本',
|
||||||
onTap: () {
|
onTap: () {
|
||||||
// TODO: 跳转到错题本页
|
context.push('/myWrong');
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
_MenuItem(
|
_MenuItem(
|
||||||
@@ -125,7 +133,7 @@ class MyPage extends ConsumerWidget {
|
|||||||
'${AppEnv.imgBaseUrl}/StaticResource/2026-04-01/collect.png',
|
'${AppEnv.imgBaseUrl}/StaticResource/2026-04-01/collect.png',
|
||||||
title: '我的收藏',
|
title: '我的收藏',
|
||||||
onTap: () {
|
onTap: () {
|
||||||
// TODO: 跳转到我的收藏页
|
context.push('/myCollect');
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
_MenuItem(
|
_MenuItem(
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import 'package:new_learn/core/api/my_report/model.dart';
|
|||||||
import 'package:new_learn/core/components/common_paged_list.dart';
|
import 'package:new_learn/core/components/common_paged_list.dart';
|
||||||
import 'package:new_learn/core/logger/app_talker.dart';
|
import 'package:new_learn/core/logger/app_talker.dart';
|
||||||
import 'package:new_learn/core/utils/img_url.dart';
|
import 'package:new_learn/core/utils/img_url.dart';
|
||||||
|
import 'package:new_learn/core/utils/subject_icons.dart';
|
||||||
|
|
||||||
/// ============================================================
|
/// ============================================================
|
||||||
/// 【MyReportPage】我的报告列表 —— 对标 Vue pages/myPackage/myReport/myReport.vue
|
/// 【MyReportPage】我的报告列表 —— 对标 Vue pages/myPackage/myReport/myReport.vue
|
||||||
@@ -25,19 +26,6 @@ import 'package:new_learn/core/utils/img_url.dart';
|
|||||||
/// 四、先只做 phone 布局,Pad 后续再说
|
/// 四、先只做 phone 布局,Pad 后续再说
|
||||||
/// ============================================================
|
/// ============================================================
|
||||||
|
|
||||||
/// 学科 icon 映射表(对标 Vue utils/constant.js SUBJECT_ICON_MAP)
|
|
||||||
const Map<String, String> _subjectIconMap = {
|
|
||||||
'语文': '/StaticResource/2026-06-11/shuxue1781163770612.png',
|
|
||||||
'化学': '/StaticResource/2026-06-11/huaxue1781163828443.png',
|
|
||||||
'英语': '/StaticResource/2026-06-11/yingyu1781163725441.png',
|
|
||||||
'物理': '/StaticResource/2026-06-11/wuli1781148438346.png',
|
|
||||||
'数学': '/StaticResource/2026-06-11/shuxue1781163770612.png',
|
|
||||||
'生物': '/StaticResource/2026-06-11/shengwu1781163791768.png',
|
|
||||||
'历史': '/StaticResource/2026-06-11/lishi1781163811822.png',
|
|
||||||
'政治': '/StaticResource/2026-06-11/zhengzhi1781163750422.png',
|
|
||||||
'地理': '/StaticResource/2026-06-11/dili1781163844311.png',
|
|
||||||
};
|
|
||||||
|
|
||||||
/// 取学科名(报告名前 2 个字,对标 Vue getSubjectName)
|
/// 取学科名(报告名前 2 个字,对标 Vue getSubjectName)
|
||||||
String _extractSubjectName(UserReportDto item) {
|
String _extractSubjectName(UserReportDto item) {
|
||||||
final name = item.reportName.trim();
|
final name = item.reportName.trim();
|
||||||
@@ -45,12 +33,6 @@ String _extractSubjectName(UserReportDto item) {
|
|||||||
return name.substring(0, 2);
|
return name.substring(0, 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// 取学科 icon URL(无匹配则用数学兜底,对标 Vue getSubjectIcon)
|
|
||||||
String _getSubjectIconUrl(String subjectName) {
|
|
||||||
final path = _subjectIconMap[subjectName] ?? _subjectIconMap['数学']!;
|
|
||||||
return ImgUrl.build(path);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// 格式化创建时间(对标 Vue getReportTime)
|
/// 格式化创建时间(对标 Vue getReportTime)
|
||||||
String _formatCreateTime(String raw) {
|
String _formatCreateTime(String raw) {
|
||||||
if (raw.isEmpty) return '';
|
if (raw.isEmpty) return '';
|
||||||
@@ -120,8 +102,8 @@ class _MyReportPageState extends ConsumerState<MyReportPage> {
|
|||||||
color: const Color(0xFFF5F8FA),
|
color: const Color(0xFFF5F8FA),
|
||||||
child: CommonPagedList<UserReportDto>(
|
child: CommonPagedList<UserReportDto>(
|
||||||
load: _loadPage,
|
load: _loadPage,
|
||||||
padding: EdgeInsets.fromLTRB(12.w, 16.h, 12.w, 0),
|
padding: EdgeInsets.fromLTRB(12.w, 4.h, 12.w, 0),
|
||||||
separatorBuilder: (_, _) => SizedBox(height: 14.h),
|
// separatorBuilder: (_, _) => SizedBox(height: 14.h),
|
||||||
buildItem: (context, item, index) {
|
buildItem: (context, item, index) {
|
||||||
return _ReportCard(item: item, onTap: () => _onTapCard(item));
|
return _ReportCard(item: item, onTap: () => _onTapCard(item));
|
||||||
},
|
},
|
||||||
@@ -140,11 +122,11 @@ class _MyReportPageState extends ConsumerState<MyReportPage> {
|
|||||||
/// ============================================================
|
/// ============================================================
|
||||||
/// 【_ReportCard】报告卡片
|
/// 【_ReportCard】报告卡片
|
||||||
///
|
///
|
||||||
/// 布局(Row 从左到右):
|
/// 左侧装饰与我的考试(exam)卡片一致:
|
||||||
/// [icon + 学科标签] → [报告名 + 时间] → [箭头]
|
/// 白色圆角卡片 + 左侧溢出书图(book_icon)+ 学科图标叠在书图上 +
|
||||||
|
/// 底部学科名胶囊。书图/卡片尺寸统一用 .w 锁定宽高比,适配 pad。
|
||||||
///
|
///
|
||||||
/// 背景图叠底,InkWell 提供点击水波纹。
|
/// 内容区:中间 [报告名 + 时间],右侧 [箭头]。
|
||||||
/// 图标/标签自然靠左,不做偏移 hack。
|
|
||||||
/// ============================================================
|
/// ============================================================
|
||||||
class _ReportCard extends StatelessWidget {
|
class _ReportCard extends StatelessWidget {
|
||||||
const _ReportCard({required this.item, required this.onTap});
|
const _ReportCard({required this.item, required this.onTap});
|
||||||
@@ -152,110 +134,132 @@ class _ReportCard extends StatelessWidget {
|
|||||||
final UserReportDto item;
|
final UserReportDto item;
|
||||||
final VoidCallback onTap;
|
final VoidCallback onTap;
|
||||||
|
|
||||||
|
static const String _cardBgBook =
|
||||||
|
'/StaticResource/2026-09-10/book_icon_final1789026573675.png';
|
||||||
|
|
||||||
|
// 书图标 / 卡片尺寸(与 exam 卡片一致,统一 .w 锁比例)
|
||||||
|
static const double _bookWidth = 124;
|
||||||
|
static const double _bookHeight =
|
||||||
|
124; // 卡片间距 = _bookHeight - _cardHeight(书图向上探出的高度)
|
||||||
|
static const double _cardHeight = 92;
|
||||||
|
static const double _cardRadius = 24;
|
||||||
|
// ⚠ book_icon.png 自带透明 padding,偏移用于补偿留白
|
||||||
|
static const double _bookOffsetLeft = -14;
|
||||||
|
static const double _bookOffsetBottom = -10;
|
||||||
|
static const double _bookExtraHeight = 0;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final subjectName = _extractSubjectName(item);
|
final subjectName = _extractSubjectName(item);
|
||||||
final subjectIconUrl = _getSubjectIconUrl(subjectName);
|
final iconUrl = subjectIconUrl(subjectName);
|
||||||
final timeText = _formatCreateTime(item.createTime);
|
final timeText = _formatCreateTime(item.createTime);
|
||||||
|
|
||||||
const bgPath =
|
return GestureDetector(
|
||||||
'/StaticResource/2026-06-10/examListItem_bg1781074465963.png';
|
behavior: HitTestBehavior.opaque,
|
||||||
|
|
||||||
return InkWell(
|
|
||||||
onTap: onTap,
|
onTap: onTap,
|
||||||
borderRadius: BorderRadius.circular(12.r),
|
child: SizedBox(
|
||||||
child: Container(
|
height: (_bookHeight + _bookExtraHeight).w,
|
||||||
height: 109.h,
|
|
||||||
decoration: BoxDecoration(borderRadius: BorderRadius.circular(12.r)),
|
|
||||||
child: Stack(
|
child: Stack(
|
||||||
|
clipBehavior: Clip.none,
|
||||||
children: [
|
children: [
|
||||||
// 底层:卡片背景图
|
// 底层:白色圆角卡片(底部对齐,书图只向上溢出)
|
||||||
Positioned.fill(
|
Positioned(
|
||||||
child: ClipRRect(
|
left: 0,
|
||||||
borderRadius: BorderRadius.circular(12.r),
|
right: 0,
|
||||||
|
bottom: 0,
|
||||||
|
child: Container(
|
||||||
|
height: _cardHeight.w,
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: Colors.white,
|
||||||
|
borderRadius: BorderRadius.circular(_cardRadius.r),
|
||||||
|
boxShadow: const [
|
||||||
|
BoxShadow(
|
||||||
|
color: Color(0x0A1D2B47),
|
||||||
|
blurRadius: 20,
|
||||||
|
offset: Offset(0, 6),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
// 中层:左侧书形装饰图
|
||||||
|
Positioned(
|
||||||
|
left: _bookOffsetLeft.w,
|
||||||
|
bottom: _bookOffsetBottom.w,
|
||||||
|
width: _bookWidth.w,
|
||||||
|
height: (_bookHeight + _bookExtraHeight).w,
|
||||||
child: CachedNetworkImage(
|
child: CachedNetworkImage(
|
||||||
imageUrl: ImgUrl.build(bgPath),
|
imageUrl: ImgUrl.build(_cardBgBook),
|
||||||
fit: BoxFit.fill,
|
fit: BoxFit.contain,
|
||||||
placeholder: (_, _) => Container(color: Colors.white),
|
alignment: Alignment.bottomLeft,
|
||||||
errorWidget: (_, _, _) => Container(color: Colors.white),
|
errorWidget: (_, __, ___) =>
|
||||||
|
SizedBox(width: _bookWidth.w, height: _bookHeight.w),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
// 学科小图标(叠在书图上半部分)
|
||||||
// 上层内容:Row 左对齐,padding 控制整体边距
|
Positioned(
|
||||||
Padding(
|
left: 22.w,
|
||||||
padding: EdgeInsets.symmetric(horizontal: 22.w),
|
top: 14.w,
|
||||||
child: Row(
|
child: CachedNetworkImage(
|
||||||
crossAxisAlignment: CrossAxisAlignment.center,
|
imageUrl: iconUrl,
|
||||||
children: [
|
|
||||||
// ── 左侧:学科 icon + 标签(垂直排列,自然靠左) ──
|
|
||||||
Column(
|
|
||||||
mainAxisSize: MainAxisSize.min,
|
|
||||||
children: [
|
|
||||||
CachedNetworkImage(
|
|
||||||
imageUrl: subjectIconUrl,
|
|
||||||
width: 56.w,
|
width: 56.w,
|
||||||
height: 56.w,
|
height: 56.w,
|
||||||
placeholder: (_, _) => const SizedBox.shrink(),
|
errorWidget: (_, _, _) => Icon(
|
||||||
errorWidget: (_, _, _) => const SizedBox.shrink(),
|
Icons.menu_book,
|
||||||
),
|
size: 56.w,
|
||||||
SizedBox(height: 4.h),
|
|
||||||
Container(
|
|
||||||
padding: EdgeInsets.symmetric(horizontal: 8.w),
|
|
||||||
height: 25.h,
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
color: const Color(0xFFEAF5FE),
|
|
||||||
borderRadius: BorderRadius.circular(7.r),
|
|
||||||
),
|
|
||||||
alignment: Alignment.center,
|
|
||||||
child: Text(
|
|
||||||
subjectName,
|
|
||||||
style: TextStyle(
|
|
||||||
fontSize: 14.sp,
|
|
||||||
color: const Color(0xFF3D7DF5),
|
color: const Color(0xFF3D7DF5),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
// 上层:内容(与卡片同高,底部对齐)
|
||||||
),
|
Positioned(
|
||||||
SizedBox(width: 40.w),
|
left: 0,
|
||||||
// ── 中间:报告名 + 时间(Expanded 占剩余) ──
|
right: 0,
|
||||||
Expanded(
|
bottom: 0,
|
||||||
child: Column(
|
height: _cardHeight.w,
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
child: Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
|
||||||
children: [
|
children: [
|
||||||
SizedBox(height: 10.h),
|
// 左侧书图区域占位
|
||||||
Text(
|
SizedBox(width: 90.w),
|
||||||
item.reportName,
|
Expanded(
|
||||||
maxLines: 1,
|
child: Padding(
|
||||||
overflow: TextOverflow.ellipsis,
|
padding: EdgeInsets.symmetric(horizontal: 12.w),
|
||||||
style: TextStyle(
|
child: Row(
|
||||||
fontWeight: FontWeight.w500,
|
children: [
|
||||||
fontSize: 16.sp,
|
Expanded(child: _buildMid(timeText)),
|
||||||
color: const Color(0xFF1D2B47),
|
_buildRight(),
|
||||||
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
SizedBox(height: 20.h),
|
|
||||||
Text(
|
|
||||||
timeText,
|
|
||||||
style: TextStyle(
|
|
||||||
fontSize: 12.sp,
|
|
||||||
color: const Color(0xFF687FAD),
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
// ── 右侧:箭头 ──
|
// 学科标签(覆盖在书图底部胶囊上,卡片贴底)
|
||||||
Padding(
|
Positioned(
|
||||||
padding: EdgeInsets.only(top: 10.h),
|
left: -10.w,
|
||||||
child: Icon(
|
bottom: 10.w,
|
||||||
Icons.chevron_right,
|
width: _bookWidth.w,
|
||||||
color: const Color(0xFF4B6B99),
|
child: Center(
|
||||||
size: 22.sp,
|
child: Container(
|
||||||
|
padding: EdgeInsets.symmetric(
|
||||||
|
horizontal: 14.w,
|
||||||
|
vertical: 6.w,
|
||||||
|
),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: const Color(0xFFE8F2FF),
|
||||||
|
borderRadius: BorderRadius.circular(12.r),
|
||||||
|
),
|
||||||
|
child: Text(
|
||||||
|
subjectName,
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 16.spMin,
|
||||||
|
fontWeight: FontWeight.w600,
|
||||||
|
color: const Color(0xFF3D7DF5),
|
||||||
|
height: 1.2,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
@@ -263,4 +267,44 @@ class _ReportCard extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 中间:报告名 + 时间
|
||||||
|
Widget _buildMid(String timeText) {
|
||||||
|
return Column(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
item.reportName,
|
||||||
|
maxLines: 1,
|
||||||
|
overflow: TextOverflow.ellipsis,
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 18.spMin,
|
||||||
|
fontWeight: FontWeight.w600,
|
||||||
|
color: const Color(0xFF1D2B47),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
SizedBox(height: 8.h),
|
||||||
|
Text(
|
||||||
|
timeText,
|
||||||
|
maxLines: 1,
|
||||||
|
overflow: TextOverflow.ellipsis,
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 14.spMin,
|
||||||
|
fontWeight: FontWeight.w400,
|
||||||
|
color: const Color(0xFF687FAD),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 右侧:箭头
|
||||||
|
Widget _buildRight() {
|
||||||
|
return Icon(
|
||||||
|
Icons.chevron_right,
|
||||||
|
color: const Color(0xFF4B6B99),
|
||||||
|
size: 22.sp,
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,372 @@
|
|||||||
|
import 'package:cached_network_image/cached_network_image.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||||
|
import 'package:go_router/go_router.dart';
|
||||||
|
import 'package:new_learn/core/api/user_collect/model.dart';
|
||||||
|
import 'package:new_learn/core/api/user_note/api.dart';
|
||||||
|
import 'package:new_learn/core/api/user_note/model.dart';
|
||||||
|
import 'package:new_learn/core/components/common_paged_list.dart';
|
||||||
|
import 'package:new_learn/core/components/rich_text_content.dart';
|
||||||
|
import 'package:new_learn/core/components/subject_tag.dart';
|
||||||
|
import 'package:new_learn/core/logger/app_talker.dart';
|
||||||
|
import 'package:new_learn/core/utils/img_url.dart';
|
||||||
|
|
||||||
|
/// ============================================================
|
||||||
|
/// 【NotePage】我的笔记 —— 对标 Vue pages/myPackage/note/note.vue
|
||||||
|
///
|
||||||
|
/// 页面结构(对齐 Vue,从上到下):
|
||||||
|
/// 1. 学科筛选 Tab("全部" + 接口返回学科,胶囊样式,点击切学科重载)
|
||||||
|
/// 2. #F5F8FA 列表区:CommonPagedList 游标分页
|
||||||
|
/// 卡片 = SubjectTag + 时间 + title + 内容富文本(限高渐隐)
|
||||||
|
/// + 右上角笔记类型角标
|
||||||
|
///
|
||||||
|
/// 与收藏/错题列表的差异:
|
||||||
|
/// ① 没有顶部总数头;
|
||||||
|
/// ② 列表不按类型过滤,type 由每条数据自带:
|
||||||
|
/// 1=题目笔记(note-stem.png)2=讲义笔记(note-teaching.png),
|
||||||
|
/// 仅用角标图标区分,详情页再按 type 渲染不同内容;
|
||||||
|
/// ③ 标题字段 title、正文字段 content。
|
||||||
|
///
|
||||||
|
/// 分页:pageKey 当 pageIndex;prevPageId 闭包维护——首页/刷新重置为 0,
|
||||||
|
/// 每页请求后更新为本页最后一条 id;切学科用 ValueKey 重建列表回首页。
|
||||||
|
/// ============================================================
|
||||||
|
class NotePage extends StatefulWidget {
|
||||||
|
const NotePage({super.key});
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<NotePage> createState() => _NotePageState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _NotePageState extends State<NotePage> {
|
||||||
|
static const int _pageSize = 10;
|
||||||
|
|
||||||
|
/// 学科 Tab 列表("全部"为客户端插入,id=null)
|
||||||
|
List<CollectTab> _tabs = const [CollectTab(name: '全部')];
|
||||||
|
|
||||||
|
/// 当前选中的学科 id(null = 全部)
|
||||||
|
int? _subjectId;
|
||||||
|
|
||||||
|
/// 游标:本页最后一条 id,首页/刷新/切学科时重置为 0
|
||||||
|
int _prevPageId = 0;
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
talker.debug('打开页面:我的笔记');
|
||||||
|
_loadTabs();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 拉取学科筛选项;失败兜底只有"全部"(对齐 Vue catch 逻辑)
|
||||||
|
Future<void> _loadTabs() async {
|
||||||
|
try {
|
||||||
|
final tabs = await UserNoteApi.instance.getSubjects();
|
||||||
|
if (!mounted) return;
|
||||||
|
setState(() {
|
||||||
|
_tabs = [const CollectTab(name: '全部'), ...tabs];
|
||||||
|
});
|
||||||
|
} catch (e) {
|
||||||
|
talker.error('获取笔记学科Tab失败', e);
|
||||||
|
if (!mounted) return;
|
||||||
|
setState(() {
|
||||||
|
_tabs = const [CollectTab(name: '全部')];
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 分页加载(CommonPagedList 回调)
|
||||||
|
Future<PagingResult<UserNoteItem>> _load(int pageKey) async {
|
||||||
|
// 首页/下拉刷新:游标重置(对齐 Vue useList pageNo===1 时 prevPageId=0)
|
||||||
|
if (pageKey == 1) _prevPageId = 0;
|
||||||
|
|
||||||
|
final res = await UserNoteApi.instance.getNoteList(
|
||||||
|
subjectId: _subjectId,
|
||||||
|
pageIndex: pageKey,
|
||||||
|
pageSize: _pageSize,
|
||||||
|
prevPageId: _prevPageId,
|
||||||
|
);
|
||||||
|
|
||||||
|
// 更新游标为本页最后一条 id
|
||||||
|
_prevPageId = res.data.isNotEmpty ? res.data.last.id : 0;
|
||||||
|
|
||||||
|
return PagingResult<UserNoteItem>(
|
||||||
|
data: res.data,
|
||||||
|
hasNext: res.total > pageKey * _pageSize,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 切学科:ValueKey 变化后 CommonPagedList 整体重建,自动回到第一页
|
||||||
|
void _onTabTap(CollectTab tab) {
|
||||||
|
if (_subjectId == tab.id) return;
|
||||||
|
setState(() {
|
||||||
|
_subjectId = tab.id;
|
||||||
|
_prevPageId = 0;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 点击卡片 → 笔记详情页
|
||||||
|
/// TODO: 详情页待接入,需要按 item.type 区分:
|
||||||
|
/// type=1 题目笔记 / type=2 讲义笔记,详情页内容结构不同;
|
||||||
|
/// Vue 跳转:/pages/myPackage/noteDetail/index?id=${item.id}&type=${item.type}
|
||||||
|
void _goDetail(UserNoteItem item) {
|
||||||
|
talker.debug('笔记详情待接入:id=${item.id} type=${item.type}(1题目笔记/2讲义笔记)');
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Scaffold(
|
||||||
|
backgroundColor: Colors.white,
|
||||||
|
appBar: AppBar(
|
||||||
|
backgroundColor: Colors.white,
|
||||||
|
surfaceTintColor: Colors.white,
|
||||||
|
elevation: 0,
|
||||||
|
title: const Text('我的笔记', style: TextStyle(color: Color(0xFF1D2B47))),
|
||||||
|
iconTheme: const IconThemeData(color: Color(0xFF1D2B47)),
|
||||||
|
leading: IconButton(
|
||||||
|
icon: const Icon(Icons.arrow_back),
|
||||||
|
onPressed: () => context.canPop() ? context.pop() : context.go('/my'),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
body: Column(
|
||||||
|
children: [
|
||||||
|
_buildTabBar(),
|
||||||
|
// 列表区(#F5F8FA 灰底)
|
||||||
|
Expanded(
|
||||||
|
child: Container(
|
||||||
|
color: const Color(0xFFF5F8FA),
|
||||||
|
child: CommonPagedList<UserNoteItem>(
|
||||||
|
// 切学科时重建列表,状态自动回第一页
|
||||||
|
key: ValueKey('note_list_$_subjectId'),
|
||||||
|
// Vue list-refresh-wrap padding-top:32rpx + listWrapper 28rpx
|
||||||
|
padding: EdgeInsets.fromLTRB(14.w, 16.h, 14.w, 14.h),
|
||||||
|
emptyWidget: _buildEmpty(),
|
||||||
|
load: _load,
|
||||||
|
buildItem: (context, item, index) =>
|
||||||
|
_NoteCard(item: item, onTap: () => _goDetail(item)),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 学科筛选胶囊 Tab 栏(横向滚动)
|
||||||
|
Widget _buildTabBar() {
|
||||||
|
return Container(
|
||||||
|
color: Colors.white,
|
||||||
|
height: 56.h, // 上下 padding 12.h + 胶囊 32.h(对齐 Vue 24rpx+64rpx)
|
||||||
|
child: ListView.separated(
|
||||||
|
scrollDirection: Axis.horizontal,
|
||||||
|
padding: EdgeInsets.symmetric(horizontal: 12.w),
|
||||||
|
itemCount: _tabs.length,
|
||||||
|
separatorBuilder: (_, _) => SizedBox(width: 12.w),
|
||||||
|
itemBuilder: (context, i) {
|
||||||
|
final tab = _tabs[i];
|
||||||
|
final active = _subjectId == tab.id;
|
||||||
|
return Center(
|
||||||
|
child: GestureDetector(
|
||||||
|
onTap: () => _onTabTap(tab),
|
||||||
|
child: Container(
|
||||||
|
height: 32.h,
|
||||||
|
alignment: Alignment.center,
|
||||||
|
padding: EdgeInsets.symmetric(horizontal: 16.w),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: active
|
||||||
|
? const Color(0xFF3D7DF5)
|
||||||
|
: const Color(0xFFF5F8FA),
|
||||||
|
borderRadius: BorderRadius.circular(999),
|
||||||
|
),
|
||||||
|
child: Text(
|
||||||
|
tab.name,
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 15.sp,
|
||||||
|
fontWeight: FontWeight.w400,
|
||||||
|
color: active ? Colors.white : const Color(0xFF687FAD),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 空状态:空态图 + 文案(对齐 Vue DataEmpty noNotess.png)
|
||||||
|
Widget _buildEmpty() {
|
||||||
|
return Center(
|
||||||
|
child: Column(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
children: [
|
||||||
|
CachedNetworkImage(
|
||||||
|
imageUrl: ImgUrl.build('/StaticResource/2026-04-11/noNotess.png'),
|
||||||
|
width: 160.w,
|
||||||
|
fit: BoxFit.contain,
|
||||||
|
placeholder: (_, _) => const SizedBox.shrink(),
|
||||||
|
errorWidget: (_, _, _) => const SizedBox.shrink(),
|
||||||
|
),
|
||||||
|
SizedBox(height: 12.h),
|
||||||
|
Text(
|
||||||
|
'暂无笔记',
|
||||||
|
style: TextStyle(fontSize: 14.sp, color: const Color(0xFF999999)),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 单条笔记卡片:SubjectTag + 时间 + title + 内容富文本 + 右上角类型角标
|
||||||
|
class _NoteCard extends StatelessWidget {
|
||||||
|
const _NoteCard({required this.item, required this.onTap});
|
||||||
|
|
||||||
|
final UserNoteItem item;
|
||||||
|
final VoidCallback onTap;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Padding(
|
||||||
|
padding: EdgeInsets.only(
|
||||||
|
bottom: 14.h,
|
||||||
|
), // Vue listItem margin-bottom: 28rpx
|
||||||
|
child: Stack(
|
||||||
|
clipBehavior: Clip.none, // 允许类型角标超出卡片顶部
|
||||||
|
children: [
|
||||||
|
Material(
|
||||||
|
color: Colors.white,
|
||||||
|
borderRadius: BorderRadius.circular(16.r),
|
||||||
|
child: InkWell(
|
||||||
|
onTap: onTap,
|
||||||
|
borderRadius: BorderRadius.circular(16.r),
|
||||||
|
// 去掉点击时默认的灰色水波纹/高亮(Vue 端卡片无按压反馈)
|
||||||
|
splashColor: Colors.transparent,
|
||||||
|
highlightColor: Colors.transparent,
|
||||||
|
child: Padding(
|
||||||
|
// Vue padding: t-32 l/r-28 b-28
|
||||||
|
padding: EdgeInsets.fromLTRB(14.w, 16.h, 14.w, 14.h),
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
// 第一行:学科标签 + 时间
|
||||||
|
Row(
|
||||||
|
children: [
|
||||||
|
SubjectTag(subject: item.subjectName),
|
||||||
|
SizedBox(width: 12.w),
|
||||||
|
Text(
|
||||||
|
item.createTime,
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 12.sp, // Vue font-24
|
||||||
|
color: const Color(0xFFB4C2E0),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
SizedBox(height: 14.h), // Vue pack-name margin-top: 28rpx
|
||||||
|
// 笔记标题
|
||||||
|
Text(
|
||||||
|
item.title,
|
||||||
|
maxLines: 2,
|
||||||
|
overflow: TextOverflow.ellipsis,
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 16.sp, // Vue font-32
|
||||||
|
fontWeight: FontWeight.w600,
|
||||||
|
color: const Color(0xFF1D2B47),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
SizedBox(
|
||||||
|
height: 16.h,
|
||||||
|
), // Vue question-stem-wrap margin-top: 32rpx
|
||||||
|
// 笔记内容富文本(限高渐隐)
|
||||||
|
_NoteContentBox(html: item.content),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
// 右上角类型角标:Vue note-type-icon top:-4rpx right:28rpx 56rpx
|
||||||
|
Positioned(top: -2.h, right: 14.w, child: _buildTypeIcon()),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 笔记类型角标:type=1 题目笔记(note-stem)/ 2 讲义笔记(note-teaching)
|
||||||
|
Widget _buildTypeIcon() {
|
||||||
|
final icon = item.type == 2
|
||||||
|
? '/StaticResource/2026-04-07/note-teaching.png'
|
||||||
|
: '/StaticResource/2026-04-07/note-stem.png';
|
||||||
|
return CachedNetworkImage(
|
||||||
|
imageUrl: ImgUrl.build(icon),
|
||||||
|
width: 28.w,
|
||||||
|
height: 28.h,
|
||||||
|
fit: BoxFit.contain,
|
||||||
|
placeholder: (_, _) => SizedBox(width: 28.w, height: 28.h),
|
||||||
|
errorWidget: (_, _, _) => SizedBox(width: 28.w, height: 28.h),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 笔记内容容器:#FAFBFD 底 + #E3ECFF 边框,内容限高 70.h(Vue 140rpx),
|
||||||
|
/// 超出部分底部渐隐遮罩(与收藏/错题列表题干样式一致)
|
||||||
|
class _NoteContentBox extends StatelessWidget {
|
||||||
|
const _NoteContentBox({required this.html});
|
||||||
|
|
||||||
|
final String html;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Container(
|
||||||
|
width: double.infinity,
|
||||||
|
padding: EdgeInsets.all(12.w), // Vue padding: 24rpx
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: const Color(0xFFFAFBFD),
|
||||||
|
borderRadius: BorderRadius.circular(8.r), // Vue 16rpx
|
||||||
|
border: Border.all(color: const Color(0xFFE3ECFF)),
|
||||||
|
),
|
||||||
|
child: Stack(
|
||||||
|
children: [
|
||||||
|
// 限高裁剪:OverflowBox 让富文本按自然高度布局,超出 70.h 的部分裁掉
|
||||||
|
ClipRect(
|
||||||
|
child: ConstrainedBox(
|
||||||
|
constraints: BoxConstraints(maxHeight: 70.h),
|
||||||
|
child: OverflowBox(
|
||||||
|
alignment: Alignment.topCenter,
|
||||||
|
minHeight: 0,
|
||||||
|
maxHeight: double.infinity,
|
||||||
|
child: RichTextContent(
|
||||||
|
html: html,
|
||||||
|
textStyle: TextStyle(
|
||||||
|
fontSize: 14.sp,
|
||||||
|
fontWeight: FontWeight.w400,
|
||||||
|
color: const Color(0xFF495A7A),
|
||||||
|
height: 1.5,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
// 底部渐隐遮罩(Vue mask-layer 60rpx):
|
||||||
|
// 终点色与底色 #FAFBFD 一致,内容不足时遮罩盖在底色上视觉不可见
|
||||||
|
Positioned(
|
||||||
|
left: 0,
|
||||||
|
right: 0,
|
||||||
|
bottom: 0,
|
||||||
|
height: 30.h,
|
||||||
|
child: IgnorePointer(
|
||||||
|
child: DecoratedBox(
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
gradient: const LinearGradient(
|
||||||
|
begin: Alignment.topCenter,
|
||||||
|
end: Alignment.bottomCenter,
|
||||||
|
colors: [Color(0x00FAFBFD), Color(0xFFFAFBFD)],
|
||||||
|
),
|
||||||
|
borderRadius: BorderRadius.circular(8.r),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,528 @@
|
|||||||
|
import 'package:cached_network_image/cached_network_image.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||||
|
import 'package:go_router/go_router.dart';
|
||||||
|
import 'package:new_learn/core/api/user_collect/api.dart';
|
||||||
|
import 'package:new_learn/core/api/user_collect/model.dart';
|
||||||
|
import 'package:new_learn/core/components/common_paged_list.dart';
|
||||||
|
import 'package:new_learn/core/components/rich_text_content.dart';
|
||||||
|
import 'package:new_learn/core/components/subject_tag.dart';
|
||||||
|
import 'package:new_learn/core/logger/app_talker.dart';
|
||||||
|
import 'package:new_learn/core/utils/img_url.dart';
|
||||||
|
import 'package:new_learn/core/utils/screen_adapt_template.dart';
|
||||||
|
|
||||||
|
/// ============================================================
|
||||||
|
/// 【QuestionListPage】我的收藏 / 错题本 列表页
|
||||||
|
/// —— 对标 Vue pages/myPackage/myCollect/myCollect.vue
|
||||||
|
/// 和 pages/myPackage/myWrong/myWrong.vue
|
||||||
|
///
|
||||||
|
/// 两个页面结构完全一致(同一套接口 UserCollect),仅 [type] 不同:
|
||||||
|
/// type=1 我的收藏(/myCollect) type=2 错题本(/myWrong)
|
||||||
|
/// 标题 / 总数文案 / 顶部背景图 / 空状态 / 装饰色带 由 [_config] 按 type 切换。
|
||||||
|
///
|
||||||
|
/// 页面结构(对齐 Vue,从上到下):
|
||||||
|
/// 1. 学科筛选 Tab("全部" + 接口返回学科,胶囊样式,点击切学科重载)
|
||||||
|
/// 2. 总数头:主题背景图 + 大号总数 + 装饰色带 + 文案(道错题/收藏题目)
|
||||||
|
/// 3. #F5F8FA 列表区:CommonPagedList 游标分页
|
||||||
|
/// 卡片 = SubjectTag + 时间 + packName + 题干富文本(限高渐隐)
|
||||||
|
///
|
||||||
|
/// 分页要点(游标分页,对齐 Vue useList):
|
||||||
|
/// pageKey 当 pageIndex;prevPageId 在闭包里维护——首页/刷新重置为 0,
|
||||||
|
/// 每页请求后更新为本页最后一条 id;切学科用 ValueKey 重建列表(天然回首页)。
|
||||||
|
///
|
||||||
|
/// 题干限高:Vue 用 DOM 测量后加渐隐遮罩;Flutter 用 OverflowBox 限高 70.h
|
||||||
|
/// 裁剪 + 底部固定渐隐遮罩(遮罩终点色与题干底色色值一致,内容不足时不可见)。
|
||||||
|
/// ============================================================
|
||||||
|
class QuestionListPage extends StatefulWidget {
|
||||||
|
const QuestionListPage({super.key, required this.type});
|
||||||
|
|
||||||
|
/// 1=我的收藏 2=错题本
|
||||||
|
final int type;
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<QuestionListPage> createState() => _QuestionListPageState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _QuestionListPageState extends State<QuestionListPage> {
|
||||||
|
static const int _pageSize = 10;
|
||||||
|
|
||||||
|
/// 学科 Tab 列表("全部"为客户端插入,id=null)
|
||||||
|
List<CollectTab> _tabs = const [CollectTab(name: '全部')];
|
||||||
|
|
||||||
|
/// 当前选中的学科 id(null = 全部)
|
||||||
|
int? _subjectId;
|
||||||
|
|
||||||
|
/// 顶部总数(来自分页响应 total)
|
||||||
|
int _total = 0;
|
||||||
|
|
||||||
|
/// 游标:本页最后一条 id,首页/刷新/切学科时重置为 0
|
||||||
|
int _prevPageId = 0;
|
||||||
|
|
||||||
|
_PageConfig get _config =>
|
||||||
|
widget.type == 1 ? _PageConfig.collect : _PageConfig.wrong;
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
talker.debug('打开页面:${widget.type == 1 ? '我的收藏' : '错题本'}');
|
||||||
|
_loadTabs();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 拉取学科筛选项;失败兜底只有"全部"(对齐 Vue catch 逻辑)
|
||||||
|
Future<void> _loadTabs() async {
|
||||||
|
try {
|
||||||
|
final tabs = await UserCollectApi.instance.getSubjects(widget.type);
|
||||||
|
if (!mounted) return;
|
||||||
|
setState(() {
|
||||||
|
_tabs = [const CollectTab(name: '全部'), ...tabs];
|
||||||
|
});
|
||||||
|
} catch (e) {
|
||||||
|
talker.error('获取学科Tab失败', e);
|
||||||
|
if (!mounted) return;
|
||||||
|
setState(() {
|
||||||
|
_tabs = const [CollectTab(name: '全部')];
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 分页加载(CommonPagedList 回调):只写请求 + 返回数据
|
||||||
|
Future<PagingResult<UserCollectItem>> _load(int pageKey) async {
|
||||||
|
// 首页/下拉刷新:游标重置(对齐 Vue useList pageNo===1 时 prevPageId=0)
|
||||||
|
if (pageKey == 1) _prevPageId = 0;
|
||||||
|
|
||||||
|
final res = await UserCollectApi.instance.getCollectList(
|
||||||
|
type: widget.type,
|
||||||
|
subjectId: _subjectId,
|
||||||
|
pageIndex: pageKey,
|
||||||
|
pageSize: _pageSize,
|
||||||
|
prevPageId: _prevPageId,
|
||||||
|
);
|
||||||
|
|
||||||
|
// 更新游标为本页最后一条 id
|
||||||
|
_prevPageId = res.data.isNotEmpty ? res.data.last.id : 0;
|
||||||
|
|
||||||
|
if (mounted) {
|
||||||
|
setState(() => _total = res.total);
|
||||||
|
}
|
||||||
|
|
||||||
|
return PagingResult<UserCollectItem>(
|
||||||
|
data: res.data,
|
||||||
|
hasNext: res.total > pageKey * _pageSize,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 切学科:ValueKey 变化后 CommonPagedList 整体重建,自动回到第一页
|
||||||
|
void _onTabTap(CollectTab tab) {
|
||||||
|
if (_subjectId == tab.id) return;
|
||||||
|
setState(() {
|
||||||
|
_subjectId = tab.id;
|
||||||
|
_prevPageId = 0;
|
||||||
|
_total = 0;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 点击卡片 → 题目解析详情页
|
||||||
|
/// TODO: 详情页待接入——错题本跳 questionAnalysis、收藏跳 collectAnalysis,
|
||||||
|
/// 参数:questionId=${item.questionId}
|
||||||
|
/// recordQuestionId=${item.recordQuestionId}
|
||||||
|
/// listDetailId=${item.id}
|
||||||
|
void _goDetail(UserCollectItem item) {
|
||||||
|
talker.debug(
|
||||||
|
'题目详情待接入:type=${widget.type} questionId=${item.questionId} '
|
||||||
|
'recordQuestionId=${item.recordQuestionId} listDetailId=${item.id}',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
final cfg = _config;
|
||||||
|
final isPad =
|
||||||
|
MediaQuery.sizeOf(context).width >= AppAdapt.tabletBreakpoint;
|
||||||
|
|
||||||
|
return Scaffold(
|
||||||
|
backgroundColor: Colors.white,
|
||||||
|
appBar: AppBar(
|
||||||
|
backgroundColor: Colors.white,
|
||||||
|
surfaceTintColor: Colors.white,
|
||||||
|
elevation: 0,
|
||||||
|
title: Text(
|
||||||
|
cfg.title,
|
||||||
|
style: const TextStyle(color: Color(0xFF1D2B47)),
|
||||||
|
),
|
||||||
|
iconTheme: const IconThemeData(color: Color(0xFF1D2B47)),
|
||||||
|
leading: IconButton(
|
||||||
|
icon: const Icon(Icons.arrow_back),
|
||||||
|
onPressed: () => context.canPop() ? context.pop() : context.go('/my'),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
body: Column(
|
||||||
|
children: [
|
||||||
|
// 1. 学科筛选 Tab(白底)
|
||||||
|
_buildTabBar(),
|
||||||
|
// 2. 总数头(背景图 + 大号数字)
|
||||||
|
_buildTotalHeader(cfg, isPad),
|
||||||
|
// 3. 列表区(#F5F8FA 灰底)
|
||||||
|
Expanded(
|
||||||
|
child: Container(
|
||||||
|
color: const Color(0xFFF5F8FA),
|
||||||
|
child: CommonPagedList<UserCollectItem>(
|
||||||
|
// 切学科时重建列表,状态自动回第一页
|
||||||
|
key: ValueKey('question_list_${widget.type}_$_subjectId'),
|
||||||
|
padding: EdgeInsets.fromLTRB(14.w, 16.h, 14.w, 14.h),
|
||||||
|
emptyWidget: _buildEmpty(cfg),
|
||||||
|
load: _load,
|
||||||
|
buildItem: (context, item, index) => _QuestionCard(
|
||||||
|
item: item,
|
||||||
|
onTap: () => _goDetail(item),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 学科筛选胶囊 Tab 栏(横向滚动)
|
||||||
|
Widget _buildTabBar() {
|
||||||
|
return Container(
|
||||||
|
color: Colors.white,
|
||||||
|
height: 56.h, // 上下 padding 12.h + 胶囊 32.h(对齐 Vue 24rpx+64rpx)
|
||||||
|
child: ListView.separated(
|
||||||
|
scrollDirection: Axis.horizontal,
|
||||||
|
padding: EdgeInsets.symmetric(horizontal: 12.w),
|
||||||
|
itemCount: _tabs.length,
|
||||||
|
separatorBuilder: (_, __) => SizedBox(width: 12.w),
|
||||||
|
itemBuilder: (context, i) {
|
||||||
|
final tab = _tabs[i];
|
||||||
|
final active = _subjectId == tab.id;
|
||||||
|
return Center(
|
||||||
|
child: GestureDetector(
|
||||||
|
onTap: () => _onTabTap(tab),
|
||||||
|
child: Container(
|
||||||
|
height: 32.h,
|
||||||
|
alignment: Alignment.center,
|
||||||
|
padding: EdgeInsets.symmetric(horizontal: 16.w),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: active
|
||||||
|
? const Color(0xFF3D7DF5)
|
||||||
|
: const Color(0xFFF5F8FA),
|
||||||
|
borderRadius: BorderRadius.circular(999),
|
||||||
|
),
|
||||||
|
child: Text(
|
||||||
|
tab.name,
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 15.sp,
|
||||||
|
fontWeight: FontWeight.w400,
|
||||||
|
color: active
|
||||||
|
? Colors.white
|
||||||
|
: const Color(0xFF687FAD),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 总数头:背景图(widthFix)+ 大号总数 + 装饰色带 + 文案
|
||||||
|
Widget _buildTotalHeader(_PageConfig cfg, bool isPad) {
|
||||||
|
final numFontSize = isPad ? 52.5.sp : 35.sp;
|
||||||
|
final labelFontSize = isPad ? 21.sp : 14.sp;
|
||||||
|
|
||||||
|
return Stack(
|
||||||
|
children: [
|
||||||
|
// 背景图:宽度撑满,高度按图比例(对齐 Vue mode="widthFix")
|
||||||
|
CachedNetworkImage(
|
||||||
|
imageUrl: ImgUrl.build(isPad ? cfg.topBgPad : cfg.topBgPhone),
|
||||||
|
width: double.infinity,
|
||||||
|
fit: BoxFit.fitWidth,
|
||||||
|
alignment: Alignment.topCenter,
|
||||||
|
placeholder: (_, __) => const SizedBox.shrink(),
|
||||||
|
errorWidget: (_, __, ___) => const SizedBox.shrink(),
|
||||||
|
),
|
||||||
|
// 数字 + 色带 + 文案(绝对定位叠在图上)
|
||||||
|
Positioned(
|
||||||
|
top: isPad ? 45.h : 16.5.h, // Vue padding-top: 90rpx / 33rpx
|
||||||
|
left: 30.w, // Vue padding-left: 60rpx
|
||||||
|
child: Row(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
|
children: [
|
||||||
|
// 大号数字 + 底部装饰色带
|
||||||
|
Stack(
|
||||||
|
clipBehavior: Clip.none,
|
||||||
|
children: [
|
||||||
|
Positioned(
|
||||||
|
left: 0,
|
||||||
|
right: 0,
|
||||||
|
bottom: isPad ? -7.h : -4.h,
|
||||||
|
child: Container(
|
||||||
|
height: 9.h, // Vue 18rpx
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
borderRadius: BorderRadius.circular(50.r),
|
||||||
|
gradient: LinearGradient(
|
||||||
|
begin: Alignment.centerLeft,
|
||||||
|
end: Alignment.centerRight,
|
||||||
|
colors: cfg.underlineColors,
|
||||||
|
stops: const [0, 0.36, 1],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Text(
|
||||||
|
'$_total',
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: numFontSize,
|
||||||
|
fontWeight: isPad ? FontWeight.w500 : FontWeight.w600,
|
||||||
|
color: const Color(0xFF1D2B47),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
SizedBox(width: 10.w), // Vue margin-l-20
|
||||||
|
// 文案(Vue margin-t-30:相对数字略微下沉)
|
||||||
|
Padding(
|
||||||
|
padding: EdgeInsets.only(top: 15.h),
|
||||||
|
child: Text(
|
||||||
|
cfg.totalLabel,
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: labelFontSize,
|
||||||
|
fontWeight: FontWeight.w400,
|
||||||
|
color: const Color(0xFF687FAD),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 空状态:空态图 + 文案(对齐 Vue DataEmpty)
|
||||||
|
Widget _buildEmpty(_PageConfig cfg) {
|
||||||
|
return Center(
|
||||||
|
child: Column(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
children: [
|
||||||
|
CachedNetworkImage(
|
||||||
|
imageUrl: ImgUrl.build(cfg.emptyImg),
|
||||||
|
width: 160.w,
|
||||||
|
fit: BoxFit.contain,
|
||||||
|
placeholder: (_, __) => const SizedBox.shrink(),
|
||||||
|
errorWidget: (_, __, ___) => const SizedBox.shrink(),
|
||||||
|
),
|
||||||
|
SizedBox(height: 12.h),
|
||||||
|
Text(
|
||||||
|
cfg.emptyText,
|
||||||
|
style: TextStyle(fontSize: 14.sp, color: const Color(0xFF999999)),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 单条收藏/错题卡片:SubjectTag + 时间 + packName + 题干富文本
|
||||||
|
///
|
||||||
|
/// 按压反馈:按下缩放到 0.97、抬起回弹,背景始终白色
|
||||||
|
/// (不用 InkWell 灰底,改用 GestureDetector 驱动 AnimatedScale)。
|
||||||
|
class _QuestionCard extends StatefulWidget {
|
||||||
|
const _QuestionCard({required this.item, required this.onTap});
|
||||||
|
|
||||||
|
final UserCollectItem item;
|
||||||
|
final VoidCallback onTap;
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<_QuestionCard> createState() => _QuestionCardState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _QuestionCardState extends State<_QuestionCard> {
|
||||||
|
/// 是否处于按压状态(控制 0.97 缩放)
|
||||||
|
bool _pressed = false;
|
||||||
|
|
||||||
|
void _setPressed(bool v) {
|
||||||
|
if (_pressed != v) setState(() => _pressed = v);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
final item = widget.item;
|
||||||
|
return Padding(
|
||||||
|
padding: EdgeInsets.only(bottom: 14.h), // Vue listItem margin-bottom: 28rpx
|
||||||
|
child: GestureDetector(
|
||||||
|
onTapDown: (_) => _setPressed(true),
|
||||||
|
onTapUp: (_) => _setPressed(false),
|
||||||
|
onTapCancel: () => _setPressed(false),
|
||||||
|
onTap: widget.onTap,
|
||||||
|
child: AnimatedScale(
|
||||||
|
scale: _pressed ? 0.97 : 1.0,
|
||||||
|
duration: const Duration(milliseconds: 100),
|
||||||
|
curve: Curves.easeOut,
|
||||||
|
child: Material(
|
||||||
|
color: Colors.white,
|
||||||
|
borderRadius: BorderRadius.circular(16.r),
|
||||||
|
child: Padding(
|
||||||
|
// Vue padding: t-32 l/r-28 b-28
|
||||||
|
padding: EdgeInsets.fromLTRB(14.w, 16.h, 14.w, 14.h),
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
// 第一行:学科标签 + 时间
|
||||||
|
Row(
|
||||||
|
children: [
|
||||||
|
SubjectTag(subject: item.subjectName),
|
||||||
|
const Spacer(),
|
||||||
|
Text(
|
||||||
|
item.createTime,
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 12.sp, // Vue font-24
|
||||||
|
color: const Color(0xFFB4C2E0),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
SizedBox(height: 14.h), // Vue pack-name margin-top: 28rpx
|
||||||
|
// 试卷/礼包名
|
||||||
|
Text(
|
||||||
|
item.packName,
|
||||||
|
maxLines: 2,
|
||||||
|
overflow: TextOverflow.ellipsis,
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 16.sp, // Vue font-32
|
||||||
|
fontWeight: FontWeight.w600,
|
||||||
|
color: const Color(0xFF1D2B47),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
SizedBox(height: 16.h), // Vue question-stem-wrap margin-top: 32rpx
|
||||||
|
// 题干富文本(限高渐隐)
|
||||||
|
_StemBox(html: item.questionStem),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 题干容器:#FAFBFD 底 + #E3ECFF 边框,内容限高 70.h(Vue 140rpx),
|
||||||
|
/// 超出部分底部渐隐遮罩
|
||||||
|
class _StemBox extends StatelessWidget {
|
||||||
|
const _StemBox({required this.html});
|
||||||
|
|
||||||
|
final String html;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Container(
|
||||||
|
width: double.infinity,
|
||||||
|
padding: EdgeInsets.all(12.w), // Vue padding: 24rpx
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: const Color(0xFFFAFBFD),
|
||||||
|
borderRadius: BorderRadius.circular(8.r), // Vue 16rpx
|
||||||
|
border: Border.all(color: const Color(0xFFE3ECFF)),
|
||||||
|
),
|
||||||
|
child: Stack(
|
||||||
|
children: [
|
||||||
|
// 限高裁剪:OverflowBox 让富文本按自然高度布局,超出 70.h 的部分裁掉
|
||||||
|
ClipRect(
|
||||||
|
child: ConstrainedBox(
|
||||||
|
constraints: BoxConstraints(maxHeight: 70.h),
|
||||||
|
child: OverflowBox(
|
||||||
|
alignment: Alignment.topCenter,
|
||||||
|
minHeight: 0,
|
||||||
|
maxHeight: double.infinity,
|
||||||
|
child: RichTextContent(
|
||||||
|
html: html,
|
||||||
|
textStyle: TextStyle(
|
||||||
|
fontSize: 14.sp,
|
||||||
|
fontWeight: FontWeight.w400,
|
||||||
|
color: const Color(0xFF495A7A),
|
||||||
|
height: 1.5,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
// 底部渐隐遮罩(Vue mask-layer 60rpx):
|
||||||
|
// 终点色与底色 #FAFBFD 一致,内容不足时遮罩盖在底色上视觉不可见
|
||||||
|
Positioned(
|
||||||
|
left: 0,
|
||||||
|
right: 0,
|
||||||
|
bottom: 0,
|
||||||
|
height: 30.h,
|
||||||
|
child: IgnorePointer(
|
||||||
|
child: DecoratedBox(
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
gradient: const LinearGradient(
|
||||||
|
begin: Alignment.topCenter,
|
||||||
|
end: Alignment.bottomCenter,
|
||||||
|
colors: [Color(0x00FAFBFD), Color(0xFFFAFBFD)],
|
||||||
|
),
|
||||||
|
borderRadius: BorderRadius.circular(8.r),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 页面差异化配置(按 type 切换文案/图片/配色)
|
||||||
|
class _PageConfig {
|
||||||
|
const _PageConfig({
|
||||||
|
required this.title,
|
||||||
|
required this.totalLabel,
|
||||||
|
required this.topBgPhone,
|
||||||
|
required this.topBgPad,
|
||||||
|
required this.emptyImg,
|
||||||
|
required this.emptyText,
|
||||||
|
required this.underlineColors,
|
||||||
|
});
|
||||||
|
|
||||||
|
final String title;
|
||||||
|
final String totalLabel;
|
||||||
|
final String topBgPhone;
|
||||||
|
final String topBgPad;
|
||||||
|
final String emptyImg;
|
||||||
|
final String emptyText;
|
||||||
|
final List<Color> underlineColors;
|
||||||
|
|
||||||
|
/// 我的收藏(type=1):橙色系装饰
|
||||||
|
static final _PageConfig collect = _PageConfig(
|
||||||
|
title: '我的收藏',
|
||||||
|
totalLabel: '收藏题目',
|
||||||
|
topBgPhone: '/StaticResource/2026-04-08/my-collect-top-bg.png',
|
||||||
|
topBgPad: '/StaticResource/2026-06-02/my-collect-top-bg-pad1780378706432.png',
|
||||||
|
emptyImg: '/StaticResource/2026-04-11/contentEmptys.png',
|
||||||
|
emptyText: '暂无收藏',
|
||||||
|
// Vue: linear-gradient(90deg, #F59C3D00 0%, #FFCA1D33 36%, #FDAD8A80 100%)
|
||||||
|
underlineColors: const [
|
||||||
|
Color(0x00F59C3D),
|
||||||
|
Color(0x33FFCA1D),
|
||||||
|
Color(0x80FDAD8A),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
|
||||||
|
/// 错题本(type=2):蓝色系装饰
|
||||||
|
static final _PageConfig wrong = _PageConfig(
|
||||||
|
title: '错题本',
|
||||||
|
totalLabel: '道错题',
|
||||||
|
topBgPhone: '/StaticResource/2026-04-08/my-wrong-top-bg.png',
|
||||||
|
topBgPad: '/StaticResource/2026-06-02/my-wrong-top-bg-pad1780372865693.png',
|
||||||
|
emptyImg: '/StaticResource/2026-04-11/noDatas.png',
|
||||||
|
emptyText: '暂无错题',
|
||||||
|
// Vue: linear-gradient(90deg, #3D7DF500 0%, #1D9CFF33 36%, #8AECFD80 100%)
|
||||||
|
underlineColors: const [
|
||||||
|
Color(0x003D7DF5),
|
||||||
|
Color(0x331D9CFF),
|
||||||
|
Color(0x808AECFD),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -0,0 +1,286 @@
|
|||||||
|
import 'dart:async';
|
||||||
|
|
||||||
|
import 'package:cached_network_image/cached_network_image.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||||
|
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||||
|
import 'package:go_router/go_router.dart';
|
||||||
|
import 'package:new_learn/core/api/auth/api.dart';
|
||||||
|
import 'package:new_learn/core/api/report/api.dart';
|
||||||
|
import 'package:new_learn/core/api/report/model.dart';
|
||||||
|
import 'package:new_learn/core/logger/app_talker.dart';
|
||||||
|
import 'package:new_learn/core/providers/user_provider.dart';
|
||||||
|
import 'package:new_learn/core/utils/img_url.dart';
|
||||||
|
import 'package:new_learn/core/utils/screen_adapt_template.dart';
|
||||||
|
import 'package:new_learn/features/report/widgets/computation_finished_popup.dart';
|
||||||
|
import 'package:new_learn/features/report/widgets/computation_progress_ring.dart';
|
||||||
|
import 'package:new_learn/features/report/widgets/computation_subject_item.dart';
|
||||||
|
|
||||||
|
/// ============================================================
|
||||||
|
/// 【ReportComputationPage】AI 加载动画页 —— 对标 Vue reportComputation.vue
|
||||||
|
///
|
||||||
|
/// 入门测 H5 壳子看完所有科目报告 → navigateTo reportComputation →
|
||||||
|
/// 圆环进度 + 每个科目依次"AI计算中"动画 → 500ms 后 finishedPopup 弹窗 →
|
||||||
|
/// 调 ChangeShowReport → refresh userProvider → switchTab 首页
|
||||||
|
///
|
||||||
|
/// Vue 端用 tPageImg/tPageColor 从 themes/default.json 抽主题;
|
||||||
|
/// Flutter 端未做主题抽离,本页资源路径/颜色集中在 _ComputationTheme。
|
||||||
|
/// ============================================================
|
||||||
|
|
||||||
|
/// 本页主题资源(对标 default.json → pages/reportPackage/reportComputation)
|
||||||
|
class _ComputationTheme {
|
||||||
|
// ---- images ----
|
||||||
|
static const String bg =
|
||||||
|
'/StaticResource/2026-06-11/bg-report21781144905849.png';
|
||||||
|
static const String bgPad =
|
||||||
|
'/StaticResource/2026-06-23/bg-report_pad1782196580176.png';
|
||||||
|
static const String bubble =
|
||||||
|
'/StaticResource/2026-06-11/Group33(2)1781142719442.png';
|
||||||
|
|
||||||
|
// ---- colors ----
|
||||||
|
static const Color pageBg = Color(0xFF275FD9); // background
|
||||||
|
}
|
||||||
|
|
||||||
|
String _img(String path) => ImgUrl.build(path);
|
||||||
|
|
||||||
|
class ReportComputationPage extends ConsumerStatefulWidget {
|
||||||
|
const ReportComputationPage({super.key});
|
||||||
|
|
||||||
|
@override
|
||||||
|
ConsumerState<ReportComputationPage> createState() =>
|
||||||
|
_ReportComputationPageState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _ReportComputationPageState extends ConsumerState<ReportComputationPage> {
|
||||||
|
List<_SubjectData> _subjectList = [];
|
||||||
|
double _ringProgress = 0;
|
||||||
|
bool _showFinishedPopup = false;
|
||||||
|
Timer? _animTimer;
|
||||||
|
|
||||||
|
/// 每个科目卡片的 key,用于动画切换时自动滚动到可见区域
|
||||||
|
/// (对标 Vue scroll-into-view / scrollToItemIfNeeded)
|
||||||
|
final List<GlobalKey> _itemKeys = [];
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||||
|
_precacheImages();
|
||||||
|
_loadAndStart();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void dispose() {
|
||||||
|
_animTimer?.cancel();
|
||||||
|
super.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 预加载弹窗/背景图,避免首次显示闪烁(对标 Vue onMounted getImageInfo)
|
||||||
|
void _precacheImages() {
|
||||||
|
final isPad = MediaQuery.sizeOf(context).width >= AppAdapt.tabletBreakpoint;
|
||||||
|
for (final path in [
|
||||||
|
isPad ? _ComputationTheme.bgPad : _ComputationTheme.bg,
|
||||||
|
ComputationFinishedPopup.topLightPadImg,
|
||||||
|
ComputationFinishedPopup.contentBgImg,
|
||||||
|
]) {
|
||||||
|
precacheImage(CachedNetworkImageProvider(_img(path)), context);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> _loadAndStart() async {
|
||||||
|
try {
|
||||||
|
final results = await Future.wait([
|
||||||
|
ReportApi.instance.getCurrentReport(),
|
||||||
|
ReportApi.instance.getCurrentReportKnow(),
|
||||||
|
]);
|
||||||
|
final report = results[0] as UserReportType;
|
||||||
|
final knowList = results[1] as List<UserReportKnowType>;
|
||||||
|
|
||||||
|
if (report.subjectReports.isEmpty) return;
|
||||||
|
|
||||||
|
final itemTime = (15 / report.subjectReports.length).floor();
|
||||||
|
final list = report.subjectReports.map((item) {
|
||||||
|
final knowItem = knowList.isNotEmpty
|
||||||
|
? knowList.firstWhere(
|
||||||
|
(k) => k.subjectName == item.subjectName,
|
||||||
|
orElse: () => const UserReportKnowType(),
|
||||||
|
)
|
||||||
|
: const UserReportKnowType();
|
||||||
|
return _SubjectData(
|
||||||
|
subjectReport: item,
|
||||||
|
knowCount: knowItem.knowCount,
|
||||||
|
time: itemTime,
|
||||||
|
);
|
||||||
|
}).toList();
|
||||||
|
|
||||||
|
if (!mounted) return;
|
||||||
|
setState(() {
|
||||||
|
_subjectList = list;
|
||||||
|
_itemKeys
|
||||||
|
..clear()
|
||||||
|
..addAll(List.generate(list.length, (_) => GlobalKey()));
|
||||||
|
});
|
||||||
|
_startSubjects(0);
|
||||||
|
} catch (e) {
|
||||||
|
talker.error('reportComputation 加载失败', e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void _startSubjects(int index) {
|
||||||
|
if (index >= _subjectList.length) {
|
||||||
|
setState(() => _ringProgress = 100);
|
||||||
|
// Vue:最后一个科目完成后延迟 500ms 弹弹窗
|
||||||
|
Timer(const Duration(milliseconds: 500), () {
|
||||||
|
if (mounted) setState(() => _showFinishedPopup = true);
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
setState(() {
|
||||||
|
_subjectList[index].status = ComputationSubjectStatus.inProgress;
|
||||||
|
_subjectList[index].progress = 0;
|
||||||
|
});
|
||||||
|
_scrollToItem(index);
|
||||||
|
|
||||||
|
final totalTimeMs = _subjectList[index].time * 1000;
|
||||||
|
final startTime = DateTime.now().millisecondsSinceEpoch;
|
||||||
|
|
||||||
|
_animTimer = Timer.periodic(const Duration(milliseconds: 30), (timer) {
|
||||||
|
final elapsed = DateTime.now().millisecondsSinceEpoch - startTime;
|
||||||
|
final progress = (elapsed / totalTimeMs * 100).clamp(0, 100).toInt();
|
||||||
|
|
||||||
|
setState(() {
|
||||||
|
_subjectList[index].progress = progress;
|
||||||
|
_ringProgress = (index * 100 + progress) / _subjectList.length;
|
||||||
|
});
|
||||||
|
|
||||||
|
if (elapsed >= totalTimeMs) {
|
||||||
|
timer.cancel();
|
||||||
|
_animTimer = null;
|
||||||
|
setState(() {
|
||||||
|
_subjectList[index].progress = 100;
|
||||||
|
_subjectList[index].status = ComputationSubjectStatus.finished;
|
||||||
|
});
|
||||||
|
_startSubjects(index + 1);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 当前科目卡片不完全可见时,滚动到可见区域
|
||||||
|
void _scrollToItem(int index) {
|
||||||
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||||
|
final ctx = _itemKeys[index].currentContext;
|
||||||
|
if (ctx != null) {
|
||||||
|
Scrollable.ensureVisible(
|
||||||
|
ctx,
|
||||||
|
duration: const Duration(milliseconds: 300),
|
||||||
|
curve: Curves.easeInOut,
|
||||||
|
alignment: 0.2,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/// finishedPopup 的"立即开启学习蝶变"按钮
|
||||||
|
Future<void> _onFinish() async {
|
||||||
|
try {
|
||||||
|
await UserApi.changeShowReport();
|
||||||
|
talker.debug('changeShowReport 成功');
|
||||||
|
await ref.read(currentUserProvider.notifier).refresh();
|
||||||
|
} catch (e) {
|
||||||
|
talker.error('changeShowReport 失败', e);
|
||||||
|
}
|
||||||
|
if (!mounted) return;
|
||||||
|
context.go('/');
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
final isPad = MediaQuery.sizeOf(context).width >= AppAdapt.tabletBreakpoint;
|
||||||
|
final bottomPadding = MediaQuery.paddingOf(context).bottom;
|
||||||
|
|
||||||
|
return Scaffold(
|
||||||
|
backgroundColor: _ComputationTheme.pageBg,
|
||||||
|
body: Stack(
|
||||||
|
children: [
|
||||||
|
// ===== 背景图:宽铺满、居顶、高度自适应(Vue mode=widthFix)=====
|
||||||
|
Positioned(
|
||||||
|
top: 0,
|
||||||
|
left: 0,
|
||||||
|
right: 0,
|
||||||
|
child: CachedNetworkImage(
|
||||||
|
imageUrl: _img(
|
||||||
|
isPad ? _ComputationTheme.bgPad : _ComputationTheme.bg,
|
||||||
|
),
|
||||||
|
fit: BoxFit.fitWidth,
|
||||||
|
errorWidget: (_, _, _) => const SizedBox.shrink(),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
SafeArea(
|
||||||
|
bottom: false,
|
||||||
|
child: Column(
|
||||||
|
children: [
|
||||||
|
SizedBox(height: 8.h),
|
||||||
|
// AI核心算力气泡(454x98rpx)
|
||||||
|
CachedNetworkImage(
|
||||||
|
imageUrl: _img(_ComputationTheme.bubble),
|
||||||
|
width: 227.w,
|
||||||
|
height: 49.h,
|
||||||
|
fit: BoxFit.fill,
|
||||||
|
errorWidget: (_, _, _) =>
|
||||||
|
SizedBox(width: 227.w, height: 49.h),
|
||||||
|
),
|
||||||
|
SizedBox(height: 7.5.h),
|
||||||
|
// 圆环进度
|
||||||
|
ComputationProgressRing(progress: _ringProgress),
|
||||||
|
// 科目列表
|
||||||
|
Expanded(
|
||||||
|
child: ListView.separated(
|
||||||
|
padding: EdgeInsets.fromLTRB(
|
||||||
|
14.w,
|
||||||
|
10.h,
|
||||||
|
14.w,
|
||||||
|
20.h + bottomPadding,
|
||||||
|
),
|
||||||
|
itemCount: _subjectList.length,
|
||||||
|
separatorBuilder: (_, _) => SizedBox(height: 7.5.h),
|
||||||
|
itemBuilder: (_, index) {
|
||||||
|
final data = _subjectList[index];
|
||||||
|
return ComputationSubjectItem(
|
||||||
|
key: _itemKeys[index],
|
||||||
|
subjectName: data.subjectReport.subjectName,
|
||||||
|
iconUrl: data.subjectReport.icon,
|
||||||
|
knowCount: data.knowCount,
|
||||||
|
progress: data.progress,
|
||||||
|
status: data.status,
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
// finishedPopup 弹窗
|
||||||
|
if (_showFinishedPopup) ComputationFinishedPopup(onStart: _onFinish),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ==================== 内部数据类 ====================
|
||||||
|
|
||||||
|
class _SubjectData {
|
||||||
|
final SubjectReportType subjectReport;
|
||||||
|
int progress = 0;
|
||||||
|
ComputationSubjectStatus status = ComputationSubjectStatus.notStarted;
|
||||||
|
final int time;
|
||||||
|
final int knowCount;
|
||||||
|
|
||||||
|
_SubjectData({
|
||||||
|
required this.subjectReport,
|
||||||
|
required this.time,
|
||||||
|
required this.knowCount,
|
||||||
|
});
|
||||||
|
}
|
||||||
@@ -0,0 +1,300 @@
|
|||||||
|
import 'package:flutter/foundation.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_inappwebview/flutter_inappwebview.dart';
|
||||||
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||||
|
import 'package:go_router/go_router.dart';
|
||||||
|
import 'package:new_learn/core/config/app_config.dart';
|
||||||
|
import 'package:new_learn/core/logger/app_talker.dart';
|
||||||
|
import 'package:new_learn/core/network/dio_client.dart';
|
||||||
|
|
||||||
|
/// ============================================================
|
||||||
|
/// 【ReportWebViewPage】报告 H5 壳子容器 —— 对标 Vue reportWebView.vue
|
||||||
|
///
|
||||||
|
/// 承载已上线的 H5 壳子(App.K12.Student.Report),它内部自己加载
|
||||||
|
/// 每个科目的报告 URL 并提供"跳过/下一步"按钮。
|
||||||
|
///
|
||||||
|
/// Flutter 端负责:
|
||||||
|
/// 1. 拼 H5 壳子的加载 URL(baseURL / token / type / safeBottom);
|
||||||
|
/// 2. 注入 window.uni JS Bridge(switchTab / navigateTo / reLaunch),
|
||||||
|
/// 让 H5 壳子里已有的 `window.uni.switchTab(...)` 等调用自然生效。
|
||||||
|
/// 【通信方式】:用 console.log('[FLUTTER_BRIDGE] xxx url') + onConsoleMessage 监听,
|
||||||
|
/// 而不是 InAppWebView.callHandler/addJavaScriptHandler。
|
||||||
|
/// 原因:callHandler 在真机上首次 onLoadStop 注入时偶尔能通,
|
||||||
|
/// 但 H5 后续真实点击触发时就失效了(之前加的 _isExiting 锁导致死循环,
|
||||||
|
/// 去掉锁也没收到调用);console.log 通道每次都能收到,更稳定。
|
||||||
|
/// 3. H5 壳子自己调 updateAfterReportStatus() 更新出门测状态,
|
||||||
|
/// Flutter Bridge 只负责路由跳转,职责单一不重复。
|
||||||
|
///
|
||||||
|
/// 路由参数(GoRouteState.extra):
|
||||||
|
/// context.push('/reportWebView', extra: {'type': 'placementTest'});
|
||||||
|
///
|
||||||
|
/// H5 路径 → Flutter 路由映射表:见 _h5PathMap
|
||||||
|
/// ============================================================
|
||||||
|
class ReportWebViewPage extends ConsumerStatefulWidget {
|
||||||
|
const ReportWebViewPage({super.key});
|
||||||
|
|
||||||
|
@override
|
||||||
|
ConsumerState<ReportWebViewPage> createState() => _ReportWebViewPageState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _ReportWebViewPageState extends ConsumerState<ReportWebViewPage> {
|
||||||
|
InAppWebViewController? _webController;
|
||||||
|
double _loadingProgress = 0;
|
||||||
|
String _reportType = 'placementTest';
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void didChangeDependencies() {
|
||||||
|
super.didChangeDependencies();
|
||||||
|
// initState 里不能调 GoRouterState.of(context)(会访问 InheritedWidget),
|
||||||
|
// didChangeDependencies 在 initState 之后、build 之前立刻调用,
|
||||||
|
// 赋值时机刚好赶得上 InAppWebView.initialUrlRequest 用 _reportType 拼 URL。
|
||||||
|
final extra =
|
||||||
|
GoRouterState.of(context).extra as Map<String, dynamic>? ?? {};
|
||||||
|
_reportType = (extra['type'] as String?) ?? 'placementTest';
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 拼 H5 壳子的加载 URL(对齐 UniApp reportWebView.vue 的 encodeURIComponent 逻辑)
|
||||||
|
String _buildH5Url() {
|
||||||
|
final token = DioClient.instance.accessToken ?? '';
|
||||||
|
final baseUrl = AppConfig.baseUrl;
|
||||||
|
final safeBottom = 0; // TODO: 计算安全底部距离
|
||||||
|
// 用 Dart Uri 统一编码所有 query param,和 UniApp 的 encodeURIComponent 对齐
|
||||||
|
final h5Uri = Uri.parse(AppConfig.reportUrl);
|
||||||
|
return h5Uri
|
||||||
|
.replace(
|
||||||
|
queryParameters: {
|
||||||
|
'baseURL': baseUrl,
|
||||||
|
'token': token,
|
||||||
|
't': DateTime.now().millisecondsSinceEpoch.toString(),
|
||||||
|
'safeBottom': safeBottom.toString(),
|
||||||
|
'type': _reportType,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 注入 window.uni JS Bridge 源码(使用 console 通道通信,比 callHandler 更稳)
|
||||||
|
String get _uniBridgeScript {
|
||||||
|
final script = '''
|
||||||
|
(function() {
|
||||||
|
window.uni = window.uni || {};
|
||||||
|
|
||||||
|
// 通过 console.log 发送指令给 Flutter 端 onConsoleMessage 监听
|
||||||
|
function callFlutter(action, url) {
|
||||||
|
console.log('[FLUTTER_BRIDGE] ' + action + ' ' + url);
|
||||||
|
}
|
||||||
|
|
||||||
|
window.uni.switchTab = function(options) {
|
||||||
|
var url = (options && options.url) || '';
|
||||||
|
console.log('[uniBridge] switchTab called, url=' + url);
|
||||||
|
callFlutter('switchTab', url);
|
||||||
|
if (options && options.success) options.success();
|
||||||
|
};
|
||||||
|
window.uni.navigateTo = function(options) {
|
||||||
|
var url = (options && options.url) || '';
|
||||||
|
console.log('[uniBridge] navigateTo called, url=' + url);
|
||||||
|
callFlutter('navigateTo', url);
|
||||||
|
if (options && options.success) options.success();
|
||||||
|
};
|
||||||
|
window.uni.reLaunch = function(options) {
|
||||||
|
var url = (options && options.url) || '';
|
||||||
|
console.log('[uniBridge] reLaunch called, url=' + url);
|
||||||
|
callFlutter('reLaunch', url);
|
||||||
|
if (options && options.success) options.success();
|
||||||
|
};
|
||||||
|
console.log('[uniBridge] window.uni injected via console channel');
|
||||||
|
})();
|
||||||
|
''';
|
||||||
|
return script;
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
final h5Url = _buildH5Url();
|
||||||
|
talker.debug('ReportWebViewPage loading: $h5Url');
|
||||||
|
|
||||||
|
return Scaffold(
|
||||||
|
backgroundColor: Colors.white,
|
||||||
|
appBar: AppBar(
|
||||||
|
backgroundColor: Colors.white,
|
||||||
|
elevation: 0,
|
||||||
|
title: Text('学生报告'),
|
||||||
|
leading: IconButton(
|
||||||
|
icon: const Icon(Icons.arrow_back_ios_new, color: Color(0xFF1D2B47)),
|
||||||
|
onPressed: () => context.canPop() ? context.pop() : context.go('/'),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
body: InAppWebView(
|
||||||
|
initialUrlRequest: URLRequest(url: WebUri(h5Url)),
|
||||||
|
initialSettings: InAppWebViewSettings(
|
||||||
|
javaScriptEnabled: true,
|
||||||
|
allowsInlineMediaPlayback: true,
|
||||||
|
useHybridComposition: true,
|
||||||
|
),
|
||||||
|
// 把 H5 壳子的 console 日志转发到 Flutter talker
|
||||||
|
onConsoleMessage: (controller, consoleMessage) {
|
||||||
|
final levelName = consoleMessage.messageLevel
|
||||||
|
.toString()
|
||||||
|
.split('.')
|
||||||
|
.last;
|
||||||
|
final rawMsg = consoleMessage.message;
|
||||||
|
final msg = '[H5] [$levelName] $rawMsg';
|
||||||
|
if (levelName == 'ERROR') {
|
||||||
|
talker.error(msg);
|
||||||
|
} else {
|
||||||
|
talker.debug(msg);
|
||||||
|
}
|
||||||
|
// 解析 H5 通过 console 发来的跳转指令:
|
||||||
|
// console.log('[FLUTTER_BRIDGE] switchTab', '/pages/tabbar/task/task')
|
||||||
|
// console.log('[FLUTTER_BRIDGE] navigateTo', '/pages/reportPackage/reportComputation/reportComputation')
|
||||||
|
// console.log('[FLUTTER_BRIDGE] reLaunch', '/pages/xxx/yyy')
|
||||||
|
if (rawMsg.startsWith('[FLUTTER_BRIDGE]')) {
|
||||||
|
final parts = rawMsg
|
||||||
|
.substring('[FLUTTER_BRIDGE]'.length)
|
||||||
|
.trim()
|
||||||
|
.split(' ');
|
||||||
|
if (parts.length >= 2) {
|
||||||
|
final action = parts[0];
|
||||||
|
final url = parts.sublist(1).join(' ');
|
||||||
|
final flutterPath = _mapH5Path(url);
|
||||||
|
talker.debug('[consoleBridge] $action $url → $flutterPath');
|
||||||
|
switch (action) {
|
||||||
|
case 'switchTab':
|
||||||
|
if (mounted) context.go(flutterPath);
|
||||||
|
break;
|
||||||
|
case 'navigateTo':
|
||||||
|
if (mounted) context.go(flutterPath);
|
||||||
|
break;
|
||||||
|
case 'reLaunch':
|
||||||
|
if (mounted) context.go(flutterPath);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
onWebViewCreated: (controller) {
|
||||||
|
_webController = controller;
|
||||||
|
_registerJsBridge(controller);
|
||||||
|
},
|
||||||
|
onLoadStop: (controller, url) async {
|
||||||
|
setState(() => _loadingProgress = 1);
|
||||||
|
// 注入 window.uni JS Bridge
|
||||||
|
await controller.evaluateJavascript(source: _uniBridgeScript);
|
||||||
|
},
|
||||||
|
onProgressChanged: (controller, progress) {
|
||||||
|
setState(() => _loadingProgress = progress / 100.0);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
bottomNavigationBar: _loadingProgress < 1.0
|
||||||
|
? LinearProgressIndicator(
|
||||||
|
value: _loadingProgress,
|
||||||
|
backgroundColor: Colors.transparent,
|
||||||
|
valueColor: const AlwaysStoppedAnimation(Color(0xFF3D7DF5)),
|
||||||
|
)
|
||||||
|
: null,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// H5 壳子传的 uni-app 路径 → Flutter 路由路径映射表
|
||||||
|
///
|
||||||
|
/// H5 壳子里所有 uni.switchTab/navigateTo/reLaunch 都用 uni-app 的路径格式,
|
||||||
|
/// Flutter Bridge 收到后先过这个表转成 Flutter 自己的路由再跳转。
|
||||||
|
static const Map<String, String> _h5PathMap = {
|
||||||
|
// switchTab
|
||||||
|
'/pages/tabbar/task/task': '/',
|
||||||
|
'/pages/tabbar/recite/recite': '/recite',
|
||||||
|
'/pages/tabbar/class/class': '/class',
|
||||||
|
'/pages/tabbar/my/my': '/my',
|
||||||
|
// navigateTo
|
||||||
|
'/pages/reportPackage/reportComputation/reportComputation':
|
||||||
|
'/reportComputation',
|
||||||
|
// reLaunch
|
||||||
|
'/pages/reportPackage/studentInfo/studentInfo': '/studentInfo',
|
||||||
|
'/pages/login/index': '/login',
|
||||||
|
};
|
||||||
|
|
||||||
|
/// 把 H5 uni-app 路径转 Flutter 路由,转不了就原样返回
|
||||||
|
String _mapH5Path(String h5Path) {
|
||||||
|
// 去掉 query 参数再匹配
|
||||||
|
final pathOnly = h5Path.split('?').first;
|
||||||
|
return _h5PathMap[pathOnly] ?? h5Path;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ============================================================
|
||||||
|
// JS Bridge:接收 H5 壳子通过 window.uni.switchTab/navigateTo/reLaunch 发起的调用
|
||||||
|
// 统一用 uniBridge 一个 handler,参数里带 name 区分
|
||||||
|
// ============================================================
|
||||||
|
void _registerJsBridge(InAppWebViewController controller) {
|
||||||
|
// addJavaScriptHandler 在 Chrome Web 平台不支持,跳过即可
|
||||||
|
if (kIsWeb) {
|
||||||
|
talker.debug('[uniBridge] Web平台跳过 registerJsBridge');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
controller.addJavaScriptHandler(
|
||||||
|
handlerName: 'uniBridge',
|
||||||
|
callback: (args) async {
|
||||||
|
// 最顶端先打,任何过滤之前
|
||||||
|
talker.debug('[uniBridge] 收到 callHandler, args=$args');
|
||||||
|
if (args.isEmpty) {
|
||||||
|
talker.debug('[uniBridge] args 为空,return');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
final payload = args.first;
|
||||||
|
if (payload is! Map) {
|
||||||
|
talker.debug(
|
||||||
|
'[uniBridge] payload 不是 Map,return: ${payload.runtimeType}',
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
final name = payload['name'] as String?;
|
||||||
|
final options = payload['options'] as Map<String, dynamic>? ?? {};
|
||||||
|
final url = options['url'] as String? ?? '';
|
||||||
|
final flutterPath = _mapH5Path(url);
|
||||||
|
|
||||||
|
talker.debug('[uniBridge] $name $url → $flutterPath');
|
||||||
|
|
||||||
|
switch (name) {
|
||||||
|
case 'switchTab':
|
||||||
|
await _handleSwitchTab(flutterPath);
|
||||||
|
break;
|
||||||
|
case 'navigateTo':
|
||||||
|
await _handleNavigateTo(flutterPath);
|
||||||
|
break;
|
||||||
|
case 'reLaunch':
|
||||||
|
await _handleReLaunch(flutterPath);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// H5 壳子调 switchTab:直接跳对应 tab
|
||||||
|
Future<void> _handleSwitchTab(String flutterPath) async {
|
||||||
|
if (!mounted) return;
|
||||||
|
context.go(flutterPath);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// H5 壳子调 navigateTo:跳到对应 Flutter 页面
|
||||||
|
Future<void> _handleNavigateTo(String flutterPath) async {
|
||||||
|
if (!mounted) return;
|
||||||
|
context.go(flutterPath);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// H5 壳子调 reLaunch:重建路由栈跳到对应页面
|
||||||
|
Future<void> _handleReLaunch(String flutterPath) async {
|
||||||
|
if (!mounted) return;
|
||||||
|
context.go(flutterPath);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void dispose() {
|
||||||
|
_webController?.dispose();
|
||||||
|
super.dispose();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,654 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||||
|
import 'package:go_router/go_router.dart';
|
||||||
|
import 'package:new_learn/core/api/report/api.dart';
|
||||||
|
import 'package:new_learn/core/api/report/model.dart';
|
||||||
|
import 'package:new_learn/core/logger/app_talker.dart';
|
||||||
|
import 'package:new_learn/core/providers/user_provider.dart';
|
||||||
|
import 'package:new_learn/core/utils/img_url.dart';
|
||||||
|
|
||||||
|
/// ============================================================
|
||||||
|
/// 【StudentInfoPage】诊断报告欢迎介绍页 —— 对标 Vue studentInfo.vue
|
||||||
|
///
|
||||||
|
/// Vue 端用 tPageImg / tPageCss / tPageColor 从 themes/default.json 抽主题;
|
||||||
|
/// Flutter 端未做主题抽离,所以直接硬编码 default.json 里这一页的资源路径、
|
||||||
|
/// 颜色值、渐变配置。集中在本文件顶部 _StudentTheme 常量,便于后续抽离。
|
||||||
|
///
|
||||||
|
/// 路由参数(GoRouteState.extra):
|
||||||
|
/// context.go('/studentInfo', extra: {'type': 'placementTest'});
|
||||||
|
/// - type: placementTest(入门测)| exitTest(出门测)
|
||||||
|
///
|
||||||
|
/// 完整链路:登录成功/全局拦截 → 此页 → H5壳子 → reportComputation(入门测)
|
||||||
|
/// 或 switchTab 首页(出门测)
|
||||||
|
/// ============================================================
|
||||||
|
|
||||||
|
/// 本页用到的所有主题资源(对标 Vue themes/default.json → pages/reportPackage/studentInfo)
|
||||||
|
class _StudentTheme {
|
||||||
|
// ---- 图片(default.json images)----
|
||||||
|
// Flutter 端用 network 加载,需拼 CDN 域名;这里存相对路径,
|
||||||
|
// 使用时调 ImgUrl.build(path)
|
||||||
|
static const String bg =
|
||||||
|
'/StaticResource/2026-06-10/bg-report1781093056538.png';
|
||||||
|
static const String bubble =
|
||||||
|
'/StaticResource/2026-06-12/report_kuang1781230963682.png';
|
||||||
|
static const String welcome =
|
||||||
|
'/StaticResource/2026-06-10/Group3331781094167604.png';
|
||||||
|
static const String analytics =
|
||||||
|
'/StaticResource/2026-06-10/analytics1781081543912.png';
|
||||||
|
static const String logo = '/StaticResource/2026-06-10/logo1781083733383.png';
|
||||||
|
static const String aiAnalysisTitle =
|
||||||
|
'/StaticResource/2026-06-10/ai-analysis-title1781087439752.png';
|
||||||
|
static const String analysisTitle =
|
||||||
|
'/StaticResource/2026-06-22/analysis-title1782110217839.png';
|
||||||
|
static const String levelA =
|
||||||
|
'/StaticResource/2026-06-23/levelA1782178351618.png';
|
||||||
|
static const String levelB =
|
||||||
|
'/StaticResource/2026-06-23/levelB1782178351618.png';
|
||||||
|
static const String levelC =
|
||||||
|
'/StaticResource/2026-06-23/levelC1782178351618.png';
|
||||||
|
static const String verify =
|
||||||
|
'/StaticResource/2026-06-10/verify1781081993368.png';
|
||||||
|
static const String starIcon =
|
||||||
|
'/StaticResource/2026-06-10/star1781089096898.png';
|
||||||
|
|
||||||
|
// ---- 颜色(default.json colors)----
|
||||||
|
static const Color pageBg = Color(0xFFE5F6FE); // background
|
||||||
|
static const Color highlight = Color(0xFF3D7DF5);
|
||||||
|
|
||||||
|
// ---- 渐变(default.json css 里的 linear-gradient/rgba 转 Flutter)----
|
||||||
|
// item-bg: linear-gradient(180deg, #F5FBFF → #E5F4FF)
|
||||||
|
static const LinearGradient itemBg = LinearGradient(
|
||||||
|
begin: Alignment.topCenter,
|
||||||
|
end: Alignment.bottomCenter,
|
||||||
|
colors: [Color(0xFFF5FBFF), Color(0xFFE5F4FF)],
|
||||||
|
);
|
||||||
|
|
||||||
|
// item-border-color: linear-gradient(180deg, #FFFFFF → #C9E9FF(50%) → #BAE2FF)
|
||||||
|
static const LinearGradient itemBorder = LinearGradient(
|
||||||
|
begin: Alignment.topCenter,
|
||||||
|
end: Alignment.bottomCenter,
|
||||||
|
colors: [Color(0xFFFFFFFF), Color(0xFFC9E9FF), Color(0xFFBAE2FF)],
|
||||||
|
);
|
||||||
|
|
||||||
|
// analysis-view-bg: linear-gradient(180deg, #DAF3FF → #D4ECFF(52%) → #E5FAFB)
|
||||||
|
static const LinearGradient analysisViewBg = LinearGradient(
|
||||||
|
begin: Alignment.topCenter,
|
||||||
|
end: Alignment.bottomCenter,
|
||||||
|
colors: [Color(0xFFDAF3FF), Color(0xFFD4ECFF), Color(0xFFE5FAFB)],
|
||||||
|
);
|
||||||
|
|
||||||
|
// text-line: 底部渐变条(大字号等级的下划线)
|
||||||
|
// linear-gradient(90deg, rgba(61,125,245,0) → rgba(29,156,255,0.2) → rgba(138,236,253,0.5))
|
||||||
|
static const LinearGradient textLine = LinearGradient(
|
||||||
|
colors: [Color(0x003D7DF5), Color(0x331D9CFF), Color(0x808AECFD)],
|
||||||
|
);
|
||||||
|
|
||||||
|
// button-text-bg: linear-gradient(0deg, #FFFFFF → #E0F2FF)
|
||||||
|
static const LinearGradient buttonTextBg = LinearGradient(
|
||||||
|
begin: Alignment.bottomCenter,
|
||||||
|
end: Alignment.topCenter,
|
||||||
|
colors: [Color(0xFFFFFFFF), Color(0xFFE0F2FF)],
|
||||||
|
);
|
||||||
|
|
||||||
|
// start-button-bg 径向渐变 + #3d7df5(简化:Flutter 径向渐变不太好还原多层 radial,
|
||||||
|
// 这里用线性渐变近似,视觉上接近即可)
|
||||||
|
static const LinearGradient startButtonBg = LinearGradient(
|
||||||
|
begin: Alignment.topCenter,
|
||||||
|
end: Alignment.bottomCenter,
|
||||||
|
colors: [Color(0xFF5B9BFF), Color(0xFF3D7DF5)],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 图片 URL 拼接工具(对标 Vue $img('/StaticResource/xxx'),复用项目 ImgUrl.build)
|
||||||
|
String _img(String path) => ImgUrl.build(path);
|
||||||
|
|
||||||
|
class StudentInfoPage extends ConsumerStatefulWidget {
|
||||||
|
const StudentInfoPage({super.key});
|
||||||
|
|
||||||
|
@override
|
||||||
|
ConsumerState<StudentInfoPage> createState() => _StudentInfoPageState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _StudentInfoPageState extends ConsumerState<StudentInfoPage> {
|
||||||
|
UserReportType _report = const UserReportType();
|
||||||
|
bool _loading = true;
|
||||||
|
String _reportType = 'placementTest';
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||||
|
final extra =
|
||||||
|
GoRouterState.of(context).extra as Map<String, dynamic>? ?? {};
|
||||||
|
_reportType = (extra['type'] as String?) ?? 'placementTest';
|
||||||
|
_loadReport();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> _loadReport() async {
|
||||||
|
setState(() => _loading = true);
|
||||||
|
try {
|
||||||
|
final isExit = _reportType == 'exitTest';
|
||||||
|
final report = isExit
|
||||||
|
? await ReportApi.instance.getCurrentAfterReport()
|
||||||
|
: await ReportApi.instance.getCurrentReport();
|
||||||
|
if (mounted) {
|
||||||
|
setState(() {
|
||||||
|
_report = report;
|
||||||
|
_loading = false;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
talker.error('加载报告数据失败', e);
|
||||||
|
if (mounted) setState(() => _loading = false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> _onStart() async {
|
||||||
|
if (_report.subjectReports.isEmpty) {
|
||||||
|
if (_reportType == 'exitTest') {
|
||||||
|
await ref.read(currentUserProvider.notifier).markShowAfterReportFalse();
|
||||||
|
} else {
|
||||||
|
await ref.read(currentUserProvider.notifier).markShowReportFalse();
|
||||||
|
}
|
||||||
|
if (mounted) context.go('/');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
context.push('/reportWebView', extra: {'type': _reportType});
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
final user = ref.watch(currentUserProvider).value;
|
||||||
|
final userName = _report.userName.isNotEmpty
|
||||||
|
? _report.userName
|
||||||
|
: (user?.userName ?? '');
|
||||||
|
|
||||||
|
return Scaffold(
|
||||||
|
backgroundColor: _StudentTheme.pageBg,
|
||||||
|
body: _loading
|
||||||
|
? const Center(child: CircularProgressIndicator())
|
||||||
|
: SizedBox.expand(
|
||||||
|
child: Stack(
|
||||||
|
children: [
|
||||||
|
// ===== 背景层(Vue bg-wrapper)铺满 =====
|
||||||
|
Positioned.fill(
|
||||||
|
child: Image.network(
|
||||||
|
_img(_StudentTheme.bg),
|
||||||
|
fit: BoxFit.cover,
|
||||||
|
errorBuilder: (_, __, ___) => const SizedBox.shrink(),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
// ===== 内容层(滚动,底部留出按钮高度)=====
|
||||||
|
SafeArea(
|
||||||
|
child: SingleChildScrollView(
|
||||||
|
padding: const EdgeInsets.only(bottom: 140),
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||||
|
children: [
|
||||||
|
_buildHeader(userName),
|
||||||
|
const SizedBox(height: 130),
|
||||||
|
// _buildAnalysisLevel(),
|
||||||
|
// const SizedBox(height: 15),
|
||||||
|
_buildSubjectCard(),
|
||||||
|
const SizedBox(height: 14),
|
||||||
|
_buildLogo(),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
// ===== 底部按钮(fixed,无边距)=====
|
||||||
|
Positioned(
|
||||||
|
left: 0,
|
||||||
|
right: 0,
|
||||||
|
bottom: 0,
|
||||||
|
child: SafeArea(top: false, child: _buildBottomButton()),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ===== 顶部问候区 + welcome 插画 =====
|
||||||
|
// Vue: bubble-wrap(背景图气泡 + userName)+ welcome-wrap(欢迎插画)
|
||||||
|
Widget _buildHeader(String userName) {
|
||||||
|
return Padding(
|
||||||
|
padding: const EdgeInsets.only(left: 14, right: 14, top: 12),
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
// bubble 气泡(用 DecoratedBox 做背景图)
|
||||||
|
Container(
|
||||||
|
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 10),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
// borderRadius: BorderRadius.circular(12),
|
||||||
|
image: DecorationImage(
|
||||||
|
image: NetworkImage(_img(_StudentTheme.bubble)),
|
||||||
|
fit: BoxFit.fill,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
child: Row(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
children: [
|
||||||
|
const Text(
|
||||||
|
'Hi . ',
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 14,
|
||||||
|
fontWeight: FontWeight.w900,
|
||||||
|
color: Colors.white,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Text(
|
||||||
|
userName,
|
||||||
|
style: const TextStyle(
|
||||||
|
fontSize: 14,
|
||||||
|
fontWeight: FontWeight.w900,
|
||||||
|
color: Colors.white,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 10),
|
||||||
|
// welcome 插画(占位,没图时跳过)
|
||||||
|
Image.network(
|
||||||
|
_img(_StudentTheme.welcome),
|
||||||
|
width: 165,
|
||||||
|
fit: BoxFit.fitWidth,
|
||||||
|
errorBuilder: (_, __, ___) => const SizedBox.shrink(),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ===== 当前档次等级卡片(Vue analysis-view,被注释掉的)=====
|
||||||
|
Widget _buildAnalysisLevel() {
|
||||||
|
return Padding(
|
||||||
|
padding: const EdgeInsets.symmetric(horizontal: 14),
|
||||||
|
child: Container(
|
||||||
|
width: double.infinity,
|
||||||
|
// analysis-view-bg 渐变外层
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
borderRadius: BorderRadius.circular(16),
|
||||||
|
gradient: _StudentTheme.analysisViewBg,
|
||||||
|
boxShadow: const [
|
||||||
|
BoxShadow(
|
||||||
|
color: Color(0x1A3D7DF5),
|
||||||
|
blurRadius: 15,
|
||||||
|
offset: Offset(0, 5),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
padding: const EdgeInsets.fromLTRB(16, 18, 16, 16),
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
// analysis-title 图
|
||||||
|
Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Image.network(
|
||||||
|
_img(_StudentTheme.analysisTitle),
|
||||||
|
height: 18,
|
||||||
|
fit: BoxFit.fitHeight,
|
||||||
|
errorBuilder: (_, __, ___) => const SizedBox.shrink(),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
const SizedBox(height: 12),
|
||||||
|
// 内层白色卡片:大字号 level + 文字
|
||||||
|
Container(
|
||||||
|
width: double.infinity,
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: Colors.white,
|
||||||
|
borderRadius: BorderRadius.circular(12),
|
||||||
|
),
|
||||||
|
padding: const EdgeInsets.fromLTRB(16, 12, 16, 18),
|
||||||
|
child: Stack(
|
||||||
|
clipBehavior: Clip.none,
|
||||||
|
children: [
|
||||||
|
Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
// 大字号等级 + text-line 下划线
|
||||||
|
Stack(
|
||||||
|
alignment: Alignment.bottomLeft,
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
_report.userLevel.isNotEmpty
|
||||||
|
? _report.userLevel
|
||||||
|
: '--',
|
||||||
|
style: const TextStyle(
|
||||||
|
fontSize: 30,
|
||||||
|
fontWeight: FontWeight.w600,
|
||||||
|
color: Color(0xFF1D2B47),
|
||||||
|
height: 1.0,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
// 底部渐变条
|
||||||
|
Positioned(
|
||||||
|
left: 0,
|
||||||
|
right: 0,
|
||||||
|
bottom: -2,
|
||||||
|
child: Container(
|
||||||
|
height: 4,
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
borderRadius: BorderRadius.circular(2),
|
||||||
|
gradient: _StudentTheme.textLine,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
const SizedBox(height: 12),
|
||||||
|
// ai-analysis-title 图("AI 智能诊断评定")
|
||||||
|
Image.network(
|
||||||
|
_img(_StudentTheme.aiAnalysisTitle),
|
||||||
|
height: 14,
|
||||||
|
fit: BoxFit.fitHeight,
|
||||||
|
errorBuilder: (_, __, ___) => const SizedBox.shrink(),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
// 右上角 level${level} 图标
|
||||||
|
Positioned(
|
||||||
|
right: -18,
|
||||||
|
top: -44,
|
||||||
|
child: _LevelIcon(level: _report.userLevel),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ===== 诊断科目分析卡片 =====
|
||||||
|
Widget _buildSubjectCard() {
|
||||||
|
return Padding(
|
||||||
|
padding: const EdgeInsets.symmetric(horizontal: 14),
|
||||||
|
child: Container(
|
||||||
|
width: double.infinity,
|
||||||
|
padding: const EdgeInsets.all(16),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: Colors.white,
|
||||||
|
borderRadius: BorderRadius.circular(16),
|
||||||
|
),
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
// header: analytics 图标 + title + 数据已校准
|
||||||
|
Row(
|
||||||
|
children: [
|
||||||
|
Image.network(
|
||||||
|
_img(_StudentTheme.analytics),
|
||||||
|
width: 18,
|
||||||
|
height: 18,
|
||||||
|
errorBuilder: (_, __, ___) => const SizedBox.shrink(),
|
||||||
|
),
|
||||||
|
const SizedBox(width: 6),
|
||||||
|
const Text(
|
||||||
|
'诊断科目分析',
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 16,
|
||||||
|
fontWeight: FontWeight.w600,
|
||||||
|
color: Color(0xFF1D2B47),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const Spacer(),
|
||||||
|
Image.network(
|
||||||
|
_img(_StudentTheme.verify),
|
||||||
|
width: 16,
|
||||||
|
height: 16,
|
||||||
|
errorBuilder: (_, __, ___) => const SizedBox.shrink(),
|
||||||
|
),
|
||||||
|
const SizedBox(width: 3),
|
||||||
|
const Text(
|
||||||
|
'数据已校准',
|
||||||
|
style: TextStyle(fontSize: 11, color: Color(0xFF00CC96)),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
const SizedBox(height: 16),
|
||||||
|
// subject list
|
||||||
|
_report.subjectReports.isEmpty
|
||||||
|
? const Center(
|
||||||
|
child: Text(
|
||||||
|
'暂无数据',
|
||||||
|
style: TextStyle(color: Color(0xFF687FAD)),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
: Wrap(
|
||||||
|
spacing: 10,
|
||||||
|
runSpacing: 10,
|
||||||
|
children: _report.subjectReports
|
||||||
|
.map((s) => _SubjectCard(subject: s))
|
||||||
|
.toList(),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ===== logo =====
|
||||||
|
Widget _buildLogo() {
|
||||||
|
return Center(
|
||||||
|
child: Image.network(
|
||||||
|
_img(_StudentTheme.logo),
|
||||||
|
width: 65, // 130rpx ≈ 65dp
|
||||||
|
fit: BoxFit.fitWidth,
|
||||||
|
errorBuilder: (_, __, ___) => const SizedBox.shrink(),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ===== 底部按钮区(fixed 底部,无边距,圆角顶对齐屏幕)=====
|
||||||
|
Widget _buildBottomButton() {
|
||||||
|
return Container(
|
||||||
|
width: double.infinity,
|
||||||
|
decoration: const BoxDecoration(
|
||||||
|
color: Colors.white,
|
||||||
|
borderRadius: BorderRadius.vertical(top: Radius.circular(16)),
|
||||||
|
),
|
||||||
|
padding: const EdgeInsets.fromLTRB(16, 14, 16, 14),
|
||||||
|
child: Column(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
RichText(
|
||||||
|
text: TextSpan(
|
||||||
|
style: const TextStyle(
|
||||||
|
fontSize: 11,
|
||||||
|
height: 1.6,
|
||||||
|
color: Color(0xFF495A7A),
|
||||||
|
),
|
||||||
|
children: [
|
||||||
|
WidgetSpan(
|
||||||
|
alignment: PlaceholderAlignment.top,
|
||||||
|
child: Padding(
|
||||||
|
padding: const EdgeInsets.only(right: 6),
|
||||||
|
child: Image.network(
|
||||||
|
_img(_StudentTheme.aiAnalysisTitle),
|
||||||
|
width: 95,
|
||||||
|
fit: BoxFit.fitWidth,
|
||||||
|
errorBuilder: (_, __, ___) => const SizedBox.shrink(),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const TextSpan(text: '本报告基于'),
|
||||||
|
const TextSpan(
|
||||||
|
text: '15年高考真题精研',
|
||||||
|
style: TextStyle(color: Color(0xFF3D7DF5)),
|
||||||
|
),
|
||||||
|
const TextSpan(text: '、'),
|
||||||
|
const TextSpan(
|
||||||
|
text: '50万道名校模拟题库',
|
||||||
|
style: TextStyle(color: Color(0xFF3D7DF5)),
|
||||||
|
),
|
||||||
|
const TextSpan(text: '及'),
|
||||||
|
const TextSpan(
|
||||||
|
text: '3,682个',
|
||||||
|
style: TextStyle(color: Color(0xFF3D7DF5)),
|
||||||
|
),
|
||||||
|
const TextSpan(text: '底层知识点拓扑结构,通过爱学智算引擎进行深度解析。'),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 10),
|
||||||
|
// start-button
|
||||||
|
SizedBox(
|
||||||
|
width: double.infinity,
|
||||||
|
height: 44,
|
||||||
|
child: ElevatedButton(
|
||||||
|
onPressed: _onStart,
|
||||||
|
style: ElevatedButton.styleFrom(
|
||||||
|
padding: EdgeInsets.zero,
|
||||||
|
foregroundColor: Colors.white,
|
||||||
|
shape: RoundedRectangleBorder(
|
||||||
|
borderRadius: BorderRadius.circular(22),
|
||||||
|
),
|
||||||
|
elevation: 0,
|
||||||
|
backgroundColor: Colors.transparent,
|
||||||
|
),
|
||||||
|
child: Ink(
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
gradient: _StudentTheme.startButtonBg,
|
||||||
|
borderRadius: BorderRadius.circular(22),
|
||||||
|
border: Border.all(color: const Color(0x4DFFFFFF), width: 2),
|
||||||
|
),
|
||||||
|
child: Container(
|
||||||
|
alignment: Alignment.center,
|
||||||
|
child: Row(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
children: [
|
||||||
|
Image.network(
|
||||||
|
_img(_StudentTheme.starIcon),
|
||||||
|
width: 24,
|
||||||
|
height: 24,
|
||||||
|
errorBuilder: (_, __, ___) => const SizedBox.shrink(),
|
||||||
|
),
|
||||||
|
const SizedBox(width: 6),
|
||||||
|
const Text(
|
||||||
|
'开启智能诊断报告',
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 16,
|
||||||
|
fontWeight: FontWeight.w600,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 科目卡片 —— item-bg 渐变 + item-border-color 渐变边框
|
||||||
|
class _SubjectCard extends StatelessWidget {
|
||||||
|
const _SubjectCard({required this.subject});
|
||||||
|
final SubjectReportType subject;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Container(
|
||||||
|
width: 72, // 144rpx
|
||||||
|
height: 88, // 176rpx
|
||||||
|
// 渐变边框用双层 Container 实现
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
borderRadius: BorderRadius.circular(12),
|
||||||
|
gradient: _StudentTheme.itemBorder,
|
||||||
|
),
|
||||||
|
padding: const EdgeInsets.all(1), // 边框厚度
|
||||||
|
child: Container(
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
borderRadius: BorderRadius.circular(11),
|
||||||
|
gradient: _StudentTheme.itemBg,
|
||||||
|
),
|
||||||
|
child: Column(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
children: [
|
||||||
|
ClipRRect(
|
||||||
|
borderRadius: BorderRadius.circular(8),
|
||||||
|
child: subject.icon.isNotEmpty
|
||||||
|
? Image.network(
|
||||||
|
subject.icon,
|
||||||
|
width: 40,
|
||||||
|
height: 40,
|
||||||
|
fit: BoxFit.cover,
|
||||||
|
errorBuilder: (_, __, ___) => const Icon(
|
||||||
|
Icons.menu_book,
|
||||||
|
size: 40,
|
||||||
|
color: Color(0xFF3D7DF5),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
: const Icon(
|
||||||
|
Icons.menu_book,
|
||||||
|
size: 40,
|
||||||
|
color: Color(0xFF3D7DF5),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 8),
|
||||||
|
Text(
|
||||||
|
subject.subjectName,
|
||||||
|
style: const TextStyle(
|
||||||
|
fontSize: 13,
|
||||||
|
fontWeight: FontWeight.w500,
|
||||||
|
color: Color(0xFF1D2B47),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 右上角等级图标:levelA/B/C 图片,加载失败时用占位
|
||||||
|
class _LevelIcon extends StatelessWidget {
|
||||||
|
const _LevelIcon({required this.level});
|
||||||
|
final String level;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
// 大写化匹配 default.json 的 key
|
||||||
|
final key = level.toUpperCase();
|
||||||
|
final iconPath = switch (key) {
|
||||||
|
'A' => _StudentTheme.levelA,
|
||||||
|
'B' => _StudentTheme.levelB,
|
||||||
|
'C' => _StudentTheme.levelC,
|
||||||
|
_ => _StudentTheme.levelB, // 兜底
|
||||||
|
};
|
||||||
|
return Image.network(
|
||||||
|
_img(iconPath),
|
||||||
|
width: 110,
|
||||||
|
height: 110,
|
||||||
|
fit: BoxFit.contain,
|
||||||
|
errorBuilder: (_, __, ___) => Container(
|
||||||
|
width: 110,
|
||||||
|
height: 110,
|
||||||
|
alignment: Alignment.center,
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
borderRadius: BorderRadius.circular(22),
|
||||||
|
gradient: _StudentTheme.startButtonBg,
|
||||||
|
),
|
||||||
|
child: Text(
|
||||||
|
key,
|
||||||
|
style: const TextStyle(
|
||||||
|
fontSize: 48,
|
||||||
|
fontWeight: FontWeight.w700,
|
||||||
|
color: Colors.white,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,171 @@
|
|||||||
|
import 'package:cached_network_image/cached_network_image.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||||
|
import 'package:new_learn/core/utils/img_url.dart';
|
||||||
|
import 'package:new_learn/core/utils/screen_adapt_template.dart';
|
||||||
|
|
||||||
|
/// ============================================================
|
||||||
|
/// 【ComputationFinishedPopup】报告生成完成弹窗
|
||||||
|
/// —— 对标 Vue finishedPopup.vue
|
||||||
|
///
|
||||||
|
/// 黑色 60% 遮罩 + 顶部 62% 屏高的 top-light 光效图 +
|
||||||
|
/// 640x570rpx content-bg 内容图,底部「立即开启学习蝶变」渐变按钮,
|
||||||
|
/// 入场 0.5s 淡入上移(popup-fade-up)。
|
||||||
|
/// ============================================================
|
||||||
|
class ComputationFinishedPopup extends StatefulWidget {
|
||||||
|
const ComputationFinishedPopup({super.key, required this.onStart});
|
||||||
|
|
||||||
|
final VoidCallback onStart;
|
||||||
|
|
||||||
|
static const String topLightImg =
|
||||||
|
'/StaticResource/2026-06-11/top-light1781173654372.png';
|
||||||
|
static const String topLightPadImg =
|
||||||
|
'/StaticResource/2026-06-24/top-light_pad1782270110001.png';
|
||||||
|
static const String contentBgImg =
|
||||||
|
'/StaticResource/2026-06-11/content-bg1781173794633.png';
|
||||||
|
static const String starImg =
|
||||||
|
'/StaticResource/2026-06-10/star1781089096898.png';
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<ComputationFinishedPopup> createState() =>
|
||||||
|
_ComputationFinishedPopupState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _ComputationFinishedPopupState extends State<ComputationFinishedPopup>
|
||||||
|
with SingleTickerProviderStateMixin {
|
||||||
|
late final AnimationController _controller = AnimationController(
|
||||||
|
vsync: this,
|
||||||
|
duration: const Duration(milliseconds: 500),
|
||||||
|
)..forward();
|
||||||
|
|
||||||
|
late final Animation<double> _opacity = CurvedAnimation(
|
||||||
|
parent: _controller,
|
||||||
|
curve: Curves.easeOut,
|
||||||
|
);
|
||||||
|
late final Animation<Offset> _offset =
|
||||||
|
Tween(begin: const Offset(0, 0.08), end: Offset.zero).animate(
|
||||||
|
CurvedAnimation(parent: _controller, curve: Curves.easeOut),
|
||||||
|
);
|
||||||
|
|
||||||
|
@override
|
||||||
|
void dispose() {
|
||||||
|
_controller.dispose();
|
||||||
|
super.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
final screenHeight = MediaQuery.sizeOf(context).height;
|
||||||
|
final isPad =
|
||||||
|
MediaQuery.sizeOf(context).width >= AppAdapt.tabletBreakpoint;
|
||||||
|
|
||||||
|
return Stack(
|
||||||
|
children: [
|
||||||
|
// popup-mask
|
||||||
|
const Positioned.fill(child: ColoredBox(color: Color(0x99000000))),
|
||||||
|
// top-light:宽铺满,高 62%,居顶
|
||||||
|
Positioned(
|
||||||
|
top: 0,
|
||||||
|
left: 0,
|
||||||
|
right: 0,
|
||||||
|
height: screenHeight * 0.62,
|
||||||
|
child: CachedNetworkImage(
|
||||||
|
imageUrl: ImgUrl.build(
|
||||||
|
isPad
|
||||||
|
? ComputationFinishedPopup.topLightPadImg
|
||||||
|
: ComputationFinishedPopup.topLightImg,
|
||||||
|
),
|
||||||
|
fit: BoxFit.fill,
|
||||||
|
errorWidget: (_, _, _) => const SizedBox.shrink(),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
// popup-content:640x570rpx
|
||||||
|
Center(
|
||||||
|
child: FadeTransition(
|
||||||
|
opacity: _opacity,
|
||||||
|
child: SlideTransition(
|
||||||
|
position: _offset,
|
||||||
|
child: SizedBox(
|
||||||
|
width: 320.w,
|
||||||
|
height: 310.h,
|
||||||
|
child: Stack(
|
||||||
|
clipBehavior: Clip.none,
|
||||||
|
children: [
|
||||||
|
Positioned.fill(
|
||||||
|
child: CachedNetworkImage(
|
||||||
|
imageUrl:
|
||||||
|
ImgUrl.build(ComputationFinishedPopup.contentBgImg),
|
||||||
|
fit: BoxFit.fill,
|
||||||
|
errorWidget: (_, _, _) => DecoratedBox(
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: Colors.white,
|
||||||
|
borderRadius: BorderRadius.circular(8.r),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
// gogo-button:90% 宽,距底 50rpx
|
||||||
|
Positioned(
|
||||||
|
left: 16.w,
|
||||||
|
right: 16.w,
|
||||||
|
bottom: 25.h,
|
||||||
|
child: _buildStartButton(),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _buildStartButton() {
|
||||||
|
return GestureDetector(
|
||||||
|
behavior: HitTestBehavior.opaque,
|
||||||
|
onTap: widget.onStart,
|
||||||
|
child: Container(
|
||||||
|
height: 50.h, // 100rpx
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
borderRadius: BorderRadius.circular(999),
|
||||||
|
// start-button-bg 多层 radial-gradient 用线性渐变近似
|
||||||
|
gradient: const LinearGradient(
|
||||||
|
begin: Alignment.topCenter,
|
||||||
|
end: Alignment.bottomCenter,
|
||||||
|
colors: [Color(0xFF6AA2FF), Color(0xFF3D7DF5)],
|
||||||
|
),
|
||||||
|
border: Border.all(color: const Color(0x4DFFFFFF), width: 1.w),
|
||||||
|
boxShadow: const [
|
||||||
|
BoxShadow(
|
||||||
|
color: Color(0x3D3D7DF5),
|
||||||
|
blurRadius: 20,
|
||||||
|
offset: Offset(0, 10),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
alignment: Alignment.center,
|
||||||
|
child: Row(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
children: [
|
||||||
|
CachedNetworkImage(
|
||||||
|
imageUrl: ImgUrl.build(ComputationFinishedPopup.starImg),
|
||||||
|
width: 24.w,
|
||||||
|
height: 24.w,
|
||||||
|
errorWidget: (_, _, _) => SizedBox(width: 24.w, height: 24.w),
|
||||||
|
),
|
||||||
|
SizedBox(width: 6.w),
|
||||||
|
Text(
|
||||||
|
'立即开启学习蝶变',
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 16.spMin,
|
||||||
|
fontWeight: FontWeight.w600,
|
||||||
|
color: Colors.white,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,235 @@
|
|||||||
|
import 'dart:math' as math;
|
||||||
|
import 'dart:ui' as ui;
|
||||||
|
|
||||||
|
import 'package:cached_network_image/cached_network_image.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||||
|
import 'package:new_learn/core/utils/img_url.dart';
|
||||||
|
|
||||||
|
/// ============================================================
|
||||||
|
/// 【ComputationProgressRing】AI 计算圆环 —— 对标 Vue ProgressRing.vue
|
||||||
|
///
|
||||||
|
/// 由外到内:
|
||||||
|
/// 1. 虚线刻度图(700rpx,6s 顺时针慢转)
|
||||||
|
/// 2. 外圈光环球图(524rpx,1.5s 反向快转)
|
||||||
|
/// 3. 外层渐变光圈 ellipse-wai(452rpx)
|
||||||
|
/// 4. 渐变进度弧(370rpx,线宽 20rpx,#8BFFF5 → #006CFF 纵向渐变)
|
||||||
|
/// 5. 白色内圆 ellipse-nei(300rpx)+ 渐变百分比文字 + 副标题
|
||||||
|
///
|
||||||
|
/// Vue 用 canvas 画弧;Flutter 用 CustomPaint,渐变方向与 Vue
|
||||||
|
/// createLinearGradient(center,0 → center,size) 保持一致(纵向)。
|
||||||
|
/// ============================================================
|
||||||
|
class ComputationProgressRing extends StatefulWidget {
|
||||||
|
const ComputationProgressRing({super.key, required this.progress});
|
||||||
|
|
||||||
|
/// 进度值 0-100
|
||||||
|
final double progress;
|
||||||
|
|
||||||
|
/// 外圈光环球图(Vue props.outerImg 默认值)
|
||||||
|
static const String outerImg =
|
||||||
|
'/StaticResource/2026-06-11/outer1781143064766.png';
|
||||||
|
|
||||||
|
/// 虚线刻度图(Vue props.dashedLineImg 默认值)
|
||||||
|
static const String dashedImg =
|
||||||
|
'/StaticResource/2026-06-11/dashedLine1781143064766.png';
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<ComputationProgressRing> createState() =>
|
||||||
|
_ComputationProgressRingState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _ComputationProgressRingState extends State<ComputationProgressRing>
|
||||||
|
with TickerProviderStateMixin {
|
||||||
|
/// 外圈:Vue rotate-cw 0 → -360deg / 1.5s
|
||||||
|
late final AnimationController _outerCtrl = AnimationController(
|
||||||
|
vsync: this,
|
||||||
|
duration: const Duration(milliseconds: 1500),
|
||||||
|
)..repeat();
|
||||||
|
|
||||||
|
/// 虚线:Vue rotate-ccw 0 → 360deg / 6s
|
||||||
|
late final AnimationController _dashedCtrl = AnimationController(
|
||||||
|
vsync: this,
|
||||||
|
duration: const Duration(seconds: 6),
|
||||||
|
)..repeat();
|
||||||
|
|
||||||
|
@override
|
||||||
|
void dispose() {
|
||||||
|
_outerCtrl.dispose();
|
||||||
|
_dashedCtrl.dispose();
|
||||||
|
super.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
final size = 262.w; // 524rpx
|
||||||
|
return SizedBox(
|
||||||
|
width: size,
|
||||||
|
height: size,
|
||||||
|
child: Stack(
|
||||||
|
clipBehavior: Clip.none,
|
||||||
|
alignment: Alignment.center,
|
||||||
|
children: [
|
||||||
|
// 虚线刻度(700rpx,超出 524rpx 容器,允许溢出绘制)
|
||||||
|
RepaintBoundary(
|
||||||
|
child: RotationTransition(
|
||||||
|
turns: _dashedCtrl,
|
||||||
|
child: _ringImage(ComputationProgressRing.dashedImg, 350.w),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
// 外圈光球
|
||||||
|
RepaintBoundary(
|
||||||
|
child: RotationTransition(
|
||||||
|
turns: ReverseAnimation(_outerCtrl),
|
||||||
|
child: _ringImage(ComputationProgressRing.outerImg, 262.w),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
// ellipse-wai:87.42deg 紫色渐变 + 内发光(内阴影用外发光近似)
|
||||||
|
Container(
|
||||||
|
width: 226.w,
|
||||||
|
height: 226.w,
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
shape: BoxShape.circle,
|
||||||
|
gradient: const LinearGradient(
|
||||||
|
begin: Alignment.centerLeft,
|
||||||
|
end: Alignment.centerRight,
|
||||||
|
stops: [0.1133, 1.0],
|
||||||
|
colors: [Color(0x6B5B5DFF), Color(0x0000FFF2)],
|
||||||
|
),
|
||||||
|
border: Border.all(color: const Color(0x33FFFFFF), width: 1.w),
|
||||||
|
boxShadow: const [
|
||||||
|
BoxShadow(color: Color(0x33FFFFFF), blurRadius: 25),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
// 进度弧(canvas)
|
||||||
|
SizedBox(
|
||||||
|
width: 185.w,
|
||||||
|
height: 185.w,
|
||||||
|
child: CustomPaint(painter: _RingArcPainter(widget.progress)),
|
||||||
|
),
|
||||||
|
// ellipse-nei:内圆
|
||||||
|
Container(
|
||||||
|
width: 150.w,
|
||||||
|
height: 150.w,
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
shape: BoxShape.circle,
|
||||||
|
gradient: const LinearGradient(
|
||||||
|
begin: Alignment(-0.6, -0.8),
|
||||||
|
end: Alignment(0.87, 0.49),
|
||||||
|
stops: [0.42, 0.82],
|
||||||
|
colors: [Color(0xFFB1DFFF), Color(0xFFFFFFFF)],
|
||||||
|
),
|
||||||
|
border: Border.all(color: const Color(0x80FFFFFF)),
|
||||||
|
boxShadow: const [
|
||||||
|
BoxShadow(
|
||||||
|
color: Color(0x0D1D2B47),
|
||||||
|
blurRadius: 28,
|
||||||
|
offset: Offset(0, 14),
|
||||||
|
),
|
||||||
|
BoxShadow(color: Color(0x80FFFFFF), blurRadius: 26),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
child: Column(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
children: [
|
||||||
|
Row(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.end,
|
||||||
|
children: [
|
||||||
|
_gradientText(
|
||||||
|
widget.progress.floor().toString(),
|
||||||
|
40.spMin,
|
||||||
|
height: 1.0,
|
||||||
|
),
|
||||||
|
Padding(
|
||||||
|
padding: EdgeInsets.only(left: 2.w, bottom: 6.h),
|
||||||
|
child: _gradientText('%', 14.5.spMin),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
SizedBox(height: 2.h),
|
||||||
|
Text(
|
||||||
|
'AI加载中',
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 14.5.spMin,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
color: const Color(0xFF0F9AFF),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _ringImage(String path, double size) {
|
||||||
|
return CachedNetworkImage(
|
||||||
|
imageUrl: ImgUrl.build(path),
|
||||||
|
width: size,
|
||||||
|
height: size,
|
||||||
|
fit: BoxFit.contain,
|
||||||
|
errorWidget: (_, _, _) => SizedBox(width: size, height: size),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 渐变文字:linear-gradient(180deg, #006cff → #529bff)
|
||||||
|
Widget _gradientText(String text, double fontSize, {double? height}) {
|
||||||
|
return ShaderMask(
|
||||||
|
shaderCallback: (rect) => ui.Gradient.linear(
|
||||||
|
rect.topCenter,
|
||||||
|
rect.bottomCenter,
|
||||||
|
const [Color(0xFF006CFF), Color(0xFF529BFF)],
|
||||||
|
),
|
||||||
|
child: Text(
|
||||||
|
text,
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: fontSize,
|
||||||
|
height: height,
|
||||||
|
fontWeight: FontWeight.w700,
|
||||||
|
color: Colors.white,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 进度弧画笔(对标 Vue canvas arc + 纵向线性渐变 + round 线帽)
|
||||||
|
class _RingArcPainter extends CustomPainter {
|
||||||
|
_RingArcPainter(this.progress);
|
||||||
|
|
||||||
|
final double progress;
|
||||||
|
|
||||||
|
@override
|
||||||
|
void paint(Canvas canvas, Size size) {
|
||||||
|
final p = progress.clamp(0.0, 100.0);
|
||||||
|
if (p <= 0) return;
|
||||||
|
|
||||||
|
final stroke = 10.w; // 20rpx
|
||||||
|
final center = Offset(size.width / 2, size.height / 2);
|
||||||
|
final radius = (size.width - stroke) / 2;
|
||||||
|
|
||||||
|
final paint = Paint()
|
||||||
|
..style = PaintingStyle.stroke
|
||||||
|
..strokeWidth = stroke
|
||||||
|
..strokeCap = StrokeCap.round
|
||||||
|
..shader = ui.Gradient.linear(
|
||||||
|
Offset(center.dx, center.dy - radius),
|
||||||
|
Offset(center.dx, center.dy + radius),
|
||||||
|
const [Color(0xFF8BFFF5), Color(0xFF006CFF)],
|
||||||
|
);
|
||||||
|
|
||||||
|
canvas.drawArc(
|
||||||
|
Rect.fromCircle(center: center, radius: radius),
|
||||||
|
-math.pi / 2, // 从 12 点方向开始
|
||||||
|
2 * math.pi * p / 100,
|
||||||
|
false,
|
||||||
|
paint,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
bool shouldRepaint(covariant _RingArcPainter oldDelegate) =>
|
||||||
|
oldDelegate.progress != progress;
|
||||||
|
}
|
||||||
@@ -0,0 +1,267 @@
|
|||||||
|
import 'package:cached_network_image/cached_network_image.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||||
|
import 'package:new_learn/core/utils/img_url.dart';
|
||||||
|
|
||||||
|
/// 科目计算状态(对标 Vue SubjectStatus)
|
||||||
|
enum ComputationSubjectStatus { notStarted, inProgress, finished }
|
||||||
|
|
||||||
|
/// ============================================================
|
||||||
|
/// 【ComputationSubjectItem】AI 计算科目卡片
|
||||||
|
/// —— 对标 reportComputation.vue 的 .subject-item
|
||||||
|
///
|
||||||
|
/// 右上角标(subscript):未开始/进行中蓝色闪电底,已完成绿色对勾底;
|
||||||
|
/// 标题行:科目名 + 科目图标 + ai-plan「AI学习计划+」图;
|
||||||
|
/// 知识点行 + 底部渐变进度条(进行中蓝 / 已完成绿)。
|
||||||
|
/// ============================================================
|
||||||
|
class ComputationSubjectItem extends StatelessWidget {
|
||||||
|
const ComputationSubjectItem({
|
||||||
|
super.key,
|
||||||
|
required this.subjectName,
|
||||||
|
required this.iconUrl,
|
||||||
|
required this.knowCount,
|
||||||
|
required this.progress,
|
||||||
|
required this.status,
|
||||||
|
});
|
||||||
|
|
||||||
|
final String subjectName;
|
||||||
|
final String iconUrl;
|
||||||
|
final int knowCount;
|
||||||
|
|
||||||
|
/// 0-100
|
||||||
|
final int progress;
|
||||||
|
final ComputationSubjectStatus status;
|
||||||
|
|
||||||
|
// ---- 图片资源(default.json ai-plan + Vue 内联 $img 角标图)----
|
||||||
|
static const String _aiPlanImg =
|
||||||
|
'/StaticResource/2026-06-11/aiPlan1781157211012.png';
|
||||||
|
static const String _subscriptBgBlue =
|
||||||
|
'/StaticResource/2026-06-11/subscript-bg11781162055363.png';
|
||||||
|
static const String _subscriptBgGreen =
|
||||||
|
'/StaticResource/2026-06-11/subscript-bg21781162055358.png';
|
||||||
|
static const String _iconFlash =
|
||||||
|
'/StaticResource/2026-06-11/subscript-cion1-1781162401643.png';
|
||||||
|
static const String _iconCheck =
|
||||||
|
'/StaticResource/2026-06-11/subscript-cion2-1781162401644.png';
|
||||||
|
|
||||||
|
bool get _isFinished => status == ComputationSubjectStatus.finished;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Opacity(
|
||||||
|
// Vue: 未开始 opacity 0.8
|
||||||
|
opacity: status == ComputationSubjectStatus.notStarted ? 0.8 : 1,
|
||||||
|
child: Container(
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
borderRadius: BorderRadius.circular(16.r), // 16rpx
|
||||||
|
gradient: LinearGradient(
|
||||||
|
begin: Alignment.topCenter,
|
||||||
|
end: Alignment.bottomCenter,
|
||||||
|
stops: const [0, 0.3, 1],
|
||||||
|
colors: _isFinished
|
||||||
|
? const [Color(0xFFE3FCF4), Color(0xFFF7FCFA), Colors.white]
|
||||||
|
: const [Color(0xFFE3F7FC), Color(0xFFF7FBFC), Colors.white],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
child: Stack(
|
||||||
|
clipBehavior: Clip.none,
|
||||||
|
children: [
|
||||||
|
Padding(
|
||||||
|
padding: EdgeInsets.fromLTRB(14.w, 14.w, 14.w, 20.h),
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
_buildTitle(),
|
||||||
|
SizedBox(height: 16.h), // 知识点行 margin 32rpx 0
|
||||||
|
_buildKnowledge(),
|
||||||
|
SizedBox(height: 16.h),
|
||||||
|
_buildProgressBar(),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
// 右上角标
|
||||||
|
Positioned(top: 0, right: 0, child: _buildSubscript()),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ===== 标题行:科目名 + 科目图标 + AI学习计划图 =====
|
||||||
|
Widget _buildTitle() {
|
||||||
|
return Row(
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
subjectName,
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 18.spMin, // 36rpx
|
||||||
|
fontWeight: FontWeight.w600,
|
||||||
|
color: const Color(0xFF1D2B47),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
SizedBox(width: 6.w),
|
||||||
|
if (iconUrl.isNotEmpty)
|
||||||
|
CachedNetworkImage(
|
||||||
|
imageUrl: ImgUrl.build(iconUrl),
|
||||||
|
width: 26.w, // 52rpx,widthFix
|
||||||
|
fit: BoxFit.fitWidth,
|
||||||
|
errorWidget: (_, _, _) => Icon(
|
||||||
|
Icons.menu_book,
|
||||||
|
size: 26.w,
|
||||||
|
color: const Color(0xFF3D7DF5),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
else
|
||||||
|
Icon(Icons.menu_book, size: 26.w, color: const Color(0xFF3D7DF5)),
|
||||||
|
SizedBox(width: 6.w),
|
||||||
|
CachedNetworkImage(
|
||||||
|
imageUrl: ImgUrl.build(_aiPlanImg),
|
||||||
|
width: 77.w, // 154rpx,widthFix
|
||||||
|
fit: BoxFit.fitWidth,
|
||||||
|
errorWidget: (_, _, _) => const SizedBox.shrink(),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ===== 知识点行(Vue 预计时间已注释,只保留知识点)=====
|
||||||
|
Widget _buildKnowledge() {
|
||||||
|
return Container(
|
||||||
|
padding: EdgeInsets.symmetric(horizontal: 8.w, vertical: 6.h),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: const Color(0xFFF3F8FE),
|
||||||
|
borderRadius: BorderRadius.circular(4.r),
|
||||||
|
),
|
||||||
|
child: Row(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
'知识点',
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 12.spMin,
|
||||||
|
color: const Color(0xFF495A7A),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
SizedBox(width: 6.w),
|
||||||
|
Container(
|
||||||
|
padding: EdgeInsets.symmetric(horizontal: 3.5.w),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: const Color(0xFFE1EAFA),
|
||||||
|
borderRadius: BorderRadius.circular(4.r),
|
||||||
|
),
|
||||||
|
child: Text(
|
||||||
|
'$knowCount',
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 12.spMin,
|
||||||
|
color: const Color(0xFF495A7A),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ===== 底部进度条:蓝渐变 / 绿渐变 =====
|
||||||
|
Widget _buildProgressBar() {
|
||||||
|
return SizedBox(
|
||||||
|
height: 6.h, // 12rpx
|
||||||
|
child: LayoutBuilder(
|
||||||
|
builder: (_, constraints) {
|
||||||
|
final fillWidth =
|
||||||
|
constraints.maxWidth * (progress.clamp(0, 100) / 100);
|
||||||
|
return Stack(
|
||||||
|
children: [
|
||||||
|
Positioned.fill(
|
||||||
|
child: DecoratedBox(
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: const Color(0xFFE9EDF5),
|
||||||
|
borderRadius: BorderRadius.circular(3.h),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Positioned(
|
||||||
|
left: 0,
|
||||||
|
top: 0,
|
||||||
|
bottom: 0,
|
||||||
|
child: Container(
|
||||||
|
width: fillWidth,
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
borderRadius: BorderRadius.circular(3.h),
|
||||||
|
gradient: LinearGradient(
|
||||||
|
colors: _isFinished
|
||||||
|
? const [Color(0xFFB4EADA), Color(0xFF19CE92)]
|
||||||
|
: const [
|
||||||
|
Color(0xFF8AD1FD),
|
||||||
|
Color(0xFF3C84FF),
|
||||||
|
Color(0xFF3D7DF5),
|
||||||
|
],
|
||||||
|
stops: _isFinished ? null : const [0, 0.64, 1],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ===== 右上角标:162x66rpx 背景图 + 状态图标 + 百分比 =====
|
||||||
|
Widget _buildSubscript() {
|
||||||
|
final bgImg = _isFinished ? _subscriptBgGreen : _subscriptBgBlue;
|
||||||
|
return SizedBox(
|
||||||
|
width: 81.w,
|
||||||
|
height: 33.h,
|
||||||
|
child: Stack(
|
||||||
|
children: [
|
||||||
|
Positioned.fill(
|
||||||
|
child: CachedNetworkImage(
|
||||||
|
imageUrl: ImgUrl.build(bgImg),
|
||||||
|
fit: BoxFit.fill,
|
||||||
|
errorWidget: (_, _, _) => DecoratedBox(
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: _isFinished
|
||||||
|
? const Color(0xFF19CE92)
|
||||||
|
: const Color(0xFF3D7DF5),
|
||||||
|
borderRadius: BorderRadius.only(
|
||||||
|
topRight: Radius.circular(8.r),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Padding(
|
||||||
|
padding: EdgeInsets.only(bottom: 5.h),
|
||||||
|
child: Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
children: [
|
||||||
|
if (status != ComputationSubjectStatus.notStarted)
|
||||||
|
Padding(
|
||||||
|
padding: EdgeInsets.only(right: 4.w),
|
||||||
|
child: CachedNetworkImage(
|
||||||
|
imageUrl: ImgUrl.build(
|
||||||
|
_isFinished ? _iconCheck : _iconFlash,
|
||||||
|
),
|
||||||
|
width: 18.w,
|
||||||
|
height: 18.w,
|
||||||
|
errorWidget: (_, _, _) =>
|
||||||
|
SizedBox(width: 18.w, height: 18.w),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Text(
|
||||||
|
'$progress%',
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 16.spMin, // 32rpx
|
||||||
|
color: Colors.white,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,12 +1,16 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_inappwebview/flutter_inappwebview.dart';
|
import 'package:flutter_inappwebview/flutter_inappwebview.dart';
|
||||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||||
|
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||||
import 'package:go_router/go_router.dart';
|
import 'package:go_router/go_router.dart';
|
||||||
|
// ignore: unused_import —— 调试结束切回 TabApp 时使用
|
||||||
import 'package:new_learn/core/app.dart';
|
import 'package:new_learn/core/app.dart';
|
||||||
import 'package:new_learn/core/network/dio_client.dart';
|
import 'package:new_learn/core/network/dio_client.dart';
|
||||||
import 'package:new_learn/core/providers/privacy_provider.dart';
|
import 'package:new_learn/core/providers/privacy_provider.dart';
|
||||||
|
import 'package:new_learn/core/router/app_router.dart';
|
||||||
import 'package:new_learn/core/storage/database/app_database.dart';
|
import 'package:new_learn/core/storage/database/app_database.dart';
|
||||||
import 'package:new_learn/core/storage/privacy_storage.dart';
|
import 'package:new_learn/core/storage/privacy_storage.dart';
|
||||||
|
import 'package:new_learn/core/utils/screen_adapt_template.dart';
|
||||||
|
|
||||||
/// App 启动入口 —— 真正的业务代码都在 app.dart / pages/ 里
|
/// App 启动入口 —— 真正的业务代码都在 app.dart / pages/ 里
|
||||||
///
|
///
|
||||||
@@ -127,4 +131,44 @@ Future<void> main() async {
|
|||||||
await AppDatabase.instance.init();
|
await AppDatabase.instance.init();
|
||||||
// ProviderScope:Riverpod 所有 provider 的容器,必须包在根
|
// ProviderScope:Riverpod 所有 provider 的容器,必须包在根
|
||||||
runApp(const ProviderScope(child: TabApp()));
|
runApp(const ProviderScope(child: TabApp()));
|
||||||
|
// 临时调试用,跑完改回。
|
||||||
|
// 注意两点:
|
||||||
|
// 1. 页面组件用了 .w/.h/.spMin,必须包 ScreenUtilInit(与 TabApp 一致),
|
||||||
|
// 否则 ScreenUtil 的 late 字段未初始化会抛 LateInitializationError;
|
||||||
|
// 2. 必须用真实 appRouter(MaterialApp.router),不能用裸 MaterialApp(home:),
|
||||||
|
// 否则页面里 context.go('/') 找不到 GoRouter,点"立即开启学习蝶变"不会跳首页。
|
||||||
|
// runApp(const ProviderScope(child: _DebugApp()));
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 临时调试壳:ScreenUtilInit + 真实路由表,启动后直接进 /reportComputation
|
||||||
|
class _DebugApp extends StatefulWidget {
|
||||||
|
const _DebugApp();
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<_DebugApp> createState() => _DebugAppState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _DebugAppState extends State<_DebugApp> {
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
// 首帧后跳到调试页(默认初始位置是 '/',直接进会先闪一帧首页)
|
||||||
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||||
|
appRouter.go('/reportComputation');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return ScreenUtilInit(
|
||||||
|
designSize: AppAdapt.designSizeOf(context),
|
||||||
|
minTextAdapt: true,
|
||||||
|
splitScreenMode: true,
|
||||||
|
fontSizeResolver: AppAdapt.fontSizeResolver,
|
||||||
|
builder: (context, _) => MaterialApp.router(
|
||||||
|
debugShowCheckedModeBanner: false,
|
||||||
|
routerConfig: appRouter,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -675,6 +675,14 @@ packages:
|
|||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.7.0"
|
version: "0.7.0"
|
||||||
|
flutter_svg:
|
||||||
|
dependency: "direct main"
|
||||||
|
description:
|
||||||
|
name: flutter_svg
|
||||||
|
sha256: "35882981abcbfb8c15b286f0cd690ff25bac12d95eff3e25ee207f37d4c42e7f"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "2.3.0"
|
||||||
flutter_test:
|
flutter_test:
|
||||||
dependency: "direct dev"
|
dependency: "direct dev"
|
||||||
description: flutter
|
description: flutter
|
||||||
@@ -1143,6 +1151,14 @@ packages:
|
|||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.9.1"
|
version: "1.9.1"
|
||||||
|
path_parsing:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: path_parsing
|
||||||
|
sha256: "883402936929eac138ee0a45da5b0f2c80f89913e6dc3bf77eb65b84b409c6ca"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "1.1.0"
|
||||||
path_provider:
|
path_provider:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
@@ -1748,6 +1764,30 @@ packages:
|
|||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "4.6.0"
|
version: "4.6.0"
|
||||||
|
vector_graphics:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: vector_graphics
|
||||||
|
sha256: "9d0e3b9cb16542ad660daee871e726a10d13a93b7b5391677c3160e8f5e83935"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "1.2.3"
|
||||||
|
vector_graphics_codec:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: vector_graphics_codec
|
||||||
|
sha256: "99fd9fbd34d9f9a32efd7b6a6aae14125d8237b10403b422a6a6dfeac2806146"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "1.1.13"
|
||||||
|
vector_graphics_compiler:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: vector_graphics_compiler
|
||||||
|
sha256: "4dca4feb77dc3ec7f6e27e49c53241eb8217f55e4f9b12599a27f8903bca5682"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "1.3.0"
|
||||||
vector_math:
|
vector_math:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
|||||||
@@ -119,6 +119,7 @@ dependencies:
|
|||||||
# 替换(customWidgetBuilder),video 留扩展点,图片/表格原生支持。
|
# 替换(customWidgetBuilder),video 留扩展点,图片/表格原生支持。
|
||||||
# 版本:0.17.x 要求 Flutter 3.32+ / just_audio ^0.10.4(本项目满足)
|
# 版本:0.17.x 要求 Flutter 3.32+ / just_audio ^0.10.4(本项目满足)
|
||||||
flutter_widget_from_html_core: ^0.17.2
|
flutter_widget_from_html_core: ^0.17.2
|
||||||
|
flutter_svg: ^2.0.17
|
||||||
|
|
||||||
# 图片预览:社区成熟方案,支持双指缩放/拖拽/多图左右切换
|
# 图片预览:社区成熟方案,支持双指缩放/拖拽/多图左右切换
|
||||||
# 单图用 PhotoView,多图用 PhotoViewGallery;
|
# 单图用 PhotoView,多图用 PhotoViewGallery;
|
||||||
|
|||||||
Reference in New Issue
Block a user