diff --git a/ios/Runner/Info.plist b/ios/Runner/Info.plist index 37a7503e..0d71e0f3 100644 --- a/ios/Runner/Info.plist +++ b/ios/Runner/Info.plist @@ -1,60 +1,62 @@ + + NSPhotoLibraryAddUsageDescription + + CADisableMinimumFrameDurationOnPhone + + CFBundleDevelopmentRegion + $(DEVELOPMENT_LANGUAGE) + CFBundleDisplayName + Kazumi + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + kazumi + CFBundlePackageType + APPL + CFBundleShortVersionString + $(FLUTTER_BUILD_NAME) + CFBundleSignature + ???? + CFBundleVersion + $(FLUTTER_BUILD_NUMBER) + LSApplicationQueriesSchemes + + vlc-x-callback + + LSRequiresIPhoneOS + + NSAppTransportSecurity - CADisableMinimumFrameDurationOnPhone + NSAllowsArbitraryLoads - CFBundleDevelopmentRegion - $(DEVELOPMENT_LANGUAGE) - CFBundleDisplayName - Kazumi - CFBundleExecutable - $(EXECUTABLE_NAME) - CFBundleIdentifier - $(PRODUCT_BUNDLE_IDENTIFIER) - CFBundleInfoDictionaryVersion - 6.0 - CFBundleName - kazumi - CFBundlePackageType - APPL - CFBundleShortVersionString - $(FLUTTER_BUILD_NAME) - CFBundleSignature - ???? - CFBundleVersion - $(FLUTTER_BUILD_NUMBER) - LSApplicationQueriesSchemes - - vlc-x-callback - - LSRequiresIPhoneOS - - NSAppTransportSecurity - - NSAllowsArbitraryLoads - - - UIApplicationSupportsIndirectInputEvents - - UILaunchStoryboardName - LaunchScreen - UIMainStoryboardFile - Main - UISupportedInterfaceOrientations - - UIInterfaceOrientationPortrait - UIInterfaceOrientationLandscapeLeft - UIInterfaceOrientationLandscapeRight - - UISupportedInterfaceOrientations~ipad - - UIInterfaceOrientationPortrait - UIInterfaceOrientationPortraitUpsideDown - UIInterfaceOrientationLandscapeLeft - UIInterfaceOrientationLandscapeRight - - UIStatusBarHidden - + UIApplicationSupportsIndirectInputEvents + + UILaunchStoryboardName + LaunchScreen + UIMainStoryboardFile + Main + UISupportedInterfaceOrientations + + UIInterfaceOrientationPortrait + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + UISupportedInterfaceOrientations~ipad + + UIInterfaceOrientationPortrait + UIInterfaceOrientationPortraitUpsideDown + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + UIStatusBarHidden + + diff --git a/lib/pages/player/player_item.dart b/lib/pages/player/player_item.dart index 86bb96c4..623cdc00 100644 --- a/lib/pages/player/player_item.dart +++ b/lib/pages/player/player_item.dart @@ -31,6 +31,7 @@ import 'package:kazumi/bean/appbar/drag_to_move_bar.dart' as dtb; import 'package:kazumi/pages/settings/danmaku/danmaku_settings_window.dart'; import 'package:kazumi/utils/constants.dart'; import 'package:kazumi/pages/player/episode_comments_sheet.dart'; +import 'package:saver_gallery/saver_gallery.dart'; class PlayerItem extends StatefulWidget { const PlayerItem( @@ -679,6 +680,20 @@ class _PlayerItemState extends State } catch (_) {} } + Future _handleScreenshot() async { + try { + Uint8List? screenshot = await playerController.mediaPlayer.screenshot(format: 'image/png'); + final result = await SaverGallery.saveImage(screenshot!, fileName: DateTime.timestamp().toString(), skipIfExists: true); + if (result.isSuccess) { + SmartDialog.showToast('截图保存到相簿成功'); + } else { + SmartDialog.showToast('截图保存失败:${result.errorMessage}'); + } + } catch (_) { + SmartDialog.showToast('截图失败'); + } + } + @override void onWindowRestore() { danmakuController.onClear(); @@ -1296,19 +1311,34 @@ class _PlayerItemState extends State bottom: 0, child: SlideTransition( position: _leftOffsetAnimation, - child: IconButton( - icon: Icon( - lockPanel - ? Icons.lock_outline - : Icons.lock_open, - color: Colors.white, + child: Column(children: [ + const Spacer(), + (lockPanel) + ? Container() + : IconButton( + icon: const Icon( + Icons.photo_camera_outlined, + color: Colors.white, + ), + onPressed: () { + _handleScreenshot(); + }, + ), + IconButton( + icon: Icon( + lockPanel + ? Icons.lock_outline + : Icons.lock_open, + color: Colors.white, + ), + onPressed: () { + setState(() { + lockPanel = !lockPanel; + }); + }, ), - onPressed: () { - setState(() { - lockPanel = !lockPanel; - }); - }, - ), + const Spacer(), + ]), ), ), diff --git a/pubspec.lock b/pubspec.lock index 82e0f1b7..23948616 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -1011,6 +1011,14 @@ packages: url: "https://pub.dev" source: hosted version: "2.0.1" + saver_gallery: + dependency: "direct main" + description: + name: saver_gallery + sha256: bf59475e50b73d666630bed7a5fdb621fed92d637f64e3c61ce81653ec6a833c + url: "https://pub.dev" + source: hosted + version: "4.0.1" screen_brightness_android: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index 3170c5e9..ba0c6f20 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -75,6 +75,7 @@ dependencies: flutter_rating_bar: ^4.0.1 scrollview_observer: ^1.22.0 styled_text: ^8.1.0 + saver_gallery: ^4.0.0 webview_windows: git: url: https://github.com/Predidit/flutter-webview-windows.git