💄 Optimized attachment insert in article compose
This commit is contained in:
parent
ee72d79c93
commit
23321171f3
@ -375,7 +375,9 @@
|
|||||||
"postContent": "Content",
|
"postContent": "Content",
|
||||||
"postSettings": "Settings",
|
"postSettings": "Settings",
|
||||||
"postPublisherUnselected": "Publisher Unspecified",
|
"postPublisherUnselected": "Publisher Unspecified",
|
||||||
"postVisibility": "Visibility",
|
"postType": "Post Type",
|
||||||
|
"articleAttachmentHint": "Attachments must be uploaded and inserted into the article body to be visible.",
|
||||||
|
"postVisibility": "Post Visibility",
|
||||||
"postVisibilityPublic": "Public",
|
"postVisibilityPublic": "Public",
|
||||||
"postVisibilityFriends": "Friends Only",
|
"postVisibilityFriends": "Friends Only",
|
||||||
"postVisibilityUnlisted": "Unlisted",
|
"postVisibilityUnlisted": "Unlisted",
|
||||||
|
@ -321,8 +321,15 @@ class ArticleComposeScreen extends HookConsumerWidget {
|
|||||||
builder: (context, attachments, _) {
|
builder: (context, attachments, _) {
|
||||||
if (attachments.isEmpty) return const SizedBox.shrink();
|
if (attachments.isEmpty) return const SizedBox.shrink();
|
||||||
return Column(
|
return Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
const Gap(16),
|
const Gap(16),
|
||||||
|
Text(
|
||||||
|
'articleAttachmentHint'.tr(),
|
||||||
|
style: Theme.of(context).textTheme.bodySmall?.copyWith(
|
||||||
|
color: Theme.of(context).colorScheme.onSurfaceVariant,
|
||||||
|
),
|
||||||
|
).padding(bottom: 8),
|
||||||
ValueListenableBuilder<Map<int, double>>(
|
ValueListenableBuilder<Map<int, double>>(
|
||||||
valueListenable: state.attachmentProgress,
|
valueListenable: state.attachmentProgress,
|
||||||
builder: (context, progressMap, _) {
|
builder: (context, progressMap, _) {
|
||||||
@ -332,8 +339,8 @@ class ArticleComposeScreen extends HookConsumerWidget {
|
|||||||
children: [
|
children: [
|
||||||
for (var idx = 0; idx < attachments.length; idx++)
|
for (var idx = 0; idx < attachments.length; idx++)
|
||||||
SizedBox(
|
SizedBox(
|
||||||
width: 120,
|
width: 280,
|
||||||
height: 120,
|
height: 280,
|
||||||
child: AttachmentPreview(
|
child: AttachmentPreview(
|
||||||
item: attachments[idx],
|
item: attachments[idx],
|
||||||
progress: progressMap[idx],
|
progress: progressMap[idx],
|
||||||
@ -358,7 +365,9 @@ class ArticleComposeScreen extends HookConsumerWidget {
|
|||||||
delta,
|
delta,
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
onInsert: () => ComposeLogic.insertAttachment(
|
onInsert:
|
||||||
|
() => ComposeLogic.insertAttachment(
|
||||||
|
ref,
|
||||||
state,
|
state,
|
||||||
idx,
|
idx,
|
||||||
),
|
),
|
||||||
|
@ -106,7 +106,11 @@ class AttachmentPreview extends StatelessWidget {
|
|||||||
style: TextStyle(color: Colors.white),
|
style: TextStyle(color: Colors.white),
|
||||||
),
|
),
|
||||||
Gap(6),
|
Gap(6),
|
||||||
Center(child: LinearProgressIndicator(value: progress)),
|
Center(
|
||||||
|
child: LinearProgressIndicator(
|
||||||
|
value: progress != null ? progress! / 100.0 : null,
|
||||||
|
),
|
||||||
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
@ -474,13 +474,14 @@ class ComposeLogic {
|
|||||||
state.attachments.value = clone;
|
state.attachments.value = clone;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void insertAttachment(ComposeState state, int index) {
|
static void insertAttachment(WidgetRef ref, ComposeState state, int index) {
|
||||||
final attachment = state.attachments.value[index];
|
final attachment = state.attachments.value[index];
|
||||||
if (!attachment.isOnCloud) {
|
if (!attachment.isOnCloud) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final cloudFile = attachment.data as SnCloudFile;
|
final cloudFile = attachment.data as SnCloudFile;
|
||||||
final markdown = '';
|
final baseUrl = ref.read(serverUrlProvider);
|
||||||
|
final markdown = '';
|
||||||
final controller = state.contentController;
|
final controller = state.contentController;
|
||||||
final text = controller.text;
|
final text = controller.text;
|
||||||
final selection = controller.selection;
|
final selection = controller.selection;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user