From 2bc4513bb6ac9ce1a8fe443321bdf2254731516c Mon Sep 17 00:00:00 2001 From: LittleSheep Date: Thu, 1 Aug 2024 11:49:28 +0800 Subject: [PATCH] :bug: Fix post tag input issue --- .github/workflows/nightly.yml | 2 +- ios/Podfile.lock | 10 ++++++ lib/controllers/post_editor_controller.dart | 6 +++- lib/screens/posts/post_editor.dart | 34 ++++++++++++++----- .../editor/post_editor_categories_tags.dart | 3 +- macos/Podfile.lock | 7 ++++ pubspec.lock | 24 +++++++++++++ pubspec.yaml | 1 + 8 files changed, 75 insertions(+), 12 deletions(-) diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index 224d496..0fd2ccd 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -16,7 +16,7 @@ jobs: channel: stable cache: true - run: flutter pub get - - run: flutter build web + - run: flutter build web --release --base-href=/ - name: Archive production artifacts uses: actions/upload-artifact@v4 with: diff --git a/ios/Podfile.lock b/ios/Podfile.lock index 85d1837..2084b67 100644 --- a/ios/Podfile.lock +++ b/ios/Podfile.lock @@ -108,6 +108,9 @@ PODS: - GoogleUtilities/UserDefaults (7.13.3): - GoogleUtilities/Logger - GoogleUtilities/Privacy + - image_cropper (0.0.4): + - Flutter + - TOCropViewController (~> 2.7.4) - image_picker_ios (0.0.1): - Flutter - livekit_client (2.2.2): @@ -155,6 +158,7 @@ PODS: - Flutter - FlutterMacOS - SwiftyGif (5.4.5) + - TOCropViewController (2.7.4) - url_launcher_ios (0.0.1): - Flutter - volume_controller (0.0.1): @@ -173,6 +177,7 @@ DEPENDENCIES: - flutter_secure_storage (from `.symlinks/plugins/flutter_secure_storage/ios`) - flutter_webrtc (from `.symlinks/plugins/flutter_webrtc/ios`) - gal (from `.symlinks/plugins/gal/darwin`) + - image_cropper (from `.symlinks/plugins/image_cropper/ios`) - image_picker_ios (from `.symlinks/plugins/image_picker_ios/ios`) - livekit_client (from `.symlinks/plugins/livekit_client/ios`) - media_kit_libs_ios_video (from `.symlinks/plugins/media_kit_libs_ios_video/ios`) @@ -208,6 +213,7 @@ SPEC REPOS: - SDWebImage - Sentry - SwiftyGif + - TOCropViewController - WebRTC-SDK EXTERNAL SOURCES: @@ -229,6 +235,8 @@ EXTERNAL SOURCES: :path: ".symlinks/plugins/flutter_webrtc/ios" gal: :path: ".symlinks/plugins/gal/darwin" + image_cropper: + :path: ".symlinks/plugins/image_cropper/ios" image_picker_ios: :path: ".symlinks/plugins/image_picker_ios/ios" livekit_client: @@ -285,6 +293,7 @@ SPEC CHECKSUMS: gal: 61e868295d28fe67ffa297fae6dacebf56fd53e1 GoogleDataTransport: 6c09b596d841063d76d4288cc2d2f42cc36e1e2a GoogleUtilities: ea963c370a38a8069cc5f7ba4ca849a60b6d7d15 + image_cropper: 37d40f62177c101ff4c164906d259ea2c3aa70cf image_picker_ios: c560581cceedb403a6ff17f2f816d7fea1421fc1 livekit_client: c767049a635d5b6d43de3273dca3c439b8a6e970 media_kit_libs_ios_video: a5fe24bc7875ccd6378a0978c13185e1344651c1 @@ -305,6 +314,7 @@ SPEC CHECKSUMS: shared_preferences_foundation: fcdcbc04712aee1108ac7fda236f363274528f78 sqflite: 673a0e54cc04b7d6dba8d24fb8095b31c3a99eec SwiftyGif: 706c60cf65fa2bc5ee0313beece843c8eb8194d4 + TOCropViewController: 80b8985ad794298fb69d3341de183f33d1853654 url_launcher_ios: 5334b05cef931de560670eeae103fd3e431ac3fe volume_controller: 531ddf792994285c9b17f9d8a7e4dcdd29b3eae9 wakelock_plus: 78ec7c5b202cab7761af8e2b2b3d0671be6c4ae1 diff --git a/lib/controllers/post_editor_controller.dart b/lib/controllers/post_editor_controller.dart index e024772..4bcaf5e 100644 --- a/lib/controllers/post_editor_controller.dart +++ b/lib/controllers/post_editor_controller.dart @@ -163,6 +163,9 @@ class PostEditorController extends GetxController { titleController.text = value.body['title'] ?? ''; descriptionController.text = value.body['description'] ?? ''; contentController.text = value.body['content'] ?? ''; + tags.value = + value.body['tags']?.map((x) => x['alias']).toList() ?? List.empty(); + tags.refresh(); attachments.value = value.body['attachments']?.cast() ?? List.empty(); attachments.refresh(); @@ -215,7 +218,7 @@ class PostEditorController extends GetxController { 'title': title, 'description': description, 'content': contentController.text, - 'tags': tags, + 'tags': tags.map((x) => {'alias': x}).toList(), 'attachments': attachments, 'visible_users': visibleUsers, 'invisible_users': invisibleUsers, @@ -229,6 +232,7 @@ class PostEditorController extends GetxController { set payload(Map value) { type = value['type']; + tags.value = value['tags'].map((x) => x['alias']).toList(); titleController.text = value['title'] ?? ''; descriptionController.text = value['description'] ?? ''; contentController.text = value['content'] ?? ''; diff --git a/lib/screens/posts/post_editor.dart b/lib/screens/posts/post_editor.dart index d9c1b10..4d77c29 100644 --- a/lib/screens/posts/post_editor.dart +++ b/lib/screens/posts/post_editor.dart @@ -91,6 +91,11 @@ class _PostPublishScreenState extends State { AppRouter.instance.pop(); } + Post? get _editTo => _editorController.editTo.value; + Post? get _replyTo => _editorController.replyTo.value; + Post? get _repostTo => _editorController.repostTo.value; + Realm? get _realm => _editorController.realmZone.value; + @override void initState() { super.initState(); @@ -167,7 +172,7 @@ class _PostPublishScreenState extends State { children: [ if (_isBusy) const LinearProgressIndicator().animate().scaleX(), - if (widget.edit != null && widget.edit!.isDraft != true) + if (_editTo != null && _editTo!.isDraft != true) MaterialBanner( leading: const Icon(Icons.edit), leadingPadding: @@ -176,7 +181,7 @@ class _PostPublishScreenState extends State { content: Text('postEditingNotify'.tr), actions: notifyBannerActions, ), - if (widget.reply != null) + if (_replyTo != null) ExpansionTile( leading: const FaIcon( FontAwesomeIcons.reply, @@ -189,12 +194,12 @@ class _PostPublishScreenState extends State { Theme.of(context).colorScheme.surfaceContainer, children: [ PostItem( - item: widget.reply!, + item: _replyTo!, isReactable: false, ).paddingOnly(bottom: 8), ], ), - if (widget.repost != null) + if (_repostTo != null) ExpansionTile( leading: const FaIcon( FontAwesomeIcons.retweet, @@ -207,12 +212,12 @@ class _PostPublishScreenState extends State { Theme.of(context).colorScheme.surfaceContainer, children: [ PostItem( - item: widget.repost!, + item: _repostTo!, isReactable: false, ).paddingOnly(bottom: 8), ], ), - if (widget.realm != null) + if (_realm != null) MaterialBanner( leading: const Icon(Icons.group), leadingPadding: @@ -220,7 +225,7 @@ class _PostPublishScreenState extends State { dividerColor: Colors.transparent, content: Text( 'postInRealmNotify' - .trParams({'realm': '#${widget.realm!.alias}'}), + .trParams({'realm': '#${_realm!.alias}'}), ), actions: notifyBannerActions, ), @@ -383,7 +388,20 @@ class _PostPublishScreenState extends State { }, ), IconButton( - icon: const Icon(Icons.tag), + icon: Obx(() { + return badges.Badge( + badgeContent: Text( + _editorController.tags.length.toString(), + style: const TextStyle(color: Colors.white), + ), + showBadge: _editorController.tags.isNotEmpty, + position: badges.BadgePosition.topEnd( + top: -12, + end: -8, + ), + child: const Icon(Icons.label), + ); + }), color: Theme.of(context).colorScheme.primary, onPressed: () { _editorController.editCategoriesAndTags(context); diff --git a/lib/widgets/posts/editor/post_editor_categories_tags.dart b/lib/widgets/posts/editor/post_editor_categories_tags.dart index 88c5f40..99365ec 100644 --- a/lib/widgets/posts/editor/post_editor_categories_tags.dart +++ b/lib/widgets/posts/editor/post_editor_categories_tags.dart @@ -16,8 +16,7 @@ class PostEditorCategoriesDialog extends StatelessWidget { mainAxisSize: MainAxisSize.min, children: [ TagsField( - initialTags: - controller.editTo.value?.tags?.map((x) => x.alias).toList(), + initialTags: controller.tags, hintText: 'postTagsPlaceholder'.tr, onUpdate: (value) { controller.tags.value = value; diff --git a/macos/Podfile.lock b/macos/Podfile.lock index 6e7e7d8..8479c14 100644 --- a/macos/Podfile.lock +++ b/macos/Podfile.lock @@ -47,6 +47,9 @@ PODS: - FlutterMacOS - WebRTC-SDK (= 125.6422.04) - FlutterMacOS (1.0.0) + - gal (1.0.0): + - Flutter + - FlutterMacOS - GoogleDataTransport (9.4.1): - GoogleUtilities/Environment (~> 7.7) - nanopb (< 2.30911.0, >= 2.30908.0) @@ -133,6 +136,7 @@ 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`) + - gal (from `Flutter/ephemeral/.symlinks/plugins/gal/darwin`) - 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`) @@ -183,6 +187,8 @@ EXTERNAL SOURCES: :path: Flutter/ephemeral/.symlinks/plugins/flutter_webrtc/macos FlutterMacOS: :path: Flutter/ephemeral + gal: + :path: Flutter/ephemeral/.symlinks/plugins/gal/darwin livekit_client: :path: Flutter/ephemeral/.symlinks/plugins/livekit_client/macos macos_window_utils: @@ -231,6 +237,7 @@ SPEC CHECKSUMS: flutter_secure_storage_macos: 59459653abe1adb92abbc8ea747d79f8d19866c9 flutter_webrtc: 2b4e4a2de70a1485836e40fd71a7a94c77d49bd9 FlutterMacOS: 8f6f14fa908a6fb3fba0cd85dbd81ec4b251fb24 + gal: 61e868295d28fe67ffa297fae6dacebf56fd53e1 GoogleDataTransport: 6c09b596d841063d76d4288cc2d2f42cc36e1e2a GoogleUtilities: ea963c370a38a8069cc5f7ba4ca849a60b6d7d15 livekit_client: c24af2b8474a39325596e714118e05551ec5eacc diff --git a/pubspec.lock b/pubspec.lock index 6f8e88b..7e6a371 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -760,6 +760,30 @@ packages: url: "https://pub.dev" source: hosted version: "4.2.0" + image_cropper: + dependency: "direct main" + description: + name: image_cropper + sha256: "7c3a85e54ec591738ee68f3cc9b8849bab0ec8e908bf8970645be959a079e17f" + url: "https://pub.dev" + source: hosted + version: "8.0.1" + image_cropper_for_web: + dependency: transitive + description: + name: image_cropper_for_web + sha256: "65f3f23fb82ff153601f22864e07e2ec14a7859db9e6ee5f643f0cde5243e9f2" + url: "https://pub.dev" + source: hosted + version: "6.0.1" + image_cropper_platform_interface: + dependency: transitive + description: + name: image_cropper_platform_interface + sha256: e8e9d2ca36360387aee39295ce49029362ae4df3071f23e8e71f2b81e40b7531 + url: "https://pub.dev" + source: hosted + version: "7.0.0" image_picker: dependency: "direct main" description: diff --git a/pubspec.yaml b/pubspec.yaml index e9f3cf3..1ae9b15 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -64,6 +64,7 @@ dependencies: provider: ^6.1.2 gal: ^2.3.0 dio: ^5.5.0+1 + image_cropper: ^8.0.1 dev_dependencies: flutter_test: