feat: 推荐列表显示「已关注」标识

This commit is contained in:
guozhigq
2023-05-12 10:12:15 +08:00
parent 7bcdd209ba
commit 4d85eedd7b
4 changed files with 26 additions and 7 deletions

View File

@ -133,6 +133,25 @@ class VideoContent extends StatelessWidget {
), ),
), ),
const SizedBox(width: 4) const SizedBox(width: 4)
] else if (videoItem.isFollowed == 1) ...[
Container(
padding: const EdgeInsets.fromLTRB(3, 1, 3, 1),
decoration: BoxDecoration(
color: Theme.of(context)
.colorScheme
.primaryContainer
.withOpacity(0.6),
borderRadius: BorderRadius.circular(3)),
child: Text(
'已关注',
style: TextStyle(
fontSize:
Theme.of(context).textTheme.labelSmall!.fontSize,
color: Theme.of(context).colorScheme.primary,
),
),
),
const SizedBox(width: 4)
], ],
Expanded( Expanded(
child: LayoutBuilder(builder: child: LayoutBuilder(builder:

View File

@ -1,7 +1,3 @@
import 'dart:io';
import 'package:dio_cookie_manager/dio_cookie_manager.dart';
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
import 'package:pilipala/http/api.dart'; import 'package:pilipala/http/api.dart';
import 'package:pilipala/http/init.dart'; import 'package:pilipala/http/init.dart';
import 'package:pilipala/models/model_hot_video_item.dart'; import 'package:pilipala/models/model_hot_video_item.dart';
@ -19,7 +15,7 @@ class VideoHttp {
var res = await Request().get( var res = await Request().get(
Api.recommendList, Api.recommendList,
data: { data: {
'feed_version': 'V3', 'feed_version': 'V4',
'ps': ps, 'ps': ps,
'fresh_idx': freshIdx, 'fresh_idx': freshIdx,
}, },
@ -31,10 +27,10 @@ class VideoHttp {
} }
return {'status': true, 'data': list}; return {'status': true, 'data': list};
} else { } else {
return {'status': false, 'data': []}; return {'status': false, 'data': [], 'msg': ''};
} }
} catch (err) { } catch (err) {
return {'status': false, 'data': [], 'msg': err}; return {'status': false, 'data': [], 'msg': err.toString()};
} }
} }

View File

@ -13,6 +13,7 @@ class RecVideoItemModel {
this.pubdate, this.pubdate,
this.owner, this.owner,
this.stat, this.stat,
this.isFollowed,
this.rcmdReason, this.rcmdReason,
}); });
@ -27,6 +28,7 @@ class RecVideoItemModel {
int? pubdate = -1; int? pubdate = -1;
Owner? owner; Owner? owner;
Stat? stat; Stat? stat;
int? isFollowed;
RcmdReason? rcmdReason; RcmdReason? rcmdReason;
RecVideoItemModel.fromJson(Map<String, dynamic> json) { RecVideoItemModel.fromJson(Map<String, dynamic> json) {
@ -41,6 +43,7 @@ class RecVideoItemModel {
pubdate = json["pubdate"]; pubdate = json["pubdate"];
owner = Owner.fromJson(json["owner"]); owner = Owner.fromJson(json["owner"]);
stat = Stat.fromJson(json["stat"]); stat = Stat.fromJson(json["stat"]);
isFollowed = json["is_followed"] ?? 0;
rcmdReason = json["rcmd_reason"] != null rcmdReason = json["rcmd_reason"] != null
? RcmdReason.fromJson(json["rcmd_reason"]) ? RcmdReason.fromJson(json["rcmd_reason"])
: RcmdReason(content: ''); : RcmdReason(content: '');

View File

@ -25,6 +25,7 @@ class HomeController extends GetxController {
freshIdx: _currentPage, freshIdx: _currentPage,
); );
if (res['status']) { if (res['status']) {
print('type: $type');
if (type == 'init') { if (type == 'init') {
videoList.value = res['data']; videoList.value = res['data'];
} else if (type == 'onRefresh') { } else if (type == 'onRefresh') {