1
0
mirror of https://gitlab.com/comunic/comunicmobile synced 2024-11-25 14:29:22 +00:00

Improved posts form

This commit is contained in:
Pierre HUBERT 2019-07-05 11:50:37 +02:00
parent 3a5a395f79
commit 14882a80cd

View File

@ -74,13 +74,16 @@ class _PostCreateFormWidgetState extends State<PostCreateFormWidget> {
return Column( return Column(
children: <Widget>[ children: <Widget>[
// Post text content // Post text content
TextField( Padding(
padding: const EdgeInsets.only(left: 8.0, right: 8.0),
child: TextField(
controller: _postTextController, controller: _postTextController,
minLines: 3, minLines: 3,
maxLines: 10, maxLines: 10,
decoration: InputDecoration(hintText: tr("Create a new post...")), decoration: InputDecoration(hintText: tr("Create a new post...")),
onChanged: (s) => setState(() {}), onChanged: (s) => setState(() {}),
), ),
),
// Post options // Post options
Padding( Padding(
@ -88,13 +91,23 @@ class _PostCreateFormWidgetState extends State<PostCreateFormWidget> {
child: Row( child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween, mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[ children: <Widget>[
// Text post button
_PostOptionWidget(
icon: Icons.text_format,
selected: postKind == PostKind.TEXT,
onTap: _resetPostSelection),
// Include image button // Include image button
_PostOptionWidget( _PostOptionWidget(
icon: Icons.image, icon: Icons.image,
selected: hasImage, selected: postKind == PostKind.IMAGE,
onTap: _pickImageForPost, onTap: _pickImageForPost,
), ),
Expanded(
child: Container(),
),
// Post visibility level // Post visibility level
_PostOptionWidget( _PostOptionWidget(
icon: PostVisibilityLevelsMapIcons[_postVisibilityLevel], icon: PostVisibilityLevelsMapIcons[_postVisibilityLevel],
@ -132,12 +145,21 @@ class _PostCreateFormWidgetState extends State<PostCreateFormWidget> {
setState(() => _postVisibilityLevel = newLevel); setState(() => _postVisibilityLevel = newLevel);
} }
/// Remove all data attached to the post (image, etc...)
void _resetPostSelection() {
setState(() {
_postImage = null;
});
}
/// Pick an image for the new post /// Pick an image for the new post
Future<void> _pickImageForPost() async { Future<void> _pickImageForPost() async {
final image = await pickImage(context); final image = await pickImage(context);
if (image == null) return; if (image == null) return;
_resetPostSelection();
setState(() { setState(() {
this._postImage = image; this._postImage = image;
}); });