diff --git a/lib/common/widgets/badge.dart b/lib/common/widgets/badge.dart index 1936dea0..b6be50e3 100644 --- a/lib/common/widgets/badge.dart +++ b/lib/common/widgets/badge.dart @@ -75,9 +75,7 @@ class PBadge extends StatelessWidget { bgColor = Colors.transparent; borderColor = theme.secondary; case PBadgeType.free: - bgColor = Get.isDarkMode - ? const Color(0xFFD66011) - : const Color(0xFFFF7F24); + bgColor = theme.freeColor; color = Colors.white; } diff --git a/lib/common/widgets/image/image_view.dart b/lib/common/widgets/image/image_view.dart index 023d7ba4..dd564d35 100644 --- a/lib/common/widgets/image/image_view.dart +++ b/lib/common/widgets/image/image_view.dart @@ -45,11 +45,11 @@ Widget imageView( ValueChanged? onDismissed, Function(List, int)? callback, }) { - double imageWidth = (maxWidth - 2 * 5) / 3; + double imageWidth = (maxWidth - 10) / 3; double imageHeight = imageWidth; if (picArr.length == 1) { - dynamic width = picArr[0].width; - dynamic height = picArr[0].height; + num width = picArr[0].width; + num height = picArr[0].height; double ratioWH = width / height; double ratioHW = height / width; imageWidth = ratioWH > 1.5 @@ -57,6 +57,9 @@ Widget imageView( : (ratioWH >= 1 || (height > width && ratioHW < 1.5)) ? 2 * imageWidth : 1.5 * imageWidth; + if (width != 1) { + imageWidth = min(imageWidth, width.toDouble()); + } imageHeight = imageWidth * min(ratioHW, _maxRatio); } else if (picArr.length == 2) { imageWidth = imageHeight = 2 * imageWidth; diff --git a/lib/pages/dynamics_mention/view.dart b/lib/pages/dynamics_mention/view.dart index 54fa5e72..cd02c678 100644 --- a/lib/pages/dynamics_mention/view.dart +++ b/lib/pages/dynamics_mention/view.dart @@ -72,7 +72,7 @@ class _DynMentionPanelState extends SearchState { } @override - void onKeywordChanged(String value) => _controller + void onValueChanged(String value) => _controller ..enableClear.value = value.isNotEmpty ..onRefresh().whenComplete( () => WidgetsBinding.instance.addPostFrameCallback( diff --git a/lib/pages/dynamics_select_topic/view.dart b/lib/pages/dynamics_select_topic/view.dart index 88cc41cb..24500445 100644 --- a/lib/pages/dynamics_select_topic/view.dart +++ b/lib/pages/dynamics_select_topic/view.dart @@ -70,7 +70,7 @@ class _SelectTopicPanelState extends SearchState { } @override - void onKeywordChanged(String value) => _controller + void onValueChanged(String value) => _controller ..enableClear.value = value.isNotEmpty ..onRefresh().whenComplete( () => WidgetsBinding.instance.addPostFrameCallback( diff --git a/lib/pages/fav/note/child_view.dart b/lib/pages/fav/note/child_view.dart index 14adf671..3b662f0d 100644 --- a/lib/pages/fav/note/child_view.dart +++ b/lib/pages/fav/note/child_view.dart @@ -91,6 +91,7 @@ class _FavNoteChildPageState extends State onChanged: (value) { _favNoteController.handleSelect( checked: !_favNoteController.allSelected.value, + disableSelect: false, ); }, ), diff --git a/lib/pages/fav/pgc/child_view.dart b/lib/pages/fav/pgc/child_view.dart index d1f18b8a..a1a5ab46 100644 --- a/lib/pages/fav/pgc/child_view.dart +++ b/lib/pages/fav/pgc/child_view.dart @@ -96,6 +96,7 @@ class _FavPgcChildPageState extends State onChanged: (value) { _favPgcController.handleSelect( checked: !_favPgcController.allSelected.value, + disableSelect: false, ); }, ), diff --git a/lib/pages/search/controller.dart b/lib/pages/search/controller.dart index a571ee29..fddcd681 100644 --- a/lib/pages/search/controller.dart +++ b/lib/pages/search/controller.dart @@ -14,17 +14,15 @@ import 'package:flutter/material.dart'; import 'package:get/get.dart'; import 'package:stream_transform/stream_transform.dart'; -mixin SearchKeywordMixin { +mixin DebounceStreamMixin { Duration duration = const Duration(milliseconds: 200); - StreamController? ctr; - StreamSubscription? sub; - void onKeywordChanged(String value); + StreamController? ctr; + StreamSubscription? sub; + void onValueChanged(T value); void subInit() { - ctr = StreamController(); - sub = ctr!.stream - .debounce(duration, trailing: true) - .listen(onKeywordChanged); + ctr = StreamController(); + sub = ctr!.stream.debounce(duration, trailing: true).listen(onValueChanged); } void subDispose() { @@ -36,7 +34,7 @@ mixin SearchKeywordMixin { } abstract class SearchState extends State - with SearchKeywordMixin { + with DebounceStreamMixin { @override void dispose() { subDispose(); @@ -50,7 +48,8 @@ abstract class SearchState extends State } } -class SSearchController extends GetxController with SearchKeywordMixin { +class SSearchController extends GetxController + with DebounceStreamMixin { SSearchController(this.tag); final String tag; @@ -187,7 +186,7 @@ class SSearchController extends GetxController with SearchKeywordMixin { } @override - Future onKeywordChanged(String value) async { + Future onValueChanged(String value) async { var res = await SearchHttp.searchSuggest(term: value); if (res['status']) { SearchSuggestModel data = res['data']; diff --git a/lib/pages/settings_search/view.dart b/lib/pages/settings_search/view.dart index 04601b2a..af59b58a 100644 --- a/lib/pages/settings_search/view.dart +++ b/lib/pages/settings_search/view.dart @@ -34,7 +34,7 @@ class _SettingsSearchPageState extends SearchState { ]; @override - void onKeywordChanged(String value) { + void onValueChanged(String value) { if (value.isEmpty) { _list.clear(); } else { diff --git a/lib/pages/video/introduction/pgc/widgets/pgc_panel.dart b/lib/pages/video/introduction/pgc/widgets/pgc_panel.dart index d38a33fd..9685288b 100644 --- a/lib/pages/video/introduction/pgc/widgets/pgc_panel.dart +++ b/lib/pages/video/introduction/pgc/widgets/pgc_panel.dart @@ -6,6 +6,7 @@ import 'package:PiliPlus/models_new/pgc/pgc_info_model/new_ep.dart'; import 'package:PiliPlus/models_new/video/video_detail/episode.dart' hide EpisodeItem; import 'package:PiliPlus/pages/video/controller.dart'; +import 'package:PiliPlus/utils/extension.dart'; import 'package:PiliPlus/utils/storage_pref.dart'; import 'package:PiliPlus/utils/utils.dart'; import 'package:flutter/material.dart'; @@ -86,7 +87,7 @@ class _PgcPanelState extends State { @override Widget build(BuildContext context) { - final theme = Theme.of(context); + final theme = Theme.of(context).colorScheme; final currEpisode = widget.pages[currentIndex]; final isPugv = currEpisode.from == 'pugv'; return Column( @@ -101,10 +102,7 @@ class _PgcPanelState extends State { child: Text( ' 正在播放:${currEpisode.longTitle ?? currEpisode.title}', overflow: TextOverflow.ellipsis, - style: TextStyle( - fontSize: 12, - color: theme.colorScheme.outline, - ), + style: TextStyle(fontSize: 12, color: theme.outline), ), ), const SizedBox(width: 10), @@ -149,12 +147,10 @@ class _PgcPanelState extends State { ); } - Widget _buildItem(ThemeData theme, bool isPugv, int index) { + Widget _buildItem(ColorScheme theme, bool isPugv, int index) { final item = widget.pages[index]; final hasLongTitle = item.longTitle?.isNotEmpty == true; - final color = index == currentIndex - ? theme.colorScheme.primary - : theme.colorScheme.onSurface; + final color = index == currentIndex ? theme.primary : theme.onSurface; return Container( width: 150, height: 60, @@ -162,7 +158,7 @@ class _PgcPanelState extends State { ? const EdgeInsets.only(right: 10) : null, child: Material( - color: theme.colorScheme.onInverseSurface, + color: theme.onInverseSurface, borderRadius: const BorderRadius.all(Radius.circular(6)), child: InkWell( borderRadius: const BorderRadius.all(Radius.circular(6)), @@ -192,7 +188,7 @@ class _PgcPanelState extends State { padding: const EdgeInsets.only(right: 6), child: Image.asset( 'assets/images/live.png', - color: theme.colorScheme.primary, + color: theme.primary, height: 12, semanticLabel: "正在播放:", ), @@ -222,7 +218,11 @@ class _PgcPanelState extends State { item.badge!, style: TextStyle( fontSize: 11, - color: theme.colorScheme.primary, + color: switch (item.badge) { + '限免' => theme.freeColor, + '预告' => theme.onSurfaceVariant, + _ => theme.primary, + }, ), ), ], diff --git a/lib/pages/webdav/view.dart b/lib/pages/webdav/view.dart index d1b62965..5ada4bff 100644 --- a/lib/pages/webdav/view.dart +++ b/lib/pages/webdav/view.dart @@ -9,10 +9,10 @@ import 'package:flutter_smart_dialog/flutter_smart_dialog.dart'; class WebDavSettingPage extends StatefulWidget { const WebDavSettingPage({ super.key, - this.showAppBar, + this.showAppBar = true, }); - final bool? showAppBar; + final bool showAppBar; @override State createState() => _WebDavSettingPageState(); @@ -38,7 +38,8 @@ class _WebDavSettingPageState extends State { Widget build(BuildContext context) { EdgeInsets padding = MediaQuery.paddingOf(context); return Scaffold( - appBar: widget.showAppBar == false + resizeToAvoidBottomInset: widget.showAppBar, + appBar: !widget.showAppBar ? null : AppBar(title: const Text('WebDAV 设置')), body: ListView( diff --git a/lib/pages/webview/view.dart b/lib/pages/webview/view.dart index a6385acd..f745fb43 100644 --- a/lib/pages/webview/view.dart +++ b/lib/pages/webview/view.dart @@ -38,6 +38,11 @@ class _WebviewPageState extends State { InAppWebViewController? _webViewController; + static final _prefixRegex = RegExp( + r'^(?!(https?://))\S+://', + caseSensitive: false, + ); + @override void initState() { super.initState(); @@ -298,10 +303,7 @@ class _WebviewPageState extends State { if (hasMatch) { progress.value = 1; return NavigationActionPolicy.CANCEL; - } else if (RegExp( - r'^(?!(https?://))\S+://', - caseSensitive: false, - ).hasMatch(url)) { + } else if (_prefixRegex.hasMatch(url)) { if (context.mounted) { SnackBar snackBar = SnackBar( content: const Text('当前网页将要打开外部链接,是否打开'), diff --git a/lib/utils/extension.dart b/lib/utils/extension.dart index 4a518559..5568379d 100644 --- a/lib/utils/extension.dart +++ b/lib/utils/extension.dart @@ -85,6 +85,9 @@ extension StringExt on String? { extension ColorSchemeExt on ColorScheme { Color get vipColor => brightness.isLight ? const Color(0xFFFF6699) : const Color(0xFFD44E7D); + + Color get freeColor => + brightness.isLight ? const Color(0xFFFF7F24) : const Color(0xFFD66011); } extension Unique on List {