提交 3b9e556c authored 作者: yueweilu's avatar yueweilu

学习历史接口调试与界面修正

上级 b2ebbece
......@@ -26,7 +26,7 @@ class CourseModel {
authors = json['authors'];
img = json['img'];
progress = json['progress'];
lastChapter = json['lastChapter'];
lastChapter = json['last_chapter'];
createTime = json['create_time'];
days = json['days'];
readNum = json['read_num'];
......@@ -96,7 +96,7 @@ class CourseModel {
map['authors'] = authors;
map['img'] = img;
map['progress'] = progress;
map['lastChapter'] = lastChapter;
map['last_chapter'] = lastChapter;
map['create_time'] = createTime;
map['days'] = days;
map['read_num'] = readNum;
......
......@@ -2,15 +2,15 @@ part of models;
class StudyHistoryModel {
StudyHistoryModel({
this.time,
this.courses,
required this.courses,
});
StudyHistoryModel.fromJson(dynamic json) {
time = json['time'];
courses = List.generate(json['list'].length, (index) => CourseModel.fromJson(index));
courses = List.generate(json['list'].length, (index) => CourseModel.fromJson(json['list'][index]));
}
String? time;
List<CourseModel>? courses;
List<CourseModel> courses = [];
}
\ No newline at end of file
......@@ -43,13 +43,8 @@ class Book extends StatelessWidget {
),
],
),
padding: EdgeInsets.all(1),
child: Container(
// margin: const EdgeInsets.only(top: 16,bottom: 10),
// color: Colors.red,
child: Image.network(model.img.toString()),
// width: 85,
),
padding: const EdgeInsets.all(1),
child: CustomImage.network(url: model.img??''),
),
),
),
......
......@@ -13,6 +13,11 @@ class HistoryController extends GetxController {
int _page = 1;
bool _noMore = false;
@override
void onReady() {
onRefresh();
super.onReady();
}
@override
void onClose() {
......@@ -30,7 +35,6 @@ class HistoryController extends GetxController {
limit: _limit
);
print('11111111111111111111111111$result');
// 如果是刷新 清理数据
if (isRefresh) histories.clear();
histories.addAll(result);
......
......@@ -23,9 +23,9 @@ class _StudyHistoryPageState extends State<StudyHistoryPage> {
onLoading: controller.onLoading,
child: ListView.builder(
itemBuilder: (BuildContext context, int index) {
return BuildDayItem();
return BuildDayItem(historyModel: controller.histories[index],);
},
itemCount: 4,
itemCount: controller.histories.length,
),
),
),
......
part of study_history;
class BuildDayItem extends StatelessWidget {
const BuildDayItem({Key? key}) : super(key: key);
final StudyHistoryModel historyModel;
const BuildDayItem({
Key? key,
required this.historyModel
}) : super(key: key);
@override
Widget build(BuildContext context) {
......@@ -23,38 +27,39 @@ class BuildDayItem extends StatelessWidget {
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Container(
margin: const EdgeInsets.only(left: 10),
decoration: const BoxDecoration(
borderRadius: BorderRadius.only(
topLeft: Radius.circular(8.0),
topRight: Radius.circular(8.0),
),
color: Colors.cyan,
// color: Colors.cyan,
),
height: 32,
alignment: Alignment.centerLeft,
child: Text('今天',style: TextStyle(fontSize: 13,height: 1.4,color: Colours.c6),),
child: Text(historyModel.time??'',style: const TextStyle(fontSize: 13,height: 1.4,color: Colours.c6),),
),
ListView.builder(
shrinkWrap: true,
physics: NeverScrollableScrollPhysics(),
physics: const NeverScrollableScrollPhysics(),
itemBuilder:(BuildContext context, int index){
return _buildItem();
return _buildItem(historyModel.courses[index]);
},
itemCount: 2,
itemCount: historyModel.courses.length,
)
],
),
);
}
Widget _buildItem(){
Widget _buildItem(CourseModel courseModel){
return Container(
margin: const EdgeInsets.only(left: 10,right: 10),
child: Column(
children: [
Container(
color: Colours.cF0,
height: 2,
height: 0.5,
),
Container(
margin: const EdgeInsets.only(top: 11.5,bottom: 14.5),
......@@ -65,7 +70,9 @@ class BuildDayItem extends StatelessWidget {
Container(
width: 72,
height: 87,
color: Colors.red,
// color: Colors.red,
child: CustomImage.network(url: courseModel.img??'')
// Image.network(courseModel.img??''),
),
Expanded(
child: Container(
......@@ -78,9 +85,9 @@ class BuildDayItem extends StatelessWidget {
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text('从现在开始,为精彩活过一百',style: TextStyle(fontSize: 14,height: 1.5,fontWeight: Fonts.medium,color: Colours.c3),maxLines: 1,overflow: TextOverflow.ellipsis,),
Text(courseModel.bookName??'',style: const TextStyle(fontSize: 14,height: 1.5,fontWeight: Fonts.medium,color: Colours.c3),maxLines: 1,overflow: TextOverflow.ellipsis,),
Gaps.vGaps5,
Text('李白',style: TextStyle(fontSize: 12,height: 1.4,color: Colours.c6),),
Text(courseModel.authors??'',style: const TextStyle(fontSize: 12,height: 1.4,color: Colours.c6),),
],
),
Gaps.vGaps25,
......@@ -88,12 +95,12 @@ class BuildDayItem extends StatelessWidget {
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Container(
color: Colors.cyan,
color: AppTheme.primary.withOpacity(0.1),
padding: const EdgeInsets.symmetric(horizontal: 3.5),
child: const Text('未学习',style: TextStyle(fontSize: 11,height: 1.3,color: Colours.c9),),
child: Text(courseModel.typeName,style: const TextStyle(fontSize: 11,height: 1.3,color:AppTheme.primary),),
),
// Spacer(),
const Text('继续学习',style: TextStyle(fontSize: 11,height: 1.3,color: AppTheme.primary),)
Text('上次读到:${courseModel.lastChapter}',style: const TextStyle(fontSize: 11,height: 1.3,color: Colours.c6),)
],
)
],
......
......@@ -109,7 +109,7 @@ class CustomImage extends StatelessWidget {
@override
Widget build(BuildContext context) {
final borderRadius = BorderRadius.all(Radius.circular(radius ?? 10));
final borderRadius = BorderRadius.all(Radius.circular(radius ?? 3));
final Widget errorChild =
error ?? const Icon(Icons.image_not_supported_outlined);
final Widget placeholderChild =
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论