mirror of
https://github.com/bggRGjQaUbCoE/PiliPlus.git
synced 2026-05-31 16:18:22 +08:00
@@ -1,17 +1,20 @@
|
||||
import 'dart:math';
|
||||
|
||||
import 'package:PiliPlus/common/widgets/list_tile.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/search/search_trending/list.dart';
|
||||
import 'package:PiliPlus/pages/search_trending/controller.dart';
|
||||
import 'package:PiliPlus/utils/context_ext.dart';
|
||||
import 'package:PiliPlus/utils/extension.dart';
|
||||
import 'package:PiliPlus/utils/image_util.dart';
|
||||
import 'package:cached_network_image/cached_network_image.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/material.dart' hide ListTile;
|
||||
import 'package:flutter/services.dart' show SystemUiOverlayStyle;
|
||||
import 'package:get/get.dart';
|
||||
import 'package:get/get.dart' hide ContextExtensionss;
|
||||
|
||||
class SearchTrendingPage extends StatefulWidget {
|
||||
const SearchTrendingPage({super.key});
|
||||
@@ -54,96 +57,90 @@ class _SearchTrendingPageState extends State<SearchTrendingPage> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final theme = Theme.of(context);
|
||||
return LayoutBuilder(
|
||||
builder: (context, constraints) {
|
||||
final maxWidth = constraints.maxWidth;
|
||||
final width = constraints.maxWidth > constraints.maxHeight
|
||||
? min(640.0, maxWidth * 0.6)
|
||||
: maxWidth;
|
||||
final height = width * 528 / 1125;
|
||||
final padding = MediaQuery.viewPaddingOf(context);
|
||||
_offset = height - 56 - padding.top;
|
||||
listener();
|
||||
final removePadding = maxWidth > width;
|
||||
return Scaffold(
|
||||
extendBody: true,
|
||||
extendBodyBehindAppBar: true,
|
||||
resizeToAvoidBottomInset: false,
|
||||
appBar: PreferredSize(
|
||||
preferredSize: const Size.fromHeight(56),
|
||||
child: Obx(
|
||||
() {
|
||||
final scrollRatio = _scrollRatio.value;
|
||||
final flag = removePadding || scrollRatio >= 0.5;
|
||||
return AppBar(
|
||||
title: Opacity(
|
||||
opacity: scrollRatio,
|
||||
child: Text(
|
||||
'bilibili热搜',
|
||||
style: TextStyle(
|
||||
color: flag ? null : Colors.white,
|
||||
),
|
||||
),
|
||||
),
|
||||
backgroundColor: theme.colorScheme.surface.withValues(
|
||||
alpha: scrollRatio,
|
||||
),
|
||||
foregroundColor: flag ? null : Colors.white,
|
||||
systemOverlayStyle: flag
|
||||
? null
|
||||
: const SystemUiOverlayStyle(
|
||||
statusBarBrightness: Brightness.dark,
|
||||
statusBarIconBrightness: Brightness.light,
|
||||
),
|
||||
shape: scrollRatio == 1
|
||||
? Border(
|
||||
bottom: BorderSide(
|
||||
color: theme.colorScheme.outline.withValues(
|
||||
alpha: 0.1,
|
||||
),
|
||||
),
|
||||
)
|
||||
: null,
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
body: Center(
|
||||
child: SizedBox(
|
||||
width: width,
|
||||
child: MediaQuery.removePadding(
|
||||
context: context,
|
||||
removeLeft: removePadding,
|
||||
removeRight: removePadding,
|
||||
child: refreshIndicator(
|
||||
onRefresh: _controller.onRefresh,
|
||||
child: CustomScrollView(
|
||||
controller: _controller.scrollController,
|
||||
physics: const AlwaysScrollableScrollPhysics(),
|
||||
slivers: [
|
||||
SliverToBoxAdapter(
|
||||
child: Image.asset(
|
||||
width: width,
|
||||
height: height,
|
||||
'assets/images/trending_banner.png',
|
||||
filterQuality: FilterQuality.low,
|
||||
),
|
||||
),
|
||||
SliverPadding(
|
||||
padding: EdgeInsets.only(bottom: padding.bottom + 100),
|
||||
sliver: Obx(
|
||||
() =>
|
||||
_buildBody(theme, _controller.loadingState.value),
|
||||
),
|
||||
),
|
||||
],
|
||||
final padding = MediaQuery.viewPaddingOf(context);
|
||||
final size = context.mediaQuerySize;
|
||||
final maxWidth = size.width - padding.horizontal;
|
||||
final width = size.isPortrait ? maxWidth : min(640.0, maxWidth * 0.6);
|
||||
final height = width * 528 / 1125;
|
||||
_offset = height - 56 - padding.top;
|
||||
listener();
|
||||
return Scaffold(
|
||||
extendBody: true,
|
||||
extendBodyBehindAppBar: true,
|
||||
resizeToAvoidBottomInset: false,
|
||||
appBar: PreferredSize(
|
||||
preferredSize: const Size.fromHeight(56),
|
||||
child: Obx(
|
||||
() {
|
||||
final scrollRatio = _scrollRatio.value;
|
||||
final flag = maxWidth > width || scrollRatio >= 0.5;
|
||||
return AppBar(
|
||||
title: Opacity(
|
||||
opacity: scrollRatio,
|
||||
child: Text(
|
||||
'bilibili热搜',
|
||||
style: TextStyle(
|
||||
color: flag ? null : Colors.white,
|
||||
),
|
||||
),
|
||||
),
|
||||
backgroundColor: theme.colorScheme.surface.withValues(
|
||||
alpha: scrollRatio,
|
||||
),
|
||||
foregroundColor: flag ? null : Colors.white,
|
||||
systemOverlayStyle: flag
|
||||
? null
|
||||
: const SystemUiOverlayStyle(
|
||||
statusBarBrightness: Brightness.dark,
|
||||
statusBarIconBrightness: Brightness.light,
|
||||
),
|
||||
shape: scrollRatio == 1
|
||||
? Border(
|
||||
bottom: BorderSide(
|
||||
color: theme.colorScheme.outline.withValues(
|
||||
alpha: 0.1,
|
||||
),
|
||||
),
|
||||
)
|
||||
: null,
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
body: Padding(
|
||||
padding: EdgeInsets.only(
|
||||
left: padding.left,
|
||||
right: padding.right,
|
||||
),
|
||||
child: Center(
|
||||
child: SizedBox(
|
||||
width: width,
|
||||
child: refreshIndicator(
|
||||
onRefresh: _controller.onRefresh,
|
||||
child: CustomScrollView(
|
||||
controller: _controller.scrollController,
|
||||
physics: const AlwaysScrollableScrollPhysics(),
|
||||
slivers: [
|
||||
SliverToBoxAdapter(
|
||||
child: Image.asset(
|
||||
width: width,
|
||||
height: height,
|
||||
'assets/images/trending_banner.png',
|
||||
filterQuality: FilterQuality.low,
|
||||
),
|
||||
),
|
||||
SliverPadding(
|
||||
padding: EdgeInsets.only(bottom: padding.bottom + 100),
|
||||
sliver: Obx(
|
||||
() => _buildBody(theme, _controller.loadingState.value),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user