feat: search trending page

Closes #684

Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
bggRGjQaUbCoE
2025-04-14 22:57:13 +08:00
parent 7cc0c83df1
commit bc9c20c509
14 changed files with 469 additions and 45 deletions

View File

@@ -0,0 +1,28 @@
import 'trending_data.dart';
class SearchTrending {
int? code;
String? message;
int? ttl;
TrendingData? data;
SearchTrending({this.code, this.message, this.ttl, this.data});
factory SearchTrending.fromJson(Map<String, dynamic> json) {
return SearchTrending(
code: json['code'] as int?,
message: json['message'] as String?,
ttl: json['ttl'] as int?,
data: json['data'] == null
? null
: TrendingData.fromJson(json['data'] as Map<String, dynamic>),
);
}
Map<String, dynamic> toJson() => {
'code': code,
'message': message,
'ttl': ttl,
'data': data?.toJson(),
};
}

View File

@@ -0,0 +1,14 @@
class StatDatas {
StatDatas();
factory StatDatas.fromJson(Map<String, dynamic> json) {
// TODO: implement fromJson
throw UnimplementedError('StatDatas.fromJson($json) is not implemented');
}
Map<String, dynamic> toJson() {
// TODO: implement toJson
throw UnimplementedError();
}
}

View File

@@ -0,0 +1,95 @@
import 'stat_datas.dart';
class TopList {
int? hotId;
String? keyword;
String? showName;
int? score;
int? wordType;
int? gotoType;
String? gotoValue;
String? icon;
List<dynamic>? liveId;
int? callReason;
String? heatLayer;
int? pos;
int? id;
String? status;
String? nameType;
int? resourceId;
int? setGray;
List<dynamic>? cardValues;
int? heatScore;
StatDatas? statDatas;
TopList({
this.hotId,
this.keyword,
this.showName,
this.score,
this.wordType,
this.gotoType,
this.gotoValue,
this.icon,
this.liveId,
this.callReason,
this.heatLayer,
this.pos,
this.id,
this.status,
this.nameType,
this.resourceId,
this.setGray,
this.cardValues,
this.heatScore,
this.statDatas,
});
factory TopList.fromJson(Map<String, dynamic> json) => TopList(
hotId: json['hot_id'] as int?,
keyword: json['keyword'] as String?,
showName: json['show_name'] as String?,
score: json['score'] as int?,
wordType: json['word_type'] as int?,
gotoType: json['goto_type'] as int?,
gotoValue: json['goto_value'] as String?,
icon: json['icon'] as String?,
liveId: json['live_id'] as List<dynamic>?,
callReason: json['call_reason'] as int?,
heatLayer: json['heat_layer'] as String?,
pos: json['pos'] as int?,
id: json['id'] as int?,
status: json['status'] as String?,
nameType: json['name_type'] as String?,
resourceId: json['resource_id'] as int?,
setGray: json['set_gray'] as int?,
cardValues: json['card_values'] as List<dynamic>?,
heatScore: json['heat_score'] as int?,
statDatas: json['stat_datas'] == null
? null
: StatDatas.fromJson(json['stat_datas'] as Map<String, dynamic>),
);
Map<String, dynamic> toJson() => {
'hot_id': hotId,
'keyword': keyword,
'show_name': showName,
'score': score,
'word_type': wordType,
'goto_type': gotoType,
'goto_value': gotoValue,
'icon': icon,
'live_id': liveId,
'call_reason': callReason,
'heat_layer': heatLayer,
'pos': pos,
'id': id,
'status': status,
'name_type': nameType,
'resource_id': resourceId,
'set_gray': setGray,
'card_values': cardValues,
'heat_score': heatScore,
'stat_datas': statDatas?.toJson(),
};
}

View File

@@ -0,0 +1,28 @@
import 'package:PiliPlus/models/search/search_trending/trending_list.dart';
class TrendingData {
String? trackid;
List<TrendingList>? list;
List<TrendingList>? topList;
String? hotwordEggInfo;
TrendingData({this.trackid, this.list, this.topList, this.hotwordEggInfo});
factory TrendingData.fromJson(Map<String, dynamic> json) => TrendingData(
trackid: json['trackid'] as String?,
list: (json['list'] as List<dynamic>?)
?.map((e) => TrendingList.fromJson(e as Map<String, dynamic>))
.toList(),
topList: (json['top_list'] as List<dynamic>?)
?.map((e) => TrendingList.fromJson(e as Map<String, dynamic>))
.toList(),
hotwordEggInfo: json['hotword_egg_info'] as String?,
);
Map<String, dynamic> toJson() => {
'trackid': trackid,
'list': list?.map((e) => e.toJson()).toList(),
'top_list': topList?.map((e) => e.toJson()).toList(),
'hotword_egg_info': hotwordEggInfo,
};
}

View File

@@ -0,0 +1,47 @@
class TrendingList {
int? position;
String? keyword;
String? showName;
int? wordType;
String? icon;
int? hotId;
String? isCommercial;
int? resourceId;
bool? showLiveIcon;
TrendingList({
this.position,
this.keyword,
this.showName,
this.wordType,
this.icon,
this.hotId,
this.isCommercial,
this.resourceId,
this.showLiveIcon,
});
factory TrendingList.fromJson(Map<String, dynamic> json) => TrendingList(
position: json['position'] as int?,
keyword: json['keyword'] as String?,
showName: json['show_name'] as String?,
wordType: json['word_type'] as int?,
icon: json['icon'] as String?,
hotId: json['hot_id'] as int?,
isCommercial: json['is_commercial'] as String?,
resourceId: json['resource_id'] as int?,
showLiveIcon: json['show_live_icon'] as bool?,
);
Map<String, dynamic> toJson() => {
'position': position,
'keyword': keyword,
'show_name': showName,
'word_type': wordType,
'icon': icon,
'hot_id': hotId,
'is_commercial': isCommercial,
'resource_id': resourceId,
'show_live_icon': showLiveIcon,
};
}