opt: search trending page

Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
bggRGjQaUbCoE
2025-04-15 09:23:25 +08:00
parent bc9c20c509
commit 3eb404a9e2
2 changed files with 26 additions and 16 deletions

View File

@@ -17,10 +17,11 @@ class SearchPage extends StatefulWidget {
State<SearchPage> createState() => _SearchPageState(); State<SearchPage> createState() => _SearchPageState();
} }
class _SearchPageState extends State<SearchPage> with RouteAware { class _SearchPageState extends State<SearchPage> {
final SSearchController _searchController = Get.put( final _tag = Utils.generateRandomString(6);
late final SSearchController _searchController = Get.put(
SSearchController(), SSearchController(),
tag: Utils.generateRandomString(6), tag: _tag,
); );
@override @override
@@ -156,7 +157,10 @@ class _SearchPageState extends State<SearchPage> with RouteAware {
GestureDetector( GestureDetector(
behavior: HitTestBehavior.opaque, behavior: HitTestBehavior.opaque,
onTap: () { onTap: () {
Get.toNamed('/searchTrending'); Get.toNamed(
'/searchTrending',
parameters: {'tag': _tag},
);
}, },
child: Padding( child: Padding(
padding: padding:

View File

@@ -18,7 +18,10 @@ class SearchTrendingPage extends StatefulWidget {
} }
class _SearchTrendingPageState extends State<SearchTrendingPage> { class _SearchTrendingPageState extends State<SearchTrendingPage> {
final _controller = Get.put(SearchTrendingController()); final _controller = Get.put(
SearchTrendingController(),
tag: Get.parameters['tag'],
);
late double _offset; late double _offset;
final RxDouble _scrollRatio = 0.0.obs; final RxDouble _scrollRatio = 0.0.obs;
@@ -33,6 +36,7 @@ class _SearchTrendingPageState extends State<SearchTrendingPage> {
void didChangeDependencies() { void didChangeDependencies() {
super.didChangeDependencies(); super.didChangeDependencies();
_offset = Get.width * 528 / 1125 - 56 - Get.mediaQuery.padding.top; _offset = Get.width * 528 / 1125 - 56 - Get.mediaQuery.padding.top;
listener();
} }
@override @override
@@ -42,12 +46,14 @@ class _SearchTrendingPageState extends State<SearchTrendingPage> {
} }
void listener() { void listener() {
if (_controller.scrollController.hasClients) {
_scrollRatio.value = clampDouble( _scrollRatio.value = clampDouble(
_controller.scrollController.position.pixels / _offset, _controller.scrollController.position.pixels / _offset,
0.0, 0.0,
1.0, 1.0,
); );
} }
}
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
@@ -140,7 +146,7 @@ class _SearchTrendingPageState extends State<SearchTrendingPage> {
}, },
leading: index < _controller.topCount leading: index < _controller.topCount
? Icon( ? Icon(
size: 16, size: 17,
Icons.vertical_align_top_outlined, Icons.vertical_align_top_outlined,
color: const Color(0xFFd1403e), color: const Color(0xFFd1403e),
) )
@@ -154,7 +160,7 @@ class _SearchTrendingPageState extends State<SearchTrendingPage> {
2 => const Color(0xFFdfa777), 2 => const Color(0xFFdfa777),
_ => Theme.of(context).colorScheme.outline, _ => Theme.of(context).colorScheme.outline,
}, },
fontSize: 16, fontSize: 17,
fontStyle: FontStyle.italic, fontStyle: FontStyle.italic,
), ),
), ),
@@ -166,21 +172,21 @@ class _SearchTrendingPageState extends State<SearchTrendingPage> {
maxLines: 1, maxLines: 1,
overflow: TextOverflow.ellipsis, overflow: TextOverflow.ellipsis,
strutStyle: StrutStyle(height: 1, leading: 0), strutStyle: StrutStyle(height: 1, leading: 0),
style: TextStyle(height: 1, fontSize: 14), style: TextStyle(height: 1, fontSize: 15),
), ),
), ),
if (item.icon?.isNotEmpty == true) ...[ if (item.icon?.isNotEmpty == true) ...[
const SizedBox(width: 4), const SizedBox(width: 4),
CachedNetworkImage( CachedNetworkImage(
imageUrl: item.icon!.http2https, imageUrl: item.icon!.http2https,
height: 15, height: 16,
), ),
] else if (item.showLiveIcon == true) ...[ ] else if (item.showLiveIcon == true) ...[
const SizedBox(width: 4), const SizedBox(width: 4),
Image.asset( Image.asset(
'assets/images/live/live_@28h.gif', 'assets/images/live/live_@28h.gif',
width: 48, width: 51,
height: 15, height: 16,
), ),
], ],
], ],