diff --git a/lib/pages/live_room/view.dart b/lib/pages/live_room/view.dart index 3a2683a3a..ea6453a50 100644 --- a/lib/pages/live_room/view.dart +++ b/lib/pages/live_room/view.dart @@ -124,7 +124,7 @@ class _LiveRoomPageState extends State videoPlayerServiceHandler.onVideoDetailDispose(heroTag); _listener?.cancel(); WidgetsBinding.instance.removeObserver(this); - ScreenBrightness().resetApplicationScreenBrightness(); + ScreenBrightness.instance.resetApplicationScreenBrightness(); PlPlayerController.setPlayCallBack(null); _liveRoomController ..msgStream?.close() diff --git a/lib/pages/save_panel/view.dart b/lib/pages/save_panel/view.dart index 47ad74fc3..707a6bf05 100644 --- a/lib/pages/save_panel/view.dart +++ b/lib/pages/save_panel/view.dart @@ -243,17 +243,19 @@ class _SavePanelState extends State { if (isShare) { Get.back(); SmartDialog.dismiss(); - Share.shareXFiles( - [ - XFile.fromData( - pngBytes, - name: picName, - mimeType: 'image/png', - ), - ], - sharePositionOrigin: await Utils.isIpad() - ? Rect.fromLTWH(0, 0, Get.width, Get.height / 2) - : null, + SharePlus.instance.share( + ShareParams( + files: [ + XFile.fromData( + pngBytes, + name: picName, + mimeType: 'image/png', + ), + ], + sharePositionOrigin: await Utils.isIpad() + ? Rect.fromLTWH(0, 0, Get.width, Get.height / 2) + : null, + ), ); } else { final result = await SaverGallery.saveImage( diff --git a/lib/pages/video/view.dart b/lib/pages/video/view.dart index 1a29ee56d..3ce4fa2e8 100644 --- a/lib/pages/video/view.dart +++ b/lib/pages/video/view.dart @@ -325,7 +325,7 @@ class _VideoDetailPageVState extends State WidgetsBinding.instance.removeObserver(this); if (!Get.previousRoute.startsWith('/video')) { - ScreenBrightness().resetApplicationScreenBrightness(); + ScreenBrightness.instance.resetApplicationScreenBrightness(); PlPlayerController.setPlayCallBack(null); } videoDetailController.positionSubscription?.cancel(); @@ -361,7 +361,7 @@ class _VideoDetailPageVState extends State WidgetsBinding.instance.removeObserver(this); - ScreenBrightness().resetApplicationScreenBrightness(); + ScreenBrightness.instance.resetApplicationScreenBrightness(); videoDetailController.positionSubscription?.cancel(); videoIntroController.canelTimer(); @@ -405,14 +405,14 @@ class _VideoDetailPageVState extends State videoDetailController.brightness!, ); if (videoDetailController.brightness != -1.0) { - ScreenBrightness().setApplicationScreenBrightness( + ScreenBrightness.instance.setApplicationScreenBrightness( videoDetailController.brightness!, ); } else { - ScreenBrightness().resetApplicationScreenBrightness(); + ScreenBrightness.instance.resetApplicationScreenBrightness(); } } else { - ScreenBrightness().resetApplicationScreenBrightness(); + ScreenBrightness.instance.resetApplicationScreenBrightness(); } } super.didPopNext(); diff --git a/lib/pages/video/widgets/header_control.dart b/lib/pages/video/widgets/header_control.dart index acdf7844d..874364ae3 100644 --- a/lib/pages/video/widgets/header_control.dart +++ b/lib/pages/video/widgets/header_control.dart @@ -888,22 +888,24 @@ class HeaderControlState extends State { SmartDialog.showToast('已保存'); } } catch (e) { - Share.shareXFiles( - [ - XFile.fromData( - res.data, - name: name, - mimeType: 'application/json', - ), - ], - sharePositionOrigin: await Utils.isIpad() - ? Rect.fromLTWH( - 0, - 0, - Get.width, - Get.height / 2, - ) - : null, + SharePlus.instance.share( + ShareParams( + files: [ + XFile.fromData( + res.data, + name: name, + mimeType: 'text/plain', + ), + ], + sharePositionOrigin: await Utils.isIpad() + ? Rect.fromLTWH( + 0, + 0, + Get.width, + Get.height / 2, + ) + : null, + ), ); } } diff --git a/lib/plugin/pl_player/controller.dart b/lib/plugin/pl_player/controller.dart index 44c4c5d00..186712df3 100644 --- a/lib/plugin/pl_player/controller.dart +++ b/lib/plugin/pl_player/controller.dart @@ -1230,7 +1230,7 @@ class PlPlayerController { /// 亮度 Future getCurrentBrightness() async { try { - _currentBrightness.value = await ScreenBrightness().application; + _currentBrightness.value = await ScreenBrightness.instance.application; } catch (e) { throw 'Failed to get current brightness'; //return 0; @@ -1244,7 +1244,7 @@ class PlPlayerController { Future setBrightness(double brightness) async { try { this.brightness.value = brightness; - ScreenBrightness().setApplicationScreenBrightness(brightness); + ScreenBrightness.instance.setApplicationScreenBrightness(brightness); // setVideoBrightness(); } catch (e) { throw 'Failed to set brightness'; diff --git a/lib/plugin/pl_player/view.dart b/lib/plugin/pl_player/view.dart index edbd728cb..4cb362ef7 100644 --- a/lib/plugin/pl_player/view.dart +++ b/lib/plugin/pl_player/view.dart @@ -194,8 +194,10 @@ class _PLVideoPlayerState extends State Future.microtask(() async { try { - _brightnessValue.value = await ScreenBrightness().application; - _listener = ScreenBrightness().onApplicationScreenBrightnessChanged + _brightnessValue.value = await ScreenBrightness.instance.application; + _listener = ScreenBrightness + .instance + .onApplicationScreenBrightnessChanged .listen((double value) { if (mounted) { _brightnessValue.value = value; @@ -224,7 +226,7 @@ class _PLVideoPlayerState extends State Future setBrightness(double value) async { try { - await ScreenBrightness().setApplicationScreenBrightness(value); + await ScreenBrightness.instance.setApplicationScreenBrightness(value); } catch (_) {} _brightnessIndicator.value = true; _brightnessTimer?.cancel(); diff --git a/lib/utils/image_util.dart b/lib/utils/image_util.dart index bc2abe3a5..ca5511902 100644 --- a/lib/utils/image_util.dart +++ b/lib/utils/image_util.dart @@ -33,15 +33,13 @@ class ImageUtil { var path = '${temp.path}/$name'; File(path).writeAsBytesSync(response.data); - Rect? sharePositionOrigin; - if (await Utils.isIpad()) { - sharePositionOrigin = Rect.fromLTWH(0, 0, Get.width, Get.height / 2); - } - - Share.shareXFiles( - [XFile(path)], - subject: url, - sharePositionOrigin: sharePositionOrigin, + SharePlus.instance.share( + ShareParams( + files: [XFile(path)], + sharePositionOrigin: await Utils.isIpad() + ? Rect.fromLTWH(0, 0, Get.width, Get.height / 2) + : null, + ), ); } catch (e) { SmartDialog.showToast(e.toString()); diff --git a/lib/utils/utils.dart b/lib/utils/utils.dart index 7e6de88bc..fdc8f4b92 100644 --- a/lib/utils/utils.dart +++ b/lib/utils/utils.dart @@ -42,13 +42,13 @@ class Utils { static Future shareText(String text) async { try { - Rect? sharePositionOrigin; - if (await isIpad()) { - sharePositionOrigin = Rect.fromLTWH(0, 0, Get.width, Get.height / 2); - } - Share.share( - text, - sharePositionOrigin: sharePositionOrigin, + SharePlus.instance.share( + ShareParams( + text: text, + sharePositionOrigin: await Utils.isIpad() + ? Rect.fromLTWH(0, 0, Get.width, Get.height / 2) + : null, + ), ); } catch (e) { SmartDialog.showToast(e.toString()); diff --git a/pubspec.lock b/pubspec.lock index eb2470130..faff480cf 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -1605,20 +1605,19 @@ packages: share_plus: dependency: "direct main" description: - path: "packages/share_plus/share_plus" - ref: main - resolved-ref: cad093514b4247c2103a803ed951a572319454e4 - url: "https://github.com/bggRGjQaUbCoE/plus_plugins.git" - source: git - version: "10.1.0" + name: share_plus + sha256: b2961506569e28948d75ec346c28775bb111986bb69dc6a20754a457e3d97fa0 + url: "https://pub.dev" + source: hosted + version: "11.0.0" share_plus_platform_interface: dependency: transitive description: name: share_plus_platform_interface - sha256: cc012a23fc2d479854e6c80150696c4a5f5bb62cb89af4de1c505cf78d0a5d0b + sha256: "1032d392bc5d2095a77447a805aa3f804d2ae6a4d5eef5e6ebb3bd94c1bc19ef" url: "https://pub.dev" source: hosted - version: "5.0.2" + version: "6.0.0" shared_preferences: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index 057b400e3..e8756a02a 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -67,12 +67,7 @@ dependencies: # 权限 permission_handler: ^12.0.0+1 # 分享 - # share_plus: ^10.0.2 - share_plus: - git: - url: https://github.com/bggRGjQaUbCoE/plus_plugins.git - ref: main - path: packages/share_plus/share_plus + share_plus: ^11.0.0 # cookie 管理 # webview_cookie_manager: ^2.0.6 # 浏览器