mirror of
https://github.com/HChaZZY/PiliPlus.git
synced 2025-12-06 09:13:48 +08:00
mod: 历史页搜索逻辑修复、简化,横屏支持
This commit is contained in:
@@ -12,7 +12,6 @@ class HistorySearchController extends GetxController {
|
|||||||
String hintText = '搜索';
|
String hintText = '搜索';
|
||||||
RxString loadingStatus = 'init'.obs;
|
RxString loadingStatus = 'init'.obs;
|
||||||
RxString loadingText = '加载中...'.obs;
|
RxString loadingText = '加载中...'.obs;
|
||||||
bool hasRequest = false;
|
|
||||||
late int mid;
|
late int mid;
|
||||||
RxString uname = ''.obs;
|
RxString uname = ''.obs;
|
||||||
int pn = 1;
|
int pn = 1;
|
||||||
@@ -37,10 +36,8 @@ class HistorySearchController extends GetxController {
|
|||||||
// 提交搜索内容
|
// 提交搜索内容
|
||||||
void submit() {
|
void submit() {
|
||||||
loadingStatus.value = 'loading';
|
loadingStatus.value = 'loading';
|
||||||
if (hasRequest) {
|
pn = 1;
|
||||||
pn = 1;
|
searchHistories();
|
||||||
searchHistories();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 搜索视频
|
// 搜索视频
|
||||||
@@ -58,18 +55,18 @@ class HistorySearchController extends GetxController {
|
|||||||
} else {
|
} else {
|
||||||
historyList.addAll(res['data'].list);
|
historyList.addAll(res['data'].list);
|
||||||
}
|
}
|
||||||
|
historyList.refresh();
|
||||||
count = res['data'].page['total'];
|
count = res['data'].page['total'];
|
||||||
if (historyList.length == count) {
|
if (historyList.length == count) {
|
||||||
loadingText.value = '没有更多了';
|
loadingText.value = '没有更多了';
|
||||||
}
|
}
|
||||||
pn += 1;
|
|
||||||
hasRequest = true;
|
|
||||||
}
|
}
|
||||||
loadingStatus.value = 'finish';
|
loadingStatus.value = 'finish';
|
||||||
return res;
|
// return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
onLoad() {
|
onLoad() {
|
||||||
|
pn += 1;
|
||||||
searchHistories(type: 'onLoad');
|
searchHistories(type: 'onLoad');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6,6 +6,8 @@ import 'package:PiliPalaX/common/widgets/http_error.dart';
|
|||||||
import 'package:PiliPalaX/common/widgets/no_data.dart';
|
import 'package:PiliPalaX/common/widgets/no_data.dart';
|
||||||
import 'package:PiliPalaX/pages/history/widgets/item.dart';
|
import 'package:PiliPalaX/pages/history/widgets/item.dart';
|
||||||
|
|
||||||
|
import '../../common/constants.dart';
|
||||||
|
import '../../utils/grid.dart';
|
||||||
import 'controller.dart';
|
import 'controller.dart';
|
||||||
|
|
||||||
class HistorySearchPage extends StatefulWidget {
|
class HistorySearchPage extends StatefulWidget {
|
||||||
@@ -80,95 +82,34 @@ class _HistorySearchPageState extends State<HistorySearchPage> {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
body: Obx(
|
body: Obx(
|
||||||
() => Column(
|
() => _historySearchCtr.loadingStatus.value == 'init'
|
||||||
children: _historySearchCtr.loadingStatus.value == 'init'
|
? const SizedBox()
|
||||||
? [const SizedBox()]
|
: CustomScrollView(
|
||||||
: [
|
physics: const AlwaysScrollableScrollPhysics(),
|
||||||
Expanded(
|
controller: scrollController,
|
||||||
child: FutureBuilder(
|
slivers: [
|
||||||
future: _historySearchCtr.searchHistories(),
|
Obx(() => SliverGrid(
|
||||||
builder: (context, snapshot) {
|
gridDelegate: SliverGridDelegateWithMaxCrossAxisExtent(
|
||||||
if (snapshot.connectionState == ConnectionState.done) {
|
mainAxisSpacing: StyleString.cardSpace,
|
||||||
Map data = snapshot.data as Map;
|
crossAxisSpacing: StyleString.safeSpace,
|
||||||
if (data['status']) {
|
maxCrossAxisExtent: Grid.maxRowWidth * 2,
|
||||||
return Obx(
|
mainAxisExtent: Grid.calculateActualWidth(context,
|
||||||
() => _historySearchCtr.historyList.isNotEmpty
|
Grid.maxRowWidth * 2, StyleString.safeSpace) /
|
||||||
? ListView.builder(
|
2.1 /
|
||||||
controller: scrollController,
|
StyleString.aspectRatio),
|
||||||
itemCount:
|
delegate: SliverChildBuilderDelegate(
|
||||||
_historySearchCtr.historyList.length +
|
(context, index) {
|
||||||
1,
|
return HistoryItem(
|
||||||
itemBuilder: (context, index) {
|
videoItem: _historySearchCtr.historyList[index],
|
||||||
if (index ==
|
ctr: _historySearchCtr,
|
||||||
_historySearchCtr
|
onChoose: null,
|
||||||
.historyList.length) {
|
onUpdateMultiple: () => null,
|
||||||
return Container(
|
|
||||||
height: MediaQuery.of(context)
|
|
||||||
.padding
|
|
||||||
.bottom +
|
|
||||||
60,
|
|
||||||
padding: EdgeInsets.only(
|
|
||||||
bottom: MediaQuery.of(context)
|
|
||||||
.padding
|
|
||||||
.bottom),
|
|
||||||
child: Center(
|
|
||||||
child: Obx(
|
|
||||||
() => Text(
|
|
||||||
_historySearchCtr
|
|
||||||
.loadingText.value,
|
|
||||||
style: TextStyle(
|
|
||||||
color: Theme.of(context)
|
|
||||||
.colorScheme
|
|
||||||
.outline,
|
|
||||||
fontSize: 13),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
return HistoryItem(
|
|
||||||
videoItem: _historySearchCtr
|
|
||||||
.historyList[index],
|
|
||||||
ctr: _historySearchCtr,
|
|
||||||
onChoose: null,
|
|
||||||
onUpdateMultiple: () => null,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
)
|
|
||||||
: _historySearchCtr.loadingStatus.value ==
|
|
||||||
'loading'
|
|
||||||
? const SizedBox(child: Text('加载中...'))
|
|
||||||
: const CustomScrollView(
|
|
||||||
slivers: <Widget>[
|
|
||||||
NoData(),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
return CustomScrollView(
|
|
||||||
slivers: <Widget>[
|
|
||||||
HttpError(
|
|
||||||
errMsg: data['msg'],
|
|
||||||
fn: () => setState(() {}),
|
|
||||||
)
|
|
||||||
],
|
|
||||||
);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// 骨架屏
|
|
||||||
return ListView.builder(
|
|
||||||
itemCount: 10,
|
|
||||||
itemBuilder: (context, index) {
|
|
||||||
return const VideoCardHSkeleton();
|
|
||||||
},
|
|
||||||
);
|
);
|
||||||
}
|
},
|
||||||
},
|
childCount: _historySearchCtr.historyList.length,
|
||||||
),
|
)))
|
||||||
),
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user