diff --git a/android/app/src/main/kotlin/com/example/piliplus/MainActivity.kt b/android/app/src/main/kotlin/com/example/piliplus/MainActivity.kt index ab3f06264..4da9df8d8 100644 --- a/android/app/src/main/kotlin/com/example/piliplus/MainActivity.kt +++ b/android/app/src/main/kotlin/com/example/piliplus/MainActivity.kt @@ -27,7 +27,6 @@ import java.io.File class MainActivity : AudioServiceActivity() { private lateinit var methodChannel: MethodChannel - private var isFoldable = false override fun configureFlutterEngine(flutterEngine: FlutterEngine) { super.configureFlutterEngine(flutterEngine) @@ -181,8 +180,8 @@ class MainActivity : AudioServiceActivity() { } } - "isFoldable" -> { - result.success(isFoldable) + "sdkInt" -> { + result.success(Build.VERSION.SDK_INT) } else -> result.notImplemented() @@ -190,18 +189,6 @@ class MainActivity : AudioServiceActivity() { } } - override fun onConfigurationChanged(newConfig: Configuration) { - super.onConfigurationChanged(newConfig) - if (isFoldable) { - maxScreenSize()?.let { - MethodChannel( - flutterEngine!!.dartExecutor.binaryMessenger, - "ScreenChannel" - ).invokeMethod("onConfigChanged", it) - } - } - } - private fun maxScreenSize(): Map? { try { val density = resources.displayMetrics.density @@ -238,14 +225,6 @@ class MainActivity : AudioServiceActivity() { window.attributes.layoutInDisplayCutoutMode = LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES } - - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) { - try { - isFoldable = - packageManager.hasSystemFeature(PackageManager.FEATURE_SENSOR_HINGE_ANGLE) - } catch (e: Exception) { - } - } } override fun onDestroy() { diff --git a/lib/common/widgets/custom_toast.dart b/lib/common/widgets/custom_toast.dart index edc416fb8..91e83f005 100644 --- a/lib/common/widgets/custom_toast.dart +++ b/lib/common/widgets/custom_toast.dart @@ -1,13 +1,10 @@ -import 'package:PiliPlus/utils/storage_pref.dart'; import 'package:flutter/material.dart'; class CustomToast extends StatelessWidget { - const CustomToast({super.key, required this.msg}); + const CustomToast(this.msg, {super.key}); final String msg; - static double toastOpacity = Pref.defaultToastOp; - @override Widget build(BuildContext context) { final colorScheme = ColorScheme.of(context); @@ -17,7 +14,7 @@ class CustomToast extends StatelessWidget { ), padding: const EdgeInsets.symmetric(horizontal: 17, vertical: 10), decoration: BoxDecoration( - color: colorScheme.primaryContainer.withValues(alpha: toastOpacity), + color: colorScheme.primaryContainer, borderRadius: const BorderRadius.all(Radius.circular(20)), ), child: Text( @@ -32,7 +29,7 @@ class CustomToast extends StatelessWidget { } class LoadingWidget extends StatelessWidget { - const LoadingWidget({super.key, required this.msg}); + const LoadingWidget(this.msg, {super.key}); ///loading msg final String msg; diff --git a/lib/common/widgets/dynamic_sliver_app_bar/dynamic_sliver_app_bar.dart b/lib/common/widgets/dynamic_sliver_app_bar/dynamic_sliver_app_bar.dart index f54770199..1972c2a78 100644 --- a/lib/common/widgets/dynamic_sliver_app_bar/dynamic_sliver_app_bar.dart +++ b/lib/common/widgets/dynamic_sliver_app_bar/dynamic_sliver_app_bar.dart @@ -22,7 +22,7 @@ import 'package:PiliPlus/common/widgets/dynamic_sliver_app_bar/rendering/sliver_ import 'package:PiliPlus/common/widgets/dynamic_sliver_app_bar/sliver_persistent_header.dart'; import 'package:PiliPlus/common/widgets/only_layout_widget.dart' show LayoutCallback; -import 'package:flutter/foundation.dart'; +import 'package:flutter/foundation.dart' show describeIdentity, clampDouble; import 'package:flutter/material.dart' hide SliverPersistentHeader, SliverPersistentHeaderDelegate; import 'package:flutter/rendering.dart' show RenderOpacity, OpacityLayer; diff --git a/lib/common/widgets/dynamic_sliver_app_bar/rendering/sliver_persistent_header.dart b/lib/common/widgets/dynamic_sliver_app_bar/rendering/sliver_persistent_header.dart index d4f31aea6..e7e4b3847 100644 --- a/lib/common/widgets/dynamic_sliver_app_bar/rendering/sliver_persistent_header.dart +++ b/lib/common/widgets/dynamic_sliver_app_bar/rendering/sliver_persistent_header.dart @@ -19,7 +19,7 @@ import 'dart:math' as math; import 'package:PiliPlus/common/widgets/dynamic_sliver_app_bar/sliver_persistent_header.dart'; import 'package:PiliPlus/common/widgets/only_layout_widget.dart'; -import 'package:flutter/foundation.dart'; +import 'package:flutter/foundation.dart' show clampDouble; import 'package:flutter/rendering.dart' hide LayoutCallback; import 'package:flutter/widgets.dart' hide SliverPersistentHeader, SliverPersistentHeaderDelegate; diff --git a/lib/common/widgets/flutter/tabs.dart b/lib/common/widgets/flutter/tabs.dart deleted file mode 100644 index cf3807362..000000000 --- a/lib/common/widgets/flutter/tabs.dart +++ /dev/null @@ -1,370 +0,0 @@ -// Copyright 2014 The Flutter Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -import 'dart:ui' show SemanticsRole; - -import 'package:flutter/foundation.dart' show clampDouble; -import 'package:flutter/gestures.dart' show DragStartBehavior; -import 'package:flutter/material.dart' hide TabBarView; - -/// A page view that displays the widget which corresponds to the currently -/// selected tab. -/// -/// This widget is typically used in conjunction with a [TabBar]. -/// -/// {@youtube 560 315 https://www.youtube.com/watch?v=POtoEH-5l40} -/// -/// If a [TabController] is not provided, then there must be a [DefaultTabController] -/// ancestor. -/// -/// The tab controller's [TabController.length] must equal the length of the -/// [children] list and the length of the [TabBar.tabs] list. -/// -/// To see a sample implementation, visit the [TabController] documentation. -class CustomTabBarView extends StatefulWidget { - /// Creates a page view with one child per tab. - /// - /// The length of [children] must be the same as the [controller]'s length. - const CustomTabBarView({ - super.key, - required this.children, - this.controller, - this.physics, - this.dragStartBehavior = DragStartBehavior.start, - this.viewportFraction = 1.0, - this.clipBehavior = Clip.hardEdge, - this.scrollDirection = Axis.horizontal, - }); - - /// This widget's selection and animation state. - /// - /// If [TabController] is not provided, then the value of [DefaultTabController.of] - /// will be used. - final TabController? controller; - - /// One widget per tab. - /// - /// Its length must match the length of the [TabBar.tabs] - /// list, as well as the [controller]'s [TabController.length]. - final List children; - - /// How the page view should respond to user input. - /// - /// For example, determines how the page view continues to animate after the - /// user stops dragging the page view. - /// - /// The physics are modified to snap to page boundaries using - /// [PageScrollPhysics] prior to being used. - /// - /// Defaults to matching platform conventions. - final ScrollPhysics? physics; - - /// {@macro flutter.widgets.scrollable.dragStartBehavior} - final DragStartBehavior dragStartBehavior; - - /// {@macro flutter.widgets.pageview.viewportFraction} - final double viewportFraction; - - /// {@macro flutter.material.Material.clipBehavior} - /// - /// Defaults to [Clip.hardEdge]. - final Clip clipBehavior; - - final Axis scrollDirection; - - @override - State createState() => _CustomTabBarViewState(); -} - -class _CustomTabBarViewState extends State { - TabController? _controller; - PageController? _pageController; - late List _childrenWithKey; - int? _currentIndex; - int _warpUnderwayCount = 0; - int _scrollUnderwayCount = 0; - bool _debugHasScheduledValidChildrenCountCheck = false; - - // If the TabBarView is rebuilt with a new tab controller, the caller should - // dispose the old one. In that case the old controller's animation will be - // null and should not be accessed. - bool get _controllerIsValid => _controller?.animation != null; - - void _updateTabController() { - final TabController? newController = - widget.controller ?? DefaultTabController.maybeOf(context); - assert(() { - if (newController == null) { - throw FlutterError( - 'No TabController for ${widget.runtimeType}.\n' - 'When creating a ${widget.runtimeType}, you must either provide an explicit ' - 'TabController using the "controller" property, or you must ensure that there ' - 'is a DefaultTabController above the ${widget.runtimeType}.\n' - 'In this case, there was neither an explicit controller nor a default controller.', - ); - } - return true; - }()); - - if (newController == _controller) { - return; - } - - if (_controllerIsValid) { - _controller!.animation!.removeListener(_handleTabControllerAnimationTick); - } - _controller = newController; - if (_controller != null) { - _controller!.animation!.addListener(_handleTabControllerAnimationTick); - } - } - - void _jumpToPage(int page) { - _warpUnderwayCount += 1; - _pageController!.jumpToPage(page); - _warpUnderwayCount -= 1; - } - - Future _animateToPage( - int page, { - required Duration duration, - required Curve curve, - }) async { - _warpUnderwayCount += 1; - await _pageController!.animateToPage( - page, - duration: duration, - curve: curve, - ); - _warpUnderwayCount -= 1; - } - - @override - void initState() { - super.initState(); - _updateChildren(); - } - - @override - void didChangeDependencies() { - super.didChangeDependencies(); - _updateTabController(); - _currentIndex = _controller!.index; - if (_pageController == null) { - _pageController = PageController( - initialPage: _currentIndex!, - viewportFraction: widget.viewportFraction, - ); - } else { - _pageController!.jumpToPage(_currentIndex!); - } - } - - @override - void didUpdateWidget(CustomTabBarView oldWidget) { - super.didUpdateWidget(oldWidget); - if (widget.controller != oldWidget.controller) { - _updateTabController(); - _currentIndex = _controller!.index; - _jumpToPage(_currentIndex!); - } - if (widget.viewportFraction != oldWidget.viewportFraction) { - _pageController?.dispose(); - _pageController = PageController( - initialPage: _currentIndex!, - viewportFraction: widget.viewportFraction, - ); - } - // While a warp is under way, we stop updating the tab page contents. - // This is tracked in https://github.com/flutter/flutter/issues/31269. - if (widget.children != oldWidget.children && _warpUnderwayCount == 0) { - _updateChildren(); - } - } - - @override - void dispose() { - if (_controllerIsValid) { - _controller!.animation!.removeListener(_handleTabControllerAnimationTick); - } - _controller = null; - _pageController?.dispose(); - // We don't own the _controller Animation, so it's not disposed here. - super.dispose(); - } - - void _updateChildren() { - _childrenWithKey = KeyedSubtree.ensureUniqueKeysForList( - widget.children.map((Widget child) { - return Semantics(role: SemanticsRole.tabPanel, child: child); - }).toList(), - ); - } - - void _handleTabControllerAnimationTick() { - if (_scrollUnderwayCount > 0 || !_controller!.indexIsChanging) { - return; - } // This widget is driving the controller's animation. - - if (_controller!.index != _currentIndex) { - _currentIndex = _controller!.index; - _warpToCurrentIndex(); - } - } - - void _warpToCurrentIndex() { - if (!mounted || _pageController!.page == _currentIndex!.toDouble()) { - return; - } - - final bool adjacentDestination = - (_currentIndex! - _controller!.previousIndex).abs() == 1; - if (adjacentDestination) { - _warpToAdjacentTab(_controller!.animationDuration); - } else { - _warpToNonAdjacentTab(_controller!.animationDuration); - } - } - - Future _warpToAdjacentTab(Duration duration) async { - if (duration == Duration.zero) { - _jumpToPage(_currentIndex!); - } else { - await _animateToPage( - _currentIndex!, - duration: duration, - curve: Curves.ease, - ); - } - if (mounted) { - setState(_updateChildren); - } - return Future.value(); - } - - Future _warpToNonAdjacentTab(Duration duration) async { - final int previousIndex = _controller!.previousIndex; - assert((_currentIndex! - previousIndex).abs() > 1); - - // initialPage defines which page is shown when starting the animation. - // This page is adjacent to the destination page. - final int initialPage = _currentIndex! > previousIndex - ? _currentIndex! - 1 - : _currentIndex! + 1; - - setState(() { - // Needed for `RenderSliverMultiBoxAdaptor.move` and kept alive children. - // For motivation, see https://github.com/flutter/flutter/pull/29188 and - // https://github.com/flutter/flutter/issues/27010#issuecomment-486475152. - _childrenWithKey = List.of(_childrenWithKey, growable: false); - final Widget temp = _childrenWithKey[initialPage]; - _childrenWithKey[initialPage] = _childrenWithKey[previousIndex]; - _childrenWithKey[previousIndex] = temp; - }); - - // Make a first jump to the adjacent page. - _jumpToPage(initialPage); - - // Jump or animate to the destination page. - if (duration == Duration.zero) { - _jumpToPage(_currentIndex!); - } else { - await _animateToPage( - _currentIndex!, - duration: duration, - curve: Curves.ease, - ); - } - - if (mounted) { - setState(_updateChildren); - } - } - - void _syncControllerOffset() { - _controller!.offset = clampDouble( - _pageController!.page! - _controller!.index, - -1.0, - 1.0, - ); - } - - // Called when the PageView scrolls - bool _handleScrollNotification(ScrollNotification notification) { - if (_warpUnderwayCount > 0 || _scrollUnderwayCount > 0) { - return false; - } - - if (notification.depth != 0) { - return false; - } - - if (!_controllerIsValid) { - return false; - } - - _scrollUnderwayCount += 1; - final double page = _pageController!.page!; - if (notification is ScrollUpdateNotification && - !_controller!.indexIsChanging) { - final bool pageChanged = (page - _controller!.index).abs() > 1.0; - if (pageChanged) { - _controller!.index = page.round(); - _currentIndex = _controller!.index; - } - _syncControllerOffset(); - } else if (notification is ScrollEndNotification) { - _controller!.index = page.round(); - _currentIndex = _controller!.index; - if (!_controller!.indexIsChanging) { - _syncControllerOffset(); - } - } - _scrollUnderwayCount -= 1; - - return false; - } - - bool _debugScheduleCheckHasValidChildrenCount() { - if (_debugHasScheduledValidChildrenCountCheck) { - return true; - } - WidgetsBinding.instance.addPostFrameCallback((Duration duration) { - _debugHasScheduledValidChildrenCountCheck = false; - if (!mounted) { - return; - } - assert(() { - if (_controller!.length != widget.children.length) { - throw FlutterError( - "Controller's length property (${_controller!.length}) does not match the " - "number of children (${widget.children.length}) present in TabBarView's children property.", - ); - } - return true; - }()); - }, debugLabel: 'TabBarView.validChildrenCountCheck'); - _debugHasScheduledValidChildrenCountCheck = true; - return true; - } - - @override - Widget build(BuildContext context) { - assert(_debugScheduleCheckHasValidChildrenCount()); - - return NotificationListener( - onNotification: _handleScrollNotification, - child: PageView( - scrollDirection: widget.scrollDirection, - dragStartBehavior: widget.dragStartBehavior, - clipBehavior: widget.clipBehavior, - controller: _pageController, - physics: widget.physics == null - ? const PageScrollPhysics().applyTo(const ClampingScrollPhysics()) - : const PageScrollPhysics().applyTo(widget.physics), - children: _childrenWithKey, - ), - ); - } -} diff --git a/lib/common/widgets/image/network_img_layer.dart b/lib/common/widgets/image/network_img_layer.dart index 99ccf3144..d8168a9dc 100644 --- a/lib/common/widgets/image/network_img_layer.dart +++ b/lib/common/widgets/image/network_img_layer.dart @@ -3,7 +3,6 @@ import 'package:PiliPlus/common/style.dart'; import 'package:PiliPlus/models/common/image_type.dart'; import 'package:PiliPlus/utils/extension/num_ext.dart'; import 'package:PiliPlus/utils/image_utils.dart'; -import 'package:PiliPlus/utils/storage_pref.dart'; import 'package:cached_network_image/cached_network_image.dart'; import 'package:flutter/material.dart'; @@ -37,9 +36,6 @@ class NetworkImgLayer extends StatelessWidget { final Alignment alignment; final bool? cacheWidth; - static Color? reduceLuxColor = Pref.reduceLuxColor; - static bool reduce = false; - @override Widget build(BuildContext context) { final isEmote = type == ImageType.emote; @@ -74,8 +70,6 @@ class NetworkImgLayer extends StatelessWidget { imageUrl: ImageUtils.thumbnailUrl( src, maxQuality: quality, - - /// remove gif suffix: src!.endsWith(ImageUtils.kSuffixGIF) ? ImageUtils.kSuffixJPG : ImageUtils.kSuffixWEBP, @@ -94,8 +88,6 @@ class NetworkImgLayer extends StatelessWidget { _placeholder(context, isEmote: isEmote, isAvatar: isAvatar), errorWidget: (_, _, _) => _placeholder(context, isEmote: isEmote, isAvatar: isAvatar), - colorBlendMode: reduce ? BlendMode.modulate : null, - color: reduce ? reduceLuxColor : null, ); } @@ -121,8 +113,6 @@ class NetworkImgLayer extends StatelessWidget { width: width, height: height, cacheWidth: width.cacheSize(context), - colorBlendMode: reduce ? BlendMode.modulate : null, - color: reduce ? reduceLuxColor : null, ), ), ); diff --git a/lib/common/widgets/image_viewer/viewer.dart b/lib/common/widgets/image_viewer/viewer.dart index 77748a0ed..d532c8f7c 100644 --- a/lib/common/widgets/image_viewer/viewer.dart +++ b/lib/common/widgets/image_viewer/viewer.dart @@ -22,7 +22,7 @@ import 'package:PiliPlus/common/widgets/gesture/horizontal_drag_gesture_recogniz import 'package:PiliPlus/common/widgets/gesture/image_horizontal_drag_gesture_recognizer.dart'; import 'package:PiliPlus/utils/extension/num_ext.dart'; import 'package:easy_debounce/easy_throttle.dart'; -import 'package:flutter/foundation.dart'; +import 'package:flutter/foundation.dart' show clampDouble; import 'package:flutter/gestures.dart'; import 'package:flutter/material.dart'; import 'package:flutter/physics.dart' show FrictionSimulation; diff --git a/lib/common/widgets/marquee.dart b/lib/common/widgets/marquee.dart index 31d9b7002..9cb258c76 100644 --- a/lib/common/widgets/marquee.dart +++ b/lib/common/widgets/marquee.dart @@ -1,4 +1,5 @@ -import 'package:flutter/foundation.dart'; +import 'package:flutter/foundation.dart' + show kDebugMode, describeIdentity, ValueListenable; import 'package:flutter/material.dart'; import 'package:flutter/rendering.dart'; import 'package:flutter/scheduler.dart'; diff --git a/lib/http/sponsor_block.dart b/lib/http/sponsor_block.dart index 553f2f051..752f81249 100644 --- a/lib/http/sponsor_block.dart +++ b/lib/http/sponsor_block.dart @@ -1,6 +1,5 @@ import 'dart:convert'; -import 'package:PiliPlus/build_config.dart'; import 'package:PiliPlus/common/constants.dart'; import 'package:PiliPlus/http/init.dart'; import 'package:PiliPlus/http/loading_state.dart'; @@ -12,20 +11,12 @@ import 'package:PiliPlus/models_new/sponsor_block/user_info.dart'; import 'package:PiliPlus/utils/storage_pref.dart'; import 'package:PiliPlus/utils/utils.dart'; import 'package:dio/dio.dart'; -import 'package:flutter/foundation.dart' show kDebugMode; /// https://github.com/hanydd/BilibiliSponsorBlock/wiki/API abstract final class SponsorBlock { static String get blockServer => Pref.blockServer; static final options = Options( followRedirects: true, - // https://github.com/hanydd/BilibiliSponsorBlock/wiki/API#1-%E5%85%AC%E7%94%A8%E5%8F%82%E6%95%B0 - headers: kDebugMode - ? null - : { - 'origin': Constants.appName, - 'x-ext-version': BuildConfig.versionName, - }, validateStatus: (status) => true, ); @@ -145,9 +136,7 @@ abstract final class SponsorBlock { 'videoID': bvid, 'cid': cid.toString(), 'userID': Pref.blockUserID, - 'userAgent': kDebugMode - ? Constants.userAgent - : '${Constants.appName}/${BuildConfig.versionName}', + 'userAgent': Constants.userAgent, 'videoDuration': videoDuration, 'segments': segments .map( diff --git a/lib/main.dart b/lib/main.dart index bc08179a5..91b1ffbb3 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -18,7 +18,6 @@ import 'package:PiliPlus/utils/cache_manager.dart'; import 'package:PiliPlus/utils/calc_window_position.dart'; import 'package:PiliPlus/utils/date_utils.dart'; import 'package:PiliPlus/utils/device_utils.dart'; -import 'package:PiliPlus/utils/extension/iterable_ext.dart'; import 'package:PiliPlus/utils/extension/theme_ext.dart'; import 'package:PiliPlus/utils/json_file_handler.dart'; import 'package:PiliPlus/utils/max_screen_size.dart'; @@ -31,12 +30,10 @@ import 'package:PiliPlus/utils/storage_pref.dart'; import 'package:PiliPlus/utils/theme_utils.dart'; import 'package:PiliPlus/utils/utils.dart'; import 'package:catcher_2/catcher_2.dart'; -import 'package:device_info_plus/device_info_plus.dart'; import 'package:dynamic_color/dynamic_color.dart'; -import 'package:flutter/foundation.dart'; +import 'package:flutter/foundation.dart' show kDebugMode; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; -import 'package:flutter_displaymode/flutter_displaymode.dart'; import 'package:flutter_inappwebview/flutter_inappwebview.dart'; import 'package:flutter_localizations/flutter_localizations.dart'; import 'package:flutter_smart_dialog/flutter_smart_dialog.dart'; @@ -90,7 +87,7 @@ Future _initAppPath() async { } Future _initSdkInt() async { - DeviceUtils.sdkInt = (await DeviceInfoPlugin().androidInfo).version.sdkInt; + DeviceUtils.sdkInt = await Utils.channel.invokeMethod('sdkInt'); } void main() async { @@ -147,20 +144,7 @@ void main() async { systemNavigationBarContrastEnforced: false, ), ); - if (Platform.isAndroid) { - FlutterDisplayMode.supported.then((mode) { - final String? storageDisplay = GStorage.setting.get( - SettingBoxKey.displayMode, - ); - DisplayMode? displayMode; - if (storageDisplay != null) { - displayMode = mode.firstWhereOrNull( - (e) => e.toString() == storageDisplay, - ); - } - FlutterDisplayMode.setPreferredMode(displayMode ?? DisplayMode.auto); - }); - } else { + if (Platform.isIOS) { ScreenBrightnessPlatform.instance.setAutoReset(false); } } else if (PlatformUtils.isDesktop) { @@ -169,9 +153,7 @@ void main() async { final windowOptions = WindowOptions( minimumSize: const Size(400, 720), skipTaskbar: false, - titleBarStyle: Pref.showWindowTitleBar - ? TitleBarStyle.normal - : TitleBarStyle.hidden, + titleBarStyle: Pref.showWindowTitleBar ? .normal : .hidden, title: Constants.appName, ); windowManager.waitUntilReadyToShow(windowOptions, () async { @@ -295,14 +277,11 @@ class MyApp extends StatelessWidget { getPages: Routes.getPages, defaultTransition: Pref.pageTransition, builder: FlutterSmartDialog.init( - toastBuilder: (msg) => CustomToast(msg: msg), - loadingBuilder: (msg) => LoadingWidget(msg: msg), + toastBuilder: CustomToast.new, + loadingBuilder: LoadingWidget.new, builder: _builder, ), - navigatorObservers: [ - routeObserver, - FlutterSmartDialog.observer, - ], + navigatorObservers: [routeObserver], scrollBehavior: PlatformUtils.isDesktop ? const CustomScrollBehavior(desktopDragDevices) : null, diff --git a/lib/models/dynamics/result.dart b/lib/models/dynamics/result.dart index 4564834ef..b35d03600 100644 --- a/lib/models/dynamics/result.dart +++ b/lib/models/dynamics/result.dart @@ -1172,13 +1172,8 @@ class RichTextNodeItem { class Emoji { String? url; late num size; - - /// remove gif Emoji.fromJson(Map json) { - url = - // noneNullOrEmptyString(json['webp_url']) ?? - // noneNullOrEmptyString(json['gif_url']) ?? - nonNullOrEmptyString(json['icon_url']); + url = nonNullOrEmptyString(json['icon_url']); size = json['size'] ?? 1; } } diff --git a/lib/models_new/space/space_opus/cover.dart b/lib/models_new/space/space_opus/cover.dart index e0045c84a..986a482cc 100644 --- a/lib/models_new/space/space_opus/cover.dart +++ b/lib/models_new/space/space_opus/cover.dart @@ -1,4 +1,4 @@ -import 'package:flutter/foundation.dart'; +import 'package:flutter/foundation.dart' show clampDouble; class Cover { String? url; diff --git a/lib/pages/about/view.dart b/lib/pages/about/view.dart index 9e59f25ca..cdb0faa11 100644 --- a/lib/pages/about/view.dart +++ b/lib/pages/about/view.dart @@ -20,7 +20,6 @@ import 'package:PiliPlus/utils/login_utils.dart'; import 'package:PiliPlus/utils/page_utils.dart'; import 'package:PiliPlus/utils/platform_utils.dart'; import 'package:PiliPlus/utils/storage.dart'; -import 'package:PiliPlus/utils/update.dart'; import 'package:PiliPlus/utils/utils.dart'; import 'package:flutter/material.dart' hide ListTile; import 'package:flutter_smart_dialog/flutter_smart_dialog.dart'; @@ -136,7 +135,6 @@ class _AboutPageState extends State { ), ), ListTile( - onTap: () => Update.checkUpdate(false), onLongPress: () => Utils.copyText(currentVersion), onSecondaryTap: PlatformUtils.isMobile ? null diff --git a/lib/pages/common/dyn/common_dyn_page.dart b/lib/pages/common/dyn/common_dyn_page.dart index ca22bbcde..8ae80a43f 100644 --- a/lib/pages/common/dyn/common_dyn_page.dart +++ b/lib/pages/common/dyn/common_dyn_page.dart @@ -14,7 +14,6 @@ import 'package:PiliPlus/pages/video/reply/widgets/reply_item_grpc.dart'; import 'package:PiliPlus/pages/video/reply_reply/view.dart'; import 'package:PiliPlus/utils/extension/num_ext.dart'; import 'package:PiliPlus/utils/extension/size_ext.dart'; -import 'package:PiliPlus/utils/feed_back.dart'; import 'package:PiliPlus/utils/num_utils.dart'; import 'package:PiliPlus/utils/storage.dart'; import 'package:PiliPlus/utils/storage_key.dart'; @@ -288,7 +287,6 @@ abstract class CommonDynPageState extends State heroTag: null, onPressed: () { try { - feedBack(); controller.onReply( null, oid: controller.oid, diff --git a/lib/pages/common/publish/common_rich_text_pub_page.dart b/lib/pages/common/publish/common_rich_text_pub_page.dart index a58ba271f..6d8b62436 100644 --- a/lib/pages/common/publish/common_rich_text_pub_page.dart +++ b/lib/pages/common/publish/common_rich_text_pub_page.dart @@ -18,7 +18,6 @@ import 'package:PiliPlus/utils/extension/file_ext.dart'; import 'package:PiliPlus/utils/extension/num_ext.dart'; import 'package:PiliPlus/utils/extension/string_ext.dart'; import 'package:PiliPlus/utils/extension/theme_ext.dart'; -import 'package:PiliPlus/utils/feed_back.dart'; import 'package:PiliPlus/utils/image_utils.dart'; import 'package:PiliPlus/utils/page_utils.dart'; import 'package:PiliPlus/utils/platform_utils.dart'; @@ -513,7 +512,6 @@ abstract class CommonRichTextPubPageState @override Future onPublish() async { - feedBack(); List>? pictures; if (imageList.isNotEmpty) { SmartDialog.showLoading(msg: '正在上传图片...'); diff --git a/lib/pages/common/publish/common_text_pub_page.dart b/lib/pages/common/publish/common_text_pub_page.dart index 0cb789ff1..ca6221f77 100644 --- a/lib/pages/common/publish/common_text_pub_page.dart +++ b/lib/pages/common/publish/common_text_pub_page.dart @@ -1,5 +1,4 @@ import 'package:PiliPlus/pages/common/publish/common_publish_page.dart'; -import 'package:PiliPlus/utils/feed_back.dart'; import 'package:flutter/material.dart'; abstract class CommonTextPubPage extends CommonPublishPage { @@ -30,7 +29,6 @@ abstract class CommonTextPubPageState @override Future onPublish() { - feedBack(); return onCustomPublish(); } } diff --git a/lib/pages/common/reply_controller.dart b/lib/pages/common/reply_controller.dart index 7b0ad4ba5..01ad1b9e5 100644 --- a/lib/pages/common/reply_controller.dart +++ b/lib/pages/common/reply_controller.dart @@ -8,7 +8,6 @@ import 'package:PiliPlus/models/common/reply/reply_sort_type.dart'; import 'package:PiliPlus/pages/common/common_list_controller.dart'; import 'package:PiliPlus/pages/common/publish/publish_route.dart'; import 'package:PiliPlus/pages/video/reply_new/view.dart'; -import 'package:PiliPlus/utils/feed_back.dart'; import 'package:PiliPlus/utils/reply_utils.dart'; import 'package:PiliPlus/utils/storage_pref.dart'; import 'package:fixnum/fixnum.dart'; @@ -101,7 +100,6 @@ abstract class ReplyController extends CommonListController { case ReplySortType.select: return; } - feedBack(); onReload(); } diff --git a/lib/pages/download/detail/widgets/item.dart b/lib/pages/download/detail/widgets/item.dart index e50e453d0..f36edc8aa 100644 --- a/lib/pages/download/detail/widgets/item.dart +++ b/lib/pages/download/detail/widgets/item.dart @@ -193,12 +193,6 @@ class DetailItem extends StatelessWidget { fit: BoxFit.cover, cacheWidth: cacheWidth, cacheHeight: cacheHeight, - colorBlendMode: NetworkImgLayer.reduce - ? BlendMode.modulate - : null, - color: NetworkImgLayer.reduce - ? NetworkImgLayer.reduceLuxColor - : null, ), ) : NetworkImgLayer( diff --git a/lib/pages/dynamics/widgets/author_panel.dart b/lib/pages/dynamics/widgets/author_panel.dart index 78a690379..8f32a5561 100644 --- a/lib/pages/dynamics/widgets/author_panel.dart +++ b/lib/pages/dynamics/widgets/author_panel.dart @@ -19,7 +19,6 @@ import 'package:PiliPlus/utils/date_utils.dart'; import 'package:PiliPlus/utils/extension/context_ext.dart'; import 'package:PiliPlus/utils/extension/num_ext.dart'; import 'package:PiliPlus/utils/extension/theme_ext.dart'; -import 'package:PiliPlus/utils/feed_back.dart'; import 'package:PiliPlus/utils/image_utils.dart'; import 'package:PiliPlus/utils/page_utils.dart'; import 'package:PiliPlus/utils/request_utils.dart'; @@ -95,10 +94,7 @@ class AuthorPanel extends StatelessWidget { } Widget header = GestureDetector( onTap: moduleAuthor.type == 'AUTHOR_TYPE_NORMAL' - ? () { - feedBack(); - Get.toNamed('/member?mid=${moduleAuthor.mid}'); - } + ? () => Get.toNamed('/member?mid=${moduleAuthor.mid}') : null, child: ExtraHitTestWidget( width: 50, diff --git a/lib/pages/dynamics/widgets/up_panel.dart b/lib/pages/dynamics/widgets/up_panel.dart index 8a53c6ca6..9e6c8c85f 100644 --- a/lib/pages/dynamics/widgets/up_panel.dart +++ b/lib/pages/dynamics/widgets/up_panel.dart @@ -7,7 +7,6 @@ import 'package:PiliPlus/pages/dynamics/controller.dart'; import 'package:PiliPlus/pages/live_follow/view.dart'; import 'package:PiliPlus/utils/accounts.dart'; import 'package:PiliPlus/utils/extension/num_ext.dart'; -import 'package:PiliPlus/utils/feed_back.dart'; import 'package:PiliPlus/utils/page_utils.dart'; import 'package:PiliPlus/utils/platform_utils.dart'; import 'package:flutter/material.dart'; @@ -216,7 +215,6 @@ class _UpPanelState extends State { width: isTop ? 70 : null, child: InkWell( onTap: () { - feedBack(); if (isLive) { PageUtils.toLiveRoom(data.roomId); } else { diff --git a/lib/pages/episode_panel/view.dart b/lib/pages/episode_panel/view.dart index ee082b0a3..faea2c42b 100644 --- a/lib/pages/episode_panel/view.dart +++ b/lib/pages/episode_panel/view.dart @@ -32,7 +32,7 @@ import 'package:PiliPlus/utils/id_utils.dart'; import 'package:PiliPlus/utils/platform_utils.dart'; import 'package:PiliPlus/utils/storage_pref.dart'; import 'package:PiliPlus/utils/utils.dart'; -import 'package:flutter/foundation.dart'; +import 'package:flutter/foundation.dart' show kDebugMode; import 'package:flutter/material.dart' hide TabBarView; import 'package:flutter_smart_dialog/flutter_smart_dialog.dart'; import 'package:get/get.dart'; diff --git a/lib/pages/fav_panel/view.dart b/lib/pages/fav_panel/view.dart index dd9fed660..0c1b9cb45 100644 --- a/lib/pages/fav_panel/view.dart +++ b/lib/pages/fav_panel/view.dart @@ -3,7 +3,6 @@ import 'package:PiliPlus/http/loading_state.dart'; import 'package:PiliPlus/models_new/fav/fav_folder/list.dart'; import 'package:PiliPlus/pages/common/common_intro_controller.dart'; import 'package:PiliPlus/utils/bili_utils.dart'; -import 'package:PiliPlus/utils/feed_back.dart'; import 'package:flutter/material.dart'; import 'package:get/get.dart'; @@ -159,10 +158,7 @@ class _FavPanelState extends State { child: const Text('取消'), ), FilledButton.tonal( - onPressed: () { - feedBack(); - widget.ctr.actionFavVideo(); - }, + onPressed: widget.ctr.actionFavVideo, style: const ButtonStyle(visualDensity: .compact), child: const Text('完成'), ), diff --git a/lib/pages/follow/widgets/follow_item.dart b/lib/pages/follow/widgets/follow_item.dart index 469cf9812..11fed1f6e 100644 --- a/lib/pages/follow/widgets/follow_item.dart +++ b/lib/pages/follow/widgets/follow_item.dart @@ -1,7 +1,6 @@ import 'package:PiliPlus/common/widgets/pendant_avatar.dart'; import 'package:PiliPlus/models_new/follow/list.dart'; import 'package:PiliPlus/pages/share/view.dart' show UserModel; -import 'package:PiliPlus/utils/feed_back.dart'; import 'package:PiliPlus/utils/request_utils.dart'; import 'package:flutter/material.dart'; import 'package:get/get.dart'; @@ -60,7 +59,6 @@ class FollowItem extends StatelessWidget { ), ); } else { - feedBack(); Get.toNamed('/member?mid=${item.mid}'); } }, diff --git a/lib/pages/group_panel/view.dart b/lib/pages/group_panel/view.dart index 8ad1d2258..aff472956 100644 --- a/lib/pages/group_panel/view.dart +++ b/lib/pages/group_panel/view.dart @@ -4,7 +4,6 @@ import 'package:PiliPlus/http/member.dart'; import 'package:PiliPlus/models/member/tags.dart'; import 'package:PiliPlus/utils/extension/iterable_ext.dart'; import 'package:PiliPlus/utils/extension/num_ext.dart'; -import 'package:PiliPlus/utils/feed_back.dart'; import 'package:PiliPlus/utils/request_utils.dart'; import 'package:flutter/material.dart'; import 'package:flutter_smart_dialog/flutter_smart_dialog.dart'; @@ -53,7 +52,6 @@ class _GroupPanelState extends State { Get.back(); return; } - feedBack(); // 保存 final res = await MemberHttp.addUsers( widget.mid.toString(), diff --git a/lib/pages/home/controller.dart b/lib/pages/home/controller.dart index e3ee49e6f..3965da6c7 100644 --- a/lib/pages/home/controller.dart +++ b/lib/pages/home/controller.dart @@ -1,8 +1,6 @@ import 'dart:async'; import 'dart:math'; -import 'package:PiliPlus/http/api.dart'; -import 'package:PiliPlus/http/init.dart'; import 'package:PiliPlus/models/common/home_tab_type.dart'; import 'package:PiliPlus/pages/common/common_controller.dart'; import 'package:PiliPlus/pages/main/controller.dart'; @@ -10,7 +8,6 @@ import 'package:PiliPlus/services/account_service.dart'; import 'package:PiliPlus/utils/storage.dart'; import 'package:PiliPlus/utils/storage_key.dart'; import 'package:PiliPlus/utils/storage_pref.dart'; -import 'package:PiliPlus/utils/wbi_sign.dart'; import 'package:flutter/foundation.dart' show kDebugMode; import 'package:flutter/material.dart'; import 'package:get/get.dart'; @@ -23,10 +20,6 @@ class HomeController extends GetxController RxBool? showTopBar; late final bool hideTopBar; - bool enableSearchWord = Pref.enableSearchWord; - late final RxString defaultSearch = ''.obs; - late int lateCheckSearchAt = 0; - ScrollOrRefreshMixin get controller => tabs[tabController.index].ctr(); @override @@ -38,7 +31,7 @@ class HomeController extends GetxController void onInit() { super.onInit(); - hideTopBar = !Pref.useSideBar && Pref.hideTopBar; + hideTopBar = Pref.hideTopBar; if (hideTopBar) { final mainCtr = Get.find(); switch (mainCtr.barHideType) { @@ -49,11 +42,6 @@ class HomeController extends GetxController } } - if (enableSearchWord) { - lateCheckSearchAt = DateTime.now().millisecondsSinceEpoch; - querySearchDefault(); - } - setTabConfig(); } @@ -84,17 +72,4 @@ class HomeController extends GetxController tabController.dispose(); super.dispose(); } - - Future querySearchDefault() async { - try { - final res = await Request().get( - Api.searchDefault, - queryParameters: await WbiSign.makSign({'web_location': 333.1365}), - ); - if (res.data['code'] == 0) { - defaultSearch.value = res.data['data']?['name'] ?? ''; - // defaultSearch.value = res.data['data']?['show_name'] ?? ''; - } - } catch (_) {} - } } diff --git a/lib/pages/home/view.dart b/lib/pages/home/view.dart index bc2862e03..035b3ecd6 100644 --- a/lib/pages/home/view.dart +++ b/lib/pages/home/view.dart @@ -8,7 +8,6 @@ import 'package:PiliPlus/pages/main/controller.dart'; import 'package:PiliPlus/pages/mine/controller.dart'; import 'package:PiliPlus/utils/extension/get_ext.dart'; import 'package:PiliPlus/utils/extension/size_ext.dart'; -import 'package:PiliPlus/utils/feed_back.dart'; import 'package:flutter/material.dart'; import 'package:get/get.dart'; import 'package:material_design_icons_flutter/material_design_icons_flutter.dart'; @@ -51,7 +50,6 @@ class _HomePageState extends CommonPageState splashBorderRadius: Style.mdRadius, tabAlignment: TabAlignment.center, onTap: (_) { - feedBack(); if (!_homeController.tabController.indexIsChanging) { _homeController.animateToTop(); } @@ -71,9 +69,7 @@ class _HomePageState extends CommonPageState } return Column( children: [ - if (!_mainController.useSideBar && - MediaQuery.sizeOf(context).isPortrait) - customAppBar(theme), + if (MediaQuery.sizeOf(context).isPortrait) customAppBar(theme), tabBar, Expanded( child: onBuild( @@ -151,33 +147,17 @@ class _HomePageState extends CommonPageState splashColor: theme.colorScheme.primaryContainer.withValues( alpha: 0.3, ), - onTap: () => Get.toNamed( - '/search', - parameters: _homeController.enableSearchWord - ? {'hintText': _homeController.defaultSearch.value} - : null, - ), - child: Row( - children: [ - const SizedBox(width: 14), - Icon( + onTap: () => Get.toNamed('/search'), + child: Align( + alignment: .centerLeft, + child: Padding( + padding: const .only(left: 14), + child: Icon( Icons.search_outlined, color: theme.colorScheme.onSecondaryContainer, semanticLabel: '搜索', ), - const SizedBox(width: 10), - Expanded( - child: Obx( - () => Text( - _homeController.defaultSearch.value, - maxLines: 1, - overflow: TextOverflow.ellipsis, - style: TextStyle(color: theme.colorScheme.outline), - ), - ), - ), - const SizedBox(width: 5), - ], + ), ), ), ), diff --git a/lib/pages/login/view.dart b/lib/pages/login/view.dart index c8ed426b0..61d9f368a 100644 --- a/lib/pages/login/view.dart +++ b/lib/pages/login/view.dart @@ -13,7 +13,7 @@ import 'package:PiliPlus/utils/image_utils.dart'; import 'package:PiliPlus/utils/page_utils.dart'; import 'package:PiliPlus/utils/platform_utils.dart'; import 'package:PiliPlus/utils/utils.dart'; -import 'package:flutter/foundation.dart'; +import 'package:flutter/foundation.dart' show kDebugMode; import 'package:flutter/material.dart'; import 'package:flutter/rendering.dart'; import 'package:flutter/services.dart'; diff --git a/lib/pages/main/controller.dart b/lib/pages/main/controller.dart index 203a2c17a..1c73a3722 100644 --- a/lib/pages/main/controller.dart +++ b/lib/pages/main/controller.dart @@ -13,11 +13,9 @@ import 'package:PiliPlus/pages/mine/view.dart'; import 'package:PiliPlus/services/account_service.dart'; import 'package:PiliPlus/utils/extension/get_ext.dart'; import 'package:PiliPlus/utils/extension/iterable_ext.dart'; -import 'package:PiliPlus/utils/feed_back.dart'; import 'package:PiliPlus/utils/storage.dart'; import 'package:PiliPlus/utils/storage_key.dart'; import 'package:PiliPlus/utils/storage_pref.dart'; -import 'package:PiliPlus/utils/update.dart'; import 'package:collection/collection.dart'; import 'package:easy_debounce/easy_throttle.dart'; import 'package:flutter/material.dart'; @@ -35,7 +33,7 @@ class MainController extends GetxController late final bool hideBottomBar; late final barHideType = Pref.barHideType; bool useBottomNav = false; - late dynamic controller; + late PageController controller; final RxInt selectedIndex = 0.obs; final RxInt dynCount = 0.obs; @@ -54,11 +52,7 @@ class MainController extends GetxController late final RxString msgUnReadCount = ''.obs; late int lastCheckUnreadAt = 0; - final enableMYBar = Pref.enableMYBar; final floatingNavBar = Pref.floatingNavBar; - final useSideBar = Pref.useSideBar; - final mainTabBarView = Pref.mainTabBarView; - late final optTabletNav = Pref.optTabletNav; late bool directExitOnBack = Pref.directExitOnBack; late bool showTrayIcon = Pref.showTrayIcon; @@ -72,22 +66,11 @@ class MainController extends GetxController @override void onInit() { super.onInit(); - if (Pref.autoUpdate) { - Update.checkUpdate(); - } - setNavBarConfig(); - controller = mainTabBarView - ? TabController( - vsync: this, - initialIndex: selectedIndex.value, - length: navigationBars.length, - ) - : PageController(initialPage: selectedIndex.value); + controller = PageController(initialPage: selectedIndex.value); - hideBottomBar = - !useSideBar && navigationBars.length > 1 && Pref.hideBottomBar; + hideBottomBar = navigationBars.length > 1 && Pref.hideBottomBar; if (hideBottomBar) { switch (barHideType) { case .instant: @@ -235,21 +218,6 @@ class MainController extends GetxController selectedIndex.value = Pref.defaultHomePageIndex; } - void checkDefaultSearch([bool shouldCheck = false]) { - if (hasHome && homeController.enableSearchWord) { - if (shouldCheck && - navigationBars[selectedIndex.value] != NavigationBarType.home) { - return; - } - int now = DateTime.now().millisecondsSinceEpoch; - if (now - homeController.lateCheckSearchAt >= _period) { - homeController - ..lateCheckSearchAt = now - ..querySearchDefault(); - } - } - } - void checkUnread([bool shouldCheck = false]) { if (accountService.isLogin.value && hasHome && @@ -284,18 +252,11 @@ class MainController extends GetxController } void setIndex(int value) { - feedBack(); - final currentNav = navigationBars[value]; if (value != selectedIndex.value) { selectedIndex.value = value; - if (mainTabBarView) { - controller.animateTo(value); - } else { - controller.jumpToPage(value); - } + controller.jumpToPage(value); if (currentNav == NavigationBarType.home) { - checkDefaultSearch(); checkUnread(); } else if (currentNav == NavigationBarType.dynamics) { setDynCount(); diff --git a/lib/pages/main/view.dart b/lib/pages/main/view.dart index 4d7e61d26..05d8e2ebf 100644 --- a/lib/pages/main/view.dart +++ b/lib/pages/main/view.dart @@ -5,8 +5,6 @@ import 'package:PiliPlus/common/constants.dart'; import 'package:PiliPlus/common/style.dart'; import 'package:PiliPlus/common/widgets/floating_navigation_bar.dart'; import 'package:PiliPlus/common/widgets/flutter/pop_scope.dart'; -import 'package:PiliPlus/common/widgets/flutter/tabs.dart'; -import 'package:PiliPlus/common/widgets/image/network_img_layer.dart'; import 'package:PiliPlus/common/widgets/route_aware_mixin.dart'; import 'package:PiliPlus/models/common/nav_bar_config.dart'; import 'package:PiliPlus/pages/home/view.dart'; @@ -73,15 +71,10 @@ class _MainAppState extends PopScopeState super.didChangeDependencies(); _padding = MediaQuery.viewPaddingOf(context); theme = Theme.of(context); - final brightness = theme.brightness; - NetworkImgLayer.reduce = - NetworkImgLayer.reduceLuxColor != null && brightness.isDark; if (PlatformUtils.isDesktop) { - windowManager.setBrightness(brightness); - } - if (!_mainController.useSideBar) { - _mainController.useBottomNav = MediaQuery.sizeOf(context).isPortrait; + windowManager.setBrightness(theme.brightness); } + _mainController.useBottomNav = MediaQuery.sizeOf(context).isPortrait; } @override @@ -89,7 +82,6 @@ class _MainAppState extends PopScopeState addObserverMobile(this); _mainController ..checkUnreadDynamic() - ..checkDefaultSearch(true) ..checkUnread(_mainController.useBottomNav); super.didPopNext(); } @@ -102,10 +94,9 @@ class _MainAppState extends PopScopeState @override void didChangeAppLifecycleState(AppLifecycleState state) { - if (state == AppLifecycleState.resumed) { + if (state == .resumed) { _mainController ..checkUnreadDynamic() - ..checkDefaultSearch(true) ..checkUnread(_mainController.useBottomNav); } } @@ -291,7 +282,7 @@ class _MainAppState extends PopScopeState .toList(), ), ); - } else if (_mainController.enableMYBar) { + } else { bottomNav = Obx( () => NavigationBar( maintainBottomViewPadding: true, @@ -308,26 +299,6 @@ class _MainAppState extends PopScopeState .toList(), ), ); - } else { - bottomNav = Obx( - () => BottomNavigationBar( - currentIndex: _mainController.selectedIndex.value, - onTap: _mainController.setIndex, - iconSize: 16, - selectedFontSize: 12, - unselectedFontSize: 12, - type: .fixed, - items: _mainController.navigationBars - .map( - (e) => BottomNavigationBarItem( - label: e.label, - icon: _buildIcon(type: e), - activeIcon: _buildIcon(type: e, selected: true), - ), - ) - .toList(), - ), - ); } if (_mainController.hideBottomBar) { @@ -360,7 +331,7 @@ class _MainAppState extends PopScopeState Widget _sideBar(ThemeData theme) { return _mainController.navigationBars.length > 1 - ? context.isTablet && _mainController.optTabletNav + ? context.isTablet ? Column( children: [ const SizedBox(height: 25), @@ -427,21 +398,11 @@ class _MainAppState extends PopScopeState @override Widget build(BuildContext context) { - Widget child; - if (_mainController.mainTabBarView) { - child = CustomTabBarView( - scrollDirection: _mainController.useBottomNav ? .horizontal : .vertical, - physics: const NeverScrollableScrollPhysics(), - controller: _mainController.controller, - children: _mainController.navigationBars.map((i) => i.page).toList(), - ); - } else { - child = PageView( - physics: const NeverScrollableScrollPhysics(), - controller: _mainController.controller, - children: _mainController.navigationBars.map((i) => i.page).toList(), - ); - } + Widget child = PageView( + physics: const NeverScrollableScrollPhysics(), + controller: _mainController.controller, + children: _mainController.navigationBars.map((i) => i.page).toList(), + ); Widget? bottomNav; if (_mainController.useBottomNav) { @@ -466,7 +427,7 @@ class _MainAppState extends PopScopeState resizeToAvoidBottomInset: false, appBar: AppBar(toolbarHeight: 0), body: Padding( - padding: EdgeInsets.only( + padding: .only( left: _mainController.useBottomNav ? _padding.left : 0.0, right: _padding.right, ), diff --git a/lib/pages/main_reply/view.dart b/lib/pages/main_reply/view.dart index 40b305c10..0056b5c62 100644 --- a/lib/pages/main_reply/view.dart +++ b/lib/pages/main_reply/view.dart @@ -12,7 +12,6 @@ import 'package:PiliPlus/pages/main_reply/controller.dart'; import 'package:PiliPlus/pages/video/reply/widgets/reply_item_grpc.dart'; import 'package:PiliPlus/pages/video/reply_reply/view.dart'; import 'package:PiliPlus/utils/extension/widget_ext.dart'; -import 'package:PiliPlus/utils/feed_back.dart'; import 'package:PiliPlus/utils/num_utils.dart'; import 'package:PiliPlus/utils/utils.dart'; import 'package:easy_debounce/easy_throttle.dart'; @@ -98,7 +97,6 @@ class _MainReplyPageState extends State heroTag: null, onPressed: () { try { - feedBack(); _controller.onReply( null, oid: _controller.oid, diff --git a/lib/pages/search_trending/view.dart b/lib/pages/search_trending/view.dart index 5170490e5..c58e474b0 100644 --- a/lib/pages/search_trending/view.dart +++ b/lib/pages/search_trending/view.dart @@ -15,7 +15,7 @@ import 'package:PiliPlus/utils/extension/num_ext.dart'; import 'package:PiliPlus/utils/extension/size_ext.dart'; import 'package:PiliPlus/utils/image_utils.dart'; import 'package:cached_network_image/cached_network_image.dart'; -import 'package:flutter/foundation.dart'; +import 'package:flutter/foundation.dart' show clampDouble; import 'package:flutter/material.dart' hide ListTile; import 'package:flutter/services.dart' show SystemUiOverlayStyle; import 'package:get/get.dart'; diff --git a/lib/pages/setting/models/extra_settings.dart b/lib/pages/setting/models/extra_settings.dart index d49caa3dd..5e44b9104 100644 --- a/lib/pages/setting/models/extra_settings.dart +++ b/lib/pages/setting/models/extra_settings.dart @@ -20,18 +20,15 @@ import 'package:PiliPlus/models/common/super_resolution_type.dart'; import 'package:PiliPlus/models/dynamics/result.dart' show DynamicsDataModel, ItemModulesModel; import 'package:PiliPlus/pages/common/slide/common_slide_page.dart'; -import 'package:PiliPlus/pages/home/controller.dart'; import 'package:PiliPlus/pages/main/controller.dart'; import 'package:PiliPlus/pages/setting/models/model.dart'; import 'package:PiliPlus/pages/setting/widgets/select_dialog.dart'; import 'package:PiliPlus/pages/setting/widgets/slider_dialog.dart'; -import 'package:PiliPlus/pages/video/reply/widgets/reply_item_grpc.dart'; import 'package:PiliPlus/plugin/pl_player/controller.dart'; import 'package:PiliPlus/services/download/download_service.dart'; import 'package:PiliPlus/utils/accounts.dart'; import 'package:PiliPlus/utils/cache_manager.dart'; import 'package:PiliPlus/utils/extension/num_ext.dart'; -import 'package:PiliPlus/utils/feed_back.dart'; import 'package:PiliPlus/utils/global_data.dart'; import 'package:PiliPlus/utils/image_utils.dart'; import 'package:PiliPlus/utils/path_utils.dart'; @@ -39,7 +36,6 @@ import 'package:PiliPlus/utils/platform_utils.dart'; import 'package:PiliPlus/utils/storage.dart'; import 'package:PiliPlus/utils/storage_key.dart'; import 'package:PiliPlus/utils/storage_pref.dart'; -import 'package:PiliPlus/utils/update.dart'; import 'package:PiliPlus/utils/utils.dart'; import 'package:file_picker/file_picker.dart'; import 'package:flutter/foundation.dart' show kDebugMode; @@ -169,16 +165,6 @@ List get extraSettings => [ defaultVal: false, onChanged: (value) => ImageGridView.horizontalPreview = value, ), - NormalModel( - title: '评论折叠行数', - subtitle: '0行为不折叠', - leading: const Icon(Icons.compress), - getTrailing: (theme) => Text( - '${ReplyItemGrpc.replyLengthLimit}行', - style: theme.textTheme.titleSmall, - ), - onTap: _showReplyLengthDialog, - ), NormalModel( title: '弹幕行高', subtitle: '默认1.6', @@ -316,13 +302,6 @@ List get extraSettings => [ setKey: SettingBoxKey.preInitPlayer, defaultVal: false, ), - const SwitchModel( - title: '首页切换页面动画', - leading: Icon(Icons.home_outlined), - setKey: SettingBoxKey.mainTabBarView, - defaultVal: false, - needReboot: true, - ), const SwitchModel( title: '搜索建议', leading: Icon(Icons.search), @@ -453,12 +432,6 @@ List get extraSettings => [ defaultVal: Platform.isIOS, onChanged: (value) => CommonSlideMixin.slideDismissReplyPage = value, ), - const SwitchModel( - title: '启用双指缩小视频', - leading: Icon(Icons.pinch), - setKey: SettingBoxKey.enableShrinkVideoSize, - defaultVal: true, - ), const SwitchModel( title: '动态/专栏详情页展示底部操作栏', leading: Icon(Icons.more_horiz), @@ -493,16 +466,6 @@ List get extraSettings => [ defaultVal: false, onChanged: (value) => ImageGridView.enableImgMenu = value, ), - SwitchModel( - setKey: SettingBoxKey.feedBackEnable, - onChanged: (value) { - enableFeedback = value; - feedBack(); - }, - leading: const Icon(Icons.vibration_outlined), - title: '震动反馈', - subtitle: '请确定手机设置中已开启震动反馈', - ), const SwitchModel( title: '大家都在搜', subtitle: '是否展示「大家都在搜」', @@ -517,23 +480,6 @@ List get extraSettings => [ setKey: SettingBoxKey.enableSearchRcmd, defaultVal: true, ), - SwitchModel( - title: '搜索默认词', - subtitle: '是否展示搜索框默认词', - leading: const Icon(Icons.whatshot_outlined), - setKey: SettingBoxKey.enableSearchWord, - defaultVal: false, - onChanged: (val) { - try { - final controller = Get.find()..enableSearchWord = val; - if (val) { - controller.querySearchDefault(); - } else { - controller.defaultSearch.value = ''; - } - } catch (_) {} - }, - ), const SwitchModel( title: '快速收藏', subtitle: '点击设置默认收藏夹\n点按收藏至默认,长按选择文件夹', @@ -542,14 +488,6 @@ List get extraSettings => [ onTap: _showFavDialog, defaultVal: false, ), - SwitchModel( - title: '评论区搜索关键词', - subtitle: '展示评论区搜索关键词', - leading: const Icon(Icons.search_outlined), - setKey: SettingBoxKey.enableWordRe, - defaultVal: false, - onChanged: (value) => ReplyItemGrpc.enableWordRe = value, - ), const SwitchModel( title: '启用AI总结', subtitle: '视频详情页开启AI总结', @@ -557,13 +495,6 @@ List get extraSettings => [ setKey: SettingBoxKey.enableAi, defaultVal: false, ), - const SwitchModel( - title: '消息页禁用"收到的赞"功能', - subtitle: '禁止打开入口,降低网络社交依赖', - leading: Icon(Icons.beach_access_outlined), - setKey: SettingBoxKey.disableLikeMsg, - defaultVal: false, - ), const SwitchModel( title: '默认展示评论区', subtitle: '在视频详情页默认切换至评论区页(仅Tab型布局)', @@ -651,18 +582,6 @@ List get extraSettings => [ leading: const Icon(Icons.delete_outlined), onTap: _showCacheDialog, ), - SwitchModel( - title: '检查更新', - subtitle: '每次启动时检查是否需要更新', - leading: const Icon(Icons.system_update_alt), - setKey: SettingBoxKey.autoUpdate, - defaultVal: true, - onChanged: (val) { - if (val) { - Update.checkUpdate(false); - } - }, - ), ]; Future audioNormalization( @@ -847,47 +766,6 @@ void _showDynDialog(BuildContext context) { ); } -void _showReplyLengthDialog(BuildContext context, VoidCallback setState) { - String replyLengthLimit = ReplyItemGrpc.replyLengthLimit.toString(); - showDialog( - context: context, - builder: (context) => AlertDialog( - title: const Text('评论折叠行数'), - content: TextFormField( - autofocus: true, - initialValue: replyLengthLimit, - keyboardType: TextInputType.number, - onChanged: (value) => replyLengthLimit = value, - inputFormatters: [FilteringTextInputFormatter.digitsOnly], - decoration: const InputDecoration(suffixText: '行'), - ), - actions: [ - TextButton( - onPressed: Get.back, - child: Text( - '取消', - style: TextStyle(color: ColorScheme.of(context).outline), - ), - ), - TextButton( - onPressed: () async { - try { - final val = int.parse(replyLengthLimit); - Get.back(); - ReplyItemGrpc.replyLengthLimit = val == 0 ? null : val; - await GStorage.setting.put(SettingBoxKey.replyLengthLimit, val); - setState(); - } catch (e) { - SmartDialog.showToast(e.toString()); - } - }, - child: const Text('确定'), - ), - ], - ), - ); -} - void _showDmHeightDialog(BuildContext context, VoidCallback setState) { String danmakuLineHeight = Pref.danmakuLineHeight.toString(); showDialog( diff --git a/lib/pages/setting/models/play_settings.dart b/lib/pages/setting/models/play_settings.dart index c240ef005..62bd07bc3 100644 --- a/lib/pages/setting/models/play_settings.dart +++ b/lib/pages/setting/models/play_settings.dart @@ -134,11 +134,11 @@ List get playSettings => [ } catch (_) {} }, ), - const SwitchModel( + SwitchModel( title: '启用键盘控制', - leading: Icon(Icons.keyboard_alt_outlined), + leading: const Icon(Icons.keyboard_alt_outlined), setKey: SettingBoxKey.keyboardControl, - defaultVal: true, + defaultVal: PlatformUtils.isDesktop, ), NormalModel( title: 'SuperChat (醒目留言) 显示类型', @@ -173,13 +173,6 @@ List get playSettings => [ setKey: SettingBoxKey.enableAutoExit, defaultVal: true, ), - const SwitchModel( - title: '延长播放控件显示时间', - subtitle: '开启后延长至30秒,便于屏幕阅读器滑动切换控件焦点', - leading: Icon(Icons.timer_outlined), - setKey: SettingBoxKey.enableLongShowControl, - defaultVal: false, - ), if (PlatformUtils.isMobile) const SwitchModel( title: '后台播放', diff --git a/lib/pages/setting/models/recommend_settings.dart b/lib/pages/setting/models/recommend_settings.dart index 256d27468..e32f117cb 100644 --- a/lib/pages/setting/models/recommend_settings.dart +++ b/lib/pages/setting/models/recommend_settings.dart @@ -3,7 +3,7 @@ import 'package:PiliPlus/pages/rcmd/controller.dart'; import 'package:PiliPlus/pages/setting/models/model.dart'; import 'package:PiliPlus/utils/recommend_filter.dart'; import 'package:PiliPlus/utils/storage_key.dart'; -import 'package:flutter/foundation.dart'; +import 'package:flutter/foundation.dart' show kDebugMode; import 'package:flutter/material.dart'; import 'package:get/get.dart'; diff --git a/lib/pages/setting/models/style_settings.dart b/lib/pages/setting/models/style_settings.dart index d44e918fa..51830e990 100644 --- a/lib/pages/setting/models/style_settings.dart +++ b/lib/pages/setting/models/style_settings.dart @@ -2,9 +2,6 @@ import 'dart:io'; import 'dart:math' as math; import 'package:PiliPlus/common/widgets/color_palette.dart'; -import 'package:PiliPlus/common/widgets/custom_toast.dart'; -import 'package:PiliPlus/common/widgets/dialog/dialog.dart'; -import 'package:PiliPlus/common/widgets/image/network_img_layer.dart'; import 'package:PiliPlus/common/widgets/scale_app.dart'; import 'package:PiliPlus/common/widgets/stateful_builder.dart'; import 'package:PiliPlus/models/common/bar_hide_type.dart'; @@ -18,7 +15,6 @@ import 'package:PiliPlus/models/common/theme/theme_type.dart'; import 'package:PiliPlus/pages/main/controller.dart'; import 'package:PiliPlus/pages/mine/controller.dart'; import 'package:PiliPlus/pages/setting/models/model.dart'; -import 'package:PiliPlus/pages/setting/slide_color_picker.dart'; import 'package:PiliPlus/pages/setting/widgets/dual_slider_dialog.dart'; import 'package:PiliPlus/pages/setting/widgets/multi_select_dialog.dart'; import 'package:PiliPlus/pages/setting/widgets/select_dialog.dart'; @@ -74,27 +70,6 @@ List get styleSettings => [ } }, ), - const SwitchModel( - title: '改用侧边栏', - subtitle: '开启后底栏与顶栏被替换,且相关设置失效', - leading: Icon(Icons.chrome_reader_mode_outlined), - setKey: SettingBoxKey.useSideBar, - defaultVal: false, - needReboot: true, - ), - SplitModel( - normalModel: const NormalModel.split( - title: 'App字体字重', - subtitle: '点击设置', - leading: Icon(Icons.text_fields), - ), - switchModel: SwitchModel.split( - defaultVal: false, - setKey: SettingBoxKey.appFontWeight, - onChanged: (_) => Get.updateMyAppTheme(), - onTap: _showFontWeightDialog, - ), - ), NormalModel( title: '界面缩放', getSubtitle: () => '当前缩放比例:${Pref.uiScale.toStringAsFixed(2)}', @@ -107,21 +82,6 @@ List get styleSettings => [ getSubtitle: () => '当前:${Pref.pageTransition.name}', onTap: _showTransitionDialog, ), - const SwitchModel( - title: '优化平板导航栏', - leading: Icon(Icons.auto_fix_high), - setKey: SettingBoxKey.optTabletNav, - defaultVal: true, - needReboot: true, - ), - const SwitchModel( - title: 'MD3样式底栏', - subtitle: 'Material You设计规范底栏,关闭可变窄', - leading: Icon(Icons.design_services_outlined), - setKey: SettingBoxKey.enableMYBar, - defaultVal: true, - needReboot: true, - ), const SwitchModel( title: '悬浮底栏', leading: Icon(MdiIcons.soundbar), @@ -254,30 +214,6 @@ List get styleSettings => [ style: theme.textTheme.titleSmall, ), ), - NormalModel( - onTap: _showReduceColorDialog, - title: '深色下图片颜色叠加', - subtitle: '显示颜色=图片原色x所选颜色,大图查看不受影响', - leading: const Icon(Icons.format_color_fill_outlined), - getTrailing: (theme) => Container( - width: 20, - height: 20, - decoration: BoxDecoration( - color: Pref.reduceLuxColor ?? Colors.white, - shape: BoxShape.circle, - ), - ), - ), - NormalModel( - leading: const Icon(Icons.opacity_outlined), - title: '气泡提示不透明度', - subtitle: '自定义气泡提示(Toast)不透明度', - getTrailing: (theme) => Text( - CustomToast.toastOpacity.toStringAsFixed(1), - style: theme.textTheme.titleSmall, - ), - onTap: _showToastDialog, - ), NormalModel( onTap: _showThemeTypeDialog, leading: const Icon(Icons.flashlight_on_outlined), @@ -371,12 +307,6 @@ List get styleSettings => [ defaultVal: false, onChanged: (value) => Get.find().directExitOnBack = value, ), - if (Platform.isAndroid) - NormalModel( - onTap: (context, setState) => Get.toNamed('/displayModeSetting'), - title: '屏幕帧率', - leading: const Icon(Icons.autofps_select_outlined), - ), ]; void _showQualityDialog({ @@ -633,23 +563,6 @@ void _showSpringDialog(BuildContext context, _) { ); } -Future _showFontWeightDialog(BuildContext context) async { - final res = await showDialog( - context: context, - builder: (context) => SliderDialog( - title: 'App字体字重', - value: Pref.appFontWeight.toDouble() + 1, - min: 1, - max: FontWeight.values.length.toDouble(), - divisions: FontWeight.values.length - 1, - ), - ); - if (res != null) { - await GStorage.setting.put(SettingBoxKey.appFontWeight, res.toInt() - 1); - Get.updateMyAppTheme(); - } -} - Future _showTransitionDialog( BuildContext context, VoidCallback setState, @@ -795,79 +708,6 @@ Future _showMsgUnReadDialog( } } -void _showReduceColorDialog( - BuildContext context, - VoidCallback setState, -) { - final reduceLuxColor = Pref.reduceLuxColor; - showDialog( - context: context, - builder: (context) => AlertDialog( - clipBehavior: Clip.hardEdge, - contentPadding: const EdgeInsets.symmetric(vertical: 16), - title: const Text('Color Picker'), - content: SlideColorPicker( - color: reduceLuxColor ?? Colors.white, - onChanged: (Color? color) { - if (color != null && color != reduceLuxColor) { - if (color == Colors.white) { - NetworkImgLayer.reduceLuxColor = null; - GStorage.setting.delete(SettingBoxKey.reduceLuxColor); - SmartDialog.showToast('设置成功'); - setState(); - } else { - void onConfirm() { - NetworkImgLayer.reduceLuxColor = color; - GStorage.setting.put( - SettingBoxKey.reduceLuxColor, - color.toARGB32(), - ); - SmartDialog.showToast('设置成功'); - setState(); - } - - if (color.computeLuminance() < 0.2) { - showConfirmDialog( - context: context, - title: Text( - '确认使用#${(color.toARGB32() & 0xFFFFFF).toRadixString(16).toUpperCase().padLeft(6)}?', - ), - content: const Text('所选颜色过于昏暗,可能会影响图片观看'), - onConfirm: onConfirm, - ); - } else { - onConfirm(); - } - } - } - }, - ), - ), - ); -} - -Future _showToastDialog( - BuildContext context, - VoidCallback setState, -) async { - final res = await showDialog( - context: context, - builder: (context) => SliderDialog( - title: 'Toast不透明度', - value: CustomToast.toastOpacity, - min: 0.0, - max: 1.0, - divisions: 10, - ), - ); - if (res != null) { - CustomToast.toastOpacity = res; - await GStorage.setting.put(SettingBoxKey.defaultToastOp, res); - SmartDialog.showToast('设置成功'); - setState(); - } -} - Future _showThemeTypeDialog( BuildContext context, VoidCallback setState, diff --git a/lib/pages/setting/models/video_settings.dart b/lib/pages/setting/models/video_settings.dart index 138dadcd1..09dd5ddb9 100644 --- a/lib/pages/setting/models/video_settings.dart +++ b/lib/pages/setting/models/video_settings.dart @@ -14,7 +14,7 @@ import 'package:PiliPlus/utils/storage.dart'; import 'package:PiliPlus/utils/storage_key.dart'; import 'package:PiliPlus/utils/storage_pref.dart'; import 'package:PiliPlus/utils/video_utils.dart'; -import 'package:flutter/foundation.dart'; +import 'package:flutter/foundation.dart' show kDebugMode; import 'package:flutter/material.dart'; import 'package:flutter/services.dart' show FilteringTextInputFormatter; import 'package:flutter_smart_dialog/flutter_smart_dialog.dart'; diff --git a/lib/pages/setting/pages/display_mode.dart b/lib/pages/setting/pages/display_mode.dart deleted file mode 100644 index 7b5e25802..000000000 --- a/lib/pages/setting/pages/display_mode.dart +++ /dev/null @@ -1,108 +0,0 @@ -import 'package:PiliPlus/utils/extension/iterable_ext.dart'; -import 'package:PiliPlus/utils/storage.dart'; -import 'package:PiliPlus/utils/storage_key.dart'; -import 'package:flutter/foundation.dart' show kDebugMode; -import 'package:flutter/material.dart'; -import 'package:flutter/services.dart' show PlatformException; -import 'package:flutter_displaymode/flutter_displaymode.dart'; -import 'package:hive_ce/hive.dart'; - -class SetDisplayMode extends StatefulWidget { - const SetDisplayMode({super.key}); - - @override - State createState() => _SetDisplayModeState(); -} - -class _SetDisplayModeState extends State { - List modes = []; - DisplayMode? active; - DisplayMode? preferred; - - Box setting = GStorage.setting; - - @override - void initState() { - super.initState(); - init(); - } - - // 获取所有的mode - Future fetchAll() async { - preferred = await FlutterDisplayMode.preferred; - active = await FlutterDisplayMode.active; - setting.put(SettingBoxKey.displayMode, preferred.toString()); - if (mounted) { - setState(() {}); - } - } - - // 初始化mode/手动设置 - Future init() async { - try { - modes = await FlutterDisplayMode.supported; - } on PlatformException catch (e) { - if (kDebugMode) debugPrint(e.toString()); - } - - final value = setting.get(SettingBoxKey.displayMode); - if (value != null) { - preferred = modes.firstWhereOrNull((e) => e.toString() == value); - } - - preferred ??= DisplayMode.auto; - - FlutterDisplayMode.setPreferredMode(preferred!).whenComplete(() { - Future.delayed(const Duration(milliseconds: 100), fetchAll); - }); - } - - @override - Widget build(BuildContext context) { - return Scaffold( - resizeToAvoidBottomInset: false, - appBar: AppBar(title: const Text('屏幕帧率设置')), - body: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Padding( - padding: - MediaQuery.viewPaddingOf(context).copyWith(top: 0, bottom: 0) + - const EdgeInsets.only(left: 25, top: 10, bottom: 5), - child: Text( - '没有生效?重启app试试', - style: TextStyle(color: Theme.of(context).colorScheme.outline), - ), - ), - Expanded( - child: RadioGroup( - onChanged: (DisplayMode? newMode) { - FlutterDisplayMode.setPreferredMode( - newMode!, - ).whenComplete( - () => Future.delayed( - const Duration(milliseconds: 100), - fetchAll, - ), - ); - }, - groupValue: preferred, - child: ListView.builder( - itemCount: modes.length, - itemBuilder: (context, index) { - final DisplayMode mode = modes[index]; - return RadioListTile( - value: mode, - title: mode == DisplayMode.auto - ? const Text('自动') - : Text('$mode${mode == active ? ' [系统]' : ''}'), - ); - }, - ), - ), - ), - ], - ), - ); - } -} diff --git a/lib/pages/setting/pages/logs.dart b/lib/pages/setting/pages/logs.dart index 040b26621..be6e52a50 100644 --- a/lib/pages/setting/pages/logs.dart +++ b/lib/pages/setting/pages/logs.dart @@ -13,7 +13,7 @@ import 'package:PiliPlus/utils/storage_pref.dart'; import 'package:PiliPlus/utils/utils.dart'; import 'package:catcher_2/model/platform_type.dart'; import 'package:catcher_2/model/report.dart' as catcher; -import 'package:flutter/foundation.dart'; +import 'package:flutter/foundation.dart' show kDebugMode; import 'package:flutter/material.dart'; import 'package:flutter_smart_dialog/flutter_smart_dialog.dart'; diff --git a/lib/pages/setting/widgets/switch_item.dart b/lib/pages/setting/widgets/switch_item.dart index 5f5c87718..2cd1ffc11 100644 --- a/lib/pages/setting/widgets/switch_item.dart +++ b/lib/pages/setting/widgets/switch_item.dart @@ -2,7 +2,6 @@ import 'package:PiliPlus/common/widgets/dialog/dialog.dart'; import 'package:PiliPlus/common/widgets/flutter/list_tile.dart'; import 'package:PiliPlus/utils/storage.dart'; import 'package:PiliPlus/utils/storage_key.dart'; -import 'package:PiliPlus/utils/storage_pref.dart'; import 'package:flutter/material.dart' hide ListTile; import 'package:flutter_smart_dialog/flutter_smart_dialog.dart'; @@ -42,14 +41,10 @@ class _SetSwitchItemState extends State { late bool val; void setVal() { - if (widget.setKey == SettingBoxKey.appFontWeight) { - val = Pref.appFontWeight != -1; - } else { - val = GStorage.setting.get( - widget.setKey, - defaultValue: widget.defaultVal, - ); - } + val = GStorage.setting.get( + widget.setKey, + defaultValue: widget.defaultVal, + ); } @override @@ -77,11 +72,7 @@ class _SetSwitchItemState extends State { ); } - if (widget.setKey == SettingBoxKey.appFontWeight) { - await GStorage.setting.put(SettingBoxKey.appFontWeight, val ? 4 : -1); - } else { - await GStorage.setting.put(widget.setKey, val); - } + await GStorage.setting.put(widget.setKey, val); widget.onChanged?.call(val); if (widget.needReboot) { diff --git a/lib/pages/video/download_panel/view.dart b/lib/pages/video/download_panel/view.dart index 9f14590b5..8bd1b1d60 100644 --- a/lib/pages/video/download_panel/view.dart +++ b/lib/pages/video/download_panel/view.dart @@ -22,10 +22,8 @@ import 'package:PiliPlus/utils/date_utils.dart'; import 'package:PiliPlus/utils/duration_utils.dart'; import 'package:PiliPlus/utils/extension/num_ext.dart'; import 'package:PiliPlus/utils/id_utils.dart'; -import 'package:PiliPlus/utils/platform_utils.dart'; import 'package:PiliPlus/utils/storage_pref.dart'; import 'package:PiliPlus/utils/utils.dart'; -import 'package:connectivity_plus/connectivity_plus.dart'; import 'package:flutter/foundation.dart' show kDebugMode, kReleaseMode; import 'package:flutter/material.dart'; import 'package:flutter_smart_dialog/flutter_smart_dialog.dart'; @@ -149,22 +147,6 @@ class _DownloadPanelState extends State { ), ), ), - if (kDebugMode || PlatformUtils.isMobile) ...[ - const Spacer(), - StreamBuilder( - stream: Connectivity().onConnectivityChanged, - builder: (context, snapshot) { - if (snapshot.data case final data?) { - final network = data.contains(ConnectivityResult.wifi) - ? 'WIFI' - : '数据'; - return Text('当前网络:$network', style: textStyle); - } - return const SizedBox.shrink(); - }, - ), - const SizedBox(width: 4), - ], ], ), ); diff --git a/lib/pages/video/introduction/local/view.dart b/lib/pages/video/introduction/local/view.dart index bf8f16dd6..200ce0645 100644 --- a/lib/pages/video/introduction/local/view.dart +++ b/lib/pages/video/introduction/local/view.dart @@ -94,12 +94,6 @@ class _LocalIntroPanelState extends State cacheHeight: cacheWidth ? null : 88.cacheSize(context), - colorBlendMode: NetworkImgLayer.reduce - ? BlendMode.modulate - : null, - color: NetworkImgLayer.reduce - ? NetworkImgLayer.reduceLuxColor - : null, ), ) : NetworkImgLayer( diff --git a/lib/pages/video/introduction/pgc/controller.dart b/lib/pages/video/introduction/pgc/controller.dart index 7c8781366..15138bb9b 100644 --- a/lib/pages/video/introduction/pgc/controller.dart +++ b/lib/pages/video/introduction/pgc/controller.dart @@ -21,7 +21,6 @@ import 'package:PiliPlus/pages/video/reply/controller.dart'; import 'package:PiliPlus/plugin/pl_player/models/play_repeat.dart'; import 'package:PiliPlus/services/service_locator.dart'; import 'package:PiliPlus/utils/extension/iterable_ext.dart'; -import 'package:PiliPlus/utils/feed_back.dart'; import 'package:PiliPlus/utils/global_data.dart'; import 'package:PiliPlus/utils/id_utils.dart'; import 'package:PiliPlus/utils/page_utils.dart'; @@ -417,7 +416,6 @@ class PgcIntroController extends CommonIntroController { // 一键三连 @override Future actionTriple() async { - feedBack(); if (!isLogin) { SmartDialog.showToast('账号未登录'); return; diff --git a/lib/pages/video/introduction/ugc/controller.dart b/lib/pages/video/introduction/ugc/controller.dart index ab097e7c6..4d14d66f5 100644 --- a/lib/pages/video/introduction/ugc/controller.dart +++ b/lib/pages/video/introduction/ugc/controller.dart @@ -33,7 +33,6 @@ import 'package:PiliPlus/utils/accounts.dart'; import 'package:PiliPlus/utils/device_utils.dart'; import 'package:PiliPlus/utils/extension/size_ext.dart'; import 'package:PiliPlus/utils/extension/string_ext.dart'; -import 'package:PiliPlus/utils/feed_back.dart'; import 'package:PiliPlus/utils/global_data.dart'; import 'package:PiliPlus/utils/id_utils.dart'; import 'package:PiliPlus/utils/page_utils.dart'; @@ -189,7 +188,6 @@ class UgcIntroController extends CommonIntroController with ReloadMixin { // 一键三连 @override Future actionTriple() async { - feedBack(); if (!isLogin) { SmartDialog.showToast('账号未登录'); return; diff --git a/lib/pages/video/introduction/ugc/view.dart b/lib/pages/video/introduction/ugc/view.dart index 32c642bf0..b2ad08c29 100644 --- a/lib/pages/video/introduction/ugc/view.dart +++ b/lib/pages/video/introduction/ugc/view.dart @@ -30,7 +30,6 @@ import 'package:PiliPlus/utils/extension/iterable_ext.dart'; import 'package:PiliPlus/utils/extension/num_ext.dart'; import 'package:PiliPlus/utils/extension/string_ext.dart'; import 'package:PiliPlus/utils/extension/theme_ext.dart'; -import 'package:PiliPlus/utils/feed_back.dart'; import 'package:PiliPlus/utils/id_utils.dart'; import 'package:PiliPlus/utils/num_utils.dart'; import 'package:PiliPlus/utils/page_utils.dart'; @@ -109,7 +108,6 @@ class _UgcIntroPanelState extends State { if (isLoading) { return; } - feedBack(); introController.expandableCtr.toggle(); }, child: Column( @@ -128,7 +126,6 @@ class _UgcIntroPanelState extends State { theme, () { if (mid != null) { - feedBack(); if (!isPortrait && introController.horizontalMemberPage) { widget.onShowMemberPage(mid); diff --git a/lib/pages/video/introduction/ugc/widgets/menu_row.dart b/lib/pages/video/introduction/ugc/widgets/menu_row.dart index d5dfa2a55..96a66ad16 100644 --- a/lib/pages/video/introduction/ugc/widgets/menu_row.dart +++ b/lib/pages/video/introduction/ugc/widgets/menu_row.dart @@ -1,4 +1,3 @@ -import 'package:PiliPlus/utils/feed_back.dart'; import 'package:flutter/material.dart'; class ActionRowLineItem extends StatelessWidget { @@ -27,10 +26,7 @@ class ActionRowLineItem extends StatelessWidget { borderRadius: const BorderRadius.all(Radius.circular(30)), child: InkWell( borderRadius: const BorderRadius.all(Radius.circular(30)), - onTap: () => { - feedBack(), - onTap?.call(), - }, + onTap: () => onTap?.call(), child: Container( padding: const EdgeInsets.fromLTRB(13, 5.5, 13, 4.5), decoration: BoxDecoration( diff --git a/lib/pages/video/reply/view.dart b/lib/pages/video/reply/view.dart index 3c4480aa2..a1dc5b91f 100644 --- a/lib/pages/video/reply/view.dart +++ b/lib/pages/video/reply/view.dart @@ -10,7 +10,6 @@ import 'package:PiliPlus/pages/common/fab_mixin.dart'; import 'package:PiliPlus/pages/video/reply/controller.dart'; import 'package:PiliPlus/pages/video/reply/widgets/reply_item_grpc.dart'; import 'package:PiliPlus/pages/video/reply_reply/view.dart'; -import 'package:PiliPlus/utils/feed_back.dart'; import 'package:easy_debounce/easy_throttle.dart'; import 'package:extended_nested_scroll_view/extended_nested_scroll_view.dart'; import 'package:flutter/material.dart'; @@ -144,14 +143,11 @@ class _VideoReplyPanelState extends State ), child: FloatingActionButton( heroTag: null, - onPressed: () { - feedBack(); - _videoReplyController.onReply( - null, - oid: _videoReplyController.aid, - replyType: _videoReplyController.videoType.replyType, - ); - }, + onPressed: () => _videoReplyController.onReply( + null, + oid: _videoReplyController.aid, + replyType: _videoReplyController.videoType.replyType, + ), tooltip: '发表评论', child: const Icon(Icons.reply), ), diff --git a/lib/pages/video/reply/widgets/reply_item_grpc.dart b/lib/pages/video/reply/widgets/reply_item_grpc.dart index cf1b1938b..0ed23ab5b 100644 --- a/lib/pages/video/reply/widgets/reply_item_grpc.dart +++ b/lib/pages/video/reply/widgets/reply_item_grpc.dart @@ -13,8 +13,6 @@ import 'package:PiliPlus/common/widgets/image_grid/image_grid_view.dart'; import 'package:PiliPlus/common/widgets/pendant_avatar.dart'; import 'package:PiliPlus/grpc/bilibili/main/community/reply/v1.pb.dart' show ReplyInfo, ReplyControl, Content, Url; -import 'package:PiliPlus/grpc/reply.dart'; -import 'package:PiliPlus/http/loading_state.dart'; import 'package:PiliPlus/http/reply.dart'; import 'package:PiliPlus/http/video.dart'; import 'package:PiliPlus/models/common/badge_type.dart'; @@ -34,13 +32,11 @@ import 'package:PiliPlus/utils/duration_utils.dart'; import 'package:PiliPlus/utils/extension/context_ext.dart'; import 'package:PiliPlus/utils/extension/num_ext.dart'; import 'package:PiliPlus/utils/extension/theme_ext.dart'; -import 'package:PiliPlus/utils/feed_back.dart'; import 'package:PiliPlus/utils/global_data.dart'; import 'package:PiliPlus/utils/image_utils.dart'; import 'package:PiliPlus/utils/page_utils.dart'; import 'package:PiliPlus/utils/platform_utils.dart'; import 'package:PiliPlus/utils/storage.dart'; -import 'package:PiliPlus/utils/storage_pref.dart'; import 'package:PiliPlus/utils/url_utils.dart'; import 'package:PiliPlus/utils/utils.dart'; import 'package:cached_network_image/cached_network_image.dart'; @@ -84,8 +80,6 @@ class ReplyItemGrpc extends StatelessWidget { static final _voteRegExp = RegExp(r"^\{vote:\d+?\}$"); static final _timeRegExp = RegExp(r'^(?:\d+[::])?\d+[::]\d+$'); - static bool enableWordRe = Pref.enableWordRe; - static int? replyLengthLimit = Pref.replyLengthLimit; @override Widget build(BuildContext context) { @@ -140,10 +134,7 @@ class ReplyItemGrpc extends StatelessWidget { Widget _buildHeader(BuildContext context, ThemeData theme) { final member = replyItem.member; Widget header = GestureDetector( - onTap: () { - feedBack(); - Get.toNamed('/member?mid=${replyItem.mid}'); - }, + onTap: () => Get.toNamed('/member?mid=${replyItem.mid}'), child: ExtraHitTestWidget( width: 46, child: Row( @@ -310,7 +301,6 @@ class ReplyItemGrpc extends StatelessWidget { height: 1.75, fontSize: theme.textTheme.bodyMedium!.fontSize, ), - maxLines: replyLevel == 1 ? replyLengthLimit : null, TextSpan( children: [ if (replyControl.isUpTop) ...[ @@ -330,9 +320,7 @@ class ReplyItemGrpc extends StatelessWidget { _buildMessage( context, theme, - replyControl.showTranslation - ? replyItem.translatedContent - : replyItem.content, + replyItem.content, replyControl, ), ], @@ -371,72 +359,6 @@ class ReplyItemGrpc extends StatelessWidget { ); } - Widget _buildTranslateBtn( - BuildContext context, - ThemeData theme, - ReplyControl replyControl, - TextStyle textStyle, - ButtonStyle buttonStyle, - ) { - late bool isProcessing = false; - final color = replyControl.showTranslation - ? theme.colorScheme.primary - : theme.colorScheme.outline.withValues(alpha: 0.8); - return SizedBox( - height: 32, - child: TextButton( - style: buttonStyle, - onPressed: () async { - if (replyControl.showTranslation) { - replyControl.showTranslation = false; - (context as Element).markNeedsBuild(); - } else { - if (isProcessing) { - return; - } - if (replyItem.hasTranslatedContent()) { - replyControl.showTranslation = true; - (context as Element).markNeedsBuild(); - return; - } - isProcessing = true; - final res = await ReplyGrpc.translateReply( - type: replyItem.type, - oid: replyItem.oid, - rpid: replyItem.id, - ); - if (res case Success(:final response)) { - final item = response.translatedReplies[replyItem.id]; - if (item != null && item.hasTranslatedContent()) { - replyControl.showTranslation = true; - replyItem.translatedContent = item.translatedContent; - if (context.mounted) { - (context as Element).markNeedsBuild(); - } - } else { - SmartDialog.showToast('翻译结果为空'); - } - } else if (res case Error(:final errMsg)) { - SmartDialog.showToast('翻译失败: $errMsg'); - } - isProcessing = false; - } - }, - child: Row( - spacing: 3, - mainAxisSize: .min, - children: [ - Icon(Icons.translate, size: 16, color: color), - Text( - replyControl.showTranslation ? '原文' : '翻译', - style: textStyle.copyWith(color: color), - ), - ], - ), - ), - ); - } - Widget buttonAction( BuildContext context, ThemeData theme, @@ -460,10 +382,7 @@ class ReplyItemGrpc extends StatelessWidget { height: 32, child: TextButton( style: buttonStyle, - onPressed: () { - feedBack(); - onReply?.call(replyItem); - }, + onPressed: () => onReply?.call(replyItem), child: Row( spacing: 3, mainAxisSize: .min, @@ -479,17 +398,7 @@ class ReplyItemGrpc extends StatelessWidget { ), ), const SizedBox(width: 2), - if (replyControl.translationSwitch == - .TRANSLATION_SWITCH_SHOW_TRANSLATION) ...[ - _buildTranslateBtn( - context, - theme, - replyControl, - textStyle, - buttonStyle, - ), - const SizedBox(width: 2), - ] else if (replyItem.replyControl.cardLabels.isNotEmpty) ...[ + if (replyItem.replyControl.cardLabels.isNotEmpty) ...[ Text( replyItem.replyControl.cardLabels .map((e) => e.textContent) @@ -598,12 +507,9 @@ class ReplyItemGrpc extends StatelessWidget { color: theme.colorScheme.primary, ), recognizer: NoDeadlineTapGestureRecognizer() - ..onTap = () { - feedBack(); - Get.toNamed( - '/member?mid=${childReply.member.mid}', - ); - }, + ..onTap = () => Get.toNamed( + '/member?mid=${childReply.member.mid}', + ), ), if (childReply.mid == upMid) ...[ const TextSpan(text: ' '), @@ -709,7 +615,7 @@ class ReplyItemGrpc extends StatelessWidget { } void addUrl(String matchStr, Url url, {bool addPlainText = false}) { - if (url.extra.isWordSearch && !enableWordRe) { + if (url.extra.isWordSearch) { if (addPlainText) { addPlainTextSpan(matchStr); } @@ -796,13 +702,7 @@ class ReplyItemGrpc extends StatelessWidget { spanChildren.add( WidgetSpan( child: NetworkImgLayer( - /// remove gif src: emote.url, - // src: emote.hasWebpUrl() - // ? emote.webpUrl - // : emote.hasGifUrl() - // ? emote.gifUrl - // : emote.url, type: ImageType.emote, width: size, height: size, diff --git a/lib/pages/video/reply/widgets/zan_grpc.dart b/lib/pages/video/reply/widgets/zan_grpc.dart index b6218051c..c919e4bbc 100644 --- a/lib/pages/video/reply/widgets/zan_grpc.dart +++ b/lib/pages/video/reply/widgets/zan_grpc.dart @@ -1,7 +1,6 @@ import 'package:PiliPlus/grpc/bilibili/main/community/reply/v1.pb.dart' show ReplyInfo; import 'package:PiliPlus/http/reply.dart'; -import 'package:PiliPlus/utils/feed_back.dart'; import 'package:PiliPlus/utils/num_utils.dart'; import 'package:fixnum/fixnum.dart' as $fixnum; import 'package:flutter/material.dart'; @@ -27,7 +26,6 @@ class ZanButtonGrpc extends StatelessWidget { return; } isProcessing = true; - feedBack(); final int oid = replyItem.oid.toInt(); final int rpid = replyItem.id.toInt(); // 1 已点赞 2 不喜欢 0 未操作 @@ -68,7 +66,6 @@ class ZanButtonGrpc extends StatelessWidget { return; } isProcessing = true; - feedBack(); final int oid = replyItem.oid.toInt(); final int rpid = replyItem.id.toInt(); // 1 已点赞 2 不喜欢 0 未操作 diff --git a/lib/pages/video/widgets/header_control.dart b/lib/pages/video/widgets/header_control.dart index a666c6bd9..177bbfacf 100644 --- a/lib/pages/video/widgets/header_control.dart +++ b/lib/pages/video/widgets/header_control.dart @@ -1,7 +1,8 @@ -import 'dart:async'; +import 'dart:async' show Timer; import 'dart:convert' show jsonDecode, utf8; -import 'dart:io'; +import 'dart:io' show Platform, File; import 'dart:math'; +import 'dart:typed_data' show Uint8List; import 'package:PiliPlus/common/constants.dart'; import 'package:PiliPlus/common/widgets/button/icon_button.dart'; @@ -59,7 +60,7 @@ import 'package:dio/dio.dart'; import 'package:easy_debounce/easy_throttle.dart'; import 'package:file_picker/file_picker.dart'; import 'package:floating/floating.dart'; -import 'package:flutter/foundation.dart'; +import 'package:flutter/foundation.dart' show compute; import 'package:flutter/material.dart' hide showBottomSheet; import 'package:flutter_smart_dialog/flutter_smart_dialog.dart'; import 'package:font_awesome_flutter/font_awesome_flutter.dart'; diff --git a/lib/pages/whisper/controller.dart b/lib/pages/whisper/controller.dart index 4a3183915..e609801bc 100644 --- a/lib/pages/whisper/controller.dart +++ b/lib/pages/whisper/controller.dart @@ -4,8 +4,7 @@ import 'package:PiliPlus/grpc/im.dart'; import 'package:PiliPlus/http/loading_state.dart'; import 'package:PiliPlus/models_new/msg/msgfeed_unread.dart'; import 'package:PiliPlus/pages/common/common_whisper_controller.dart'; -import 'package:PiliPlus/utils/storage_pref.dart'; -import 'package:flutter/foundation.dart'; +import 'package:flutter/foundation.dart' show listEquals; import 'package:flutter/material.dart'; import 'package:get/get.dart'; import 'package:protobuf/protobuf.dart' show PbMap; @@ -14,8 +13,7 @@ class WhisperController extends CommonWhisperController { @override SessionPageType sessionPageType = SessionPageType.SESSION_PAGE_TYPE_HOME; - late final List<({bool enabled, IconData icon, String name, String route})> - msgFeedTopItems; + late final List<({IconData icon, String name, String route})> msgFeedTopItems; late final RxList unreadCounts; PbMap? offset; @@ -31,25 +29,21 @@ class WhisperController extends CommonWhisperController { name: "回复我的", icon: Icons.message_outlined, route: "/replyMe", - enabled: true, ), const ( name: "@我", icon: Icons.alternate_email_outlined, route: "/atMe", - enabled: true, ), ( name: "收到的赞", icon: Icons.favorite_border_outlined, route: "/likeMe", - enabled: !Pref.disableLikeMsg, ), const ( name: "系统通知", icon: Icons.notifications_none_outlined, route: "/sysMsg", - enabled: true, ), ]; unreadCounts = List.filled(msgFeedTopItems.length, 0).obs; diff --git a/lib/pages/whisper/view.dart b/lib/pages/whisper/view.dart index 5a1ea50df..d23115c9f 100644 --- a/lib/pages/whisper/view.dart +++ b/lib/pages/whisper/view.dart @@ -9,7 +9,6 @@ import 'package:PiliPlus/utils/extension/theme_ext.dart'; import 'package:PiliPlus/utils/extension/three_dot_ext.dart'; import 'package:PiliPlus/utils/theme_utils.dart'; import 'package:flutter/material.dart'; -import 'package:flutter_smart_dialog/flutter_smart_dialog.dart'; import 'package:get/get.dart'; class WhisperPage extends StatefulWidget { @@ -194,10 +193,6 @@ class _WhisperPageState extends State { ), ), onTap: () { - if (!item.enabled) { - SmartDialog.showToast('已禁用'); - return; - } _controller.unreadCounts[index] = 0; Get.toNamed(item.route); }, diff --git a/lib/pages/whisper_detail/controller.dart b/lib/pages/whisper_detail/controller.dart index 3422a01a8..0f0e8b412 100644 --- a/lib/pages/whisper_detail/controller.dart +++ b/lib/pages/whisper_detail/controller.dart @@ -10,7 +10,6 @@ import 'package:PiliPlus/http/msg.dart'; import 'package:PiliPlus/pages/common/common_list_controller.dart'; import 'package:PiliPlus/utils/accounts.dart'; import 'package:PiliPlus/utils/extension/scroll_controller_ext.dart'; -import 'package:PiliPlus/utils/feed_back.dart'; import 'package:fixnum/fixnum.dart'; import 'package:flutter/material.dart'; import 'package:flutter_smart_dialog/flutter_smart_dialog.dart'; @@ -101,7 +100,6 @@ class WhisperDetailController extends CommonListController { assert((message != null) ^ (picMsg != null)); if (_isSending) return; _isSending = true; - feedBack(); SmartDialog.dismiss(); if (!account.isLogin) { SmartDialog.showToast('请先登录'); diff --git a/lib/pages/whisper_detail/view.dart b/lib/pages/whisper_detail/view.dart index 9962334d8..78d249b1e 100644 --- a/lib/pages/whisper_detail/view.dart +++ b/lib/pages/whisper_detail/view.dart @@ -20,7 +20,6 @@ import 'package:PiliPlus/pages/whisper_link_setting/view.dart'; import 'package:PiliPlus/utils/extension/file_ext.dart'; import 'package:PiliPlus/utils/extension/num_ext.dart'; import 'package:PiliPlus/utils/extension/widget_ext.dart'; -import 'package:PiliPlus/utils/feed_back.dart'; import 'package:PiliPlus/utils/page_utils.dart'; import 'package:PiliPlus/utils/platform_utils.dart'; import 'package:PiliPlus/utils/utils.dart'; @@ -63,7 +62,6 @@ class _WhisperDetailPageState behavior: HitTestBehavior.opaque, onTap: () { if (_whisperDetailController.mid != null) { - feedBack(); Get.toNamed('/member?mid=${_whisperDetailController.mid}'); } }, diff --git a/lib/pages/whisper_detail/widget/chat_item.dart b/lib/pages/whisper_detail/widget/chat_item.dart index 0133b4311..2e7c59c4b 100644 --- a/lib/pages/whisper_detail/widget/chat_item.dart +++ b/lib/pages/whisper_detail/widget/chat_item.dart @@ -671,9 +671,7 @@ class ChatItem extends StatelessWidget { if (eInfos != null) { for (final e in eInfos!) { emojiMap[e.text] ??= { - /// remove gif 'url': e.url, - // 'url': e.hasGifUrl() ? e.gifUrl : e.url, 'size': e.size * 22.0, }; } diff --git a/lib/plugin/pl_player/controller.dart b/lib/plugin/pl_player/controller.dart index 4b92e21e8..a45b51d8a 100644 --- a/lib/plugin/pl_player/controller.dart +++ b/lib/plugin/pl_player/controller.dart @@ -34,7 +34,6 @@ import 'package:PiliPlus/utils/asset_utils.dart'; import 'package:PiliPlus/utils/device_utils.dart'; import 'package:PiliPlus/utils/extension/box_ext.dart'; import 'package:PiliPlus/utils/extension/num_ext.dart'; -import 'package:PiliPlus/utils/feed_back.dart'; import 'package:PiliPlus/utils/image_utils.dart'; import 'package:PiliPlus/utils/page_utils.dart'; import 'package:PiliPlus/utils/path_utils.dart'; @@ -324,9 +323,7 @@ class PlPlayerController with BlockConfigMixin { late List speedList = Pref.speedList; late bool enableAutoLongPressSpeed = Pref.enableAutoLongPressSpeed; - late final showControlDuration = Pref.enableLongShowControl - ? const Duration(seconds: 30) - : const Duration(seconds: 3); + late final showControlDuration = const Duration(seconds: 3); // 字幕 late double subtitleFontScale = Pref.subtitleFontScale; late double subtitleFontScaleFS = Pref.subtitleFontScaleFS; @@ -339,7 +336,6 @@ class PlPlayerController with BlockConfigMixin { // settings late final showFSActionItem = Pref.showFSActionItem; - late final enableShrinkVideoSize = Pref.enableShrinkVideoSize; late final darkVideoPage = Pref.darkVideoPage; late final enableSlideVolumeBrightness = Pref.enableSlideVolumeBrightness; late final enableSlideFS = Pref.enableSlideFS; @@ -1241,9 +1237,6 @@ class PlPlayerController with BlockConfigMixin { } void onChangedSliderEnd() { - if (cancelSeek != true) { - feedBack(); - } cancelSeek = null; hasToast = null; isSliderMoving.value = false; @@ -1409,7 +1402,6 @@ class PlPlayerController with BlockConfigMixin { /// 关闭控制栏 void onLockControl(bool val) { - feedBack(); controlsLock.value = val; if (!val && showControls.value) { showControls.refresh(); diff --git a/lib/plugin/pl_player/view/view.dart b/lib/plugin/pl_player/view/view.dart index 7674430b6..0aa91173b 100644 --- a/lib/plugin/pl_player/view/view.dart +++ b/lib/plugin/pl_player/view/view.dart @@ -67,7 +67,7 @@ import 'package:canvas_danmaku/canvas_danmaku.dart'; import 'package:collection/collection.dart'; import 'package:easy_debounce/easy_throttle.dart'; import 'package:fl_chart/fl_chart.dart'; -import 'package:flutter/foundation.dart'; +import 'package:flutter/foundation.dart' show clampDouble, kDebugMode; import 'package:flutter/gestures.dart'; import 'package:flutter/material.dart'; import 'package:flutter/rendering.dart' @@ -2046,11 +2046,8 @@ class _PLVideoPlayerState extends State onInteractionUpdate: _onInteractionUpdate, onInteractionEnd: _onInteractionEnd, panEnabled: false, - minScale: plPlayerController.enableShrinkVideoSize ? 0.75 : 1, + minScale: 1.0, maxScale: 2.0, - boundaryMargin: plPlayerController.enableShrinkVideoSize - ? const EdgeInsets.all(double.infinity) - : EdgeInsets.zero, panAxis: PanAxis.aligned, transformationController: transformationController, onTranslate: () { diff --git a/lib/plugin/pl_player/widgets/bottom_control.dart b/lib/plugin/pl_player/widgets/bottom_control.dart index ac449c0ec..e990a8ff6 100644 --- a/lib/plugin/pl_player/widgets/bottom_control.dart +++ b/lib/plugin/pl_player/widgets/bottom_control.dart @@ -4,7 +4,6 @@ import 'package:PiliPlus/pages/video/controller.dart'; import 'package:PiliPlus/plugin/pl_player/controller.dart'; import 'package:PiliPlus/plugin/pl_player/view/view.dart'; import 'package:PiliPlus/utils/extension/theme_ext.dart'; -import 'package:PiliPlus/utils/feed_back.dart'; import 'package:PiliPlus/utils/platform_utils.dart'; import 'package:flutter/material.dart'; import 'package:get/get.dart'; @@ -26,7 +25,6 @@ class BottomControl extends StatelessWidget { final VideoDetailController videoDetailController; void onDragStart(ThumbDragDetails duration) { - feedBack(); controller.onChangedSliderStart(duration.timeStamp); } diff --git a/lib/router/app_pages.dart b/lib/router/app_pages.dart index d26c3d522..b0ffa21e1 100644 --- a/lib/router/app_pages.dart +++ b/lib/router/app_pages.dart @@ -56,7 +56,6 @@ import 'package:PiliPlus/pages/search_trending/view.dart'; import 'package:PiliPlus/pages/setting/extra_setting.dart'; import 'package:PiliPlus/pages/setting/pages/bar_set.dart'; import 'package:PiliPlus/pages/setting/pages/color_select.dart'; -import 'package:PiliPlus/pages/setting/pages/display_mode.dart'; import 'package:PiliPlus/pages/setting/pages/font_size_select.dart'; import 'package:PiliPlus/pages/setting/pages/logs.dart'; import 'package:PiliPlus/pages/setting/pages/play_speed_set.dart'; @@ -132,8 +131,6 @@ class Routes { GetPage(name: '/blackListPage', page: () => const BlackListPage()), GetPage(name: '/colorSetting', page: () => const ColorSelectPage()), GetPage(name: '/fontSizeSetting', page: () => const FontSizeSelectPage()), - // 屏幕帧率 - GetPage(name: '/displayModeSetting', page: () => const SetDisplayMode()), // 关于 GetPage(name: '/about', page: () => const AboutPage()), // diff --git a/lib/services/download/download_service.dart b/lib/services/download/download_service.dart index 1d469da0d..6e846b6b8 100644 --- a/lib/services/download/download_service.dart +++ b/lib/services/download/download_service.dart @@ -20,7 +20,8 @@ import 'package:PiliPlus/utils/extension/file_ext.dart'; import 'package:PiliPlus/utils/extension/string_ext.dart'; import 'package:PiliPlus/utils/id_utils.dart'; import 'package:PiliPlus/utils/path_utils.dart'; -import 'package:flutter/foundation.dart'; +import 'package:flutter/foundation.dart' + show kDebugMode, debugPrint, VoidCallback; import 'package:flutter_cache_manager/flutter_cache_manager.dart'; import 'package:flutter_smart_dialog/flutter_smart_dialog.dart'; import 'package:get/get.dart'; diff --git a/lib/utils/app_scheme.dart b/lib/utils/app_scheme.dart index 334340417..74cc0c908 100644 --- a/lib/utils/app_scheme.dart +++ b/lib/utils/app_scheme.dart @@ -20,7 +20,7 @@ import 'package:PiliPlus/utils/request_utils.dart'; import 'package:PiliPlus/utils/url_utils.dart'; import 'package:PiliPlus/utils/utils.dart'; import 'package:app_links/app_links.dart'; -import 'package:flutter/foundation.dart'; +import 'package:flutter/foundation.dart' show kDebugMode; import 'package:flutter/material.dart'; import 'package:flutter_smart_dialog/flutter_smart_dialog.dart'; import 'package:get/get.dart'; diff --git a/lib/utils/feed_back.dart b/lib/utils/feed_back.dart deleted file mode 100644 index d43a9ca6d..000000000 --- a/lib/utils/feed_back.dart +++ /dev/null @@ -1,9 +0,0 @@ -import 'package:PiliPlus/utils/storage_pref.dart'; -import 'package:flutter/services.dart' show HapticFeedback; - -bool enableFeedback = Pref.feedBackEnable; -void feedBack() { - if (enableFeedback) { - HapticFeedback.lightImpact(); - } -} diff --git a/lib/utils/max_screen_size.dart b/lib/utils/max_screen_size.dart index cc51bfed6..c91749d42 100644 --- a/lib/utils/max_screen_size.dart +++ b/lib/utils/max_screen_size.dart @@ -1,25 +1,13 @@ import 'dart:io' show Platform; import 'package:PiliPlus/utils/utils.dart'; -import 'package:flutter/services.dart' show MethodChannel; abstract final class MaxScreenSize { static int? _maxWidth; static int? _maxHeight; static Future init() { - return Future.wait([_initFoldable(), _initScreenSize()]); - } - - static Future _initFoldable() async { - final isFoldable = await Utils.channel.invokeMethod('isFoldable'); - if (isFoldable == true) { - const MethodChannel('ScreenChannel').setMethodCallHandler((call) async { - if (call.method == 'onConfigChanged') { - _handleRes(call.arguments); - } - }); - } + return _initScreenSize(); } static Future _initScreenSize() async { diff --git a/lib/utils/page_utils.dart b/lib/utils/page_utils.dart index 3ed12e32a..3a8d6d136 100644 --- a/lib/utils/page_utils.dart +++ b/lib/utils/page_utils.dart @@ -23,7 +23,6 @@ import 'package:PiliPlus/utils/extension/extension.dart'; import 'package:PiliPlus/utils/extension/iterable_ext.dart'; import 'package:PiliPlus/utils/extension/size_ext.dart'; import 'package:PiliPlus/utils/extension/string_ext.dart'; -import 'package:PiliPlus/utils/feed_back.dart'; import 'package:PiliPlus/utils/global_data.dart'; import 'package:PiliPlus/utils/id_utils.dart'; import 'package:PiliPlus/utils/platform_utils.dart'; @@ -209,8 +208,6 @@ abstract final class PageUtils { DynamicItemModel item, { bool isPush = false, }) async { - feedBack(); - void push() { if (item.basic?.commentType == 12) { toDupNamed( diff --git a/lib/utils/permission_handler.dart b/lib/utils/permission_handler.dart index 9e373df4e..49806164f 100644 --- a/lib/utils/permission_handler.dart +++ b/lib/utils/permission_handler.dart @@ -1,7 +1,7 @@ import 'dart:async'; import 'dart:io'; -import 'package:flutter/foundation.dart'; +import 'package:flutter/foundation.dart' show VoidCallback; import 'package:permission_handler_platform_interface/permission_handler_platform_interface.dart'; export 'package:permission_handler_platform_interface/permission_handler_platform_interface.dart' diff --git a/lib/utils/request_utils.dart b/lib/utils/request_utils.dart index a8b623ad3..513537a04 100644 --- a/lib/utils/request_utils.dart +++ b/lib/utils/request_utils.dart @@ -31,7 +31,6 @@ import 'package:PiliPlus/utils/extension/context_ext.dart'; import 'package:PiliPlus/utils/extension/size_ext.dart'; import 'package:PiliPlus/utils/extension/string_ext.dart'; import 'package:PiliPlus/utils/extension/theme_ext.dart'; -import 'package:PiliPlus/utils/feed_back.dart'; import 'package:PiliPlus/utils/platform_utils.dart'; import 'package:PiliPlus/utils/storage.dart'; import 'package:PiliPlus/utils/storage_key.dart'; @@ -142,7 +141,6 @@ abstract final class RequestUtils { if (mid == null) { return; } - feedBack(); if (!isFollow) { final res = await VideoHttp.relationMod( mid: mid, @@ -396,8 +394,6 @@ abstract final class RequestUtils { bool uiStatus, VoidCallback onSuccess, ) async { - feedBack(); - final like = item.modules.moduleStat?.like; final status = like?.status ?? false; diff --git a/lib/utils/storage_key.dart b/lib/utils/storage_key.dart index a67fb8522..767774084 100644 --- a/lib/utils/storage_key.dart +++ b/lib/utils/storage_key.dart @@ -10,7 +10,6 @@ abstract final class SettingBoxKey { fullScreenMode = 'fullScreenMode', defaultDecode = 'defaultDecode', secondDecode = 'secondDecode', - defaultToastOp = 'defaultToastOp', defaultPicQa = 'defaultPicQa', enableHA = 'enableHA', audioOutput = 'audioOutput', @@ -31,8 +30,6 @@ abstract final class SettingBoxKey { showBatteryLevel = 'showBatteryLevel'; static const String enableVerticalExpand = 'enableVerticalExpand', - feedBackEnable = 'feedBackEnable', - enableLongShowControl = 'enableLongShowControl', horizontalScreen = 'horizontalScreen', CDNService = 'CDNService', disableAudioCDN = 'disableAudioCDN', @@ -52,7 +49,6 @@ abstract final class SettingBoxKey { exemptFilterForFollowed = 'exemptFilterForFollowed', banWordForRecommend = 'banWordForRecommend', applyFilterToRelatedVideos = 'applyFilterToRelatedVideos', - autoUpdate = 'autoUpdate', autoClearCache = 'autoClearCache', maxCacheSize = 'maxCacheSize', defaultShowComment = 'defaultShowComment', @@ -62,11 +58,8 @@ abstract final class SettingBoxKey { enableHotKey = 'enableHotKey', enableSearchRcmd = 'enableSearchRcmd', enableQuickFav = 'enableQuickFav', - enableWordRe = 'enableWordRe', - enableSearchWord = 'enableSearchWord', enableSystemProxy = 'enableSystemProxy', enableAi = 'enableAi', - disableLikeMsg = 'disableLikeMsg', defaultHomePage = 'defaultHomePage', previewQuality = 'previewQuality', checkDynamic = 'checkDynamic', @@ -80,7 +73,6 @@ abstract final class SettingBoxKey { expandIntroPanelH = 'exapndIntroPanelH', horizontalSeasonPanel = 'horizontalSeasonPanel', horizontalMemberPage = 'horizontalMemberPage', - replyLengthLimit = 'replyLengthLimit', showArgueMsg = 'showArgueMsg', reverseFromFirst = 'reverseFromFirst', badCertificateCallback = 'badCertificateCallback', @@ -98,7 +90,6 @@ abstract final class SettingBoxKey { fallbackNormalization = 'fallbackNormalization', superResolutionType = 'superResolutionType', preInitPlayer = 'preInitPlayer', - mainTabBarView = 'mainTabBarView', searchSuggestion = 'searchSuggestion', showDecorate = 'showDynDecorate', showMedal = 'showMedal', @@ -117,7 +108,6 @@ abstract final class SettingBoxKey { enableHttp2 = 'enableHttp2', slideDismissReplyPage = 'slideDismissReplyPage', showFSActionItem = 'showFSActionItem', - enableShrinkVideoSize = 'enableShrinkVideoSize', showDynActionBar = 'showDynActionBar', darkVideoPage = 'darkVideoPage', enableSlideVolumeBrightness = 'enableSlideVolumeBrightness', @@ -126,12 +116,10 @@ abstract final class SettingBoxKey { retryDelay = 'retryDelay', liveQuality = 'liveQuality', liveQualityCellular = 'liveQualityCellular', - appFontWeight = 'appFontWeight', fastForBackwardDuration = 'fastForBackwardDuration', recordSearchHistory = 'recordSearchHistory', showPgcTimeline = 'showPgcTimeline', pageTransition = 'pageTransition', - optTabletNav = 'optTabletNav', banWordForDyn = 'banWordForDyn', enableLog = 'enableLog', memberTab = 'memberTab', @@ -213,14 +201,11 @@ abstract final class SettingBoxKey { defaultTextScale = 'textScale', dynamicColor = 'dynamicColor', customColor = 'customColor', - displayMode = 'displayMode', smallCardWidth = 'smallCardWidth', recommendCardWidth = 'recommendCardWidth', dynamicsWaterfallFlow = 'dynamicsWaterfallFlow', upPanelPosition = 'upPanelPosition', dynamicsShowAllFollowedUp = 'dynamicsShowAllFollowedUp', - useSideBar = 'useSideBar', - enableMYBar = 'enableMYBar', hideTopBar = 'hideSearchBar', hideBottomBar = 'hideTabBar', barHideType = 'barHideType', @@ -230,7 +215,6 @@ abstract final class SettingBoxKey { msgUnReadTypeV2 = 'msgUnReadTypeV2', navBarSort = 'navBarSort', tempPlayerConf = 'tempPlayerConf', - reduceLuxColor = 'reduceLuxColor', liveCdnUrl = 'liveCdnUrl', saveReply = 'saveReply'; } diff --git a/lib/utils/storage_pref.dart b/lib/utils/storage_pref.dart index b3d44be75..868aa0daa 100644 --- a/lib/utils/storage_pref.dart +++ b/lib/utils/storage_pref.dart @@ -42,7 +42,6 @@ import 'package:PiliPlus/utils/storage_key.dart'; import 'package:PiliPlus/utils/utils.dart'; import 'package:crypto/crypto.dart'; import 'package:flex_seed_scheme/flex_seed_scheme.dart' show FlexSchemeVariant; -import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:get/get.dart'; import 'package:hive_ce/hive.dart'; @@ -145,9 +144,6 @@ abstract final class Pref { ).toList(); } - static bool get feedBackEnable => - _setting.get(SettingBoxKey.feedBackEnable, defaultValue: false); - static int get picQuality => _setting.get(SettingBoxKey.defaultPicQa, defaultValue: 10); @@ -334,7 +330,7 @@ abstract final class Pref { ); static bool get blockTrack => - _setting.get(SettingBoxKey.blockTrack, defaultValue: !kDebugMode); + _setting.get(SettingBoxKey.blockTrack, defaultValue: false); static bool get checkDynamic => _setting.get(SettingBoxKey.checkDynamic, defaultValue: true); @@ -396,14 +392,6 @@ abstract final class Pref { defaultValue: horizontalScreen, ); - static int? get replyLengthLimit { - int length = _setting.get(SettingBoxKey.replyLengthLimit, defaultValue: 6); - if (length <= 0) { - return null; - } - return length; - } - static int get defaultPicQa => _setting.get(SettingBoxKey.defaultPicQa, defaultValue: 10); @@ -440,9 +428,6 @@ abstract final class Pref { static bool get cdnSpeedTest => _setting.get(SettingBoxKey.cdnSpeedTest, defaultValue: true); - static bool get autoUpdate => - _setting.get(SettingBoxKey.autoUpdate, defaultValue: true); - static bool get horizontalPreview => _setting.get(SettingBoxKey.horizontalPreview, defaultValue: false); @@ -479,9 +464,6 @@ abstract final class Pref { static bool get preInitPlayer => _setting.get(SettingBoxKey.preInitPlayer, defaultValue: false); - static bool get mainTabBarView => - _setting.get(SettingBoxKey.mainTabBarView, defaultValue: false); - static bool get searchSuggestion => _setting.get(SettingBoxKey.searchSuggestion, defaultValue: true); @@ -533,9 +515,6 @@ abstract final class Pref { static bool get showFSActionItem => _setting.get(SettingBoxKey.showFSActionItem, defaultValue: true); - static bool get enableShrinkVideoSize => - _setting.get(SettingBoxKey.enableShrinkVideoSize, defaultValue: true); - static bool get showDynActionBar => _setting.get(SettingBoxKey.showDynActionBar, defaultValue: true); @@ -566,9 +545,6 @@ abstract final class Pref { defaultValue: LiveQuality.superHD.code, ); - static int get appFontWeight => - _setting.get(SettingBoxKey.appFontWeight, defaultValue: -1); - static bool get enableDragSubtitle => _setting.get(SettingBoxKey.enableDragSubtitle, defaultValue: false); @@ -596,9 +572,6 @@ abstract final class Pref { static num get maxCacheSize => _setting.get(SettingBoxKey.maxCacheSize) ?? pow(1024, 3); - static bool get optTabletNav => - _setting.get(SettingBoxKey.optTabletNav, defaultValue: true); - static bool get horizontalScreen { bool? horizontalScreen = _setting.get(SettingBoxKey.horizontalScreen); if (horizontalScreen == null) { @@ -638,12 +611,6 @@ abstract final class Pref { static bool get enableBackgroundPlay => _setting.get(SettingBoxKey.enableBackgroundPlay, defaultValue: true); - static bool get disableLikeMsg => - _setting.get(SettingBoxKey.disableLikeMsg, defaultValue: false); - - static bool get enableWordRe => - _setting.get(SettingBoxKey.enableWordRe, defaultValue: false); - static bool get autoExitFullscreen => _setting.get(SettingBoxKey.enableAutoExit, defaultValue: true); @@ -683,12 +650,6 @@ abstract final class Pref { defaultValue: BarHideType.sync.index, )]; - static bool get enableSearchWord => - _setting.get(SettingBoxKey.enableSearchWord, defaultValue: false); - - static bool get useSideBar => - _setting.get(SettingBoxKey.useSideBar, defaultValue: false); - static bool get dynamicsShowAllFollowedUp => _setting.get( SettingBoxKey.dynamicsShowAllFollowedUp, defaultValue: false, @@ -734,9 +695,6 @@ abstract final class Pref { defaultValue: DynamicBadgeMode.number.index, )]; - static bool get enableMYBar => - _setting.get(SettingBoxKey.enableMYBar, defaultValue: true); - static Transition get pageTransition => Transition.values[_setting.get( SettingBoxKey.pageTransition, @@ -792,9 +750,6 @@ abstract final class Pref { defaultValue: PlatformUtils.isMobile ? 5 : 6, ); - static bool get enableLongShowControl => - _setting.get(SettingBoxKey.enableLongShowControl, defaultValue: false); - static bool get expandBuffer => _setting.get(SettingBoxKey.expandBuffer, defaultValue: false); @@ -833,9 +788,6 @@ abstract final class Pref { static bool get enableSaveLastData => _setting.get(SettingBoxKey.enableSaveLastData, defaultValue: true); - static double get defaultToastOp => - _setting.get(SettingBoxKey.defaultToastOp, defaultValue: 1.0); - static PlayRepeat get playRepeat => PlayRepeat.values[_video.get( VideoBoxKey.playRepeat, @@ -859,14 +811,6 @@ abstract final class Pref { static bool get tempPlayerConf => _setting.get(SettingBoxKey.tempPlayerConf, defaultValue: false); - static Color? get reduceLuxColor { - final int? color = _setting.get(SettingBoxKey.reduceLuxColor); - if (color != null && color != 0xFFFFFFFF) { - return Color(color); - } - return null; - } - static bool get showFsScreenshotBtn => _setting.get(SettingBoxKey.showFsScreenshotBtn, defaultValue: true); @@ -914,8 +858,10 @@ abstract final class Pref { static bool get isWindowMaximized => _setting.get(SettingBoxKey.isWindowMaximized, defaultValue: false); - static bool get keyboardControl => - _setting.get(SettingBoxKey.keyboardControl, defaultValue: true); + static bool get keyboardControl => _setting.get( + SettingBoxKey.keyboardControl, + defaultValue: PlatformUtils.isDesktop, + ); static bool get pauseOnMinimize => _setting.get(SettingBoxKey.pauseOnMinimize, defaultValue: false); diff --git a/lib/utils/theme_utils.dart b/lib/utils/theme_utils.dart index d37f75c35..5415ee6d2 100644 --- a/lib/utils/theme_utils.dart +++ b/lib/utils/theme_utils.dart @@ -31,39 +31,9 @@ abstract final class ThemeUtils { required bool isDynamic, bool isDark = false, }) { - final appFontWeight = Pref.appFontWeight.clamp( - -1, - FontWeight.values.length - 1, - ); - final fontWeight = appFontWeight == -1 - ? null - : FontWeight.values[appFontWeight]; - late final textStyle = TextStyle(fontWeight: fontWeight); ThemeData themeData = ThemeData( colorScheme: colorScheme, useMaterial3: true, - textTheme: fontWeight == null - ? null - : TextTheme( - displayLarge: textStyle, - displayMedium: textStyle, - displaySmall: textStyle, - headlineLarge: textStyle, - headlineMedium: textStyle, - headlineSmall: textStyle, - titleLarge: textStyle, - titleMedium: textStyle, - titleSmall: textStyle, - bodyLarge: textStyle, - bodyMedium: textStyle, - bodySmall: textStyle, - labelLarge: textStyle, - labelMedium: textStyle, - labelSmall: textStyle, - ), - tabBarTheme: fontWeight == null - ? null - : TabBarThemeData(labelStyle: textStyle), appBarTheme: AppBarTheme( elevation: 0, titleSpacing: 0, @@ -73,7 +43,6 @@ abstract final class ThemeUtils { titleTextStyle: TextStyle( fontSize: 16, color: colorScheme.onSurface, - fontWeight: fontWeight, ), ), navigationBarTheme: NavigationBarThemeData( @@ -108,7 +77,6 @@ abstract final class ThemeUtils { titleTextStyle: TextStyle( fontSize: 18, color: colorScheme.onSurface, - fontWeight: fontWeight, ), backgroundColor: colorScheme.surface, constraints: const BoxConstraints(minWidth: 280, maxWidth: 420), diff --git a/lib/utils/update.dart b/lib/utils/update.dart deleted file mode 100644 index 71a6450f3..000000000 --- a/lib/utils/update.dart +++ /dev/null @@ -1,155 +0,0 @@ -import 'dart:io' show Platform; - -import 'package:PiliPlus/build_config.dart'; -import 'package:PiliPlus/common/constants.dart'; -import 'package:PiliPlus/http/api.dart'; -import 'package:PiliPlus/http/browser_ua.dart'; -import 'package:PiliPlus/http/init.dart'; -import 'package:PiliPlus/utils/accounts/account.dart'; -import 'package:PiliPlus/utils/page_utils.dart'; -import 'package:PiliPlus/utils/storage.dart'; -import 'package:PiliPlus/utils/storage_key.dart'; -import 'package:device_info_plus/device_info_plus.dart'; -import 'package:dio/dio.dart'; -import 'package:flutter/foundation.dart' show kDebugMode; -import 'package:flutter/material.dart'; -import 'package:flutter_smart_dialog/flutter_smart_dialog.dart'; - -abstract final class Update { - // 检查更新 - static Future checkUpdate([bool isAuto = true]) async { - if (kDebugMode) return; - SmartDialog.dismiss(); - try { - final res = await Request().get( - Api.latestApp, - options: Options( - headers: {'user-agent': BrowserUa.mob}, - extra: {'account': const NoAccount()}, - ), - ); - if (res.data is Map || res.data.isEmpty) { - if (!isAuto) { - SmartDialog.showToast('检查更新失败,GitHub接口未返回数据,请检查网络'); - } - return; - } - final data = res.data[0]; - final int latest = - DateTime.parse(data['created_at']).millisecondsSinceEpoch ~/ 1000; - if (BuildConfig.buildTime >= latest) { - if (!isAuto) { - SmartDialog.showToast('已是最新版本'); - } - } else { - SmartDialog.show( - animationType: SmartAnimationType.centerFade_otherSlide, - builder: (context) { - final ThemeData theme = Theme.of(context); - Widget downloadBtn(String text, {String? ext}) => TextButton( - onPressed: () => onDownload(data, ext: ext), - child: Text(text), - ); - return AlertDialog( - title: const Text('🎉 发现新版本 '), - content: SizedBox( - height: 280, - child: SingleChildScrollView( - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - '${data['tag_name']}', - style: const TextStyle(fontSize: 20), - ), - const SizedBox(height: 8), - Text('${data['body']}'), - TextButton( - onPressed: () => PageUtils.launchURL( - '${Constants.sourceCodeUrl}/commits/main', - ), - child: Text( - "点此查看完整更新(即commit)内容", - style: TextStyle( - color: theme.colorScheme.primary, - ), - ), - ), - ], - ), - ), - ), - actions: [ - if (isAuto) - TextButton( - onPressed: () { - SmartDialog.dismiss(); - GStorage.setting.put(SettingBoxKey.autoUpdate, false); - }, - child: Text( - '不再提醒', - style: TextStyle( - color: theme.colorScheme.outline, - ), - ), - ), - TextButton( - onPressed: SmartDialog.dismiss, - child: Text( - '取消', - style: TextStyle( - color: theme.colorScheme.outline, - ), - ), - ), - if (Platform.isWindows) ...[ - downloadBtn('zip', ext: 'zip'), - downloadBtn('exe', ext: 'exe'), - ] else if (Platform.isLinux) ...[ - downloadBtn('rpm', ext: 'rpm'), - downloadBtn('deb', ext: 'deb'), - downloadBtn('targz', ext: 'tar.gz'), - ] else - downloadBtn('Github'), - ], - ); - }, - ); - } - } catch (e) { - if (kDebugMode) debugPrint('failed to check update: $e'); - } - } - - // 下载适用于当前系统的安装包 - static Future onDownload(Map data, {String? ext}) async { - SmartDialog.dismiss(); - try { - void download(String plat) { - if (data['assets'].isNotEmpty) { - for (Map i in data['assets']) { - final String name = i['name']; - if (name.contains(plat) && - (ext == null || ext.isEmpty ? true : name.endsWith(ext))) { - PageUtils.launchURL(i['browser_download_url']); - return; - } - } - throw UnsupportedError('platform not found: $plat'); - } - } - - if (Platform.isAndroid) { - // 获取设备信息 - AndroidDeviceInfo androidInfo = await DeviceInfoPlugin().androidInfo; - // [arm64-v8a] - download(androidInfo.supportedAbis.first); - } else { - download(Platform.operatingSystem); - } - } catch (e) { - if (kDebugMode) debugPrint('download error: $e'); - PageUtils.launchURL('${Constants.sourceCodeUrl}/releases/latest'); - } - } -} diff --git a/pubspec.lock b/pubspec.lock index bc4253a17..4faaa5980 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -604,14 +604,6 @@ packages: url: "https://pub.dev" source: hosted version: "3.4.1" - flutter_displaymode: - dependency: "direct main" - description: - name: flutter_displaymode - sha256: ecd44b1e902b0073b42ff5b55bf283f38e088270724cdbb7f7065ccf54aa60a8 - url: "https://pub.dev" - source: hosted - version: "0.7.0" flutter_html: dependency: "direct main" description: diff --git a/pubspec.yaml b/pubspec.yaml index 028416a01..2b40e3ba6 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -147,7 +147,7 @@ dependencies: # 防抖节流 easy_debounce: ^2.0.3 # 高帧率 - flutter_displaymode: ^0.7.0 + # flutter_displaymode: ^0.7.0 # scheme跳转 app_links: ^7.0.0 # 弹幕