mod: 数据请求
This commit is contained in:
@ -136,6 +136,8 @@ class Api {
|
|||||||
|
|
||||||
// 关注的up动态
|
// 关注的up动态
|
||||||
// https://api.bilibili.com/x/polymer/web-dynamic/v1/feed/all
|
// https://api.bilibili.com/x/polymer/web-dynamic/v1/feed/all
|
||||||
|
// https://api.bilibili.com/x/polymer/web-dynamic/v1/feed/all?timezone_offset=-480&type=video&page=1&features=itemOpusStyle
|
||||||
|
// https://api.bilibili.com/x/polymer/web-dynamic/v1/feed/all?host_mid=548196587&offset=&page=1&features=itemOpusStyle
|
||||||
static const String followDynamic = '/x/polymer/web-dynamic/v1/feed/all';
|
static const String followDynamic = '/x/polymer/web-dynamic/v1/feed/all';
|
||||||
|
|
||||||
// 获取稍后再看
|
// 获取稍后再看
|
||||||
|
@ -10,7 +10,8 @@ class DynamicsHttp {
|
|||||||
var res = await Request().get(Api.followDynamic, data: {
|
var res = await Request().get(Api.followDynamic, data: {
|
||||||
'type': type ?? 'all',
|
'type': type ?? 'all',
|
||||||
'page': page ?? 1,
|
'page': page ?? 1,
|
||||||
'offest': page == 1 ? '' : offset,
|
'timezone_offset': '-480',
|
||||||
|
'offset': page == 1 ? '' : offset,
|
||||||
'features': 'itemOpusStyle'
|
'features': 'itemOpusStyle'
|
||||||
});
|
});
|
||||||
if (res.data['code'] == 0) {
|
if (res.data['code'] == 0) {
|
||||||
|
11
lib/models/common/dynamics_type.dart
Normal file
11
lib/models/common/dynamics_type.dart
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
enum DynamicsType {
|
||||||
|
all,
|
||||||
|
video,
|
||||||
|
pgc,
|
||||||
|
article,
|
||||||
|
}
|
||||||
|
|
||||||
|
extension BusinessTypeExtension on DynamicsType {
|
||||||
|
String get values => ['all', 'video', 'pgc', 'article'][index];
|
||||||
|
String get labels => ['全部', '视频投稿', '追番追剧', '专栏'][index];
|
||||||
|
}
|
@ -1,3 +1,5 @@
|
|||||||
|
import 'dart:convert';
|
||||||
|
|
||||||
class DynamicsDataModel {
|
class DynamicsDataModel {
|
||||||
DynamicsDataModel({
|
DynamicsDataModel({
|
||||||
this.hasMore,
|
this.hasMore,
|
||||||
@ -186,13 +188,17 @@ class DynamicAddModel {
|
|||||||
DynamicAddModel({
|
DynamicAddModel({
|
||||||
this.type,
|
this.type,
|
||||||
this.vote,
|
this.vote,
|
||||||
|
this.ugc,
|
||||||
});
|
});
|
||||||
|
|
||||||
String? type;
|
String? type;
|
||||||
Vote? vote;
|
Vote? vote;
|
||||||
|
Ugc? ugc;
|
||||||
|
|
||||||
DynamicAddModel.fromJson(Map<String, dynamic> json) {
|
DynamicAddModel.fromJson(Map<String, dynamic> json) {
|
||||||
type = json['type'];
|
type = json['type'];
|
||||||
vote = json['vote'] != null ? Vote.fromJson(json['vote']) : null;
|
vote = json['vote'] != null ? Vote.fromJson(json['vote']) : null;
|
||||||
|
ugc = json['ugc'] != null ? Ugc.fromJson(json['ugc']) : null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -214,7 +220,7 @@ class Vote {
|
|||||||
int? defaultShare;
|
int? defaultShare;
|
||||||
int? endTime;
|
int? endTime;
|
||||||
int? joinNum;
|
int? joinNum;
|
||||||
String? status;
|
int? status;
|
||||||
String? type;
|
String? type;
|
||||||
int? uid;
|
int? uid;
|
||||||
int? voteId;
|
int? voteId;
|
||||||
@ -232,6 +238,39 @@ class Vote {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class Ugc {
|
||||||
|
Ugc({
|
||||||
|
this.cover,
|
||||||
|
this.descSecond,
|
||||||
|
this.duration,
|
||||||
|
this.headText,
|
||||||
|
this.idStr,
|
||||||
|
this.jumpUrl,
|
||||||
|
this.multiLine,
|
||||||
|
this.title,
|
||||||
|
});
|
||||||
|
|
||||||
|
String? cover;
|
||||||
|
String? descSecond;
|
||||||
|
String? duration;
|
||||||
|
String? headText;
|
||||||
|
String? idStr;
|
||||||
|
String? jumpUrl;
|
||||||
|
String? multiLine;
|
||||||
|
String? title;
|
||||||
|
|
||||||
|
Ugc.fromJson(Map<String, dynamic> json) {
|
||||||
|
cover = json['cover'];
|
||||||
|
descSecond = json['desc_second'];
|
||||||
|
duration = json['duration'];
|
||||||
|
headText = json['head_text'];
|
||||||
|
idStr = json['id_str'];
|
||||||
|
jumpUrl = json['jump_url'];
|
||||||
|
multiLine = json['multi_line'];
|
||||||
|
title = json['title'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
class DynamicDescModel {
|
class DynamicDescModel {
|
||||||
DynamicDescModel({
|
DynamicDescModel({
|
||||||
this.richTextNodes,
|
this.richTextNodes,
|
||||||
@ -258,6 +297,8 @@ class DynamicMajorModel {
|
|||||||
this.draw,
|
this.draw,
|
||||||
this.ugcSeason,
|
this.ugcSeason,
|
||||||
this.opus,
|
this.opus,
|
||||||
|
this.pgc,
|
||||||
|
this.liveRcmd,
|
||||||
this.none,
|
this.none,
|
||||||
this.type,
|
this.type,
|
||||||
});
|
});
|
||||||
@ -266,6 +307,8 @@ class DynamicMajorModel {
|
|||||||
DynamicDrawModel? draw;
|
DynamicDrawModel? draw;
|
||||||
DynamicArchiveModel? ugcSeason;
|
DynamicArchiveModel? ugcSeason;
|
||||||
DynamicOpusModel? opus;
|
DynamicOpusModel? opus;
|
||||||
|
DynamicArchiveModel? pgc;
|
||||||
|
DynamicLiveModel? liveRcmd;
|
||||||
DynamicNoneModel? none;
|
DynamicNoneModel? none;
|
||||||
// MAJOR_TYPE_DRAW 图片
|
// MAJOR_TYPE_DRAW 图片
|
||||||
// MAJOR_TYPE_ARCHIVE 视频
|
// MAJOR_TYPE_ARCHIVE 视频
|
||||||
@ -283,6 +326,11 @@ class DynamicMajorModel {
|
|||||||
: null;
|
: null;
|
||||||
opus =
|
opus =
|
||||||
json['opus'] != null ? DynamicOpusModel.fromJson(json['opus']) : null;
|
json['opus'] != null ? DynamicOpusModel.fromJson(json['opus']) : null;
|
||||||
|
pgc =
|
||||||
|
json['pgc'] != null ? DynamicArchiveModel.fromJson(json['pgc']) : null;
|
||||||
|
liveRcmd = json['live_rcmd'] != null
|
||||||
|
? DynamicLiveModel.fromJson(json['live_rcmd'])
|
||||||
|
: null;
|
||||||
none =
|
none =
|
||||||
json['none'] != null ? DynamicNoneModel.fromJson(json['none']) : null;
|
json['none'] != null ? DynamicNoneModel.fromJson(json['none']) : null;
|
||||||
type = json['type'];
|
type = json['type'];
|
||||||
@ -506,6 +554,46 @@ class DynamicDrawItemModel {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class DynamicLiveModel {
|
||||||
|
DynamicLiveModel({
|
||||||
|
this.content,
|
||||||
|
});
|
||||||
|
|
||||||
|
String? content;
|
||||||
|
int? type;
|
||||||
|
Map? livePlayInfo;
|
||||||
|
int? uid;
|
||||||
|
String? parentAreaName;
|
||||||
|
int? roomId;
|
||||||
|
String? liveId;
|
||||||
|
int? liveStatus;
|
||||||
|
String? cover;
|
||||||
|
int? online;
|
||||||
|
String? areaName;
|
||||||
|
String? title;
|
||||||
|
int? liveStartTime;
|
||||||
|
|
||||||
|
DynamicLiveModel.fromJson(Map<String, dynamic> json) {
|
||||||
|
content = json['content'];
|
||||||
|
if (json['content'] != null) {
|
||||||
|
Map<String, dynamic> data = jsonDecode(json['content']);
|
||||||
|
|
||||||
|
type = data['type'];
|
||||||
|
Map livePlayInfo = data['live_play_info'];
|
||||||
|
uid = livePlayInfo['uid'];
|
||||||
|
parentAreaName = livePlayInfo['parent_area_name'];
|
||||||
|
roomId = livePlayInfo['room_id'];
|
||||||
|
liveId = livePlayInfo['live_id'];
|
||||||
|
liveStatus = livePlayInfo['live_status'];
|
||||||
|
cover = livePlayInfo['cover'];
|
||||||
|
online = livePlayInfo['online'];
|
||||||
|
areaName = livePlayInfo['area_name'];
|
||||||
|
title = livePlayInfo['title'];
|
||||||
|
liveStartTime = livePlayInfo['live_start_time'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// 动态状态 转发、评论、点赞
|
// 动态状态 转发、评论、点赞
|
||||||
class ModuleStatModel {
|
class ModuleStatModel {
|
||||||
ModuleStatModel({
|
ModuleStatModel({
|
||||||
|
@ -4,14 +4,15 @@ import 'package:pilipala/models/dynamics/result.dart';
|
|||||||
|
|
||||||
class DynamicsController extends GetxController {
|
class DynamicsController extends GetxController {
|
||||||
int page = 1;
|
int page = 1;
|
||||||
String reqType = 'all';
|
String? offset = '';
|
||||||
String? offset;
|
|
||||||
RxList<DynamicItemModel>? dynamicsList = [DynamicItemModel()].obs;
|
RxList<DynamicItemModel>? dynamicsList = [DynamicItemModel()].obs;
|
||||||
|
RxString dynamicsType = 'all'.obs;
|
||||||
|
RxString dynamicsTypeLabel = '全部'.obs;
|
||||||
|
|
||||||
Future queryFollowDynamic({type = 'init'}) async {
|
Future queryFollowDynamic({type = 'init'}) async {
|
||||||
var res = await DynamicsHttp.followDynamic(
|
var res = await DynamicsHttp.followDynamic(
|
||||||
page: page,
|
page: type == 'init' ? 1 : page,
|
||||||
type: reqType,
|
type: dynamicsType.value,
|
||||||
offset: offset,
|
offset: offset,
|
||||||
);
|
);
|
||||||
if (res['status']) {
|
if (res['status']) {
|
||||||
@ -21,7 +22,14 @@ class DynamicsController extends GetxController {
|
|||||||
dynamicsList!.addAll(res['data'].items);
|
dynamicsList!.addAll(res['data'].items);
|
||||||
}
|
}
|
||||||
offset = res['data'].offset;
|
offset = res['data'].offset;
|
||||||
|
page++;
|
||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onSelectType(value, label) {
|
||||||
|
dynamicsType.value = value;
|
||||||
|
dynamicsTypeLabel.value = label;
|
||||||
|
queryFollowDynamic();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
import 'package:pilipala/common/widgets/http_error.dart';
|
import 'package:pilipala/common/widgets/http_error.dart';
|
||||||
|
import 'package:pilipala/models/common/dynamics_type.dart';
|
||||||
import 'package:pilipala/models/dynamics/result.dart';
|
import 'package:pilipala/models/dynamics/result.dart';
|
||||||
|
|
||||||
import 'controller.dart';
|
import 'controller.dart';
|
||||||
@ -17,7 +18,8 @@ class _DynamicsPageState extends State<DynamicsPage>
|
|||||||
with AutomaticKeepAliveClientMixin {
|
with AutomaticKeepAliveClientMixin {
|
||||||
DynamicsController _dynamicsController = Get.put(DynamicsController());
|
DynamicsController _dynamicsController = Get.put(DynamicsController());
|
||||||
Future? _futureBuilderFuture;
|
Future? _futureBuilderFuture;
|
||||||
|
final ScrollController scrollController = ScrollController();
|
||||||
|
bool _isLoadingMore = false;
|
||||||
@override
|
@override
|
||||||
bool get wantKeepAlive => true;
|
bool get wantKeepAlive => true;
|
||||||
|
|
||||||
@ -25,6 +27,19 @@ class _DynamicsPageState extends State<DynamicsPage>
|
|||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
_futureBuilderFuture = _dynamicsController.queryFollowDynamic();
|
_futureBuilderFuture = _dynamicsController.queryFollowDynamic();
|
||||||
|
|
||||||
|
scrollController.addListener(
|
||||||
|
() async {
|
||||||
|
if (scrollController.position.pixels >=
|
||||||
|
scrollController.position.maxScrollExtent - 200) {
|
||||||
|
if (!_isLoadingMore) {
|
||||||
|
_isLoadingMore = true;
|
||||||
|
await _dynamicsController.queryFollowDynamic(type: 'onLoad');
|
||||||
|
_isLoadingMore = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -34,12 +49,42 @@ class _DynamicsPageState extends State<DynamicsPage>
|
|||||||
centerTitle: false,
|
centerTitle: false,
|
||||||
title: const Text('动态'),
|
title: const Text('动态'),
|
||||||
actions: [
|
actions: [
|
||||||
IconButton(onPressed: () {}, icon: const Icon(Icons.more_horiz)),
|
Obx(
|
||||||
|
() => PopupMenuButton(
|
||||||
|
initialValue: _dynamicsController.dynamicsType.value,
|
||||||
|
position: PopupMenuPosition.under,
|
||||||
|
itemBuilder: (context) => [
|
||||||
|
for (var i in DynamicsType.values) ...[
|
||||||
|
PopupMenuItem(
|
||||||
|
value: i.values,
|
||||||
|
onTap: () =>
|
||||||
|
_dynamicsController.onSelectType(i.values, i.labels),
|
||||||
|
child: Text(i.labels),
|
||||||
|
)
|
||||||
|
],
|
||||||
|
],
|
||||||
|
child: Row(
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
_dynamicsController.dynamicsTypeLabel.value,
|
||||||
|
style: TextStyle(
|
||||||
|
color: Theme.of(context).colorScheme.primary,
|
||||||
|
),
|
||||||
|
),
|
||||||
const SizedBox(width: 10)
|
const SizedBox(width: 10)
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
body: FutureBuilder(
|
),
|
||||||
future: _dynamicsController.queryFollowDynamic(),
|
),
|
||||||
|
const SizedBox(width: 4)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
body: RefreshIndicator(
|
||||||
|
onRefresh: () async {
|
||||||
|
await _dynamicsController.queryFollowDynamic();
|
||||||
|
},
|
||||||
|
child: FutureBuilder(
|
||||||
|
future: _futureBuilderFuture,
|
||||||
builder: (context, snapshot) {
|
builder: (context, snapshot) {
|
||||||
if (snapshot.connectionState == ConnectionState.done) {
|
if (snapshot.connectionState == ConnectionState.done) {
|
||||||
Map data = snapshot.data;
|
Map data = snapshot.data;
|
||||||
@ -47,6 +92,7 @@ class _DynamicsPageState extends State<DynamicsPage>
|
|||||||
List<DynamicItemModel> list = _dynamicsController.dynamicsList!;
|
List<DynamicItemModel> list = _dynamicsController.dynamicsList!;
|
||||||
return Obx(
|
return Obx(
|
||||||
() => ListView.builder(
|
() => ListView.builder(
|
||||||
|
controller: scrollController,
|
||||||
shrinkWrap: true,
|
shrinkWrap: true,
|
||||||
itemCount: list.length,
|
itemCount: list.length,
|
||||||
itemBuilder: (BuildContext context, index) {
|
itemBuilder: (BuildContext context, index) {
|
||||||
@ -75,6 +121,7 @@ class _DynamicsPageState extends State<DynamicsPage>
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -99,7 +99,11 @@ class DynamicPanel extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
Text.rich(richNode(item, context)),
|
Text.rich(
|
||||||
|
richNode(item, context),
|
||||||
|
maxLines: 4,
|
||||||
|
overflow: TextOverflow.ellipsis,
|
||||||
|
),
|
||||||
],
|
],
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
@ -135,7 +139,25 @@ class DynamicPanel extends StatelessWidget {
|
|||||||
],
|
],
|
||||||
),
|
),
|
||||||
const SizedBox(height: 2),
|
const SizedBox(height: 2),
|
||||||
Text(item.modules.moduleDynamic.desc.text),
|
if (item.modules.moduleDynamic.topic != null) ...[
|
||||||
|
Padding(
|
||||||
|
padding: floor == 2
|
||||||
|
? EdgeInsets.zero
|
||||||
|
: const EdgeInsets.only(left: 12, right: 12),
|
||||||
|
child: GestureDetector(
|
||||||
|
child: Text(
|
||||||
|
'#${item.modules.moduleDynamic.topic.name}',
|
||||||
|
style: authorStyle,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
Text.rich(
|
||||||
|
richNode(item, context),
|
||||||
|
maxLines: 4,
|
||||||
|
overflow: TextOverflow.ellipsis,
|
||||||
|
),
|
||||||
|
// Text(item.modules.moduleDynamic.desc.text),
|
||||||
const SizedBox(height: 4),
|
const SizedBox(height: 4),
|
||||||
],
|
],
|
||||||
Padding(
|
Padding(
|
||||||
@ -188,60 +210,203 @@ class DynamicPanel extends StatelessWidget {
|
|||||||
.copyWith(fontWeight: FontWeight.bold),
|
.copyWith(fontWeight: FontWeight.bold),
|
||||||
),
|
),
|
||||||
const SizedBox(height: 2),
|
const SizedBox(height: 2),
|
||||||
Text(item.modules.moduleDynamic.major.opus.summary.richTextNodes
|
if (item.modules.moduleDynamic.major.opus.summary.text !=
|
||||||
.first.text),
|
'undefined')
|
||||||
|
Text(
|
||||||
|
item.modules.moduleDynamic.major.opus.summary.richTextNodes
|
||||||
|
.first.text,
|
||||||
|
maxLines: 4,
|
||||||
|
overflow: TextOverflow.ellipsis,
|
||||||
|
),
|
||||||
picWidget(item, context)
|
picWidget(item, context)
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
// 转发
|
// 转发
|
||||||
case 'DYNAMIC_TYPE_FORWARD':
|
case 'DYNAMIC_TYPE_FORWARD':
|
||||||
switch (item.orig.type) {
|
|
||||||
// 递归
|
|
||||||
case 'DYNAMIC_TYPE_AV':
|
|
||||||
return Container(
|
return Container(
|
||||||
padding: const EdgeInsets.only(
|
padding:
|
||||||
left: 15, top: 10, right: 15, bottom: 10),
|
const EdgeInsets.only(left: 15, top: 10, right: 15, bottom: 10),
|
||||||
color: Theme.of(context).dividerColor.withOpacity(0.08),
|
color: Theme.of(context).dividerColor.withOpacity(0.08),
|
||||||
child: forWard(item.orig, context, floor: 2),
|
child: forWard(item.orig, context, floor: 2),
|
||||||
);
|
);
|
||||||
case 'DYNAMIC_TYPE_DRAW':
|
// switch (item.orig.type) {
|
||||||
return Container(
|
// // 递归
|
||||||
padding: const EdgeInsets.only(
|
// case 'DYNAMIC_TYPE_AV':
|
||||||
left: 15, top: 10, right: 15, bottom: 10),
|
// return Container(
|
||||||
color: Theme.of(context).dividerColor.withOpacity(0.08),
|
// padding: const EdgeInsets.only(
|
||||||
child: forWard(item.orig, context, floor: 2),
|
// left: 15, top: 10, right: 15, bottom: 10),
|
||||||
);
|
// color: Theme.of(context).dividerColor.withOpacity(0.08),
|
||||||
case 'DYNAMIC_TYPE_WORD':
|
// child: forWard(item.orig, context, floor: 2),
|
||||||
return Container(
|
// );
|
||||||
width: double.infinity,
|
// case 'DYNAMIC_TYPE_DRAW':
|
||||||
padding: const EdgeInsets.only(
|
// return Container(
|
||||||
left: 15, top: 10, right: 15, bottom: 10),
|
// padding: const EdgeInsets.only(
|
||||||
color: Theme.of(context).dividerColor.withOpacity(0.08),
|
// left: 15, top: 10, right: 15, bottom: 10),
|
||||||
child: forWard(item.orig, context, floor: 2),
|
// color: Theme.of(context).dividerColor.withOpacity(0.08),
|
||||||
);
|
// child: forWard(item.orig, context, floor: 2),
|
||||||
case 'DYNAMIC_TYPE_NONE':
|
// );
|
||||||
return Container(
|
// case 'DYNAMIC_TYPE_WORD':
|
||||||
width: double.infinity,
|
// return Container(
|
||||||
padding: const EdgeInsets.only(
|
// width: double.infinity,
|
||||||
left: 15, top: 10, right: 15, bottom: 10),
|
// padding: const EdgeInsets.only(
|
||||||
color: Theme.of(context).dividerColor.withOpacity(0.08),
|
// left: 15, top: 10, right: 15, bottom: 10),
|
||||||
child: forWard(item.orig, context, floor: 2),
|
// color: Theme.of(context).dividerColor.withOpacity(0.08),
|
||||||
);
|
// child: forWard(item.orig, context, floor: 2),
|
||||||
case 'DYNAMIC_TYPE_ARTICLE':
|
// );
|
||||||
return Container(
|
// case 'DYNAMIC_TYPE_NONE':
|
||||||
width: double.infinity,
|
// return Container(
|
||||||
padding: const EdgeInsets.only(
|
// width: double.infinity,
|
||||||
left: 15, top: 10, right: 15, bottom: 10),
|
// padding: const EdgeInsets.only(
|
||||||
color: Theme.of(context).dividerColor.withOpacity(0.08),
|
// left: 15, top: 10, right: 15, bottom: 10),
|
||||||
child: forWard(item.orig, context, floor: 2),
|
// color: Theme.of(context).dividerColor.withOpacity(0.08),
|
||||||
);
|
// child: forWard(item.orig, context, floor: 2),
|
||||||
default:
|
// );
|
||||||
return const Text('渲染出错了1');
|
// case 'DYNAMIC_TYPE_ARTICLE':
|
||||||
}
|
// return Container(
|
||||||
|
// width: double.infinity,
|
||||||
|
// padding: const EdgeInsets.only(
|
||||||
|
// left: 15, top: 10, right: 15, bottom: 10),
|
||||||
|
// color: Theme.of(context).dividerColor.withOpacity(0.08),
|
||||||
|
// child: forWard(item.orig, context, floor: 2),
|
||||||
|
// );
|
||||||
|
// case 'DYNAMIC_TYPE_PGC':
|
||||||
|
// return Container(
|
||||||
|
// width: double.infinity,
|
||||||
|
// padding: const EdgeInsets.only(
|
||||||
|
// left: 15, top: 10, right: 15, bottom: 10),
|
||||||
|
// color: Theme.of(context).dividerColor.withOpacity(0.08),
|
||||||
|
// child: forWard(item.orig, context, floor: 2),
|
||||||
|
// );
|
||||||
|
// case 'DYNAMIC_TYPE_LIVE_RCMD':
|
||||||
|
// return Container(
|
||||||
|
// width: double.infinity,
|
||||||
|
// padding: const EdgeInsets.only(
|
||||||
|
// left: 15, top: 10, right: 15, bottom: 10),
|
||||||
|
// color: Theme.of(context).dividerColor.withOpacity(0.08),
|
||||||
|
// child: forWard(item.orig, context, floor: 2),
|
||||||
|
// );
|
||||||
|
// default:
|
||||||
|
// return const Text('渲染出错了1');
|
||||||
|
// }
|
||||||
// 直播
|
// 直播
|
||||||
case 'DYNAMIC_TYPE_LIVE_RCMD':
|
case 'DYNAMIC_TYPE_LIVE_RCMD':
|
||||||
return const Text('DYNAMIC_TYPE_LIVE_RCMD');
|
return Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
if (floor == 2) ...[
|
||||||
|
Row(
|
||||||
|
children: [
|
||||||
|
GestureDetector(
|
||||||
|
onTap: () {},
|
||||||
|
child: Text(
|
||||||
|
'@${item.modules.moduleAuthor.name}',
|
||||||
|
style: authorStyle,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(width: 6),
|
||||||
|
Text(
|
||||||
|
Utils.dateFormat(item.modules.moduleAuthor.pubTs),
|
||||||
|
style: TextStyle(
|
||||||
|
color: Theme.of(context).colorScheme.outline,
|
||||||
|
fontSize:
|
||||||
|
Theme.of(context).textTheme.labelSmall!.fontSize),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
],
|
||||||
|
const SizedBox(height: 4),
|
||||||
|
if (item.modules.moduleDynamic.topic != null) ...[
|
||||||
|
Padding(
|
||||||
|
padding: floor == 2
|
||||||
|
? EdgeInsets.zero
|
||||||
|
: const EdgeInsets.only(left: 12, right: 12),
|
||||||
|
child: GestureDetector(
|
||||||
|
child: Text(
|
||||||
|
'#${item.modules.moduleDynamic.topic.name}',
|
||||||
|
style: authorStyle,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 6),
|
||||||
|
],
|
||||||
|
if (floor == 2 && item.modules.moduleDynamic.desc != null) ...[
|
||||||
|
Text.rich(richNode(item, context)),
|
||||||
|
const SizedBox(height: 6),
|
||||||
|
],
|
||||||
|
GestureDetector(
|
||||||
|
onTap: () {},
|
||||||
|
child: LayoutBuilder(builder: (context, box) {
|
||||||
|
double width = box.maxWidth;
|
||||||
|
return Stack(
|
||||||
|
children: [
|
||||||
|
NetworkImgLayer(
|
||||||
|
type: floor == 1 ? 'emote' : null,
|
||||||
|
width: width,
|
||||||
|
height: width / StyleString.aspectRatio,
|
||||||
|
src: item.modules.moduleDynamic.major.liveRcmd.cover,
|
||||||
|
),
|
||||||
|
Positioned(
|
||||||
|
left: 0,
|
||||||
|
right: 0,
|
||||||
|
bottom: 0,
|
||||||
|
child: Container(
|
||||||
|
height: 80,
|
||||||
|
padding: const EdgeInsets.fromLTRB(12, 0, 10, 10),
|
||||||
|
clipBehavior: Clip.hardEdge,
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
gradient: const LinearGradient(
|
||||||
|
begin: Alignment.topCenter,
|
||||||
|
end: Alignment.bottomCenter,
|
||||||
|
colors: <Color>[
|
||||||
|
Colors.transparent,
|
||||||
|
Colors.black87,
|
||||||
|
],
|
||||||
|
),
|
||||||
|
borderRadius: floor == 1
|
||||||
|
? null
|
||||||
|
: const BorderRadius.all(Radius.circular(6))),
|
||||||
|
child: Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.end,
|
||||||
|
children: [
|
||||||
|
DefaultTextStyle.merge(
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: Theme.of(context)
|
||||||
|
.textTheme
|
||||||
|
.labelMedium!
|
||||||
|
.fontSize,
|
||||||
|
color: Colors.white),
|
||||||
|
child: Row(
|
||||||
|
children: [
|
||||||
|
Text(item.modules.moduleDynamic.major
|
||||||
|
.liveRcmd.areaName ??
|
||||||
|
''),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
)),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 6),
|
||||||
|
Padding(
|
||||||
|
padding: floor == 1
|
||||||
|
? const EdgeInsets.only(left: 12, right: 12)
|
||||||
|
: EdgeInsets.zero,
|
||||||
|
child: Text(
|
||||||
|
item.modules.moduleDynamic.major.liveRcmd.title,
|
||||||
|
maxLines: 1,
|
||||||
|
style: const TextStyle(fontWeight: FontWeight.bold),
|
||||||
|
overflow: TextOverflow.ellipsis,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 2),
|
||||||
|
],
|
||||||
|
);
|
||||||
// 合集
|
// 合集
|
||||||
case 'DYNAMIC_TYPE_UGC_SEASON':
|
case 'DYNAMIC_TYPE_UGC_SEASON':
|
||||||
return videoSeasonWidget(item, context, 'ugcSeason');
|
return videoSeasonWidget(item, context, 'ugcSeason');
|
||||||
@ -276,7 +441,8 @@ class DynamicPanel extends StatelessWidget {
|
|||||||
],
|
],
|
||||||
)
|
)
|
||||||
: const SizedBox(height: 0);
|
: const SizedBox(height: 0);
|
||||||
|
case 'DYNAMIC_TYPE_PGC':
|
||||||
|
return videoSeasonWidget(item, context, 'pgc', floor: floor);
|
||||||
case 'DYNAMIC_TYPE_NONE':
|
case 'DYNAMIC_TYPE_NONE':
|
||||||
return Row(
|
return Row(
|
||||||
children: [
|
children: [
|
||||||
@ -371,7 +537,7 @@ class DynamicPanel extends StatelessWidget {
|
|||||||
: len ~/ crossCount + 1) +
|
: len ~/ crossCount + 1) +
|
||||||
6;
|
6;
|
||||||
return Container(
|
return Container(
|
||||||
padding: const EdgeInsets.only(top: 6),
|
padding: const EdgeInsets.only(top: 4),
|
||||||
height: height,
|
height: height,
|
||||||
child: GridView.count(
|
child: GridView.count(
|
||||||
padding: EdgeInsets.zero,
|
padding: EdgeInsets.zero,
|
||||||
@ -401,6 +567,7 @@ class DynamicPanel extends StatelessWidget {
|
|||||||
Map<dynamic, dynamic> dynamicProperty = {
|
Map<dynamic, dynamic> dynamicProperty = {
|
||||||
'ugcSeason': item.modules.moduleDynamic.major.ugcSeason,
|
'ugcSeason': item.modules.moduleDynamic.major.ugcSeason,
|
||||||
'archive': item.modules.moduleDynamic.major.archive,
|
'archive': item.modules.moduleDynamic.major.archive,
|
||||||
|
'pgc': item.modules.moduleDynamic.major.pgc
|
||||||
};
|
};
|
||||||
dynamic content = dynamicProperty[type];
|
dynamic content = dynamicProperty[type];
|
||||||
|
|
||||||
@ -427,8 +594,8 @@ class DynamicPanel extends StatelessWidget {
|
|||||||
],
|
],
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
if (item.modules.moduleDynamic.topic != null) ...[
|
|
||||||
const SizedBox(height: 4),
|
const SizedBox(height: 4),
|
||||||
|
if (item.modules.moduleDynamic.topic != null) ...[
|
||||||
Padding(
|
Padding(
|
||||||
padding: floor == 2
|
padding: floor == 2
|
||||||
? EdgeInsets.zero
|
? EdgeInsets.zero
|
||||||
@ -440,8 +607,12 @@ class DynamicPanel extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
|
||||||
const SizedBox(height: 6),
|
const SizedBox(height: 6),
|
||||||
|
],
|
||||||
|
if (floor == 2 && item.modules.moduleDynamic.desc != null) ...[
|
||||||
|
Text.rich(richNode(item, context)),
|
||||||
|
const SizedBox(height: 6),
|
||||||
|
],
|
||||||
GestureDetector(
|
GestureDetector(
|
||||||
onTap: () {},
|
onTap: () {},
|
||||||
child: LayoutBuilder(builder: (context, box) {
|
child: LayoutBuilder(builder: (context, box) {
|
||||||
@ -487,7 +658,8 @@ class DynamicPanel extends StatelessWidget {
|
|||||||
color: Colors.white),
|
color: Colors.white),
|
||||||
child: Row(
|
child: Row(
|
||||||
children: [
|
children: [
|
||||||
Text(content.durationText),
|
Text(content.durationText ?? ''),
|
||||||
|
if (content.durationText != null)
|
||||||
const SizedBox(width: 10),
|
const SizedBox(width: 10),
|
||||||
Text(content.stat.play + '次围观'),
|
Text(content.stat.play + '次围观'),
|
||||||
const SizedBox(width: 10),
|
const SizedBox(width: 10),
|
||||||
@ -526,12 +698,13 @@ class DynamicPanel extends StatelessWidget {
|
|||||||
|
|
||||||
InlineSpan richNode(item, context) {
|
InlineSpan richNode(item, context) {
|
||||||
TextStyle authorStyle =
|
TextStyle authorStyle =
|
||||||
TextStyle(color: Theme.of(context).colorScheme.primary, fontSize: 13);
|
TextStyle(color: Theme.of(context).colorScheme.primary);
|
||||||
List<InlineSpan> spanChilds = [];
|
List<InlineSpan> spanChilds = [];
|
||||||
for (var i in item.modules.moduleDynamic.desc.richTextNodes) {
|
for (var i in item.modules.moduleDynamic.desc.richTextNodes) {
|
||||||
if (i.type == 'RICH_TEXT_NODE_TYPE_TEXT') {
|
if (i.type == 'RICH_TEXT_NODE_TYPE_TEXT') {
|
||||||
spanChilds.add(TextSpan(text: i.origText));
|
spanChilds.add(TextSpan(text: i.origText));
|
||||||
}
|
}
|
||||||
|
// @用户
|
||||||
if (i.type == 'RICH_TEXT_NODE_TYPE_AT') {
|
if (i.type == 'RICH_TEXT_NODE_TYPE_AT') {
|
||||||
spanChilds.add(
|
spanChilds.add(
|
||||||
WidgetSpan(
|
WidgetSpan(
|
||||||
@ -542,7 +715,7 @@ class DynamicPanel extends StatelessWidget {
|
|||||||
GestureDetector(
|
GestureDetector(
|
||||||
onTap: () {},
|
onTap: () {},
|
||||||
child: Text(
|
child: Text(
|
||||||
'@${item.modules.moduleAuthor.name}',
|
'${i.text}',
|
||||||
style: authorStyle,
|
style: authorStyle,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@ -551,6 +724,7 @@ class DynamicPanel extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
// 话题
|
||||||
if (i.type == 'RICH_TEXT_NODE_TYPE_TOPIC') {
|
if (i.type == 'RICH_TEXT_NODE_TYPE_TOPIC') {
|
||||||
spanChilds.add(
|
spanChilds.add(
|
||||||
WidgetSpan(
|
WidgetSpan(
|
||||||
@ -564,6 +738,7 @@ class DynamicPanel extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
// 网页链接
|
||||||
if (i.type == 'RICH_TEXT_NODE_TYPE_WEB') {
|
if (i.type == 'RICH_TEXT_NODE_TYPE_WEB') {
|
||||||
spanChilds.add(
|
spanChilds.add(
|
||||||
WidgetSpan(
|
WidgetSpan(
|
||||||
@ -577,6 +752,7 @@ class DynamicPanel extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
// 投票
|
||||||
if (i.type == 'RICH_TEXT_NODE_TYPE_VOTE') {
|
if (i.type == 'RICH_TEXT_NODE_TYPE_VOTE') {
|
||||||
spanChilds.add(
|
spanChilds.add(
|
||||||
WidgetSpan(
|
WidgetSpan(
|
||||||
@ -590,6 +766,7 @@ class DynamicPanel extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
// 表情
|
||||||
if (i.type == 'RICH_TEXT_NODE_TYPE_EMOJI') {
|
if (i.type == 'RICH_TEXT_NODE_TYPE_EMOJI') {
|
||||||
spanChilds.add(
|
spanChilds.add(
|
||||||
WidgetSpan(
|
WidgetSpan(
|
||||||
@ -602,7 +779,38 @@ class DynamicPanel extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
// 抽奖
|
||||||
|
if (i.type == 'RICH_TEXT_NODE_TYPE_LOTTERY') {
|
||||||
|
spanChilds.add(
|
||||||
|
WidgetSpan(
|
||||||
|
child: GestureDetector(
|
||||||
|
onTap: () {},
|
||||||
|
child: Text(
|
||||||
|
' ${i.origText} ',
|
||||||
|
style: authorStyle,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
return TextSpan(children: spanChilds);
|
|
||||||
|
/// TODO 商品
|
||||||
|
if (i.type == 'RICH_TEXT_NODE_TYPE_GOODS') {
|
||||||
|
spanChilds.add(
|
||||||
|
WidgetSpan(
|
||||||
|
child: GestureDetector(
|
||||||
|
onTap: () {},
|
||||||
|
child: Text(
|
||||||
|
' ${i.text} ',
|
||||||
|
style: authorStyle,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return TextSpan(
|
||||||
|
children: spanChilds,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user