diff --git a/ios/Podfile b/ios/Podfile index a4d3d31..406b251 100644 --- a/ios/Podfile +++ b/ios/Podfile @@ -1,5 +1,6 @@ # Uncomment this line to define a global platform for your project platform :ios, '13.0' +use_frameworks! # CocoaPods analytics sends network stats synchronously affecting flutter build latency. ENV['COCOAPODS_DISABLE_STATS'] = 'true' diff --git a/ios/Podfile.lock b/ios/Podfile.lock index 5a10eb4..709a396 100644 --- a/ios/Podfile.lock +++ b/ios/Podfile.lock @@ -73,8 +73,6 @@ PODS: - flutter_secure_storage_darwin (10.0.0): - Flutter - FlutterMacOS - - flutter_volume_controller (0.0.1): - - Flutter - gal (1.0.0): - Flutter - FlutterMacOS @@ -216,6 +214,8 @@ PODS: - sqlite3/rtree - url_launcher_ios (0.0.1): - Flutter + - video_compress (0.3.0): + - Flutter - video_player_avfoundation (0.0.1): - Flutter - FlutterMacOS @@ -235,7 +235,6 @@ DEPENDENCIES: - flutter_keyboard_visibility (from `.symlinks/plugins/flutter_keyboard_visibility/ios`) - flutter_local_notifications (from `.symlinks/plugins/flutter_local_notifications/ios`) - flutter_secure_storage_darwin (from `.symlinks/plugins/flutter_secure_storage_darwin/darwin`) - - flutter_volume_controller (from `.symlinks/plugins/flutter_volume_controller/ios`) - gal (from `.symlinks/plugins/gal/darwin`) - GoogleUtilities - image_picker_ios (from `.symlinks/plugins/image_picker_ios/ios`) @@ -250,6 +249,7 @@ DEPENDENCIES: - sqlite3 - sqlite3_flutter_libs (from `.symlinks/plugins/sqlite3_flutter_libs/darwin`) - url_launcher_ios (from `.symlinks/plugins/url_launcher_ios/ios`) + - video_compress (from `.symlinks/plugins/video_compress/ios`) - video_player_avfoundation (from `.symlinks/plugins/video_player_avfoundation/darwin`) SPEC REPOS: @@ -293,8 +293,6 @@ EXTERNAL SOURCES: :path: ".symlinks/plugins/flutter_local_notifications/ios" flutter_secure_storage_darwin: :path: ".symlinks/plugins/flutter_secure_storage_darwin/darwin" - flutter_volume_controller: - :path: ".symlinks/plugins/flutter_volume_controller/ios" gal: :path: ".symlinks/plugins/gal/darwin" image_picker_ios: @@ -319,6 +317,8 @@ EXTERNAL SOURCES: :path: ".symlinks/plugins/sqlite3_flutter_libs/darwin" url_launcher_ios: :path: ".symlinks/plugins/url_launcher_ios/ios" + video_compress: + :path: ".symlinks/plugins/video_compress/ios" video_player_avfoundation: :path: ".symlinks/plugins/video_player_avfoundation/darwin" @@ -339,7 +339,6 @@ SPEC CHECKSUMS: flutter_keyboard_visibility: 4625131e43015dbbe759d9b20daaf77e0e3f6619 flutter_local_notifications: a5a732f069baa862e728d839dd2ebb904737effb flutter_secure_storage_darwin: ce237a8775b39723566dc72571190a3769d70468 - flutter_volume_controller: c2be490cb0487e8b88d0d9fc2b7e1c139a4ebccb gal: baecd024ebfd13c441269ca7404792a7152fde89 GoogleAppMeasurement: 36684bfb3ee034e2b42b4321eb19da3a1b81e65d GoogleDataTransport: aae35b7ea0c09004c3797d53c8c41f66f219d6a7 @@ -363,8 +362,9 @@ SPEC CHECKSUMS: sqlite3: fc1400008a9b3525f5914ed715a5d1af0b8f4983 sqlite3_flutter_libs: f6acaa2172e6bb3e2e70c771661905080e8ebcf2 url_launcher_ios: 694010445543906933d732453a59da0a173ae33d + video_compress: f2133a07762889d67f0711ac831faa26f956980e video_player_avfoundation: 2cef49524dd1f16c5300b9cd6efd9611ce03639b -PODFILE CHECKSUM: 4d78ee29daee4dd5268f87f2e6b41e472cc27728 +PODFILE CHECKSUM: 4fb7efca82567164b90218acb0591fb9166bfb73 COCOAPODS: 1.16.2 diff --git a/ios/Runner.xcodeproj/project.pbxproj b/ios/Runner.xcodeproj/project.pbxproj index c174ec3..b8f0dc3 100644 --- a/ios/Runner.xcodeproj/project.pbxproj +++ b/ios/Runner.xcodeproj/project.pbxproj @@ -7,16 +7,16 @@ objects = { /* Begin PBXBuildFile section */ - 01781A704D3196889C029F13 /* libPods-RunnerTests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 1D2A72578A796660F4740845 /* libPods-RunnerTests.a */; }; + 05CF222065FC24670B05B6D0 /* Pods_RunnerTests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DC1EE71614E1B4F84D6FDC2D /* Pods_RunnerTests.framework */; }; + 06AA21445BEAF2C45DC9DCDF /* Pods_NotificationService.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A198C9B5D90584C4F96206B2 /* Pods_NotificationService.framework */; }; 1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */ = {isa = PBXBuildFile; fileRef = 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */; }; 331C808B294A63AB00263BE5 /* RunnerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 331C807B294A618700263BE5 /* RunnerTests.swift */; }; 3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; }; 74858FAF1ED2DC5600515810 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74858FAE1ED2DC5600515810 /* AppDelegate.swift */; }; - 951DB0F2008EB94699D02555 /* libPods-Runner.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 5F3BB8E3AC9CEA61248BD989 /* libPods-Runner.a */; }; 97C146FC1CF9000F007C117D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FA1CF9000F007C117D /* Main.storyboard */; }; 97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FD1CF9000F007C117D /* Assets.xcassets */; }; 97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */; }; - B78043D680BC6AA2F7329CB5 /* libPods-NotificationService.a in Frameworks */ = {isa = PBXBuildFile; fileRef = CF25E171552AB36BFB27E57B /* libPods-NotificationService.a */; }; + CA4FDF5DD8F229C30DE512AF /* Pods_Runner.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = EE2CCFEE4ABECF33852F7735 /* Pods_Runner.framework */; }; D21FCEAB2D9F2B750088701D /* NotificationService.appex in Embed Foundation Extensions */ = {isa = PBXBuildFile; fileRef = D21FCEA42D9F2B750088701D /* NotificationService.appex */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; }; F3C66D726A2EB28484DF0B10 /* GoogleService-Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = 16FBC6F5B58E1C6646F5D447 /* GoogleService-Info.plist */; }; /* End PBXBuildFile section */ @@ -67,13 +67,11 @@ 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneratedPluginRegistrant.m; sourceTree = ""; }; 1581CC44342D555EFB889768 /* Pods-RunnerTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RunnerTests.debug.xcconfig"; path = "Target Support Files/Pods-RunnerTests/Pods-RunnerTests.debug.xcconfig"; sourceTree = ""; }; 16FBC6F5B58E1C6646F5D447 /* GoogleService-Info.plist */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.xml; name = "GoogleService-Info.plist"; path = "Runner/GoogleService-Info.plist"; sourceTree = ""; }; - 1D2A72578A796660F4740845 /* libPods-RunnerTests.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-RunnerTests.a"; sourceTree = BUILT_PRODUCTS_DIR; }; 331C807B294A618700263BE5 /* RunnerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RunnerTests.swift; sourceTree = ""; }; 331C8081294A63A400263BE5 /* RunnerTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = RunnerTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 35366FD433E0EFC6EF19A452 /* Pods-NotificationService.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-NotificationService.release.xcconfig"; path = "Target Support Files/Pods-NotificationService/Pods-NotificationService.release.xcconfig"; sourceTree = ""; }; 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = ""; }; 4D78471482626812FE2468E9 /* Pods-NotificationService.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-NotificationService.debug.xcconfig"; path = "Target Support Files/Pods-NotificationService/Pods-NotificationService.debug.xcconfig"; sourceTree = ""; }; - 5F3BB8E3AC9CEA61248BD989 /* libPods-Runner.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-Runner.a"; sourceTree = BUILT_PRODUCTS_DIR; }; 6EB462F87F0A23758713308F /* Pods-Runner.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.debug.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"; sourceTree = ""; }; 70E8A5E1DA4031C0E3F86C77 /* Pods-Runner.profile.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.profile.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.profile.xcconfig"; sourceTree = ""; }; 74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Runner-Bridging-Header.h"; sourceTree = ""; }; @@ -87,11 +85,13 @@ 97C146FD1CF9000F007C117D /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 97C147001CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 97C147021CF9000F007C117D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + A198C9B5D90584C4F96206B2 /* Pods_NotificationService.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_NotificationService.framework; sourceTree = BUILT_PRODUCTS_DIR; }; B3B27B7FBEEA31DB7793A0C2 /* Pods-Runner.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.release.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"; sourceTree = ""; }; - CF25E171552AB36BFB27E57B /* libPods-NotificationService.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-NotificationService.a"; sourceTree = BUILT_PRODUCTS_DIR; }; D21FCEA42D9F2B750088701D /* NotificationService.appex */ = {isa = PBXFileReference; explicitFileType = "wrapper.app-extension"; includeInIndex = 0; path = NotificationService.appex; sourceTree = BUILT_PRODUCTS_DIR; }; D2265DD42D920142000D99BB /* Runner.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = Runner.entitlements; sourceTree = ""; }; + DC1EE71614E1B4F84D6FDC2D /* Pods_RunnerTests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_RunnerTests.framework; sourceTree = BUILT_PRODUCTS_DIR; }; E96A5ACA32A7118204F050A5 /* Pods-RunnerTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RunnerTests.release.xcconfig"; path = "Target Support Files/Pods-RunnerTests/Pods-RunnerTests.release.xcconfig"; sourceTree = ""; }; + EE2CCFEE4ABECF33852F7735 /* Pods_Runner.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Runner.framework; sourceTree = BUILT_PRODUCTS_DIR; }; F02F7A1D63544AA9F23A1085 /* Pods-NotificationService.profile.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-NotificationService.profile.xcconfig"; path = "Target Support Files/Pods-NotificationService/Pods-NotificationService.profile.xcconfig"; sourceTree = ""; }; /* End PBXFileReference section */ @@ -121,7 +121,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - 01781A704D3196889C029F13 /* libPods-RunnerTests.a in Frameworks */, + 05CF222065FC24670B05B6D0 /* Pods_RunnerTests.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -129,7 +129,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - 951DB0F2008EB94699D02555 /* libPods-Runner.a in Frameworks */, + CA4FDF5DD8F229C30DE512AF /* Pods_Runner.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -137,7 +137,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - B78043D680BC6AA2F7329CB5 /* libPods-NotificationService.a in Frameworks */, + 06AA21445BEAF2C45DC9DCDF /* Pods_NotificationService.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -206,9 +206,9 @@ E5079CCEE4804DB65AA3F23F /* Frameworks */ = { isa = PBXGroup; children = ( - 5F3BB8E3AC9CEA61248BD989 /* libPods-Runner.a */, - 1D2A72578A796660F4740845 /* libPods-RunnerTests.a */, - CF25E171552AB36BFB27E57B /* libPods-NotificationService.a */, + A198C9B5D90584C4F96206B2 /* Pods_NotificationService.framework */, + EE2CCFEE4ABECF33852F7735 /* Pods_Runner.framework */, + DC1EE71614E1B4F84D6FDC2D /* Pods_RunnerTests.framework */, ); name = Frameworks; sourceTree = ""; @@ -264,6 +264,7 @@ 9705A1C41CF9048500538489 /* Embed Frameworks */, 3B06AD1E1E4923F5004D2608 /* Thin Binary */, A3027D78D4FF6E79C9EFD470 /* [CP] Copy Pods Resources */, + 32D7521D6B8F508A844DBC22 /* [CP] Embed Pods Frameworks */, ); buildRules = ( ); @@ -283,7 +284,6 @@ D21FCEA02D9F2B750088701D /* Sources */, D21FCEA12D9F2B750088701D /* Frameworks */, D21FCEA22D9F2B750088701D /* Resources */, - 058310D0E53ED9534CBBCE88 /* [CP] Copy Pods Resources */, ); buildRules = ( ); @@ -371,23 +371,6 @@ /* End PBXResourcesBuildPhase section */ /* Begin PBXShellScriptBuildPhase section */ - 058310D0E53ED9534CBBCE88 /* [CP] Copy Pods Resources */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputFileListPaths = ( - "${PODS_ROOT}/Target Support Files/Pods-NotificationService/Pods-NotificationService-resources-${CONFIGURATION}-input-files.xcfilelist", - ); - name = "[CP] Copy Pods Resources"; - outputFileListPaths = ( - "${PODS_ROOT}/Target Support Files/Pods-NotificationService/Pods-NotificationService-resources-${CONFIGURATION}-output-files.xcfilelist", - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-NotificationService/Pods-NotificationService-resources.sh\"\n"; - showEnvVarsInLog = 0; - }; 2915B65131340B0D0BD69DF9 /* [CP] Check Pods Manifest.lock */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; @@ -410,6 +393,23 @@ shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; showEnvVarsInLog = 0; }; + 32D7521D6B8F508A844DBC22 /* [CP] Embed Pods Frameworks */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + "${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-input-files.xcfilelist", + ); + name = "[CP] Embed Pods Frameworks"; + outputFileListPaths = ( + "${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-output-files.xcfilelist", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh\"\n"; + showEnvVarsInLog = 0; + }; 38633DCCA126701FCA357CBC /* [CP] Check Pods Manifest.lock */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; diff --git a/lib/src/providers/api/media.dart b/lib/src/providers/api/media.dart index 3c3abf0..2ba9b5a 100644 --- a/lib/src/providers/api/media.dart +++ b/lib/src/providers/api/media.dart @@ -1,4 +1,5 @@ import 'dart:convert'; +import 'package:camera/camera.dart'; import 'package:cryptography_plus/cryptography_plus.dart'; import 'package:drift/drift.dart'; import 'package:hive/hive.dart'; @@ -14,6 +15,7 @@ import 'package:twonly/src/providers/api/api_utils.dart'; import 'package:twonly/src/providers/hive.dart'; import 'package:twonly/src/services/notification_service.dart'; import 'package:twonly/src/utils/misc.dart'; +import 'package:video_compress/video_compress.dart'; Future tryDownloadAllMediaFiles() async { if (!await isAllowedToDownload()) { @@ -151,21 +153,8 @@ class States { } } -class ImageUploader { - static Future prepareState(Uint8List imageBytes) async { - Uint8List? imageBytesCompressed = await getCompressedImage(imageBytes); - if (imageBytesCompressed == null) { - // non recoverable state - Logger("media.dart").shout("Error compressing image!"); - return null; - } - - if (imageBytesCompressed.length >= 10000000) { - // non recoverable state - Logger("media.dart").shout("Image to big aborting!"); - return null; - } - +class Uploader { + static Future prepareState(Uint8List rawBytes) async { var state = PrepareState(); try { @@ -177,7 +166,7 @@ class ImageUploader { state.encryptionNonce = xchacha20.newNonce(); final secretBox = await xchacha20.encrypt( - imageBytesCompressed, + rawBytes, secretKey: secretKey, nonce: state.encryptionNonce, ); @@ -285,13 +274,46 @@ class ImageUploader { } } -Future sendImage( +Future sendMediaFile( List userIds, Uint8List imageBytes, bool isRealTwonly, int maxShowTime, + XFile? videoFilePath, + bool? enableVideoAudio, ) async { - final prepareState = await ImageUploader.prepareState(imageBytes); + // First: Compress the image. + Uint8List? imageBytesCompressed = await getCompressedImage(imageBytes); + if (imageBytesCompressed == null) { + // non recoverable state + Logger("media.dart").shout("Error compressing image!"); + return null; + } + + if (imageBytesCompressed.length >= 2000000) { + // non recoverable state + Logger("media.dart").shout("Image to big aborting!"); + return null; + } + + if (videoFilePath != null) { + print(videoFilePath.path); + // Second: If existand compress video + MediaInfo? mediaInfo = await VideoCompress.compressVideo( + videoFilePath.path, + quality: VideoQuality.MediumQuality, + includeAudio: enableVideoAudio, + deleteOrigin: false, + ); + + if (mediaInfo == null) { + Logger("send.media.file").shout("Error while compressing the video!"); + return; + } + print(mediaInfo.file); + } + + final prepareState = await Uploader.prepareState(imageBytes); if (prepareState == null) { // non recoverable state return; @@ -398,7 +420,7 @@ Future retransmitMediaFiles() async { Future uploadMediaState( String stateId, PrepareState prepareState, Metadata metadata) async { final uploadState = - await ImageUploader.uploadState(prepareState, metadata.userIds.length); + await Uploader.uploadState(prepareState, metadata.userIds.length); if (uploadState == null) { return false; } @@ -411,7 +433,7 @@ Future uploadMediaState( } } - await ImageUploader.notifyState(prepareState, uploadState, metadata); + await Uploader.notifyState(prepareState, uploadState, metadata); return true; } diff --git a/lib/src/views/camera/camera_preview_view.dart b/lib/src/views/camera/camera_preview_view.dart index 5660ac9..deef5d9 100644 --- a/lib/src/views/camera/camera_preview_view.dart +++ b/lib/src/views/camera/camera_preview_view.dart @@ -222,13 +222,13 @@ class _CameraPreviewViewState extends State { } Future pushMediaEditor( - Future? imageBytes, XFile? videFilePath) async { + Future? imageBytes, XFile? videoFilePath) async { bool? shoudReturn = await Navigator.push( context, PageRouteBuilder( opaque: false, pageBuilder: (context, a1, a2) => ShareImageEditorView( - videFilePath: videFilePath, + videoFilePath: videoFilePath, imageBytes: imageBytes, sendTo: widget.sendTo, ), diff --git a/lib/src/views/camera/image_editor/action_button.dart b/lib/src/views/camera/image_editor/action_button.dart index 3c85c02..3d43fcb 100644 --- a/lib/src/views/camera/image_editor/action_button.dart +++ b/lib/src/views/camera/image_editor/action_button.dart @@ -22,7 +22,7 @@ class ActionButton extends StatelessWidget { child: IconButton( icon: FaIcon( icon, - size: 30, + size: (icon is FontAwesomeIcons) ? 25 : 30, color: disable ? const Color.fromARGB(154, 255, 255, 255) : color ?? Colors.white, diff --git a/lib/src/views/camera/share_image_editor_view.dart b/lib/src/views/camera/share_image_editor_view.dart index b3d3a6f..8eeb034 100644 --- a/lib/src/views/camera/share_image_editor_view.dart +++ b/lib/src/views/camera/share_image_editor_view.dart @@ -30,17 +30,17 @@ List removedLayers = []; class ShareImageEditorView extends StatefulWidget { const ShareImageEditorView( - {super.key, this.imageBytes, this.sendTo, this.videFilePath}); + {super.key, this.imageBytes, this.sendTo, this.videoFilePath}); final Future? imageBytes; - final XFile? videFilePath; + final XFile? videoFilePath; final Contact? sendTo; @override State createState() => _ShareImageEditorView(); } class _ShareImageEditorView extends State { - bool imageLoadedReady = false; bool _isRealTwonly = false; + bool videoWithAudio = true; int maxShowTime = 999999; String? sendNextMediaToUserName; double tabDownPostion = 0; @@ -57,9 +57,9 @@ class _ShareImageEditorView extends State { initAsync(); if (widget.imageBytes != null) { loadImage(widget.imageBytes!); - } else if (widget.videFilePath != null) { + } else if (widget.videoFilePath != null) { videoController = - VideoPlayerController.file(File(widget.videFilePath!.path)); + VideoPlayerController.file(File(widget.videoFilePath!.path)); videoController?.setLooping(true); videoController?.initialize().then((_) { videoController!.play(); @@ -68,7 +68,7 @@ class _ShareImageEditorView extends State { Logger("ui.share_image_editor").shout(error); }); videoController?.play(); - print(widget.videFilePath!.path); + print(widget.videoFilePath!.path); } } @@ -107,7 +107,7 @@ class _ShareImageEditorView extends State { } return [ ActionButton( - FontAwesomeIcons.font, + Icons.text_fields_rounded, tooltipText: context.lang.addTextItem, onPressed: () async { layers = layers.where((x) => !x.isDeleted).toList(); @@ -122,7 +122,7 @@ class _ShareImageEditorView extends State { ), const SizedBox(height: 8), ActionButton( - FontAwesomeIcons.pencil, + Icons.draw_rounded, tooltipText: context.lang.addDrawing, onPressed: () async { undoLayers.clear(); @@ -133,7 +133,7 @@ class _ShareImageEditorView extends State { ), const SizedBox(height: 8), ActionButton( - FontAwesomeIcons.faceGrinWide, + Icons.add_reaction_outlined, tooltipText: context.lang.addEmoji, onPressed: () async { EmojiLayerData? layer = await showModalBottomSheet( @@ -153,9 +153,8 @@ class _ShareImageEditorView extends State { const SizedBox(height: 8), NotificationBadge( count: maxShowTime == 999999 ? "∞" : maxShowTime.toString(), - // count: "", child: ActionButton( - FontAwesomeIcons.stopwatch, + Icons.timer_outlined, tooltipText: context.lang.protectAsARealTwonly, onPressed: () async { if (maxShowTime == 999999) { @@ -174,6 +173,18 @@ class _ShareImageEditorView extends State { }, ), ), + if (widget.videoFilePath != null) const SizedBox(height: 8), + if (widget.videoFilePath != null) + ActionButton( + (videoWithAudio) ? Icons.volume_up_rounded : Icons.volume_off_rounded, + tooltipText: context.lang.protectAsARealTwonly, + color: Colors.white, + onPressed: () async { + setState(() { + videoWithAudio = !videoWithAudio; + }); + }, + ), const SizedBox(height: 8), ActionButton( FontAwesomeIcons.shieldHeart, @@ -296,10 +307,6 @@ class _ShareImageEditorView extends State { )); layers.add(FilterLayerData()); - - setState(() { - imageLoadedReady = true; - }); } Future sendImageToSinglePerson() async { @@ -313,12 +320,8 @@ class _ShareImageEditorView extends State { Navigator.pop(context, false); return; } - sendImage( - [widget.sendTo!.userId], - imageBytes, - _isRealTwonly, - maxShowTime, - ); + sendMediaFile([widget.sendTo!.userId], imageBytes, _isRealTwonly, + maxShowTime, widget.videoFilePath, videoWithAudio); if (context.mounted) { // ignore: use_build_context_synchronously Navigator.pop(context, true); @@ -334,7 +337,7 @@ class _ShareImageEditorView extends State { } return Scaffold( - backgroundColor: imageLoadedReady ? null : Colors.white.withAlpha(0), + backgroundColor: Colors.white.withAlpha(0), resizeToAvoidBottomInset: false, body: Stack( fit: StackFit.expand, diff --git a/lib/src/views/camera/share_image_view.dart b/lib/src/views/camera/share_image_view.dart index ac4c5c3..8dc35f5 100644 --- a/lib/src/views/camera/share_image_view.dart +++ b/lib/src/views/camera/share_image_view.dart @@ -1,6 +1,7 @@ import 'dart:async'; import 'dart:collection'; import 'dart:typed_data'; +import 'package:camera/camera.dart'; import 'package:flutter/material.dart'; import 'package:font_awesome_flutter/font_awesome_flutter.dart'; import 'package:twonly/globals.dart'; @@ -21,11 +22,15 @@ class ShareImageView extends StatefulWidget { required this.imageBytesFuture, required this.isRealTwonly, required this.maxShowTime, - this.preselectedUser}); + this.preselectedUser, + this.videoFilePath, + this.enableVideoAudio}); final Future imageBytesFuture; final bool isRealTwonly; final int maxShowTime; + final XFile? videoFilePath; final Contact? preselectedUser; + final bool? enableVideoAudio; @override State createState() => _ShareImageView(); @@ -226,12 +231,13 @@ class _ShareImageView extends State { setState(() { sendingImage = true; }); - sendImage( - _selectedUserIds.toList(), - imageBytes!, - widget.isRealTwonly, - widget.maxShowTime, - ); + sendMediaFile( + _selectedUserIds.toList(), + imageBytes!, + widget.isRealTwonly, + widget.maxShowTime, + widget.videoFilePath, + widget.enableVideoAudio); if (context.mounted) { if (widget.preselectedUser != null) { Navigator.pop(context, true);