mirror of
https://github.com/HChaZZY/PiliPlus.git
synced 2025-12-06 09:13:48 +08:00
opt: search page
Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import 'package:PiliPlus/common/widgets/loading_widget.dart';
|
||||
import 'package:PiliPlus/common/widgets/http_error.dart';
|
||||
import 'package:PiliPlus/http/loading_state.dart';
|
||||
import 'package:PiliPlus/pages/common/common_search_controller.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
@@ -48,19 +48,25 @@ abstract class CommonSearchPageState<S extends CommonSearchPage, R, T>
|
||||
onSubmitted: (value) => controller.onRefresh(),
|
||||
),
|
||||
),
|
||||
body: Obx(() => _buildBody(controller.loadingState.value)),
|
||||
body: CustomScrollView(
|
||||
physics: const AlwaysScrollableScrollPhysics(),
|
||||
controller: controller.scrollController,
|
||||
slivers: [
|
||||
Obx(() => _buildBody(controller.loadingState.value)),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildBody(LoadingState<List<T>?> loadingState) {
|
||||
return switch (loadingState) {
|
||||
Loading() => errorWidget(),
|
||||
Loading() => HttpError(),
|
||||
Success() => loadingState.response?.isNotEmpty == true
|
||||
? buildList(loadingState.response!)
|
||||
: errorWidget(
|
||||
: HttpError(
|
||||
callback: controller.onReload,
|
||||
),
|
||||
Error() => errorWidget(
|
||||
Error() => HttpError(
|
||||
errMsg: loadingState.errMsg,
|
||||
callback: controller.onReload,
|
||||
),
|
||||
|
||||
@@ -26,11 +26,7 @@ class _FavSearchPageState extends CommonSearchPageState<FavSearchPage,
|
||||
|
||||
@override
|
||||
Widget buildList(List<FavDetailItemData> list) {
|
||||
return CustomScrollView(
|
||||
physics: const AlwaysScrollableScrollPhysics(),
|
||||
controller: controller.scrollController,
|
||||
slivers: [
|
||||
SliverPadding(
|
||||
return SliverPadding(
|
||||
padding: EdgeInsets.only(
|
||||
bottom: MediaQuery.of(context).padding.bottom + 80,
|
||||
),
|
||||
@@ -74,8 +70,6 @@ class _FavSearchPageState extends CommonSearchPageState<FavSearchPage,
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,11 +24,11 @@ class _FollowSearchPageState extends CommonSearchPageState<FollowSearchPage,
|
||||
|
||||
@override
|
||||
Widget buildList(List<FollowItemModel> list) {
|
||||
return ListView.builder(
|
||||
return SliverPadding(
|
||||
padding: EdgeInsets.only(
|
||||
bottom: MediaQuery.of(context).padding.bottom + 80,
|
||||
),
|
||||
controller: controller.scrollController,
|
||||
sliver: SliverList.builder(
|
||||
itemCount: list.length,
|
||||
itemBuilder: ((context, index) {
|
||||
if (index == list.length - 1) {
|
||||
@@ -36,6 +36,7 @@ class _FollowSearchPageState extends CommonSearchPageState<FollowSearchPage,
|
||||
}
|
||||
return FollowItem(item: list[index]);
|
||||
}),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,11 +25,7 @@ class _HistorySearchPageState
|
||||
|
||||
@override
|
||||
Widget buildList(List<HisListItem> list) {
|
||||
return CustomScrollView(
|
||||
physics: const AlwaysScrollableScrollPhysics(),
|
||||
controller: controller.scrollController,
|
||||
slivers: [
|
||||
SliverPadding(
|
||||
return SliverPadding(
|
||||
padding: EdgeInsets.only(
|
||||
bottom: MediaQuery.of(context).padding.bottom + 80,
|
||||
),
|
||||
@@ -53,8 +49,6 @@ class _HistorySearchPageState
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,11 +28,7 @@ class _LaterSearchPageState
|
||||
|
||||
@override
|
||||
Widget buildList(List<HotVideoItemModel> list) {
|
||||
return CustomScrollView(
|
||||
physics: const AlwaysScrollableScrollPhysics(),
|
||||
controller: controller.scrollController,
|
||||
slivers: [
|
||||
SliverPadding(
|
||||
return SliverPadding(
|
||||
padding: EdgeInsets.only(
|
||||
bottom: MediaQuery.of(context).padding.bottom + 80,
|
||||
),
|
||||
@@ -79,8 +75,8 @@ class _LaterSearchPageState
|
||||
child: Container(
|
||||
alignment: Alignment.center,
|
||||
height: constraints.maxHeight,
|
||||
width: constraints.maxHeight *
|
||||
StyleString.aspectRatio,
|
||||
width:
|
||||
constraints.maxHeight * StyleString.aspectRatio,
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
color: Colors.black.withOpacity(0.6),
|
||||
@@ -95,8 +91,8 @@ class _LaterSearchPageState
|
||||
child: IconButton(
|
||||
tooltip: '取消选择',
|
||||
style: ButtonStyle(
|
||||
padding: WidgetStateProperty.all(
|
||||
EdgeInsets.zero),
|
||||
padding:
|
||||
WidgetStateProperty.all(EdgeInsets.zero),
|
||||
backgroundColor:
|
||||
WidgetStateProperty.resolveWith(
|
||||
(states) {
|
||||
@@ -110,8 +106,7 @@ class _LaterSearchPageState
|
||||
onPressed: null,
|
||||
icon: Icon(
|
||||
Icons.done_all_outlined,
|
||||
color:
|
||||
Theme.of(context).colorScheme.primary,
|
||||
color: Theme.of(context).colorScheme.primary,
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -135,8 +130,7 @@ class _LaterSearchPageState
|
||||
);
|
||||
},
|
||||
icon: Icons.clear,
|
||||
iconColor:
|
||||
Theme.of(context).colorScheme.onSurfaceVariant,
|
||||
iconColor: Theme.of(context).colorScheme.onSurfaceVariant,
|
||||
bgColor: Colors.transparent,
|
||||
),
|
||||
),
|
||||
@@ -145,8 +139,6 @@ class _LaterSearchPageState
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user