Post editor tags

This commit is contained in:
2025-06-27 00:56:07 +08:00
parent e90b35f19f
commit 0361f031db
35 changed files with 1329 additions and 128 deletions

View File

@ -22,11 +22,14 @@ mixin _$ChatRoomMemberState {
@pragma('vm:prefer-inline')
$ChatRoomMemberStateCopyWith<ChatRoomMemberState> get copyWith => _$ChatRoomMemberStateCopyWithImpl<ChatRoomMemberState>(this as ChatRoomMemberState, _$identity);
@override
bool operator ==(Object other) {
return identical(this, other) || (other.runtimeType == runtimeType&&other is ChatRoomMemberState&&const DeepCollectionEquality().equals(other.members, members)&&(identical(other.isLoading, isLoading) || other.isLoading == isLoading)&&(identical(other.total, total) || other.total == total)&&(identical(other.error, error) || other.error == error));
}
@override
int get hashCode => Object.hash(runtimeType,const DeepCollectionEquality().hash(members),isLoading,total,error);
@ -35,6 +38,7 @@ String toString() {
return 'ChatRoomMemberState(members: $members, isLoading: $isLoading, total: $total, error: $error)';
}
}
/// @nodoc
@ -45,6 +49,9 @@ $Res call({
List<SnChatMember> members, bool isLoading, int total, String? error
});
}
/// @nodoc
class _$ChatRoomMemberStateCopyWithImpl<$Res>
@ -68,8 +75,10 @@ as String?,
}
/// @nodoc
class _ChatRoomMemberState implements ChatRoomMemberState {
const _ChatRoomMemberState({required final List<SnChatMember> members, required this.isLoading, required this.total, this.error}): _members = members;
@ -91,11 +100,14 @@ class _ChatRoomMemberState implements ChatRoomMemberState {
@pragma('vm:prefer-inline')
_$ChatRoomMemberStateCopyWith<_ChatRoomMemberState> get copyWith => __$ChatRoomMemberStateCopyWithImpl<_ChatRoomMemberState>(this, _$identity);
@override
bool operator ==(Object other) {
return identical(this, other) || (other.runtimeType == runtimeType&&other is _ChatRoomMemberState&&const DeepCollectionEquality().equals(other._members, _members)&&(identical(other.isLoading, isLoading) || other.isLoading == isLoading)&&(identical(other.total, total) || other.total == total)&&(identical(other.error, error) || other.error == error));
}
@override
int get hashCode => Object.hash(runtimeType,const DeepCollectionEquality().hash(_members),isLoading,total,error);
@ -104,6 +116,7 @@ String toString() {
return 'ChatRoomMemberState(members: $members, isLoading: $isLoading, total: $total, error: $error)';
}
}
/// @nodoc
@ -114,6 +127,9 @@ $Res call({
List<SnChatMember> members, bool isLoading, int total, String? error
});
}
/// @nodoc
class __$ChatRoomMemberStateCopyWithImpl<$Res>
@ -135,6 +151,7 @@ as String?,
));
}
}
// dart format on

View File

@ -22,11 +22,14 @@ mixin _$StickerWithPackQuery {
@pragma('vm:prefer-inline')
$StickerWithPackQueryCopyWith<StickerWithPackQuery> get copyWith => _$StickerWithPackQueryCopyWithImpl<StickerWithPackQuery>(this as StickerWithPackQuery, _$identity);
@override
bool operator ==(Object other) {
return identical(this, other) || (other.runtimeType == runtimeType&&other is StickerWithPackQuery&&(identical(other.packId, packId) || other.packId == packId)&&(identical(other.id, id) || other.id == id));
}
@override
int get hashCode => Object.hash(runtimeType,packId,id);
@ -35,6 +38,7 @@ String toString() {
return 'StickerWithPackQuery(packId: $packId, id: $id)';
}
}
/// @nodoc
@ -45,6 +49,9 @@ $Res call({
String packId, String id
});
}
/// @nodoc
class _$StickerWithPackQueryCopyWithImpl<$Res>
@ -66,8 +73,10 @@ as String,
}
/// @nodoc
class _StickerWithPackQuery implements StickerWithPackQuery {
const _StickerWithPackQuery({required this.packId, required this.id});
@ -81,11 +90,14 @@ class _StickerWithPackQuery implements StickerWithPackQuery {
@pragma('vm:prefer-inline')
_$StickerWithPackQueryCopyWith<_StickerWithPackQuery> get copyWith => __$StickerWithPackQueryCopyWithImpl<_StickerWithPackQuery>(this, _$identity);
@override
bool operator ==(Object other) {
return identical(this, other) || (other.runtimeType == runtimeType&&other is _StickerWithPackQuery&&(identical(other.packId, packId) || other.packId == packId)&&(identical(other.id, id) || other.id == id));
}
@override
int get hashCode => Object.hash(runtimeType,packId,id);
@ -94,6 +106,7 @@ String toString() {
return 'StickerWithPackQuery(packId: $packId, id: $id)';
}
}
/// @nodoc
@ -104,6 +117,9 @@ $Res call({
String packId, String id
});
}
/// @nodoc
class __$StickerWithPackQueryCopyWithImpl<$Res>
@ -123,6 +139,7 @@ as String,
));
}
}
// dart format on

