✨ Attachment preview
This commit is contained in:
		| @@ -54,6 +54,7 @@ class _PostPublishingScreenState extends State<PostPublishingScreen> { | ||||
|   void showAttachments() { | ||||
|     showModalBottomSheet( | ||||
|       context: context, | ||||
|       isScrollControlled: true, | ||||
|       builder: (context) => AttachmentPublishPopup( | ||||
|         usage: 'i.attachment', | ||||
|         current: _attachments, | ||||
|   | ||||
| @@ -16,6 +16,7 @@ import 'package:solian/models/attachment.dart'; | ||||
| import 'package:solian/platform.dart'; | ||||
| import 'package:solian/providers/auth.dart'; | ||||
| import 'package:solian/providers/content/attachment.dart'; | ||||
| import 'package:solian/widgets/attachments/attachment_item.dart'; | ||||
|  | ||||
| class AttachmentPublishPopup extends StatefulWidget { | ||||
|   final String usage; | ||||
| @@ -156,7 +157,7 @@ class _AttachmentPublishPopupState extends State<AttachmentPublishPopup> { | ||||
|  | ||||
|   void pasteFileToUpload() async { | ||||
|     final data = await Pasteboard.image; | ||||
|     if(data == null) return; | ||||
|     if (data == null) return; | ||||
|  | ||||
|     setState(() => _isBusy = true); | ||||
|  | ||||
| @@ -237,6 +238,25 @@ class _AttachmentPublishPopupState extends State<AttachmentPublishPopup> { | ||||
|     } | ||||
|   } | ||||
|  | ||||
|   void showEdit(Attachment element, int index) { | ||||
|     showDialog( | ||||
|       context: context, | ||||
|       builder: (context) { | ||||
|         return AttachmentEditorDialog( | ||||
|           item: element, | ||||
|           onDelete: () { | ||||
|             setState(() => _attachments.removeAt(index)); | ||||
|             widget.onUpdate(_attachments.map((e) => e!.id).toList()); | ||||
|           }, | ||||
|           onUpdate: (item) { | ||||
|             setState(() => _attachments[index] = item); | ||||
|             widget.onUpdate(_attachments.map((e) => e!.id).toList()); | ||||
|           }, | ||||
|         ); | ||||
|       }, | ||||
|     ); | ||||
|   } | ||||
|  | ||||
|   @override | ||||
|   void initState() { | ||||
|     super.initState(); | ||||
| @@ -294,57 +314,65 @@ class _AttachmentPublishPopupState extends State<AttachmentPublishPopup> { | ||||
|                       return Container( | ||||
|                         padding: const EdgeInsets.only( | ||||
|                             left: 16, right: 8, bottom: 16), | ||||
|                         child: Row( | ||||
|                           children: [ | ||||
|                             Expanded( | ||||
|                               child: Column( | ||||
|                                 crossAxisAlignment: CrossAxisAlignment.start, | ||||
|                                 children: [ | ||||
|                                   Text( | ||||
|                                     element.alt, | ||||
|                                     overflow: TextOverflow.ellipsis, | ||||
|                                     maxLines: 1, | ||||
|                                     style: const TextStyle( | ||||
|                                         fontWeight: FontWeight.bold), | ||||
|                         child: Card( | ||||
|                           color: Theme.of(context).colorScheme.surface, | ||||
|                           child: Column( | ||||
|                             children: [ | ||||
|                               SizedBox( | ||||
|                                 height: 280, | ||||
|                                 child: ClipRRect( | ||||
|                                   borderRadius: const BorderRadius.only( | ||||
|                                     topLeft: Radius.circular(8), | ||||
|                                     topRight: Radius.circular(8), | ||||
|                                   ), | ||||
|                                   Text( | ||||
|                                     '${fileType[0].toUpperCase()}${fileType.substring(1)} · ${formatBytes(element.size)}', | ||||
|                                   child: AttachmentItem( | ||||
|                                     parentId: 'attachment-editor', | ||||
|                                     item: element, | ||||
|                                     showBadge: false, | ||||
|                                     showHideButton: false, | ||||
|                                   ), | ||||
|                                 ], | ||||
|                                 ), | ||||
|                               ), | ||||
|                             ), | ||||
|                             IconButton( | ||||
|                               style: TextButton.styleFrom( | ||||
|                                 shape: const CircleBorder(), | ||||
|                                 foregroundColor: Theme.of(context).primaryColor, | ||||
|                               SizedBox( | ||||
|                                 height: 54, | ||||
|                                 child: Row( | ||||
|                                   children: [ | ||||
|                                     Expanded( | ||||
|                                       child: Column( | ||||
|                                         crossAxisAlignment: | ||||
|                                             CrossAxisAlignment.start, | ||||
|                                         children: [ | ||||
|                                           Text( | ||||
|                                             element.alt, | ||||
|                                             overflow: TextOverflow.ellipsis, | ||||
|                                             maxLines: 1, | ||||
|                                             style: const TextStyle( | ||||
|                                               fontWeight: FontWeight.bold, | ||||
|                                               fontFamily: 'monospace' | ||||
|                                             ), | ||||
|                                           ), | ||||
|                                           Text( | ||||
|                                             '${fileType[0].toUpperCase()}${fileType.substring(1)} · ${formatBytes(element.size)}', | ||||
|                                             style: | ||||
|                                                 const TextStyle(fontSize: 12), | ||||
|                                           ), | ||||
|                                         ], | ||||
|                                       ), | ||||
|                                     ), | ||||
|                                     IconButton( | ||||
|                                       style: TextButton.styleFrom( | ||||
|                                         shape: const CircleBorder(), | ||||
|                                         foregroundColor: | ||||
|                                             Theme.of(context).primaryColor, | ||||
|                                       ), | ||||
|                                       icon: const Icon(Icons.more_horiz), | ||||
|                                       onPressed: () => showEdit(element, index), | ||||
|                                     ), | ||||
|                                   ], | ||||
|                                 ).paddingSymmetric(vertical: 8, horizontal: 16), | ||||
|                               ), | ||||
|                               icon: const Icon(Icons.more_horiz), | ||||
|                               onPressed: () { | ||||
|                                 showDialog( | ||||
|                                   context: context, | ||||
|                                   builder: (context) { | ||||
|                                     return AttachmentEditorDialog( | ||||
|                                       item: element, | ||||
|                                       onDelete: () { | ||||
|                                         setState( | ||||
|                                             () => _attachments.removeAt(index)); | ||||
|                                         widget.onUpdate(_attachments | ||||
|                                             .map((e) => e!.id) | ||||
|                                             .toList()); | ||||
|                                       }, | ||||
|                                       onUpdate: (item) { | ||||
|                                         setState( | ||||
|                                             () => _attachments[index] = item); | ||||
|                                         widget.onUpdate(_attachments | ||||
|                                             .map((e) => e!.id) | ||||
|                                             .toList()); | ||||
|                                       }, | ||||
|                                     ); | ||||
|                                   }, | ||||
|                                 ); | ||||
|                               }, | ||||
|                             ), | ||||
|                           ], | ||||
|                             ], | ||||
|                           ), | ||||
|                         ), | ||||
|                       ); | ||||
|                     }, | ||||
|   | ||||
| @@ -46,6 +46,7 @@ class _ChatMessageInputState extends State<ChatMessageInput> { | ||||
|   void showAttachments() { | ||||
|     showModalBottomSheet( | ||||
|       context: context, | ||||
|       isScrollControlled: true, | ||||
|       builder: (context) => AttachmentPublishPopup( | ||||
|         usage: 'm.attachment', | ||||
|         current: _attachments, | ||||
|   | ||||
| @@ -2,6 +2,8 @@ PODS: | ||||
|   - connectivity_plus (0.0.1): | ||||
|     - Flutter | ||||
|     - FlutterMacOS | ||||
|   - desktop_drop (0.0.1): | ||||
|     - FlutterMacOS | ||||
|   - device_info_plus (0.0.1): | ||||
|     - FlutterMacOS | ||||
|   - file_selector_macos (0.0.1): | ||||
| @@ -76,8 +78,6 @@ PODS: | ||||
|   - GoogleUtilities/UserDefaults (7.13.3): | ||||
|     - GoogleUtilities/Logger | ||||
|     - GoogleUtilities/Privacy | ||||
|   - irondash_engine_context (0.0.1): | ||||
|     - FlutterMacOS | ||||
|   - livekit_client (2.2.0): | ||||
|     - FlutterMacOS | ||||
|     - WebRTC-SDK (= 114.5735.10) | ||||
| @@ -96,6 +96,8 @@ PODS: | ||||
|   - nanopb/encode (2.30910.0) | ||||
|   - package_info_plus (0.0.1): | ||||
|     - FlutterMacOS | ||||
|   - pasteboard (0.0.1): | ||||
|     - FlutterMacOS | ||||
|   - path_provider_foundation (0.0.1): | ||||
|     - Flutter | ||||
|     - FlutterMacOS | ||||
| @@ -112,8 +114,6 @@ PODS: | ||||
|   - sqflite (0.0.3): | ||||
|     - Flutter | ||||
|     - FlutterMacOS | ||||
|   - super_native_extensions (0.0.1): | ||||
|     - FlutterMacOS | ||||
|   - url_launcher_macos (0.0.1): | ||||
|     - FlutterMacOS | ||||
|   - wakelock_plus (0.0.1): | ||||
| @@ -122,6 +122,7 @@ PODS: | ||||
|  | ||||
| DEPENDENCIES: | ||||
|   - connectivity_plus (from `Flutter/ephemeral/.symlinks/plugins/connectivity_plus/darwin`) | ||||
|   - desktop_drop (from `Flutter/ephemeral/.symlinks/plugins/desktop_drop/macos`) | ||||
|   - device_info_plus (from `Flutter/ephemeral/.symlinks/plugins/device_info_plus/macos`) | ||||
|   - file_selector_macos (from `Flutter/ephemeral/.symlinks/plugins/file_selector_macos/macos`) | ||||
|   - firebase_core (from `Flutter/ephemeral/.symlinks/plugins/firebase_core/macos`) | ||||
| @@ -130,19 +131,18 @@ DEPENDENCIES: | ||||
|   - flutter_secure_storage_macos (from `Flutter/ephemeral/.symlinks/plugins/flutter_secure_storage_macos/macos`) | ||||
|   - flutter_webrtc (from `Flutter/ephemeral/.symlinks/plugins/flutter_webrtc/macos`) | ||||
|   - FlutterMacOS (from `Flutter/ephemeral`) | ||||
|   - irondash_engine_context (from `Flutter/ephemeral/.symlinks/plugins/irondash_engine_context/macos`) | ||||
|   - livekit_client (from `Flutter/ephemeral/.symlinks/plugins/livekit_client/macos`) | ||||
|   - macos_window_utils (from `Flutter/ephemeral/.symlinks/plugins/macos_window_utils/macos`) | ||||
|   - media_kit_libs_macos_video (from `Flutter/ephemeral/.symlinks/plugins/media_kit_libs_macos_video/macos`) | ||||
|   - media_kit_native_event_loop (from `Flutter/ephemeral/.symlinks/plugins/media_kit_native_event_loop/macos`) | ||||
|   - media_kit_video (from `Flutter/ephemeral/.symlinks/plugins/media_kit_video/macos`) | ||||
|   - package_info_plus (from `Flutter/ephemeral/.symlinks/plugins/package_info_plus/macos`) | ||||
|   - pasteboard (from `Flutter/ephemeral/.symlinks/plugins/pasteboard/macos`) | ||||
|   - path_provider_foundation (from `Flutter/ephemeral/.symlinks/plugins/path_provider_foundation/darwin`) | ||||
|   - protocol_handler_macos (from `Flutter/ephemeral/.symlinks/plugins/protocol_handler_macos/macos`) | ||||
|   - screen_brightness_macos (from `Flutter/ephemeral/.symlinks/plugins/screen_brightness_macos/macos`) | ||||
|   - sentry_flutter (from `Flutter/ephemeral/.symlinks/plugins/sentry_flutter/macos`) | ||||
|   - sqflite (from `Flutter/ephemeral/.symlinks/plugins/sqflite/darwin`) | ||||
|   - super_native_extensions (from `Flutter/ephemeral/.symlinks/plugins/super_native_extensions/macos`) | ||||
|   - url_launcher_macos (from `Flutter/ephemeral/.symlinks/plugins/url_launcher_macos/macos`) | ||||
|   - wakelock_plus (from `Flutter/ephemeral/.symlinks/plugins/wakelock_plus/macos`) | ||||
|  | ||||
| @@ -163,6 +163,8 @@ SPEC REPOS: | ||||
| EXTERNAL SOURCES: | ||||
|   connectivity_plus: | ||||
|     :path: Flutter/ephemeral/.symlinks/plugins/connectivity_plus/darwin | ||||
|   desktop_drop: | ||||
|     :path: Flutter/ephemeral/.symlinks/plugins/desktop_drop/macos | ||||
|   device_info_plus: | ||||
|     :path: Flutter/ephemeral/.symlinks/plugins/device_info_plus/macos | ||||
|   file_selector_macos: | ||||
| @@ -179,8 +181,6 @@ EXTERNAL SOURCES: | ||||
|     :path: Flutter/ephemeral/.symlinks/plugins/flutter_webrtc/macos | ||||
|   FlutterMacOS: | ||||
|     :path: Flutter/ephemeral | ||||
|   irondash_engine_context: | ||||
|     :path: Flutter/ephemeral/.symlinks/plugins/irondash_engine_context/macos | ||||
|   livekit_client: | ||||
|     :path: Flutter/ephemeral/.symlinks/plugins/livekit_client/macos | ||||
|   macos_window_utils: | ||||
| @@ -193,6 +193,8 @@ EXTERNAL SOURCES: | ||||
|     :path: Flutter/ephemeral/.symlinks/plugins/media_kit_video/macos | ||||
|   package_info_plus: | ||||
|     :path: Flutter/ephemeral/.symlinks/plugins/package_info_plus/macos | ||||
|   pasteboard: | ||||
|     :path: Flutter/ephemeral/.symlinks/plugins/pasteboard/macos | ||||
|   path_provider_foundation: | ||||
|     :path: Flutter/ephemeral/.symlinks/plugins/path_provider_foundation/darwin | ||||
|   protocol_handler_macos: | ||||
| @@ -203,8 +205,6 @@ EXTERNAL SOURCES: | ||||
|     :path: Flutter/ephemeral/.symlinks/plugins/sentry_flutter/macos | ||||
|   sqflite: | ||||
|     :path: Flutter/ephemeral/.symlinks/plugins/sqflite/darwin | ||||
|   super_native_extensions: | ||||
|     :path: Flutter/ephemeral/.symlinks/plugins/super_native_extensions/macos | ||||
|   url_launcher_macos: | ||||
|     :path: Flutter/ephemeral/.symlinks/plugins/url_launcher_macos/macos | ||||
|   wakelock_plus: | ||||
| @@ -212,6 +212,7 @@ EXTERNAL SOURCES: | ||||
|  | ||||
| SPEC CHECKSUMS: | ||||
|   connectivity_plus: ddd7f30999e1faaef5967c23d5b6d503d10434db | ||||
|   desktop_drop: 69eeff437544aa619c8db7f4481b3a65f7696898 | ||||
|   device_info_plus: ce1b7762849d3ec103d0e0517299f2db7ad60720 | ||||
|   file_selector_macos: 54fdab7caa3ac3fc43c9fac4d7d8d231277f8cf2 | ||||
|   Firebase: 26b040b20866a55f55eb3611b9fcf3ae64816b86 | ||||
| @@ -227,7 +228,6 @@ SPEC CHECKSUMS: | ||||
|   FlutterMacOS: 8f6f14fa908a6fb3fba0cd85dbd81ec4b251fb24 | ||||
|   GoogleDataTransport: 6c09b596d841063d76d4288cc2d2f42cc36e1e2a | ||||
|   GoogleUtilities: ea963c370a38a8069cc5f7ba4ca849a60b6d7d15 | ||||
|   irondash_engine_context: da62996ee25616d2f01bbeb85dc115d813359478 | ||||
|   livekit_client: 9b39e0f1b8e1a8ec794bb72a4f9bbfc28c959ece | ||||
|   macos_window_utils: 933f91f64805e2eb91a5bd057cf97cd097276663 | ||||
|   media_kit_libs_macos_video: b3e2bbec2eef97c285f2b1baa7963c67c753fb82 | ||||
| @@ -235,6 +235,7 @@ SPEC CHECKSUMS: | ||||
|   media_kit_video: c75b07f14d59706c775778e4dd47dd027de8d1e5 | ||||
|   nanopb: 438bc412db1928dac798aa6fd75726007be04262 | ||||
|   package_info_plus: fa739dd842b393193c5ca93c26798dff6e3d0e0c | ||||
|   pasteboard: 9b69dba6fedbb04866be632205d532fe2f6b1d99 | ||||
|   path_provider_foundation: 2b6b4c569c0fb62ec74538f866245ac84301af46 | ||||
|   PromisesObjC: f5707f49cb48b9636751c5b2e7d227e43fba9f47 | ||||
|   protocol_handler_macos: d10a6c01d6373389ffd2278013ab4c47ed6d6daa | ||||
| @@ -242,7 +243,6 @@ SPEC CHECKSUMS: | ||||
|   Sentry: 016de45ee5ce5fca2a829996f1bfafeb5e62e8b4 | ||||
|   sentry_flutter: 5fb57c5b7e6427a9dc1fedde4269eb65823982d4 | ||||
|   sqflite: 673a0e54cc04b7d6dba8d24fb8095b31c3a99eec | ||||
|   super_native_extensions: 85efee3a7495b46b04befcfc86ed12069264ebf3 | ||||
|   url_launcher_macos: 5f437abeda8c85500ceb03f5c1938a8c5a705399 | ||||
|   wakelock_plus: 4783562c9a43d209c458cb9b30692134af456269 | ||||
|   WebRTC-SDK: 8c0edd05b880a39648118192c252667ea06dea51 | ||||
|   | ||||
		Reference in New Issue
	
	Block a user