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