merge: model_hot_video_item
This commit is contained in:
@ -32,7 +32,7 @@ class VideoCardH extends StatelessWidget {
|
||||
child: InkWell(
|
||||
onTap: () async {
|
||||
await Future.delayed(const Duration(milliseconds: 200));
|
||||
int aid = videoItem['id'] ?? videoItem['aid'];
|
||||
int aid = videoItem.aid ?? videoItem.id;
|
||||
Get.toNamed('/video?aid=$aid',
|
||||
arguments: {'videoItem': videoItem});
|
||||
},
|
||||
@ -62,7 +62,7 @@ class VideoCardH extends StatelessWidget {
|
||||
NetworkImgLayer(
|
||||
// src: videoItem['pic'] +
|
||||
// '@${(maxWidth * 2).toInt()}w',
|
||||
src: videoItem['pic'] + '@.webp',
|
||||
src: videoItem.pic + '@.webp',
|
||||
width: maxWidth,
|
||||
height: maxHeight,
|
||||
),
|
||||
@ -77,11 +77,12 @@ class VideoCardH extends StatelessWidget {
|
||||
borderRadius: BorderRadius.circular(4),
|
||||
color: Colors.black54.withOpacity(0.4)),
|
||||
child: Text(
|
||||
Utils.timeFormat(videoItem['duration']!),
|
||||
Utils.timeFormat(videoItem.duration!),
|
||||
style: const TextStyle(
|
||||
fontSize: 11, color: Colors.white),
|
||||
),
|
||||
),
|
||||
// Image.network( videoItem['pic'], width: double.infinity, height: double.infinity,),
|
||||
)
|
||||
],
|
||||
);
|
||||
@ -116,7 +117,7 @@ class VideoContent extends StatelessWidget {
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
videoItem['title'],
|
||||
videoItem.title,
|
||||
textAlign: TextAlign.start,
|
||||
style: TextStyle(
|
||||
fontSize: Theme.of(context).textTheme.titleSmall!.fontSize,
|
||||
@ -125,8 +126,8 @@ class VideoContent extends StatelessWidget {
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
const Spacer(),
|
||||
if (videoItem['rcmd_reason'] != '' &&
|
||||
videoItem['rcmd_reason']['content'] != '')
|
||||
if (videoItem.rcmdReason != '' &&
|
||||
videoItem.rcmdReason.content != '')
|
||||
Container(
|
||||
padding: const EdgeInsets.symmetric(vertical: 2, horizontal: 5),
|
||||
decoration: BoxDecoration(
|
||||
@ -135,7 +136,7 @@ class VideoContent extends StatelessWidget {
|
||||
color: Theme.of(context).colorScheme.surfaceTint),
|
||||
),
|
||||
child: Text(
|
||||
videoItem['rcmd_reason']['content'],
|
||||
videoItem.rcmdReason.content,
|
||||
style: TextStyle(
|
||||
fontSize: 9,
|
||||
color: Theme.of(context).colorScheme.surfaceTint),
|
||||
@ -151,7 +152,7 @@ class VideoContent extends StatelessWidget {
|
||||
),
|
||||
const SizedBox(width: 2),
|
||||
Text(
|
||||
videoItem['owner']['name'],
|
||||
videoItem.owner.name,
|
||||
style: TextStyle(
|
||||
fontSize: Theme.of(context).textTheme.labelSmall!.fontSize,
|
||||
color: Theme.of(context).colorScheme.outline,
|
||||
@ -163,11 +164,11 @@ class VideoContent extends StatelessWidget {
|
||||
children: [
|
||||
StatView(
|
||||
theme: 'gray',
|
||||
view: videoItem['stat']['view'],
|
||||
view: videoItem.stat.view,
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
Text(
|
||||
Utils.dateFormat(videoItem['pubdate']!),
|
||||
Utils.dateFormat(videoItem.pubdate!),
|
||||
style: TextStyle(
|
||||
fontSize: 11,
|
||||
color: Theme.of(context).colorScheme.outline),
|
||||
|
162
lib/models/model_hot_video_item.dart
Normal file
162
lib/models/model_hot_video_item.dart
Normal file
@ -0,0 +1,162 @@
|
||||
import './model_owner.dart';
|
||||
|
||||
class HotVideoItemModel {
|
||||
HotVideoItemModel({
|
||||
this.aid,
|
||||
this.cid,
|
||||
this.bvid,
|
||||
this.videos,
|
||||
this.tid,
|
||||
this.tname,
|
||||
this.copyright,
|
||||
this.pic,
|
||||
this.title,
|
||||
this.pubdate,
|
||||
this.ctime,
|
||||
this.desc,
|
||||
this.state,
|
||||
this.duration,
|
||||
this.middionId,
|
||||
this.owner,
|
||||
this.stat,
|
||||
this.vDynamic,
|
||||
this.dimension,
|
||||
this.shortLinkV2,
|
||||
this.firstFrame,
|
||||
this.pubLocation,
|
||||
this.seasontype,
|
||||
this.isOgv,
|
||||
this.rcmdReason,
|
||||
});
|
||||
|
||||
int? aid;
|
||||
int? cid;
|
||||
String? bvid;
|
||||
int? videos;
|
||||
int? tid;
|
||||
String? tname;
|
||||
int? copyright;
|
||||
String? pic;
|
||||
String? title;
|
||||
int? pubdate;
|
||||
int? ctime;
|
||||
String? desc;
|
||||
int? state;
|
||||
int? duration;
|
||||
int? middionId;
|
||||
Owner? owner;
|
||||
Stat? stat;
|
||||
String? vDynamic;
|
||||
Dimension? dimension;
|
||||
String? shortLinkV2;
|
||||
String? firstFrame;
|
||||
String? pubLocation;
|
||||
int? seasontype;
|
||||
bool? isOgv;
|
||||
RcmdReason? rcmdReason;
|
||||
|
||||
HotVideoItemModel.fromJson(Map<String, dynamic> json) {
|
||||
aid = json["aid"];
|
||||
cid = json["cid"];
|
||||
bvid = json["bvid"];
|
||||
videos = json["videos"];
|
||||
tid = json["tid"];
|
||||
tname = json["tname"];
|
||||
copyright = json["copyright"];
|
||||
pic = json["pic"];
|
||||
title = json["title"];
|
||||
pubdate = json["pubdate"];
|
||||
ctime = json["ctime"];
|
||||
desc = json["desc"];
|
||||
state = json["state"];
|
||||
duration = json["duration"];
|
||||
middionId = json["middion_id"];
|
||||
owner = Owner.fromJson(json["owner"]);
|
||||
stat = Stat.fromJson(json['stat']);
|
||||
vDynamic = json["vDynamic"];
|
||||
dimension = Dimension.fromMap(json['dimension']);
|
||||
shortLinkV2 = json["short_link_v2"];
|
||||
firstFrame = json["first_frame"];
|
||||
pubLocation = json["pub_location"];
|
||||
seasontype = json["seasontype"];
|
||||
isOgv = json["isOgv"];
|
||||
rcmdReason = RcmdReason.fromJson(json['rcmd_reason']);
|
||||
}
|
||||
}
|
||||
|
||||
class Stat {
|
||||
Stat({
|
||||
this.aid,
|
||||
this.view,
|
||||
this.danmaku,
|
||||
this.reply,
|
||||
this.favorite,
|
||||
this.coin,
|
||||
this.share,
|
||||
this.nowRank,
|
||||
this.hisRank,
|
||||
this.like,
|
||||
this.dislike,
|
||||
this.vt,
|
||||
this.vv,
|
||||
});
|
||||
|
||||
int? aid;
|
||||
int? view;
|
||||
int? danmaku;
|
||||
int? reply;
|
||||
int? favorite;
|
||||
int? coin;
|
||||
int? share;
|
||||
int? nowRank;
|
||||
int? hisRank;
|
||||
int? like;
|
||||
int? dislike;
|
||||
int? vt;
|
||||
int? vv;
|
||||
|
||||
Stat.fromJson(Map<String, dynamic> json) {
|
||||
aid = json["aid"];
|
||||
view = json["view"];
|
||||
danmaku = json['danmaku'];
|
||||
reply = json["reply"];
|
||||
favorite = json["favorite"];
|
||||
coin = json['coin'];
|
||||
share = json["share"];
|
||||
nowRank = json["now_rank"];
|
||||
hisRank = json['his_rank'];
|
||||
like = json["like"];
|
||||
dislike = json["dislike"];
|
||||
vt = json['vt'];
|
||||
vv = json["vv"];
|
||||
}
|
||||
}
|
||||
|
||||
class Dimension {
|
||||
Dimension({this.width, this.height, this.rotate});
|
||||
|
||||
int? width;
|
||||
int? height;
|
||||
int? rotate;
|
||||
|
||||
Dimension.fromMap(Map<String, dynamic> json) {
|
||||
width = json["width"];
|
||||
height = json["height"];
|
||||
rotate = json["rotate"];
|
||||
}
|
||||
}
|
||||
|
||||
class RcmdReason {
|
||||
RcmdReason({
|
||||
this.rcornerMark,
|
||||
this.content,
|
||||
});
|
||||
|
||||
int? rcornerMark;
|
||||
String? content = '';
|
||||
|
||||
RcmdReason.fromJson(Map<String, dynamic> json) {
|
||||
rcornerMark = json["corner_mark"];
|
||||
content = json["content"] ?? '';
|
||||
}
|
||||
}
|
17
lib/models/model_owner.dart
Normal file
17
lib/models/model_owner.dart
Normal file
@ -0,0 +1,17 @@
|
||||
class Owner {
|
||||
Owner({
|
||||
this.mid,
|
||||
this.name,
|
||||
this.face,
|
||||
});
|
||||
|
||||
int? mid;
|
||||
String? name;
|
||||
String? face;
|
||||
|
||||
Owner.fromJson(Map<String, dynamic> json) {
|
||||
mid = json["mid"];
|
||||
name = json["name"];
|
||||
face = json['face'];
|
||||
}
|
||||
}
|
@ -1,3 +1,5 @@
|
||||
import './model_owner.dart';
|
||||
|
||||
class RecVideoItemModel {
|
||||
RecVideoItemModel({
|
||||
this.id,
|
||||
@ -23,7 +25,7 @@ class RecVideoItemModel {
|
||||
String? title = '';
|
||||
int? duration = -1;
|
||||
int? pubdate = -1;
|
||||
Onwer? owner;
|
||||
Owner? owner;
|
||||
Stat? stat;
|
||||
RcmdReason? rcmdReason;
|
||||
|
||||
@ -37,7 +39,7 @@ class RecVideoItemModel {
|
||||
title = json["title"];
|
||||
duration = json["duration"];
|
||||
pubdate = json["pubdate"];
|
||||
owner = Onwer.fromJson(json["owner"]);
|
||||
owner = Owner.fromJson(json["owner"]);
|
||||
stat = Stat.fromJson(json["stat"]);
|
||||
rcmdReason = json["rcmd_reason"] != null
|
||||
? RcmdReason.fromJson(json["rcmd_reason"])
|
||||
@ -45,24 +47,6 @@ class RecVideoItemModel {
|
||||
}
|
||||
}
|
||||
|
||||
class Onwer {
|
||||
Onwer({
|
||||
this.mid,
|
||||
this.name,
|
||||
this.face,
|
||||
});
|
||||
|
||||
int? mid;
|
||||
String? name;
|
||||
String? face;
|
||||
|
||||
Onwer.fromJson(Map<String, dynamic> json) {
|
||||
mid = json["mid"];
|
||||
name = json["name"];
|
||||
face = json['face'];
|
||||
}
|
||||
}
|
||||
|
||||
class Stat {
|
||||
Stat({
|
||||
this.view,
|
@ -2,7 +2,7 @@ import 'package:flutter/cupertino.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:pilipala/http/api.dart';
|
||||
import 'package:pilipala/http/init.dart';
|
||||
import 'package:pilipala/models/models_rec_video_item.dart';
|
||||
import 'package:pilipala/models/model_rec_video_item.dart';
|
||||
|
||||
class HomeController extends GetxController {
|
||||
final ScrollController scrollController = ScrollController();
|
||||
|
@ -2,10 +2,8 @@ import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:pilipala/common/skeleton/video_card_v.dart';
|
||||
import 'package:pilipala/common/widgets/animated_dialog.dart';
|
||||
import 'package:pilipala/common/widgets/network_img_layer.dart';
|
||||
import 'package:pilipala/common/widgets/overlay_pop.dart';
|
||||
import 'package:pilipala/common/widgets/video_card_v.dart';
|
||||
import 'package:pilipala/models/models_rec_video_item.dart';
|
||||
import './controller.dart';
|
||||
import 'package:pilipala/common/constants.dart';
|
||||
import 'package:pilipala/pages/home/widgets/app_bar.dart';
|
||||
@ -114,7 +112,7 @@ class _HomePageState extends State<HomePage>
|
||||
);
|
||||
}
|
||||
|
||||
OverlayEntry _createPopupDialog(RecVideoItemModel videoItem) {
|
||||
OverlayEntry _createPopupDialog(videoItem) {
|
||||
return OverlayEntry(
|
||||
builder: (context) => AnimatedDialog(
|
||||
child: OverlayPop(videoItem: videoItem),
|
||||
|
@ -3,12 +3,13 @@ import 'package:flutter/cupertino.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:pilipala/http/api.dart';
|
||||
import 'package:pilipala/http/init.dart';
|
||||
import 'package:pilipala/models/model_hot_video_item.dart';
|
||||
|
||||
class HotController extends GetxController {
|
||||
final ScrollController scrollController = ScrollController();
|
||||
final int _count = 20;
|
||||
int _currentPage = 1;
|
||||
RxList videoList = [].obs;
|
||||
RxList<HotVideoItemModel> videoList = [HotVideoItemModel()].obs;
|
||||
bool isLoadingMore = false;
|
||||
bool flag = false;
|
||||
OverlayEntry? popupDialog;
|
||||
@ -25,13 +26,16 @@ class HotController extends GetxController {
|
||||
Api.hotList,
|
||||
data: {'pn': _currentPage, 'ps': _count},
|
||||
);
|
||||
var data = res.data['data']['list'];
|
||||
List<HotVideoItemModel> list = [];
|
||||
for (var i in res.data['data']['list']) {
|
||||
list.add(HotVideoItemModel.fromJson(i));
|
||||
}
|
||||
if (type == 'init') {
|
||||
videoList.value = data;
|
||||
videoList.value = list;
|
||||
} else if (type == 'onRefresh') {
|
||||
videoList.insertAll(0, data);
|
||||
videoList.insertAll(0, list);
|
||||
} else if (type == 'onLoad') {
|
||||
videoList.addAll(data);
|
||||
videoList.addAll(list);
|
||||
}
|
||||
_currentPage += 1;
|
||||
isLoadingMore = false;
|
||||
|
Reference in New Issue
Block a user