View File

@ -107,6 +107,21 @@ class PostComposeScreen extends HookConsumerWidget {
[originalPost, effectiveForwardedPost, effectiveRepliedPost],
);
// Add a listener to the entire state to trigger rebuilds
final stateNotifier = useMemoized(
() => Listenable.merge([
state.titleController,
state.descriptionController,
state.contentController,
state.visibility,
state.attachments,
state.attachmentProgress,
state.currentPublisher,
state.submitting,
]),
[state]);
useListenable(stateNotifier);
// Start auto-save when component mounts
useEffect(() {
if (originalPost == null) {
@ -184,6 +199,8 @@ class PostComposeScreen extends HookConsumerWidget {
titleController: state.titleController,
descriptionController: state.descriptionController,
visibility: state.visibility,
tagsController: state.tagsController,
categoriesController: state.categoriesController,
onVisibilityChanged: () {
// Trigger rebuild if needed
},
@ -203,22 +220,18 @@ class PostComposeScreen extends HookConsumerWidget {
),
itemCount: state.attachments.value.length,
itemBuilder: (context, idx) {
return ValueListenableBuilder<Map<int, double>>(
valueListenable: state.attachmentProgress,
builder: (context, progressMap, _) {
return AttachmentPreview(
item: state.attachments.value[idx],
progress: progressMap[idx],
onRequestUpload:
() => ComposeLogic.uploadAttachment(ref, state, idx),
onDelete: () => ComposeLogic.deleteAttachment(ref, state, idx),
onMove: (delta) {
state.attachments.value = ComposeLogic.moveAttachment(
state.attachments.value,
idx,
delta,
);
},
final progressMap = state.attachmentProgress.value;
return AttachmentPreview(
item: state.attachments.value[idx],
progress: progressMap[idx],
onRequestUpload:
() => ComposeLogic.uploadAttachment(ref, state, idx),
onDelete: () => ComposeLogic.deleteAttachment(ref, state, idx),
onMove: (delta) {
state.attachments.value = ComposeLogic.moveAttachment(
state.attachments.value,
idx,
delta,
);
},
);
@ -232,26 +245,24 @@ class PostComposeScreen extends HookConsumerWidget {
for (var idx = 0; idx < state.attachments.value.length; idx++)
Container(
margin: const EdgeInsets.only(bottom: 8),
child: ValueListenableBuilder<Map<int, double>>(
valueListenable: state.attachmentProgress,
builder: (context, progressMap, _) {
return AttachmentPreview(
item: state.attachments.value[idx],
progress: progressMap[idx],
onRequestUpload:
() => ComposeLogic.uploadAttachment(ref, state, idx),
onDelete:
() => ComposeLogic.deleteAttachment(ref, state, idx),
onMove: (delta) {
state.attachments.value = ComposeLogic.moveAttachment(
state.attachments.value,
idx,
delta,
);
},
);
},
),
child: () {
final progressMap = state.attachmentProgress.value;
return AttachmentPreview(
item: state.attachments.value[idx],
progress: progressMap[idx],
onRequestUpload:
() => ComposeLogic.uploadAttachment(ref, state, idx),
onDelete:
() => ComposeLogic.deleteAttachment(ref, state, idx),
onMove: (delta) {
state.attachments.value = ComposeLogic.moveAttachment(
state.attachments.value,
idx,
delta,
);
},
);
}(),
),
],
);
@ -306,14 +317,11 @@ class PostComposeScreen extends HookConsumerWidget {
onPressed: showSettingsSheet,
tooltip: 'postSettings'.tr(),
),
ValueListenableBuilder<bool>(
valueListenable: state.submitting,
builder: (context, submitting, _) {
return IconButton(
onPressed:
submitting
? null
: () => ComposeLogic.performAction(
IconButton(
onPressed:
state.submitting.value
? null
: () => ComposeLogic.performAction(
ref,
state,
context,
@ -322,23 +330,21 @@ class PostComposeScreen extends HookConsumerWidget {
forwardedPost: forwardedPost,
postType: 0, // Regular post type
),
icon:
submitting
? SizedBox(
width: 28,
height: 28,
child: const CircularProgressIndicator(
color: Colors.white,
strokeWidth: 2.5,
),
).center()
: Icon(
originalPost != null
? Symbols.edit
: Symbols.upload,
),
);
},
icon:
state.submitting.value
? SizedBox(
width: 28,
height: 28,
child: const CircularProgressIndicator(
color: Colors.white,
strokeWidth: 2.5,
),
).center()
: Icon(
originalPost != null
? Symbols.edit
: Symbols.upload,
),
),
const Gap(8),
],
@ -420,22 +426,17 @@ class PostComposeScreen extends HookConsumerWidget {
const Gap(8),
// Attachments preview
ValueListenableBuilder<List<UniversalFile>>(
valueListenable: state.attachments,
builder: (context, attachments, _) {
if (attachments.isEmpty) {
return const SizedBox.shrink();
}
return LayoutBuilder(
builder: (context, constraints) {
final isWide = isWideScreen(context);
return isWide
? buildWideAttachmentGrid()
: buildNarrowAttachmentList();
},
);
},
),
if (state.attachments.value.isNotEmpty)
LayoutBuilder(
builder: (context, constraints) {
final isWide = isWideScreen(context);
return isWide
? buildWideAttachmentGrid()
: buildNarrowAttachmentList();
},
)
else
const SizedBox.shrink(),
],
),
),

View File

@ -26,6 +26,7 @@ $PostComposeInitialStateCopyWith<PostComposeInitialState> get copyWith => _$Post
/// Serializes this PostComposeInitialState to a JSON map.
Map<String, dynamic> toJson();
@override
bool operator ==(Object other) {
return identical(this, other) || (other.runtimeType == runtimeType&&other is PostComposeInitialState&&(identical(other.title, title) || other.title == title)&&(identical(other.description, description) || other.description == description)&&(identical(other.content, content) || other.content == content)&&const DeepCollectionEquality().equals(other.attachments, attachments)&&(identical(other.visibility, visibility) || other.visibility == visibility));
@ -40,6 +41,7 @@ String toString() {
return 'PostComposeInitialState(title: $title, description: $description, content: $content, attachments: $attachments, visibility: $visibility)';
}
}
/// @nodoc
@ -50,6 +52,9 @@ $Res call({
String? title, String? description, String? content, List<UniversalFile> attachments, int? visibility
});
}
/// @nodoc
class _$PostComposeInitialStateCopyWithImpl<$Res>
@ -74,6 +79,7 @@ as int?,
}
/// @nodoc
@JsonSerializable()
@ -118,6 +124,7 @@ String toString() {
return 'PostComposeInitialState(title: $title, description: $description, content: $content, attachments: $attachments, visibility: $visibility)';
}
}
/// @nodoc
@ -128,6 +135,9 @@ $Res call({
String? title, String? description, String? content, List<UniversalFile> attachments, int? visibility
});
}
/// @nodoc
class __$PostComposeInitialStateCopyWithImpl<$Res>
@ -150,6 +160,7 @@ as int?,
));
}
}
// dart format on

View File

@ -140,6 +140,8 @@ class ArticleComposeScreen extends HookConsumerWidget {
titleController: state.titleController,
descriptionController: state.descriptionController,
visibility: state.visibility,
tagsController: state.tagsController,
categoriesController: state.categoriesController,
onVisibilityChanged: () {
// Trigger rebuild if needed
},