✨ Post editing
This commit is contained in:
parent
7646a51cd9
commit
a7d4975e18
@ -185,8 +185,8 @@ class PostComposeScreen extends HookConsumerWidget {
|
||||
);
|
||||
|
||||
final client = ref.watch(apiClientProvider);
|
||||
await client.post(
|
||||
'/posts',
|
||||
await client.request(
|
||||
originalPost == null ? '/posts' : '/posts/${originalPost!.id}',
|
||||
data: {
|
||||
'content': contentController.text,
|
||||
'attachments':
|
||||
@ -195,7 +195,10 @@ class PostComposeScreen extends HookConsumerWidget {
|
||||
.map((e) => e.data.id)
|
||||
.toList(),
|
||||
},
|
||||
options: Options(headers: {'X-Pub': currentPublisher.value?.name}),
|
||||
options: Options(
|
||||
headers: {'X-Pub': currentPublisher.value?.name},
|
||||
method: originalPost == null ? 'POST' : 'PATCH',
|
||||
),
|
||||
);
|
||||
if (context.mounted) {
|
||||
context.maybePop(true);
|
||||
@ -223,6 +226,8 @@ class PostComposeScreen extends HookConsumerWidget {
|
||||
strokeWidth: 2.5,
|
||||
),
|
||||
).center()
|
||||
: originalPost != null
|
||||
? const Icon(LucideIcons.edit)
|
||||
: const Icon(LucideIcons.upload),
|
||||
),
|
||||
const Gap(8),
|
||||
@ -357,7 +362,8 @@ class _AttachmentPreview extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return AspectRatio(
|
||||
aspectRatio: 1,
|
||||
aspectRatio:
|
||||
(item.isOnCloud ? (item.data.fileMeta?['ratio'] ?? 1) : 1).toDouble(),
|
||||
child: ClipRRect(
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
child: Stack(
|
||||
@ -485,7 +491,7 @@ class _AttachmentPreview extends StatelessWidget {
|
||||
color: Colors.black.withOpacity(0.5),
|
||||
padding: EdgeInsets.symmetric(horizontal: 8, vertical: 4),
|
||||
child:
|
||||
(item is SnCloudFile)
|
||||
(item.isOnCloud)
|
||||
? Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
|
@ -1,10 +1,12 @@
|
||||
import 'package:auto_route/auto_route.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:island/models/post.dart';
|
||||
import 'package:island/route.gr.dart';
|
||||
import 'package:island/widgets/content/cloud_file_collection.dart';
|
||||
import 'package:island/widgets/content/cloud_files.dart';
|
||||
import 'package:island/widgets/content/markdown.dart';
|
||||
import 'package:lucide_icons/lucide_icons.dart';
|
||||
import 'package:styled_widget/styled_widget.dart';
|
||||
|
||||
class PostItem extends StatelessWidget {
|
||||
@ -23,12 +25,28 @@ class PostItem extends StatelessWidget {
|
||||
final renderingPadding =
|
||||
padding ?? EdgeInsets.symmetric(horizontal: 12, vertical: 16);
|
||||
|
||||
return Padding(
|
||||
return CupertinoContextMenu.builder(
|
||||
actions: [
|
||||
CupertinoContextMenuAction(
|
||||
trailingIcon: LucideIcons.edit,
|
||||
onPressed: () {
|
||||
context.router.push(PostEditRoute(id: item.id));
|
||||
},
|
||||
child: Text('Edit'),
|
||||
),
|
||||
],
|
||||
builder: (context, animation) {
|
||||
return Material(
|
||||
color: Theme.of(context).colorScheme.surface,
|
||||
child: SingleChildScrollView(
|
||||
physics: const NeverScrollableScrollPhysics(),
|
||||
child: Padding(
|
||||
padding: renderingPadding,
|
||||
child: Column(
|
||||
spacing: 8,
|
||||
children: [
|
||||
Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
spacing: 12,
|
||||
children: [
|
||||
@ -56,6 +74,10 @@ class PostItem extends StatelessWidget {
|
||||
CloudFileList(files: item.attachments),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user