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

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

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