kopia lustrzana https://gitlab.com/mysocialportal/relatica
Add ability to set gallery for new images
rodzic
0f7b24ae29
commit
1215363dc4
|
@ -1,7 +1,7 @@
|
|||
import 'media_upload_attachment.dart';
|
||||
|
||||
class EntryMediaItems {
|
||||
final String albumName;
|
||||
String albumName;
|
||||
|
||||
final List<MediaUploadAttachment> attachments;
|
||||
|
||||
|
|
|
@ -61,9 +61,11 @@ class _EditorScreenState extends State<EditorScreen> {
|
|||
buildSnackbar(context, "Can't submit an empty post/comment");
|
||||
return;
|
||||
}
|
||||
|
||||
setState(() {
|
||||
isSubmitting = false;
|
||||
isSubmitting = true;
|
||||
});
|
||||
|
||||
final result = await manager.createNewStatus(
|
||||
contentController.text,
|
||||
spoilerText: spoilerController.text,
|
||||
|
@ -78,75 +80,103 @@ class _EditorScreenState extends State<EditorScreen> {
|
|||
buildSnackbar(context, 'Error posting: ${result.error}');
|
||||
return;
|
||||
}
|
||||
context.pop();
|
||||
|
||||
if (mounted && context.canPop()) {
|
||||
context.pop();
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
print('Build editor $isComment $parentEntry');
|
||||
_logger.finest('Build editor $isComment $parentEntry');
|
||||
final manager = context.read<TimelineManager>();
|
||||
|
||||
final mainBody = Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: Center(
|
||||
child: SingleChildScrollView(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: [
|
||||
if (isComment && parentEntry != null)
|
||||
buildCommentPreview(context, parentEntry!),
|
||||
TextFormField(
|
||||
readOnly: isSubmitting,
|
||||
enabled: !isSubmitting,
|
||||
controller: spoilerController,
|
||||
decoration: InputDecoration(
|
||||
labelText: '$statusType Spoiler Text (optional)',
|
||||
border: OutlineInputBorder(
|
||||
borderSide: BorderSide(
|
||||
color: Theme.of(context).backgroundColor,
|
||||
),
|
||||
borderRadius: BorderRadius.circular(5.0),
|
||||
),
|
||||
),
|
||||
),
|
||||
const VerticalPadding(),
|
||||
TextFormField(
|
||||
readOnly: isSubmitting,
|
||||
enabled: !isSubmitting,
|
||||
maxLines: 10,
|
||||
controller: contentController,
|
||||
decoration: InputDecoration(
|
||||
labelText: '$statusType Content',
|
||||
alignLabelWithHint: true,
|
||||
border: OutlineInputBorder(
|
||||
borderSide: BorderSide(
|
||||
color: Theme.of(context).backgroundColor,
|
||||
),
|
||||
borderRadius: BorderRadius.circular(5.0),
|
||||
),
|
||||
),
|
||||
),
|
||||
const VerticalPadding(),
|
||||
MediaUploadsControl(
|
||||
entryMediaItems: entryMediaItems,
|
||||
),
|
||||
buildButtonBar(context, manager),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
final submittingBody = Stack(
|
||||
children: [
|
||||
mainBody,
|
||||
Card(
|
||||
color: Theme.of(context).canvasColor.withOpacity(0.8),
|
||||
child: SizedBox(
|
||||
width: MediaQuery.of(context).size.width,
|
||||
height: MediaQuery.of(context).size.height,
|
||||
child: Center(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
const CircularProgressIndicator(),
|
||||
const VerticalPadding(),
|
||||
Text('Submitting New $statusType'),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
automaticallyImplyLeading: false,
|
||||
title: Text(widget.id.isEmpty ? 'New $statusType' : 'Edit $statusType'),
|
||||
),
|
||||
body: Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: Center(
|
||||
child: SingleChildScrollView(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: [
|
||||
if (isComment && parentEntry != null)
|
||||
buildCommentPreview(context, parentEntry!),
|
||||
TextFormField(
|
||||
readOnly: isSubmitting,
|
||||
enabled: !isSubmitting,
|
||||
controller: spoilerController,
|
||||
decoration: InputDecoration(
|
||||
labelText: '$statusType Spoiler Text (optional)',
|
||||
border: OutlineInputBorder(
|
||||
borderSide: BorderSide(
|
||||
color: Theme.of(context).backgroundColor,
|
||||
),
|
||||
borderRadius: BorderRadius.circular(5.0),
|
||||
),
|
||||
),
|
||||
),
|
||||
const VerticalPadding(),
|
||||
TextFormField(
|
||||
readOnly: isSubmitting,
|
||||
enabled: !isSubmitting,
|
||||
maxLines: 10,
|
||||
controller: contentController,
|
||||
decoration: InputDecoration(
|
||||
labelText: '$statusType Content',
|
||||
alignLabelWithHint: true,
|
||||
border: OutlineInputBorder(
|
||||
borderSide: BorderSide(
|
||||
color: Theme.of(context).backgroundColor,
|
||||
),
|
||||
borderRadius: BorderRadius.circular(5.0),
|
||||
),
|
||||
),
|
||||
),
|
||||
const VerticalPadding(),
|
||||
MediaUploadsControl(
|
||||
entryMediaItems: entryMediaItems,
|
||||
),
|
||||
buildButtonBar(context, manager),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
body: isSubmitting ? submittingBody : mainBody,
|
||||
);
|
||||
}
|
||||
|
||||
Widget buildCommentPreview(BuildContext context, TimelineEntry entry) {
|
||||
print('Build preview');
|
||||
_logger.finest('Build preview');
|
||||
return Column(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
|
@ -190,8 +220,7 @@ class _EditorScreenState extends State<EditorScreen> {
|
|||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
ElevatedButton(
|
||||
onPressed:
|
||||
isSubmitting ? null : () async => createStatus(context, manager),
|
||||
onPressed: isSubmitting ? null : () => createStatus(context, manager),
|
||||
child: const Text('Submit'),
|
||||
),
|
||||
const HorizontalPadding(),
|
||||
|
|
Ładowanie…
Reference in New Issue