🐛 Fix post tag input issue

This commit is contained in:
LittleSheep 2024-08-01 11:49:28 +08:00
parent f10393f6d0
commit 2bc4513bb6
8 changed files with 75 additions and 12 deletions

View File

@ -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:

View File

@ -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

View File

@ -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<int>() ?? 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<String, dynamic> 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'] ?? '';

View File

@ -91,6 +91,11 @@ class _PostPublishScreenState extends State<PostPublishScreen> {
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<PostPublishScreen> {
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<PostPublishScreen> {
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<PostPublishScreen> {
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<PostPublishScreen> {
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<PostPublishScreen> {
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<PostPublishScreen> {
},
),
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);

View File

@ -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;

View File

@ -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

View File

@ -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:

View File

@ -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: