mirror of
https://github.com/HChaZZY/PiliPlus.git
synced 2025-12-06 09:13:48 +08:00
Compare commits
4 Commits
26a5b7b7a7
...
edb5ea7a7a
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
edb5ea7a7a | ||
|
|
b4c1568869 | ||
|
|
83e25ec0bf | ||
|
|
6d55321699 |
@@ -850,6 +850,12 @@ class Api {
|
||||
|
||||
static const String dynReserve = '/x/dynamic/feed/reserve/click';
|
||||
|
||||
static const String favPugv = '/pugv/app/web/favorite/page';
|
||||
|
||||
static const String addFavPugv = '/pugv/app/web/favorite/add';
|
||||
|
||||
static const String delFavPugv = '/pugv/app/web/favorite/del';
|
||||
|
||||
static const String favTopicList = '/x/topic/web/fav/list';
|
||||
|
||||
static const String addFavTopic = '/x/topic/fav/sub/add';
|
||||
@@ -920,6 +926,8 @@ class Api {
|
||||
|
||||
static const String spaceAudio = '/audio/music-service/web/song/upper';
|
||||
|
||||
static const String spaceCheese = '/pugv/app/web/season/page';
|
||||
|
||||
static const String dynMention = '/x/polymer/web-dynamic/v1/mention/search';
|
||||
|
||||
static const String createVote = '/x/vote/create';
|
||||
|
||||
@@ -10,6 +10,7 @@ import 'package:PiliPlus/models_new/fav/fav_folder/list.dart';
|
||||
import 'package:PiliPlus/models_new/fav/fav_note/list.dart';
|
||||
import 'package:PiliPlus/models_new/fav/fav_pgc/data.dart';
|
||||
import 'package:PiliPlus/models_new/fav/fav_topic/data.dart';
|
||||
import 'package:PiliPlus/models_new/space/space_cheese/data.dart';
|
||||
import 'package:PiliPlus/models_new/space/space_fav/data.dart';
|
||||
import 'package:PiliPlus/models_new/sub/sub_detail/data.dart';
|
||||
import 'package:PiliPlus/utils/accounts.dart';
|
||||
@@ -142,6 +143,58 @@ class FavHttp {
|
||||
}
|
||||
}
|
||||
|
||||
static Future<LoadingState<SpaceCheeseData>> favPugv({
|
||||
required int mid,
|
||||
required int page,
|
||||
}) async {
|
||||
var res = await Request().get(
|
||||
Api.favPugv,
|
||||
queryParameters: {
|
||||
'mid': mid,
|
||||
'ps': 20,
|
||||
'pn': page,
|
||||
'web_location': 333.1387,
|
||||
},
|
||||
);
|
||||
if (res.data['code'] == 0) {
|
||||
return Success(SpaceCheeseData.fromJson(res.data['data']));
|
||||
} else {
|
||||
return Error(res.data['message']);
|
||||
}
|
||||
}
|
||||
|
||||
static Future addFavPugv(seasonId) async {
|
||||
var res = await Request().post(
|
||||
Api.addFavPugv,
|
||||
data: {
|
||||
'season_id': seasonId,
|
||||
'csrf': Accounts.main.csrf,
|
||||
},
|
||||
options: Options(contentType: Headers.formUrlEncodedContentType),
|
||||
);
|
||||
if (res.data['code'] == 0) {
|
||||
return {'status': true};
|
||||
} else {
|
||||
return {'status': false, 'msg': res.data['message']};
|
||||
}
|
||||
}
|
||||
|
||||
static Future delFavPugv(seasonId) async {
|
||||
var res = await Request().post(
|
||||
Api.delFavPugv,
|
||||
data: {
|
||||
'season_id': seasonId,
|
||||
'csrf': Accounts.main.csrf,
|
||||
},
|
||||
options: Options(contentType: Headers.formUrlEncodedContentType),
|
||||
);
|
||||
if (res.data['code'] == 0) {
|
||||
return {'status': true};
|
||||
} else {
|
||||
return {'status': false, 'msg': res.data['message']};
|
||||
}
|
||||
}
|
||||
|
||||
static Future<LoadingState<FavTopicData>> favTopic({
|
||||
required int page,
|
||||
}) async {
|
||||
|
||||
@@ -20,6 +20,7 @@ import 'package:PiliPlus/models_new/space/space/data.dart';
|
||||
import 'package:PiliPlus/models_new/space/space_archive/data.dart';
|
||||
import 'package:PiliPlus/models_new/space/space_article/data.dart';
|
||||
import 'package:PiliPlus/models_new/space/space_audio/data.dart';
|
||||
import 'package:PiliPlus/models_new/space/space_cheese/data.dart';
|
||||
import 'package:PiliPlus/models_new/space/space_opus/data.dart';
|
||||
import 'package:PiliPlus/models_new/space/space_season_series/item.dart';
|
||||
import 'package:PiliPlus/models_new/upower_rank/data.dart';
|
||||
@@ -186,6 +187,26 @@ class MemberHttp {
|
||||
}
|
||||
}
|
||||
|
||||
static Future<LoadingState<SpaceCheeseData>> spaceCheese({
|
||||
required int page,
|
||||
required mid,
|
||||
}) async {
|
||||
var res = await Request().get(
|
||||
Api.spaceCheese,
|
||||
queryParameters: {
|
||||
'pn': page,
|
||||
'ps': 30,
|
||||
'mid': mid,
|
||||
'web_location': 333.1387,
|
||||
},
|
||||
);
|
||||
if (res.data['code'] == 0) {
|
||||
return Success(SpaceCheeseData.fromJson(res.data['data']));
|
||||
} else {
|
||||
return Error(res.data['message']);
|
||||
}
|
||||
}
|
||||
|
||||
static Future<LoadingState> spaceStory({
|
||||
required mid,
|
||||
required aid,
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import 'package:PiliPlus/pages/fav/article/view.dart';
|
||||
import 'package:PiliPlus/pages/fav/cheese/view.dart';
|
||||
import 'package:PiliPlus/pages/fav/note/view.dart';
|
||||
import 'package:PiliPlus/pages/fav/pgc/view.dart';
|
||||
import 'package:PiliPlus/pages/fav/topic/view.dart';
|
||||
@@ -11,7 +12,8 @@ enum FavTabType {
|
||||
cinema('追剧', FavPgcPage(type: 2)),
|
||||
article('专栏', FavArticlePage()),
|
||||
note('笔记', FavNotePage()),
|
||||
topic('话题', FavTopicPage());
|
||||
topic('话题', FavTopicPage()),
|
||||
cheese('课堂', FavCheesePage());
|
||||
|
||||
final String title;
|
||||
final Widget page;
|
||||
|
||||
@@ -4,7 +4,17 @@ enum MemberTabType {
|
||||
dynamic('动态'),
|
||||
contribute('投稿'),
|
||||
favorite('收藏'),
|
||||
bangumi('番剧');
|
||||
bangumi('番剧'),
|
||||
cheese('课堂');
|
||||
|
||||
static bool contains(String type) {
|
||||
for (var e in MemberTabType.values) {
|
||||
if (e.name == type) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
final String title;
|
||||
const MemberTabType(this.title);
|
||||
|
||||
27
lib/models/common/search/article_search_type.dart
Normal file
27
lib/models/common/search/article_search_type.dart
Normal file
@@ -0,0 +1,27 @@
|
||||
enum ArticleOrderType {
|
||||
totalrank('综合排序'),
|
||||
pubdate('最新发布'),
|
||||
click('最多点击'),
|
||||
attention('最多喜欢'),
|
||||
scores('最多评论');
|
||||
|
||||
String get order => name;
|
||||
final String label;
|
||||
const ArticleOrderType(this.label);
|
||||
}
|
||||
|
||||
enum ArticleZoneType {
|
||||
all('全部分区', 0),
|
||||
douga('动画', 2),
|
||||
game('游戏', 1),
|
||||
cinephile('影视', 28),
|
||||
life('生活', 3),
|
||||
interest('兴趣', 29),
|
||||
novel('轻小说', 16),
|
||||
tech('科技', 17),
|
||||
note('笔记', 41);
|
||||
|
||||
final String label;
|
||||
final int categoryId;
|
||||
const ArticleZoneType(this.label, this.categoryId);
|
||||
}
|
||||
22
lib/models/common/search/user_search_type.dart
Normal file
22
lib/models/common/search/user_search_type.dart
Normal file
@@ -0,0 +1,22 @@
|
||||
enum UserOrderType {
|
||||
def('默认排序', 0, ''),
|
||||
fansDesc('粉丝数由高到低', 0, 'fans'),
|
||||
fansAsc('粉丝数由低到高', 1, 'fans'),
|
||||
levelDesc('Lv等级由高到低', 0, 'level'),
|
||||
levelAsc('Lv等级由低到高', 1, 'level');
|
||||
|
||||
final String label;
|
||||
final int orderSort;
|
||||
final String order;
|
||||
const UserOrderType(this.label, this.orderSort, this.order);
|
||||
}
|
||||
|
||||
enum UserType {
|
||||
all('全部用户'),
|
||||
up('UP主'),
|
||||
common('普通用户'),
|
||||
verified('认证用户');
|
||||
|
||||
final String label;
|
||||
const UserType(this.label);
|
||||
}
|
||||
49
lib/models/common/search/video_search_type.dart
Normal file
49
lib/models/common/search/video_search_type.dart
Normal file
@@ -0,0 +1,49 @@
|
||||
enum VideoPubTimeType {
|
||||
all('不限'),
|
||||
day('最近一天'),
|
||||
week('最近一周'),
|
||||
halfYear('最近半年');
|
||||
|
||||
final String label;
|
||||
const VideoPubTimeType(this.label);
|
||||
}
|
||||
|
||||
enum VideoDurationType {
|
||||
all('全部时长'),
|
||||
tenMins('0-10分钟'),
|
||||
halfHour('0-30分钟'),
|
||||
hour('30-60分钟'),
|
||||
hourPlus('60分钟+');
|
||||
|
||||
final String label;
|
||||
const VideoDurationType(this.label);
|
||||
}
|
||||
|
||||
enum VideoZoneType {
|
||||
all('全部'),
|
||||
douga('动画', tids: 1),
|
||||
anime('番剧', tids: 13),
|
||||
guochuang('国创', tids: 167),
|
||||
music('音乐', tids: 3),
|
||||
dance('舞蹈', tids: 129),
|
||||
game('游戏', tids: 4),
|
||||
knowledge('知识', tids: 36),
|
||||
tech('科技', tids: 188),
|
||||
sports('运动', tids: 234),
|
||||
car('汽车', tids: 223),
|
||||
life('生活', tids: 160),
|
||||
food('美食', tids: 221),
|
||||
animal('动物', tids: 217),
|
||||
kichiku('鬼畜', tids: 119),
|
||||
fashion('时尚', tids: 115),
|
||||
info('资讯', tids: 202),
|
||||
ent('娱乐', tids: 5),
|
||||
cinephile('影视', tids: 181),
|
||||
documentary('记录', tids: 177),
|
||||
movie('电影', tids: 23),
|
||||
tv('电视', tids: 11);
|
||||
|
||||
final String label;
|
||||
final int? tids;
|
||||
const VideoZoneType(this.label, {this.tids});
|
||||
}
|
||||
@@ -11,16 +11,16 @@ class Brief {
|
||||
}
|
||||
|
||||
class Img {
|
||||
num? aspectRatio;
|
||||
num aspectRatio;
|
||||
String? url;
|
||||
|
||||
Img({
|
||||
this.aspectRatio,
|
||||
required this.aspectRatio,
|
||||
this.url,
|
||||
});
|
||||
|
||||
factory Img.fromJson(Map<String, dynamic> json) => Img(
|
||||
aspectRatio: json['aspect_ratio'],
|
||||
aspectRatio: json['aspect_ratio'] ?? 1,
|
||||
url: json['url'] as String?,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ class UserStatus {
|
||||
int? payPackPaid;
|
||||
int? sponsor;
|
||||
UserProgress? progress;
|
||||
int? favored;
|
||||
|
||||
UserStatus({
|
||||
this.areaLimit,
|
||||
@@ -21,6 +22,7 @@ class UserStatus {
|
||||
this.payPackPaid,
|
||||
this.sponsor,
|
||||
this.progress,
|
||||
this.favored,
|
||||
});
|
||||
|
||||
factory UserStatus.fromJson(Map<String, dynamic> json) => UserStatus(
|
||||
@@ -35,5 +37,6 @@ class UserStatus {
|
||||
progress: json['progress'] == null
|
||||
? null
|
||||
: UserProgress.fromJson(json['progress']),
|
||||
favored: json['favored'] as int?,
|
||||
);
|
||||
}
|
||||
|
||||
19
lib/models_new/space/space_cheese/data.dart
Normal file
19
lib/models_new/space/space_cheese/data.dart
Normal file
@@ -0,0 +1,19 @@
|
||||
import 'package:PiliPlus/models_new/space/space_cheese/item.dart';
|
||||
import 'package:PiliPlus/models_new/space/space_cheese/page.dart';
|
||||
|
||||
class SpaceCheeseData {
|
||||
List<SpaceCheeseItem>? items;
|
||||
SpaceCheesePage? page;
|
||||
|
||||
SpaceCheeseData({this.items, this.page});
|
||||
|
||||
factory SpaceCheeseData.fromJson(Map<String, dynamic> json) =>
|
||||
SpaceCheeseData(
|
||||
items: (json['items'] as List<dynamic>?)
|
||||
?.map((e) => SpaceCheeseItem.fromJson(e as Map<String, dynamic>))
|
||||
.toList(),
|
||||
page: json['page'] == null
|
||||
? null
|
||||
: SpaceCheesePage.fromJson(json['page'] as Map<String, dynamic>),
|
||||
);
|
||||
}
|
||||
48
lib/models_new/space/space_cheese/item.dart
Normal file
48
lib/models_new/space/space_cheese/item.dart
Normal file
@@ -0,0 +1,48 @@
|
||||
class SpaceCheeseItem {
|
||||
bool? cooperated;
|
||||
String? cooperationMark;
|
||||
String? cover;
|
||||
int? epCount;
|
||||
String? link;
|
||||
List<String>? marks;
|
||||
int? page;
|
||||
int? play;
|
||||
int? seasonId;
|
||||
String? status;
|
||||
String? subtitle;
|
||||
String? title;
|
||||
String? ctime;
|
||||
|
||||
SpaceCheeseItem({
|
||||
this.cooperated,
|
||||
this.cooperationMark,
|
||||
this.cover,
|
||||
this.epCount,
|
||||
this.link,
|
||||
this.marks,
|
||||
this.page,
|
||||
this.play,
|
||||
this.seasonId,
|
||||
this.status,
|
||||
this.subtitle,
|
||||
this.title,
|
||||
this.ctime,
|
||||
});
|
||||
|
||||
factory SpaceCheeseItem.fromJson(Map<String, dynamic> json) =>
|
||||
SpaceCheeseItem(
|
||||
cooperated: json['cooperated'] as bool?,
|
||||
cooperationMark: json['cooperation_mark'] as String?,
|
||||
cover: json['cover'] as String?,
|
||||
epCount: json['ep_count'] as int?,
|
||||
link: json['link'] as String?,
|
||||
marks: (json['marks'] as List?)?.cast(),
|
||||
page: json['page'] as int?,
|
||||
play: json['play'] as int?,
|
||||
seasonId: json['season_id'] as int?,
|
||||
status: json['status'] as String?,
|
||||
subtitle: json['subtitle'] as String?,
|
||||
title: json['title'] as String?,
|
||||
ctime: json['ctime'] as String?,
|
||||
);
|
||||
}
|
||||
16
lib/models_new/space/space_cheese/page.dart
Normal file
16
lib/models_new/space/space_cheese/page.dart
Normal file
@@ -0,0 +1,16 @@
|
||||
class SpaceCheesePage {
|
||||
bool? next;
|
||||
int? num;
|
||||
int? size;
|
||||
int? total;
|
||||
|
||||
SpaceCheesePage({this.next, this.num, this.size, this.total});
|
||||
|
||||
factory SpaceCheesePage.fromJson(Map<String, dynamic> json) =>
|
||||
SpaceCheesePage(
|
||||
next: json['next'] as bool?,
|
||||
num: json['num'] as int?,
|
||||
size: json['size'] as int?,
|
||||
total: json['total'] as int?,
|
||||
);
|
||||
}
|
||||
@@ -81,10 +81,10 @@ mixin DeleteItemMixin<R, T extends MultiSelectData>
|
||||
} else {
|
||||
list.removeWhere(removeList.contains);
|
||||
}
|
||||
if (!isEnd) {
|
||||
onReload();
|
||||
} else {
|
||||
if (list.isNotEmpty || isEnd) {
|
||||
loadingState.refresh();
|
||||
} else {
|
||||
onReload();
|
||||
}
|
||||
if (enableMultiSelect.value) {
|
||||
rxCount.value = 0;
|
||||
|
||||
@@ -10,11 +10,11 @@ import 'package:PiliPlus/http/loading_state.dart';
|
||||
import 'package:PiliPlus/models_new/dynamic/dyn_mention/group.dart';
|
||||
import 'package:PiliPlus/pages/dynamics_mention/controller.dart';
|
||||
import 'package:PiliPlus/pages/dynamics_mention/widgets/item.dart';
|
||||
import 'package:PiliPlus/pages/search/controller.dart';
|
||||
import 'package:PiliPlus/utils/context_ext.dart';
|
||||
import 'package:PiliPlus/utils/extension.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart' hide ContextExtensionss;
|
||||
import 'package:stream_transform/stream_transform.dart';
|
||||
|
||||
class DynMentionPanel extends StatefulWidget {
|
||||
const DynMentionPanel({
|
||||
@@ -58,10 +58,11 @@ class DynMentionPanel extends StatefulWidget {
|
||||
State<DynMentionPanel> createState() => _DynMentionPanelState();
|
||||
}
|
||||
|
||||
class _DynMentionPanelState extends State<DynMentionPanel> {
|
||||
class _DynMentionPanelState extends State<DynMentionPanel>
|
||||
with SearchKeywordMixin {
|
||||
final _controller = Get.put(DynMentionController());
|
||||
final StreamController<String> _ctr = StreamController<String>();
|
||||
late StreamSubscription<String> _sub;
|
||||
@override
|
||||
Duration get duration => const Duration(milliseconds: 300);
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
@@ -69,25 +70,24 @@ class _DynMentionPanelState extends State<DynMentionPanel> {
|
||||
if (_controller.loadingState.value is Error) {
|
||||
_controller.onReload();
|
||||
}
|
||||
_sub = _ctr.stream
|
||||
.debounce(const Duration(milliseconds: 300), trailing: true)
|
||||
.listen((value) {
|
||||
_controller
|
||||
subInit();
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
subDispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
ValueChanged<String> get onKeywordChanged =>
|
||||
(value) => _controller
|
||||
..enableClear.value = value.isNotEmpty
|
||||
..onRefresh().whenComplete(
|
||||
() => WidgetsBinding.instance.addPostFrameCallback(
|
||||
(_) => widget.scrollController?.jumpToTop(),
|
||||
),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_sub.cancel();
|
||||
_ctr.close();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@@ -114,7 +114,7 @@ class _DynMentionPanelState extends State<DynMentionPanel> {
|
||||
child: TextField(
|
||||
focusNode: _controller.focusNode,
|
||||
controller: _controller.controller,
|
||||
onChanged: _ctr.add,
|
||||
onChanged: ctr!.add,
|
||||
decoration: InputDecoration(
|
||||
border: const OutlineInputBorder(
|
||||
gapPadding: 0,
|
||||
|
||||
@@ -8,11 +8,11 @@ import 'package:PiliPlus/http/loading_state.dart';
|
||||
import 'package:PiliPlus/models_new/dynamic/dyn_topic_top/topic_item.dart';
|
||||
import 'package:PiliPlus/pages/dynamics_select_topic/controller.dart';
|
||||
import 'package:PiliPlus/pages/dynamics_select_topic/widgets/item.dart';
|
||||
import 'package:PiliPlus/pages/search/controller.dart';
|
||||
import 'package:PiliPlus/utils/context_ext.dart';
|
||||
import 'package:PiliPlus/utils/extension.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart' hide ContextExtensionss;
|
||||
import 'package:stream_transform/stream_transform.dart';
|
||||
|
||||
class SelectTopicPanel extends StatefulWidget {
|
||||
const SelectTopicPanel({
|
||||
@@ -56,10 +56,11 @@ class SelectTopicPanel extends StatefulWidget {
|
||||
State<SelectTopicPanel> createState() => _SelectTopicPanelState();
|
||||
}
|
||||
|
||||
class _SelectTopicPanelState extends State<SelectTopicPanel> {
|
||||
class _SelectTopicPanelState extends State<SelectTopicPanel>
|
||||
with SearchKeywordMixin {
|
||||
final _controller = Get.put(SelectTopicController());
|
||||
final StreamController<String> _ctr = StreamController<String>();
|
||||
late StreamSubscription<String> _sub;
|
||||
@override
|
||||
Duration get duration => const Duration(milliseconds: 300);
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
@@ -67,25 +68,24 @@ class _SelectTopicPanelState extends State<SelectTopicPanel> {
|
||||
if (_controller.loadingState.value is Error) {
|
||||
_controller.onReload();
|
||||
}
|
||||
_sub = _ctr.stream
|
||||
.debounce(const Duration(milliseconds: 300), trailing: true)
|
||||
.listen((value) {
|
||||
_controller
|
||||
subInit();
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
subDispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
ValueChanged<String> get onKeywordChanged =>
|
||||
(value) => _controller
|
||||
..enableClear.value = value.isNotEmpty
|
||||
..onRefresh().whenComplete(
|
||||
() => WidgetsBinding.instance.addPostFrameCallback(
|
||||
(_) => widget.scrollController?.jumpToTop(),
|
||||
),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_sub.cancel();
|
||||
_ctr.close();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@@ -110,7 +110,7 @@ class _SelectTopicPanelState extends State<SelectTopicPanel> {
|
||||
child: TextField(
|
||||
focusNode: _controller.focusNode,
|
||||
controller: _controller.controller,
|
||||
onChanged: _ctr.add,
|
||||
onChanged: ctr!.add,
|
||||
decoration: InputDecoration(
|
||||
border: const OutlineInputBorder(
|
||||
gapPadding: 0,
|
||||
|
||||
40
lib/pages/fav/cheese/controller.dart
Normal file
40
lib/pages/fav/cheese/controller.dart
Normal file
@@ -0,0 +1,40 @@
|
||||
import 'package:PiliPlus/http/fav.dart';
|
||||
import 'package:PiliPlus/http/loading_state.dart';
|
||||
import 'package:PiliPlus/models_new/space/space_cheese/data.dart';
|
||||
import 'package:PiliPlus/models_new/space/space_cheese/item.dart';
|
||||
import 'package:PiliPlus/pages/common/common_list_controller.dart';
|
||||
import 'package:PiliPlus/utils/accounts.dart';
|
||||
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
||||
|
||||
class FavCheeseController
|
||||
extends CommonListController<SpaceCheeseData, SpaceCheeseItem> {
|
||||
final mid = Accounts.main.mid;
|
||||
|
||||
@override
|
||||
void onInit() {
|
||||
super.onInit();
|
||||
queryData();
|
||||
}
|
||||
|
||||
@override
|
||||
List<SpaceCheeseItem>? getDataList(SpaceCheeseData response) {
|
||||
isEnd = response.page?.next == false;
|
||||
return response.items;
|
||||
}
|
||||
|
||||
@override
|
||||
Future<LoadingState<SpaceCheeseData>> customGetData() =>
|
||||
FavHttp.favPugv(mid: mid, page: page);
|
||||
|
||||
Future<void> onRemove(int index, int? sid) async {
|
||||
var res = await FavHttp.delFavPugv(sid);
|
||||
if (res['status']) {
|
||||
loadingState
|
||||
..value.data!.removeAt(index)
|
||||
..refresh();
|
||||
SmartDialog.showToast('已取消收藏');
|
||||
} else {
|
||||
SmartDialog.showToast(res['msg']);
|
||||
}
|
||||
}
|
||||
}
|
||||
87
lib/pages/fav/cheese/view.dart
Normal file
87
lib/pages/fav/cheese/view.dart
Normal file
@@ -0,0 +1,87 @@
|
||||
import 'package:PiliPlus/common/widgets/dialog/dialog.dart';
|
||||
import 'package:PiliPlus/common/widgets/loading_widget/http_error.dart';
|
||||
import 'package:PiliPlus/common/widgets/loading_widget/loading_widget.dart';
|
||||
import 'package:PiliPlus/common/widgets/refresh_indicator.dart';
|
||||
import 'package:PiliPlus/http/loading_state.dart';
|
||||
import 'package:PiliPlus/models_new/space/space_cheese/item.dart';
|
||||
import 'package:PiliPlus/pages/fav/cheese/controller.dart';
|
||||
import 'package:PiliPlus/pages/member_cheese/widgets/item.dart';
|
||||
import 'package:PiliPlus/utils/grid.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
class FavCheesePage extends StatefulWidget {
|
||||
const FavCheesePage({super.key});
|
||||
|
||||
@override
|
||||
State<FavCheesePage> createState() => _FavCheesePageState();
|
||||
}
|
||||
|
||||
class _FavCheesePageState extends State<FavCheesePage>
|
||||
with AutomaticKeepAliveClientMixin {
|
||||
final FavCheeseController _controller = Get.put(FavCheeseController());
|
||||
|
||||
@override
|
||||
bool get wantKeepAlive => true;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
super.build(context);
|
||||
final ThemeData theme = Theme.of(context);
|
||||
return refreshIndicator(
|
||||
onRefresh: _controller.onRefresh,
|
||||
child: CustomScrollView(
|
||||
controller: _controller.scrollController,
|
||||
physics: const AlwaysScrollableScrollPhysics(),
|
||||
slivers: [
|
||||
SliverPadding(
|
||||
padding: EdgeInsets.only(
|
||||
top: 7,
|
||||
bottom: MediaQuery.paddingOf(context).bottom + 80,
|
||||
),
|
||||
sliver: Obx(
|
||||
() => _buildBody(theme, _controller.loadingState.value),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildBody(
|
||||
ThemeData theme,
|
||||
LoadingState<List<SpaceCheeseItem>?> loadingState,
|
||||
) {
|
||||
return switch (loadingState) {
|
||||
Loading() => linearLoading,
|
||||
Success(:var response) =>
|
||||
response?.isNotEmpty == true
|
||||
? SliverGrid(
|
||||
gridDelegate: Grid.videoCardHDelegate(context),
|
||||
delegate: SliverChildBuilderDelegate(
|
||||
(context, index) {
|
||||
if (index == response.length - 1) {
|
||||
_controller.onLoadMore();
|
||||
}
|
||||
final item = response[index];
|
||||
return MemberCheeseItem(
|
||||
item: item,
|
||||
onRemove: () => showConfirmDialog(
|
||||
context: context,
|
||||
title: '确定取消收藏该课堂?',
|
||||
onConfirm: () =>
|
||||
_controller.onRemove(index, item.seasonId),
|
||||
),
|
||||
);
|
||||
},
|
||||
childCount: response!.length,
|
||||
),
|
||||
)
|
||||
: HttpError(onReload: _controller.onReload),
|
||||
Error(:var errMsg) => HttpError(
|
||||
errMsg: errMsg,
|
||||
onReload: _controller.onReload,
|
||||
),
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,7 @@ import 'package:PiliPlus/http/loading_state.dart';
|
||||
import 'package:PiliPlus/models/common/fav_type.dart';
|
||||
import 'package:PiliPlus/models_new/fav/fav_folder/list.dart';
|
||||
import 'package:PiliPlus/pages/fav/article/controller.dart';
|
||||
import 'package:PiliPlus/pages/fav/cheese/controller.dart';
|
||||
import 'package:PiliPlus/pages/fav/topic/controller.dart';
|
||||
import 'package:PiliPlus/pages/fav/video/controller.dart';
|
||||
import 'package:PiliPlus/pages/fav_folder_sort/view.dart';
|
||||
@@ -141,6 +142,9 @@ class _FavPageState extends State<FavPage> with SingleTickerProviderStateMixin {
|
||||
.animToTop();
|
||||
case FavTabType.topic:
|
||||
Get.find<FavTopicController>().scrollController.animToTop();
|
||||
case FavTabType.cheese:
|
||||
Get.find<FavCheeseController>().scrollController
|
||||
.animToTop();
|
||||
default:
|
||||
}
|
||||
}
|
||||
|
||||
@@ -182,6 +182,7 @@ class VideoCardHLater extends StatelessWidget {
|
||||
);
|
||||
return Expanded(
|
||||
child: Stack(
|
||||
clipBehavior: Clip.none,
|
||||
children: [
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
@@ -249,7 +250,7 @@ class VideoCardHLater extends StatelessWidget {
|
||||
),
|
||||
Positioned(
|
||||
right: 0,
|
||||
bottom: 0,
|
||||
bottom: -8,
|
||||
child: iconButton(
|
||||
tooltip: '移除',
|
||||
context: context,
|
||||
|
||||
@@ -41,13 +41,6 @@ class MemberController extends CommonDataController<SpaceData, SpaceData?>
|
||||
late List<Tab> tabs;
|
||||
TabController? tabController;
|
||||
RxInt contributeInitialIndex = 0.obs;
|
||||
late final implTabs = const [
|
||||
'home',
|
||||
'dynamic',
|
||||
'contribute',
|
||||
'favorite',
|
||||
'bangumi',
|
||||
];
|
||||
|
||||
bool? hasSeasonOrSeries;
|
||||
|
||||
@@ -83,7 +76,7 @@ class MemberController extends CommonDataController<SpaceData, SpaceData?>
|
||||
data.series?.item?.isNotEmpty == true) {
|
||||
hasSeasonOrSeries = true;
|
||||
}
|
||||
tab2?.retainWhere((item) => implTabs.contains(item.param));
|
||||
tab2?.retainWhere((item) => MemberTabType.contains(item.param!));
|
||||
if (tab2?.isNotEmpty == true) {
|
||||
if (data.hasItem != true && tab2!.first.param == 'home') {
|
||||
// remove empty home tab
|
||||
|
||||
@@ -9,6 +9,7 @@ import 'package:PiliPlus/pages/exp_log/view.dart';
|
||||
import 'package:PiliPlus/pages/login_log/view.dart';
|
||||
import 'package:PiliPlus/pages/member/controller.dart';
|
||||
import 'package:PiliPlus/pages/member/widget/user_info_card.dart';
|
||||
import 'package:PiliPlus/pages/member_cheese/view.dart';
|
||||
import 'package:PiliPlus/pages/member_contribute/view.dart';
|
||||
import 'package:PiliPlus/pages/member_dynamics/view.dart';
|
||||
import 'package:PiliPlus/pages/member_favorite/view.dart';
|
||||
@@ -325,6 +326,10 @@ class _MemberPageState extends State<MemberPage> {
|
||||
heroTag: _heroTag,
|
||||
mid: _mid,
|
||||
),
|
||||
'cheese' => MemberCheese(
|
||||
heroTag: _heroTag,
|
||||
mid: _mid,
|
||||
),
|
||||
_ => Center(child: Text(item.title ?? '')),
|
||||
};
|
||||
}).toList(),
|
||||
|
||||
31
lib/pages/member_cheese/controller.dart
Normal file
31
lib/pages/member_cheese/controller.dart
Normal file
@@ -0,0 +1,31 @@
|
||||
import 'package:PiliPlus/http/loading_state.dart';
|
||||
import 'package:PiliPlus/http/member.dart';
|
||||
import 'package:PiliPlus/models_new/space/space_cheese/data.dart';
|
||||
import 'package:PiliPlus/models_new/space/space_cheese/item.dart';
|
||||
import 'package:PiliPlus/pages/common/common_list_controller.dart';
|
||||
|
||||
class MemberCheeseController
|
||||
extends CommonListController<SpaceCheeseData, SpaceCheeseItem> {
|
||||
MemberCheeseController(this.mid);
|
||||
|
||||
final int mid;
|
||||
|
||||
@override
|
||||
void onInit() {
|
||||
super.onInit();
|
||||
queryData();
|
||||
}
|
||||
|
||||
@override
|
||||
List<SpaceCheeseItem>? getDataList(SpaceCheeseData response) {
|
||||
isEnd = response.page?.next == false;
|
||||
return response.items;
|
||||
}
|
||||
|
||||
@override
|
||||
Future<LoadingState<SpaceCheeseData>> customGetData() =>
|
||||
MemberHttp.spaceCheese(
|
||||
page: page,
|
||||
mid: mid,
|
||||
);
|
||||
}
|
||||
80
lib/pages/member_cheese/view.dart
Normal file
80
lib/pages/member_cheese/view.dart
Normal file
@@ -0,0 +1,80 @@
|
||||
import 'package:PiliPlus/common/widgets/loading_widget/http_error.dart';
|
||||
import 'package:PiliPlus/common/widgets/loading_widget/loading_widget.dart';
|
||||
import 'package:PiliPlus/common/widgets/refresh_indicator.dart';
|
||||
import 'package:PiliPlus/http/loading_state.dart';
|
||||
import 'package:PiliPlus/models_new/space/space_cheese/item.dart';
|
||||
import 'package:PiliPlus/pages/member_cheese/controller.dart';
|
||||
import 'package:PiliPlus/pages/member_cheese/widgets/item.dart';
|
||||
import 'package:PiliPlus/utils/grid.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
class MemberCheese extends StatefulWidget {
|
||||
const MemberCheese({
|
||||
super.key,
|
||||
required this.heroTag,
|
||||
required this.mid,
|
||||
});
|
||||
|
||||
final String? heroTag;
|
||||
final int mid;
|
||||
|
||||
@override
|
||||
State<MemberCheese> createState() => _MemberCheeseState();
|
||||
}
|
||||
|
||||
class _MemberCheeseState extends State<MemberCheese>
|
||||
with AutomaticKeepAliveClientMixin {
|
||||
late final _controller = Get.put(
|
||||
MemberCheeseController(widget.mid),
|
||||
tag: widget.heroTag,
|
||||
);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
super.build(context);
|
||||
return refreshIndicator(
|
||||
onRefresh: _controller.onRefresh,
|
||||
child: CustomScrollView(
|
||||
physics: const AlwaysScrollableScrollPhysics(),
|
||||
slivers: [
|
||||
SliverPadding(
|
||||
padding: EdgeInsets.only(
|
||||
top: 7,
|
||||
bottom: MediaQuery.paddingOf(context).bottom + 80,
|
||||
),
|
||||
sliver: Obx(() => _buildBody(_controller.loadingState.value)),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
bool get wantKeepAlive => true;
|
||||
|
||||
Widget _buildBody(LoadingState<List<SpaceCheeseItem>?> loadingState) {
|
||||
return switch (loadingState) {
|
||||
Loading() => linearLoading,
|
||||
Success(:var response) =>
|
||||
response?.isNotEmpty == true
|
||||
? SliverGrid(
|
||||
gridDelegate: Grid.videoCardHDelegate(context),
|
||||
delegate: SliverChildBuilderDelegate(
|
||||
(context, index) {
|
||||
if (index == response.length - 1) {
|
||||
_controller.onLoadMore();
|
||||
}
|
||||
return MemberCheeseItem(item: response[index]);
|
||||
},
|
||||
childCount: response!.length,
|
||||
),
|
||||
)
|
||||
: HttpError(onReload: _controller.onReload),
|
||||
Error(:var errMsg) => HttpError(
|
||||
errMsg: errMsg,
|
||||
onReload: _controller.onReload,
|
||||
),
|
||||
};
|
||||
}
|
||||
}
|
||||
124
lib/pages/member_cheese/widgets/item.dart
Normal file
124
lib/pages/member_cheese/widgets/item.dart
Normal file
@@ -0,0 +1,124 @@
|
||||
import 'package:PiliPlus/common/constants.dart';
|
||||
import 'package:PiliPlus/common/widgets/badge.dart';
|
||||
import 'package:PiliPlus/common/widgets/button/icon_button.dart';
|
||||
import 'package:PiliPlus/common/widgets/image/image_save.dart';
|
||||
import 'package:PiliPlus/common/widgets/image/network_img_layer.dart';
|
||||
import 'package:PiliPlus/models_new/space/space_cheese/item.dart';
|
||||
import 'package:PiliPlus/utils/date_util.dart';
|
||||
import 'package:PiliPlus/utils/page_utils.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class MemberCheeseItem extends StatelessWidget {
|
||||
const MemberCheeseItem({
|
||||
super.key,
|
||||
required this.item,
|
||||
this.onRemove,
|
||||
});
|
||||
|
||||
final SpaceCheeseItem item;
|
||||
final VoidCallback? onRemove;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final theme = Theme.of(context);
|
||||
Widget child = Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
item.title!,
|
||||
maxLines: 2,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
if (item.status != null) ...[
|
||||
const SizedBox(height: 6),
|
||||
Text(
|
||||
item.status!,
|
||||
style: TextStyle(
|
||||
fontSize: 13,
|
||||
color: theme.colorScheme.onSurfaceVariant,
|
||||
),
|
||||
),
|
||||
],
|
||||
if (item.ctime != null) ...[
|
||||
const Spacer(),
|
||||
Text(
|
||||
'收藏于${DateUtil.dateFormat(int.parse(item.ctime!))}',
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
color: theme.colorScheme.outline,
|
||||
),
|
||||
),
|
||||
],
|
||||
],
|
||||
);
|
||||
if (onRemove != null) {
|
||||
child = Stack(
|
||||
clipBehavior: Clip.none,
|
||||
children: [
|
||||
child,
|
||||
Positioned(
|
||||
right: 0,
|
||||
bottom: -8,
|
||||
child: iconButton(
|
||||
tooltip: '移除',
|
||||
context: context,
|
||||
onPressed: onRemove,
|
||||
icon: Icons.clear,
|
||||
iconColor: theme.colorScheme.outline,
|
||||
bgColor: Colors.transparent,
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
return Material(
|
||||
type: MaterialType.transparency,
|
||||
child: InkWell(
|
||||
onTap: () => PageUtils.viewPugv(seasonId: item.seasonId),
|
||||
onLongPress: () =>
|
||||
imageSaveDialog(title: item.title, cover: item.cover),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: StyleString.safeSpace,
|
||||
vertical: 5,
|
||||
),
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
AspectRatio(
|
||||
aspectRatio: StyleString.aspectRatio,
|
||||
child: LayoutBuilder(
|
||||
builder: (context, boxConstraints) {
|
||||
Widget child = NetworkImgLayer(
|
||||
radius: 4,
|
||||
src: item.cover,
|
||||
width: boxConstraints.maxWidth,
|
||||
height: boxConstraints.maxHeight,
|
||||
);
|
||||
if (item.marks?.isNotEmpty == true) {
|
||||
return Stack(
|
||||
clipBehavior: Clip.none,
|
||||
children: [
|
||||
child,
|
||||
PBadge(
|
||||
right: 6,
|
||||
top: 6,
|
||||
text: item.marks!.join('|'),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
return child;
|
||||
},
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 10),
|
||||
Expanded(child: child),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -14,7 +14,26 @@ import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:stream_transform/stream_transform.dart';
|
||||
|
||||
class SSearchController extends GetxController {
|
||||
mixin SearchKeywordMixin {
|
||||
Duration duration = const Duration(milliseconds: 200);
|
||||
StreamController<String>? ctr;
|
||||
StreamSubscription<String>? sub;
|
||||
ValueChanged<String> get onKeywordChanged;
|
||||
|
||||
void subInit() {
|
||||
ctr = StreamController<String>();
|
||||
sub = ctr!.stream
|
||||
.debounce(duration, trailing: true)
|
||||
.listen(onKeywordChanged);
|
||||
}
|
||||
|
||||
void subDispose() {
|
||||
sub?.cancel();
|
||||
ctr?.close();
|
||||
}
|
||||
}
|
||||
|
||||
class SSearchController extends GetxController with SearchKeywordMixin {
|
||||
SSearchController(this.tag);
|
||||
final String tag;
|
||||
|
||||
@@ -34,8 +53,7 @@ class SSearchController extends GetxController {
|
||||
|
||||
// suggestion
|
||||
final bool searchSuggestion = Pref.searchSuggestion;
|
||||
StreamController<String>? _ctr;
|
||||
StreamSubscription<String>? _sub;
|
||||
|
||||
late final RxList<SearchSuggestItem> searchSuggestList;
|
||||
|
||||
// trending
|
||||
@@ -61,10 +79,7 @@ class SSearchController extends GetxController {
|
||||
).obs;
|
||||
|
||||
if (searchSuggestion) {
|
||||
_ctr = StreamController<String>();
|
||||
_sub = _ctr!.stream
|
||||
.debounce(const Duration(milliseconds: 200), trailing: true)
|
||||
.listen(querySearchSuggest);
|
||||
subInit();
|
||||
searchSuggestList = <SearchSuggestItem>[].obs;
|
||||
}
|
||||
|
||||
@@ -89,7 +104,7 @@ class SSearchController extends GetxController {
|
||||
if (value.isEmpty) {
|
||||
searchSuggestList.clear();
|
||||
} else {
|
||||
_ctr!.add(value);
|
||||
ctr!.add(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -154,7 +169,8 @@ class SSearchController extends GetxController {
|
||||
submit();
|
||||
}
|
||||
|
||||
Future<void> querySearchSuggest(String value) async {
|
||||
@override
|
||||
ValueChanged<String> get onKeywordChanged => (String value) async {
|
||||
var res = await SearchHttp.searchSuggest(term: value);
|
||||
if (res['status']) {
|
||||
SearchSuggestModel data = res['data'];
|
||||
@@ -162,7 +178,7 @@ class SSearchController extends GetxController {
|
||||
searchSuggestList.value = data.tag!;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
void onLongSelect(String word) {
|
||||
historyList.remove(word);
|
||||
@@ -182,10 +198,9 @@ class SSearchController extends GetxController {
|
||||
|
||||
@override
|
||||
void onClose() {
|
||||
subDispose();
|
||||
searchFocusNode.dispose();
|
||||
controller.dispose();
|
||||
_sub?.cancel();
|
||||
_ctr?.close();
|
||||
super.onClose();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,12 +42,12 @@ class SearchAllController
|
||||
Future<LoadingState<SearchAllData>> customGetData() => SearchHttp.searchAll(
|
||||
keyword: keyword,
|
||||
page: page,
|
||||
order: order.value,
|
||||
duration: searchType == SearchType.video ? duration.value : null,
|
||||
tids: tids,
|
||||
orderSort: orderSort,
|
||||
userType: userType,
|
||||
categoryId: categoryId,
|
||||
order: order,
|
||||
duration: null,
|
||||
tids: videoZoneType?.tids,
|
||||
orderSort: userOrderType?.value.orderSort,
|
||||
userType: userType?.value.index,
|
||||
categoryId: articleZoneType?.value.categoryId,
|
||||
pubBegin: pubBegin,
|
||||
pubEnd: pubEnd,
|
||||
);
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import 'dart:math';
|
||||
|
||||
import 'package:PiliPlus/models/common/search/article_search_type.dart';
|
||||
import 'package:PiliPlus/models/search/result.dart';
|
||||
import 'package:PiliPlus/pages/search/widgets/search_text.dart';
|
||||
import 'package:PiliPlus/pages/search_panel/controller.dart';
|
||||
import 'package:PiliPlus/utils/context_ext.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
||||
import 'package:get/get.dart' hide ContextExtensionss;
|
||||
|
||||
class SearchArticleController
|
||||
@@ -19,6 +19,7 @@ class SearchArticleController
|
||||
@override
|
||||
void onInit() {
|
||||
super.onInit();
|
||||
articleZoneType = ArticleZoneType.all.obs;
|
||||
jump2Article();
|
||||
}
|
||||
|
||||
@@ -40,27 +41,7 @@ class SearchArticleController
|
||||
}
|
||||
}
|
||||
|
||||
// sort
|
||||
late final List orderFiltersList = [
|
||||
{'label': '综合排序', 'value': 0, 'order': 'totalrank'},
|
||||
{'label': '最新发布', 'value': 1, 'order': 'pubdate'},
|
||||
{'label': '最多点击', 'value': 2, 'order': 'click'},
|
||||
{'label': '最多喜欢', 'value': 3, 'order': 'attention'},
|
||||
{'label': '最多评论', 'value': 4, 'order': 'scores'},
|
||||
];
|
||||
late final List zoneFiltersList = [
|
||||
{'label': '全部分区', 'value': 0, 'categoryId': 0},
|
||||
{'label': '动画', 'value': 1, 'categoryId': 2},
|
||||
{'label': '游戏', 'value': 2, 'categoryId': 1},
|
||||
{'label': '影视', 'value': 3, 'categoryId': 28},
|
||||
{'label': '生活', 'value': 4, 'categoryId': 3},
|
||||
{'label': '兴趣', 'value': 5, 'categoryId': 29},
|
||||
{'label': '轻小说', 'value': 6, 'categoryId': 16},
|
||||
{'label': '科技', 'value': 7, 'categoryId': 17},
|
||||
{'label': '笔记', 'value': 8, 'categoryId': 41},
|
||||
];
|
||||
RxInt currentOrderFilterval = 0.obs;
|
||||
RxInt currentZoneFilterval = 0.obs;
|
||||
Rx<ArticleOrderType> articleOrderType = ArticleOrderType.totalrank.obs;
|
||||
|
||||
void onShowFilterDialog(BuildContext context) {
|
||||
showModalBottomSheet(
|
||||
@@ -91,30 +72,25 @@ class SearchArticleController
|
||||
Wrap(
|
||||
spacing: 8,
|
||||
runSpacing: 8,
|
||||
children: orderFiltersList
|
||||
.map(
|
||||
(item) => SearchText(
|
||||
text: item['label'],
|
||||
onTap: (_) async {
|
||||
Get.back();
|
||||
currentOrderFilterval.value = item['value'];
|
||||
SmartDialog.dismiss();
|
||||
SmartDialog.showToast("「${item['label']}」的筛选结果");
|
||||
order.value = item['order'];
|
||||
SmartDialog.showLoading(msg: 'loading');
|
||||
await onReload();
|
||||
SmartDialog.dismiss();
|
||||
children: ArticleOrderType.values.map(
|
||||
(e) {
|
||||
final isCurr = e == articleOrderType.value;
|
||||
return SearchText(
|
||||
text: e.label,
|
||||
onTap: (_) {
|
||||
articleOrderType.value = e;
|
||||
order = e.order;
|
||||
onSortSearch(label: e.label);
|
||||
},
|
||||
bgColor: item['value'] == currentOrderFilterval.value
|
||||
bgColor: isCurr
|
||||
? theme.colorScheme.secondaryContainer
|
||||
: null,
|
||||
textColor:
|
||||
item['value'] == currentOrderFilterval.value
|
||||
textColor: isCurr
|
||||
? theme.colorScheme.onSecondaryContainer
|
||||
: null,
|
||||
),
|
||||
)
|
||||
.toList(),
|
||||
);
|
||||
},
|
||||
).toList(),
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
const Text('分区', style: TextStyle(fontSize: 16)),
|
||||
@@ -122,29 +98,24 @@ class SearchArticleController
|
||||
Wrap(
|
||||
spacing: 8,
|
||||
runSpacing: 8,
|
||||
children: zoneFiltersList
|
||||
.map(
|
||||
(item) => SearchText(
|
||||
text: item['label'],
|
||||
onTap: (_) async {
|
||||
Get.back();
|
||||
currentZoneFilterval.value = item['value'];
|
||||
SmartDialog.dismiss();
|
||||
SmartDialog.showToast("「${item['label']}」的筛选结果");
|
||||
categoryId = item['categoryId'];
|
||||
SmartDialog.showLoading(msg: 'loading');
|
||||
await onReload();
|
||||
SmartDialog.dismiss();
|
||||
children: ArticleZoneType.values.map(
|
||||
(e) {
|
||||
final isCurr = e == articleZoneType!.value;
|
||||
return SearchText(
|
||||
text: e.label,
|
||||
onTap: (_) {
|
||||
articleZoneType!.value = e;
|
||||
onSortSearch(label: e.label);
|
||||
},
|
||||
bgColor: item['value'] == currentZoneFilterval.value
|
||||
bgColor: isCurr
|
||||
? theme.colorScheme.secondaryContainer
|
||||
: null,
|
||||
textColor: item['value'] == currentZoneFilterval.value
|
||||
textColor: isCurr
|
||||
? theme.colorScheme.onSecondaryContainer
|
||||
: null,
|
||||
),
|
||||
)
|
||||
.toList(),
|
||||
);
|
||||
},
|
||||
).toList(),
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
@@ -51,7 +51,7 @@ class _SearchArticlePanelState
|
||||
children: [
|
||||
Obx(
|
||||
() => Text(
|
||||
'排序: ${controller.orderFiltersList[controller.currentOrderFilterval.value]['label']}',
|
||||
'排序: ${controller.articleOrderType.value.label}',
|
||||
maxLines: 1,
|
||||
style: TextStyle(color: theme.colorScheme.outline),
|
||||
),
|
||||
@@ -59,7 +59,7 @@ class _SearchArticlePanelState
|
||||
const Spacer(),
|
||||
Obx(
|
||||
() => Text(
|
||||
'分区: ${controller.zoneFiltersList[controller.currentZoneFilterval.value]['label']}',
|
||||
'分区: ${controller.articleZoneType!.value.label}',
|
||||
maxLines: 1,
|
||||
style: TextStyle(color: theme.colorScheme.outline),
|
||||
),
|
||||
|
||||
@@ -1,10 +1,14 @@
|
||||
import 'package:PiliPlus/http/loading_state.dart';
|
||||
import 'package:PiliPlus/http/search.dart';
|
||||
import 'package:PiliPlus/models/common/search/article_search_type.dart';
|
||||
import 'package:PiliPlus/models/common/search/user_search_type.dart';
|
||||
import 'package:PiliPlus/models/common/search/video_search_type.dart';
|
||||
import 'package:PiliPlus/models/common/search_type.dart';
|
||||
import 'package:PiliPlus/models/search/result.dart';
|
||||
import 'package:PiliPlus/pages/common/common_list_controller.dart';
|
||||
import 'package:PiliPlus/pages/search_result/controller.dart';
|
||||
import 'package:PiliPlus/utils/extension.dart';
|
||||
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
class SearchPanelController<R extends SearchNumData<T>, T>
|
||||
@@ -19,17 +23,37 @@ class SearchPanelController<R extends SearchNumData<T>, T>
|
||||
final SearchType searchType;
|
||||
|
||||
// sort
|
||||
final RxString order = ''.obs;
|
||||
late final RxInt duration = 0.obs;
|
||||
int? tids;
|
||||
int? orderSort;
|
||||
int? userType;
|
||||
int? categoryId;
|
||||
// common
|
||||
String order = '';
|
||||
|
||||
// video
|
||||
VideoDurationType? videoDurationType; // int duration
|
||||
VideoZoneType? videoZoneType; // int? tids;
|
||||
int? pubBegin;
|
||||
int? pubEnd;
|
||||
|
||||
// user
|
||||
Rx<UserOrderType>? userOrderType;
|
||||
Rx<UserType>? userType;
|
||||
|
||||
// article
|
||||
Rx<ArticleZoneType>? articleZoneType; // int? categoryId;
|
||||
|
||||
SearchResultController? searchResultController;
|
||||
|
||||
void onSortSearch({
|
||||
bool getBack = true,
|
||||
String? label,
|
||||
}) {
|
||||
if (getBack) Get.back();
|
||||
SmartDialog.dismiss();
|
||||
if (label != null) {
|
||||
SmartDialog.showToast("「$label」的筛选结果");
|
||||
}
|
||||
SmartDialog.showLoading(msg: 'loading');
|
||||
onReload().whenComplete(SmartDialog.dismiss);
|
||||
}
|
||||
|
||||
@override
|
||||
void onInit() {
|
||||
super.onInit();
|
||||
@@ -55,12 +79,12 @@ class SearchPanelController<R extends SearchNumData<T>, T>
|
||||
searchType: searchType,
|
||||
keyword: keyword,
|
||||
page: page,
|
||||
order: order.value,
|
||||
duration: searchType == SearchType.video ? duration.value : null,
|
||||
tids: tids,
|
||||
orderSort: orderSort,
|
||||
userType: userType,
|
||||
categoryId: categoryId,
|
||||
order: order,
|
||||
duration: videoDurationType?.index,
|
||||
tids: videoZoneType?.tids,
|
||||
orderSort: userOrderType?.value.orderSort,
|
||||
userType: userType?.value.index,
|
||||
categoryId: articleZoneType?.value.categoryId,
|
||||
pubBegin: pubBegin,
|
||||
pubEnd: pubEnd,
|
||||
);
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import 'dart:math';
|
||||
|
||||
import 'package:PiliPlus/models/common/search/user_search_type.dart';
|
||||
import 'package:PiliPlus/models/search/result.dart';
|
||||
import 'package:PiliPlus/pages/search/widgets/search_text.dart';
|
||||
import 'package:PiliPlus/pages/search_panel/controller.dart';
|
||||
import 'package:PiliPlus/utils/context_ext.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
||||
import 'package:get/get.dart' hide ContextExtensionss;
|
||||
|
||||
class SearchUserController
|
||||
@@ -16,22 +16,12 @@ class SearchUserController
|
||||
required super.tag,
|
||||
});
|
||||
|
||||
// sort
|
||||
late final List orderFiltersList = [
|
||||
{'label': '默认排序', 'value': 0, 'orderSort': 0, 'order': ''},
|
||||
{'label': '粉丝数由高到低', 'value': 1, 'orderSort': 0, 'order': 'fans'},
|
||||
{'label': '粉丝数由低到高', 'value': 2, 'orderSort': 1, 'order': 'fans'},
|
||||
{'label': 'Lv等级由高到低', 'value': 3, 'orderSort': 0, 'order': 'level'},
|
||||
{'label': 'Lv等级由低到高', 'value': 4, 'orderSort': 1, 'order': 'level'},
|
||||
];
|
||||
late final List userTypeFiltersList = [
|
||||
{'label': '全部用户', 'value': 0, 'userType': 0},
|
||||
{'label': 'UP主', 'value': 1, 'userType': 1},
|
||||
{'label': '普通用户', 'value': 2, 'userType': 2},
|
||||
{'label': '认证用户', 'value': 3, 'userType': 3},
|
||||
];
|
||||
RxInt currentOrderFilterval = 0.obs;
|
||||
RxInt currentUserTypeFilterval = 0.obs;
|
||||
@override
|
||||
void onInit() {
|
||||
super.onInit();
|
||||
userType = UserType.all.obs;
|
||||
userOrderType = UserOrderType.def.obs;
|
||||
}
|
||||
|
||||
void onShowFilterDialog(BuildContext context) {
|
||||
showModalBottomSheet(
|
||||
@@ -62,31 +52,25 @@ class SearchUserController
|
||||
Wrap(
|
||||
spacing: 8,
|
||||
runSpacing: 8,
|
||||
children: orderFiltersList
|
||||
.map(
|
||||
(item) => SearchText(
|
||||
text: item['label'],
|
||||
onTap: (_) async {
|
||||
Get.back();
|
||||
currentOrderFilterval.value = item['value'];
|
||||
SmartDialog.dismiss();
|
||||
SmartDialog.showToast("「${item['label']}」的筛选结果");
|
||||
orderSort = item['orderSort'];
|
||||
order.value = item['order'];
|
||||
SmartDialog.showLoading(msg: 'loading');
|
||||
await onReload();
|
||||
SmartDialog.dismiss();
|
||||
children: UserOrderType.values.map(
|
||||
(e) {
|
||||
final isCurr = e == userOrderType!.value;
|
||||
return SearchText(
|
||||
text: e.label,
|
||||
onTap: (_) {
|
||||
userOrderType!.value = e;
|
||||
order = e.order;
|
||||
onSortSearch(label: e.label);
|
||||
},
|
||||
bgColor: item['value'] == currentOrderFilterval.value
|
||||
bgColor: isCurr
|
||||
? theme.colorScheme.secondaryContainer
|
||||
: null,
|
||||
textColor:
|
||||
item['value'] == currentOrderFilterval.value
|
||||
textColor: isCurr
|
||||
? theme.colorScheme.onSecondaryContainer
|
||||
: null,
|
||||
),
|
||||
)
|
||||
.toList(),
|
||||
);
|
||||
},
|
||||
).toList(),
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
const Text('用户分类', style: TextStyle(fontSize: 16)),
|
||||
@@ -94,31 +78,24 @@ class SearchUserController
|
||||
Wrap(
|
||||
spacing: 8,
|
||||
runSpacing: 8,
|
||||
children: userTypeFiltersList
|
||||
.map(
|
||||
(item) => SearchText(
|
||||
text: item['label'],
|
||||
onTap: (_) async {
|
||||
Get.back();
|
||||
currentUserTypeFilterval.value = item['value'];
|
||||
SmartDialog.dismiss();
|
||||
SmartDialog.showToast("「${item['label']}」的筛选结果");
|
||||
userType = item['userType'];
|
||||
SmartDialog.showLoading(msg: 'loading');
|
||||
await onReload();
|
||||
SmartDialog.dismiss();
|
||||
children: UserType.values.map(
|
||||
(e) {
|
||||
final isCurr = e == userType!.value;
|
||||
return SearchText(
|
||||
text: e.label,
|
||||
onTap: (_) {
|
||||
userType!.value = e;
|
||||
onSortSearch(label: e.label);
|
||||
},
|
||||
bgColor:
|
||||
item['value'] == currentUserTypeFilterval.value
|
||||
bgColor: isCurr
|
||||
? theme.colorScheme.secondaryContainer
|
||||
: null,
|
||||
textColor:
|
||||
item['value'] == currentUserTypeFilterval.value
|
||||
textColor: isCurr
|
||||
? theme.colorScheme.onSecondaryContainer
|
||||
: null,
|
||||
),
|
||||
)
|
||||
.toList(),
|
||||
);
|
||||
},
|
||||
).toList(),
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
@@ -51,7 +51,7 @@ class _SearchUserPanelState
|
||||
children: [
|
||||
Obx(
|
||||
() => Text(
|
||||
'排序: ${controller.orderFiltersList[controller.currentOrderFilterval.value]['label']}',
|
||||
'排序: ${controller.userOrderType!.value.label}',
|
||||
maxLines: 1,
|
||||
style: TextStyle(color: theme.colorScheme.outline),
|
||||
),
|
||||
@@ -59,7 +59,7 @@ class _SearchUserPanelState
|
||||
const Spacer(),
|
||||
Obx(
|
||||
() => Text(
|
||||
'用户类型: ${controller.userTypeFiltersList[controller.currentUserTypeFilterval.value]['label']}',
|
||||
'用户类型: ${controller.userType!.value.label}',
|
||||
maxLines: 1,
|
||||
style: TextStyle(color: theme.colorScheme.outline),
|
||||
),
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import 'dart:math';
|
||||
|
||||
import 'package:PiliPlus/http/loading_state.dart';
|
||||
import 'package:PiliPlus/models/common/search/video_search_type.dart';
|
||||
import 'package:PiliPlus/models/common/search_type.dart';
|
||||
import 'package:PiliPlus/models/search/result.dart';
|
||||
import 'package:PiliPlus/pages/search/widgets/search_text.dart';
|
||||
@@ -26,23 +27,11 @@ class SearchVideoController
|
||||
@override
|
||||
void onInit() {
|
||||
super.onInit();
|
||||
videoDurationType = VideoDurationType.all;
|
||||
videoZoneType = VideoZoneType.all;
|
||||
DateTime now = DateTime.now();
|
||||
pubBeginDate = DateTime(
|
||||
now.year,
|
||||
now.month,
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
);
|
||||
pubEndDate = DateTime(
|
||||
now.year,
|
||||
now.month,
|
||||
now.day,
|
||||
23,
|
||||
59,
|
||||
59,
|
||||
);
|
||||
pubBeginDate = DateTime(now.year, now.month, 1, 0, 0, 0);
|
||||
pubEndDate = DateTime(now.year, now.month, now.day, 23, 59, 59);
|
||||
|
||||
jump2Video();
|
||||
}
|
||||
@@ -86,61 +75,12 @@ class SearchVideoController
|
||||
}
|
||||
}
|
||||
|
||||
// sort
|
||||
late final List<Map> filterList = ArchiveFilterType.values
|
||||
.map(
|
||||
(type) => {
|
||||
'label': type.desc,
|
||||
'type': type,
|
||||
},
|
||||
)
|
||||
.toList();
|
||||
late final Rx<ArchiveFilterType> selectedType =
|
||||
ArchiveFilterType.values.first.obs;
|
||||
late final List pubTimeFiltersList = [
|
||||
{'label': '不限', 'value': 0},
|
||||
{'label': '最近一天', 'value': 1},
|
||||
{'label': '最近一周', 'value': 2},
|
||||
{'label': '最近半年', 'value': 3},
|
||||
];
|
||||
late final List timeFiltersList = [
|
||||
{'label': '全部时长', 'value': 0},
|
||||
{'label': '0-10分钟', 'value': 1},
|
||||
{'label': '10-30分钟', 'value': 2},
|
||||
{'label': '30-60分钟', 'value': 3},
|
||||
{'label': '60分钟+', 'value': 4},
|
||||
];
|
||||
late final List zoneFiltersList = [
|
||||
{'label': '全部', 'value': 0},
|
||||
{'label': '动画', 'value': 1, 'tids': 1},
|
||||
{'label': '番剧', 'value': 2, 'tids': 13},
|
||||
{'label': '国创', 'value': 3, 'tids': 167},
|
||||
{'label': '音乐', 'value': 4, 'tids': 3},
|
||||
{'label': '舞蹈', 'value': 5, 'tids': 129},
|
||||
{'label': '游戏', 'value': 6, 'tids': 4},
|
||||
{'label': '知识', 'value': 7, 'tids': 36},
|
||||
{'label': '科技', 'value': 8, 'tids': 188},
|
||||
{'label': '运动', 'value': 9, 'tids': 234},
|
||||
{'label': '汽车', 'value': 10, 'tids': 223},
|
||||
{'label': '生活', 'value': 11, 'tids': 160},
|
||||
{'label': '美食', 'value': 12, 'tids': 221},
|
||||
{'label': '动物', 'value': 13, 'tids': 217},
|
||||
{'label': '鬼畜', 'value': 14, 'tids': 119},
|
||||
{'label': '时尚', 'value': 15, 'tids': 155},
|
||||
{'label': '资讯', 'value': 16, 'tids': 202},
|
||||
{'label': '娱乐', 'value': 17, 'tids': 5},
|
||||
{'label': '影视', 'value': 18, 'tids': 181},
|
||||
{'label': '记录', 'value': 19, 'tids': 177},
|
||||
{'label': '电影', 'value': 20, 'tids': 23},
|
||||
{'label': '电视', 'value': 21, 'tids': 11},
|
||||
];
|
||||
int currentPubTimeFilter = 0;
|
||||
final Rx<ArchiveFilterType> selectedType = ArchiveFilterType.totalrank.obs;
|
||||
VideoPubTimeType? pubTimeType = VideoPubTimeType.all;
|
||||
late DateTime pubBeginDate;
|
||||
late DateTime pubEndDate;
|
||||
bool customPubBeginDate = false;
|
||||
bool customPubEndDate = false;
|
||||
int currentTimeFilter = 0;
|
||||
int currentZoneFilter = 0;
|
||||
|
||||
void onShowFilterDialog(BuildContext context) {
|
||||
showModalBottomSheet(
|
||||
@@ -154,6 +94,9 @@ class SearchVideoController
|
||||
builder: (context, setState) {
|
||||
final theme = Theme.of(context);
|
||||
Widget dateWidget([bool isFirst = true]) {
|
||||
final enable =
|
||||
pubTimeType == null &&
|
||||
(isFirst ? customPubBeginDate : customPubEndDate);
|
||||
return SearchText(
|
||||
text: DateUtil.longFormat.format(
|
||||
isFirst ? pubBeginDate : pubEndDate,
|
||||
@@ -165,7 +108,7 @@ class SearchVideoController
|
||||
initialDate: isFirst ? pubBeginDate : pubEndDate,
|
||||
firstDate: isFirst ? DateTime(2009, 6, 26) : pubBeginDate,
|
||||
lastDate: isFirst ? pubEndDate : DateTime.now(),
|
||||
).then((selectedDate) async {
|
||||
).then((selectedDate) {
|
||||
if (selectedDate != null) {
|
||||
if (isFirst) {
|
||||
customPubBeginDate = true;
|
||||
@@ -174,7 +117,7 @@ class SearchVideoController
|
||||
customPubEndDate = true;
|
||||
pubEndDate = selectedDate;
|
||||
}
|
||||
currentPubTimeFilter = -1;
|
||||
pubTimeType = null;
|
||||
SmartDialog.dismiss();
|
||||
pubBegin =
|
||||
DateTime(
|
||||
@@ -197,20 +140,14 @@ class SearchVideoController
|
||||
).millisecondsSinceEpoch ~/
|
||||
1000;
|
||||
setState(() {});
|
||||
SmartDialog.showLoading(msg: 'loading');
|
||||
await onReload();
|
||||
SmartDialog.dismiss();
|
||||
onSortSearch(getBack: false);
|
||||
}
|
||||
});
|
||||
},
|
||||
bgColor:
|
||||
currentPubTimeFilter == -1 &&
|
||||
(isFirst ? customPubBeginDate : customPubEndDate)
|
||||
bgColor: enable
|
||||
? theme.colorScheme.secondaryContainer
|
||||
: theme.colorScheme.outline.withValues(alpha: 0.1),
|
||||
textColor:
|
||||
currentPubTimeFilter == -1 &&
|
||||
(isFirst ? customPubBeginDate : customPubEndDate)
|
||||
textColor: enable
|
||||
? theme.colorScheme.onSecondaryContainer
|
||||
: theme.colorScheme.outline.withValues(alpha: 0.8),
|
||||
);
|
||||
@@ -235,17 +172,15 @@ class SearchVideoController
|
||||
Wrap(
|
||||
spacing: 8,
|
||||
runSpacing: 8,
|
||||
children: pubTimeFiltersList
|
||||
.map(
|
||||
(item) => SearchText(
|
||||
text: item['label'],
|
||||
onTap: (text) async {
|
||||
Get.back();
|
||||
currentPubTimeFilter = item['value'];
|
||||
SmartDialog.dismiss();
|
||||
SmartDialog.showToast("「${item['label']}」的筛选结果");
|
||||
children: VideoPubTimeType.values.map(
|
||||
(e) {
|
||||
final isCurr = e == pubTimeType;
|
||||
return SearchText(
|
||||
text: e.label,
|
||||
onTap: (text) {
|
||||
pubTimeType = e;
|
||||
DateTime now = DateTime.now();
|
||||
if (item['value'] == 0) {
|
||||
if (e == VideoPubTimeType.all) {
|
||||
pubBegin = null;
|
||||
pubEnd = null;
|
||||
} else {
|
||||
@@ -254,9 +189,9 @@ class SearchVideoController
|
||||
now.year,
|
||||
now.month,
|
||||
now.day -
|
||||
(item['value'] == 0
|
||||
(e == VideoPubTimeType.day
|
||||
? 0
|
||||
: item['value'] == 1
|
||||
: e == VideoPubTimeType.week
|
||||
? 6
|
||||
: 179),
|
||||
0,
|
||||
@@ -275,30 +210,24 @@ class SearchVideoController
|
||||
).millisecondsSinceEpoch ~/
|
||||
1000;
|
||||
}
|
||||
SmartDialog.showLoading(msg: 'loading');
|
||||
await onReload();
|
||||
SmartDialog.dismiss();
|
||||
onSortSearch();
|
||||
},
|
||||
bgColor: item['value'] == currentPubTimeFilter
|
||||
bgColor: isCurr
|
||||
? theme.colorScheme.secondaryContainer
|
||||
: null,
|
||||
textColor: item['value'] == currentPubTimeFilter
|
||||
textColor: isCurr
|
||||
? theme.colorScheme.onSecondaryContainer
|
||||
: null,
|
||||
),
|
||||
)
|
||||
.toList(),
|
||||
);
|
||||
},
|
||||
).toList(),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
Row(
|
||||
spacing: 8,
|
||||
children: [
|
||||
Expanded(child: dateWidget()),
|
||||
const SizedBox(width: 8),
|
||||
const Text(
|
||||
'至',
|
||||
style: TextStyle(fontSize: 13),
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
const Text('至', style: TextStyle(fontSize: 13)),
|
||||
Expanded(child: dateWidget(false)),
|
||||
],
|
||||
),
|
||||
@@ -308,29 +237,24 @@ class SearchVideoController
|
||||
Wrap(
|
||||
spacing: 8,
|
||||
runSpacing: 8,
|
||||
children: timeFiltersList
|
||||
.map(
|
||||
(item) => SearchText(
|
||||
text: item['label'],
|
||||
onTap: (text) async {
|
||||
Get.back();
|
||||
currentTimeFilter = item['value'];
|
||||
SmartDialog.dismiss();
|
||||
SmartDialog.showToast("「${item['label']}」的筛选结果");
|
||||
duration.value = item['value'];
|
||||
SmartDialog.showLoading(msg: 'loading');
|
||||
await onReload();
|
||||
SmartDialog.dismiss();
|
||||
children: VideoDurationType.values.map(
|
||||
(e) {
|
||||
final isCurr = e == videoDurationType;
|
||||
return SearchText(
|
||||
text: e.label,
|
||||
onTap: (_) {
|
||||
videoDurationType = e;
|
||||
onSortSearch(label: e.label);
|
||||
},
|
||||
bgColor: item['value'] == currentTimeFilter
|
||||
bgColor: isCurr
|
||||
? theme.colorScheme.secondaryContainer
|
||||
: null,
|
||||
textColor: item['value'] == currentTimeFilter
|
||||
textColor: isCurr
|
||||
? theme.colorScheme.onSecondaryContainer
|
||||
: null,
|
||||
),
|
||||
)
|
||||
.toList(),
|
||||
);
|
||||
},
|
||||
).toList(),
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
const Text('内容分区', style: TextStyle(fontSize: 16)),
|
||||
@@ -338,29 +262,24 @@ class SearchVideoController
|
||||
Wrap(
|
||||
spacing: 8,
|
||||
runSpacing: 8,
|
||||
children: zoneFiltersList
|
||||
.map(
|
||||
(item) => SearchText(
|
||||
text: item['label'],
|
||||
onTap: (text) async {
|
||||
Get.back();
|
||||
currentZoneFilter = item['value'];
|
||||
SmartDialog.dismiss();
|
||||
SmartDialog.showToast("「${item['label']}」的筛选结果");
|
||||
tids = item['tids'];
|
||||
SmartDialog.showLoading(msg: 'loading');
|
||||
await onReload();
|
||||
SmartDialog.dismiss();
|
||||
children: VideoZoneType.values.map(
|
||||
(e) {
|
||||
final isCurr = e == videoZoneType;
|
||||
return SearchText(
|
||||
text: e.label,
|
||||
onTap: (_) {
|
||||
videoZoneType = e;
|
||||
onSortSearch(label: e.label);
|
||||
},
|
||||
bgColor: item['value'] == currentZoneFilter
|
||||
bgColor: isCurr
|
||||
? theme.colorScheme.secondaryContainer
|
||||
: null,
|
||||
textColor: item['value'] == currentZoneFilter
|
||||
textColor: isCurr
|
||||
? theme.colorScheme.onSecondaryContainer
|
||||
: null,
|
||||
),
|
||||
)
|
||||
.toList(),
|
||||
);
|
||||
},
|
||||
).toList(),
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
import 'package:PiliPlus/common/widgets/custom_sliver_persistent_header_delegate.dart';
|
||||
import 'package:PiliPlus/common/widgets/video_card/video_card_h.dart';
|
||||
import 'package:PiliPlus/models/common/search_type.dart';
|
||||
import 'package:PiliPlus/models/search/result.dart';
|
||||
import 'package:PiliPlus/pages/search/widgets/search_text.dart';
|
||||
import 'package:PiliPlus/pages/search_panel/video/controller.dart';
|
||||
import 'package:PiliPlus/pages/search_panel/view.dart';
|
||||
import 'package:PiliPlus/utils/grid.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
class SearchVideoPanel extends CommonSearchPanel {
|
||||
@@ -56,30 +56,22 @@ class _SearchVideoPanelState
|
||||
scrollDirection: Axis.horizontal,
|
||||
child: Wrap(
|
||||
children: [
|
||||
for (var i in controller.filterList) ...[
|
||||
for (var e in ArchiveFilterType.values)
|
||||
Obx(
|
||||
() => SearchText(
|
||||
fontSize: 13,
|
||||
text: i['label'],
|
||||
text: e.desc,
|
||||
bgColor: Colors.transparent,
|
||||
textColor:
|
||||
controller.selectedType.value == i['type']
|
||||
textColor: controller.selectedType.value == e
|
||||
? theme.colorScheme.primary
|
||||
: theme.colorScheme.outline,
|
||||
onTap: (value) async {
|
||||
controller.selectedType.value = i['type'];
|
||||
controller.order.value = i['type']
|
||||
.toString()
|
||||
.split('.')
|
||||
.last;
|
||||
SmartDialog.showLoading(msg: 'loading');
|
||||
await controller.onReload();
|
||||
SmartDialog.dismiss();
|
||||
},
|
||||
onTap: (_) => controller
|
||||
..order = e.name
|
||||
..selectedType.value = e
|
||||
..onSortSearch(getBack: false),
|
||||
),
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:PiliPlus/common/widgets/loading_widget/http_error.dart';
|
||||
import 'package:PiliPlus/pages/search/controller.dart';
|
||||
import 'package:PiliPlus/pages/setting/models/extra_settings.dart';
|
||||
import 'package:PiliPlus/pages/setting/models/model.dart';
|
||||
import 'package:PiliPlus/pages/setting/models/play_settings.dart';
|
||||
@@ -11,7 +10,6 @@ import 'package:PiliPlus/pages/setting/models/video_settings.dart';
|
||||
import 'package:PiliPlus/utils/grid.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:stream_transform/stream_transform.dart';
|
||||
import 'package:waterfall_flow/waterfall_flow.dart';
|
||||
|
||||
class SettingsSearchPage extends StatefulWidget {
|
||||
@@ -21,7 +19,8 @@ class SettingsSearchPage extends StatefulWidget {
|
||||
State<SettingsSearchPage> createState() => _SettingsSearchPageState();
|
||||
}
|
||||
|
||||
class _SettingsSearchPageState extends State<SettingsSearchPage> {
|
||||
class _SettingsSearchPageState extends State<SettingsSearchPage>
|
||||
with SearchKeywordMixin {
|
||||
final _textEditingController = TextEditingController();
|
||||
final RxList<SettingsModel> _list = <SettingsModel>[].obs;
|
||||
late final _settings = [
|
||||
@@ -32,16 +31,15 @@ class _SettingsSearchPageState extends State<SettingsSearchPage> {
|
||||
...playSettings,
|
||||
...styleSettings,
|
||||
];
|
||||
late StreamController<String> _ctr;
|
||||
late StreamSubscription<String> _sub;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_ctr = StreamController<String>();
|
||||
_sub = _ctr.stream
|
||||
.debounce(const Duration(milliseconds: 200), trailing: true)
|
||||
.listen((value) {
|
||||
subInit();
|
||||
}
|
||||
|
||||
@override
|
||||
ValueChanged<String> get onKeywordChanged => (value) {
|
||||
if (value.isEmpty) {
|
||||
_list.clear();
|
||||
} else {
|
||||
@@ -49,20 +47,18 @@ class _SettingsSearchPageState extends State<SettingsSearchPage> {
|
||||
_list.value = _settings
|
||||
.where(
|
||||
(item) =>
|
||||
(item.title ?? item.getTitle?.call())
|
||||
?.toLowerCase()
|
||||
.contains(value) ||
|
||||
(item.title ?? item.getTitle?.call())?.toLowerCase().contains(
|
||||
value,
|
||||
) ||
|
||||
item.subtitle?.toLowerCase().contains(value) == true,
|
||||
)
|
||||
.toList();
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_sub.cancel();
|
||||
_ctr.close();
|
||||
subDispose();
|
||||
_textEditingController.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
@@ -89,7 +85,7 @@ class _SettingsSearchPageState extends State<SettingsSearchPage> {
|
||||
autofocus: true,
|
||||
controller: _textEditingController,
|
||||
textAlignVertical: TextAlignVertical.center,
|
||||
onChanged: _ctr.add,
|
||||
onChanged: ctr!.add,
|
||||
decoration: const InputDecoration(
|
||||
isDense: true,
|
||||
hintText: '搜索',
|
||||
|
||||
@@ -5,6 +5,7 @@ import 'package:PiliPlus/grpc/bilibili/app/viewunite/pgcanymodel.pb.dart'
|
||||
show ViewPgcAny;
|
||||
import 'package:PiliPlus/grpc/view.dart';
|
||||
import 'package:PiliPlus/http/constants.dart';
|
||||
import 'package:PiliPlus/http/fav.dart';
|
||||
import 'package:PiliPlus/http/search.dart';
|
||||
import 'package:PiliPlus/http/video.dart';
|
||||
import 'package:PiliPlus/models/common/video/source_type.dart';
|
||||
@@ -51,6 +52,7 @@ class PgcIntroController extends CommonIntroController {
|
||||
|
||||
late final RxBool isFollowed = false.obs;
|
||||
late final RxInt followStatus = (-1).obs;
|
||||
late final RxBool isFav = (pgcItem.userStatus?.favored == 1).obs;
|
||||
|
||||
@override
|
||||
void onInit() {
|
||||
@@ -479,4 +481,16 @@ class PgcIntroController extends CommonIntroController {
|
||||
artist: pgcItem.title,
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> onFavPugv(bool isFav) async {
|
||||
final res = isFav
|
||||
? await FavHttp.delFavPugv(seasonId)
|
||||
: await FavHttp.addFavPugv(seasonId);
|
||||
if (res['status']) {
|
||||
this.isFav.value = !isFav;
|
||||
SmartDialog.showToast('${isFav ? '取消' : ''}收藏成功');
|
||||
} else {
|
||||
SmartDialog.showToast(res['msg']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ import 'dart:math';
|
||||
|
||||
import 'package:PiliPlus/common/constants.dart';
|
||||
import 'package:PiliPlus/common/widgets/badge.dart';
|
||||
import 'package:PiliPlus/common/widgets/button/icon_button.dart';
|
||||
import 'package:PiliPlus/common/widgets/dialog/dialog.dart';
|
||||
import 'package:PiliPlus/common/widgets/image/network_img_layer.dart';
|
||||
import 'package:PiliPlus/common/widgets/stat/stat.dart';
|
||||
@@ -80,7 +81,7 @@ class _PgcIntroPageState extends State<PgcIntroPage>
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
spacing: 10,
|
||||
children: [
|
||||
_buildCover(isLandscape, item),
|
||||
_buildCover(theme, isLandscape, item),
|
||||
Expanded(child: _buildInfoPanel(isLandscape, theme, item)),
|
||||
],
|
||||
),
|
||||
@@ -142,6 +143,7 @@ class _PgcIntroPageState extends State<PgcIntroPage>
|
||||
radius: 0,
|
||||
src: e.url,
|
||||
width: imgWidth,
|
||||
height: imgWidth * e.aspectRatio,
|
||||
),
|
||||
);
|
||||
}).toList(),
|
||||
@@ -153,7 +155,7 @@ class _PgcIntroPageState extends State<PgcIntroPage>
|
||||
return null;
|
||||
}
|
||||
|
||||
Widget _buildCover(bool isLandscape, PgcInfoModel item) {
|
||||
Widget _buildCover(ThemeData theme, bool isLandscape, PgcInfoModel item) {
|
||||
return Stack(
|
||||
clipBehavior: Clip.none,
|
||||
children: [
|
||||
@@ -183,6 +185,24 @@ class _PgcIntroPageState extends State<PgcIntroPage>
|
||||
bottom: 6,
|
||||
left: null,
|
||||
),
|
||||
if (!pgcIntroController.isPgc)
|
||||
Positioned(
|
||||
right: 6,
|
||||
bottom: 6,
|
||||
child: Obx(() {
|
||||
final isFav = pgcIntroController.isFav.value;
|
||||
return iconButton(
|
||||
context: context,
|
||||
size: 28,
|
||||
iconSize: 26,
|
||||
tooltip: '${isFav ? '取消' : ''}收藏',
|
||||
onPressed: () => pgcIntroController.onFavPugv(isFav),
|
||||
icon: isFav ? Icons.star_rounded : Icons.star_border_rounded,
|
||||
bgColor: isFav ? null : theme.colorScheme.onInverseSurface,
|
||||
iconColor: isFav ? null : theme.colorScheme.onSurfaceVariant,
|
||||
);
|
||||
}),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
@@ -374,7 +394,7 @@ class _PgcIntroPageState extends State<PgcIntroPage>
|
||||
item.upInfo!.avatar!,
|
||||
item.upInfo!.uname!,
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
const SizedBox(height: 6),
|
||||
],
|
||||
Text(
|
||||
item.title!,
|
||||
|
||||
Reference in New Issue
Block a user