mirror of
https://gitlab.com/comunic/comunicmobile
synced 2024-11-25 14:29:22 +00:00
Improved posts form
This commit is contained in:
parent
3a5a395f79
commit
14882a80cd
@ -74,12 +74,15 @@ class _PostCreateFormWidgetState extends State<PostCreateFormWidget> {
|
|||||||
return Column(
|
return Column(
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
// Post text content
|
// Post text content
|
||||||
TextField(
|
Padding(
|
||||||
controller: _postTextController,
|
padding: const EdgeInsets.only(left: 8.0, right: 8.0),
|
||||||
minLines: 3,
|
child: TextField(
|
||||||
maxLines: 10,
|
controller: _postTextController,
|
||||||
decoration: InputDecoration(hintText: tr("Create a new post...")),
|
minLines: 3,
|
||||||
onChanged: (s) => setState(() {}),
|
maxLines: 10,
|
||||||
|
decoration: InputDecoration(hintText: tr("Create a new post...")),
|
||||||
|
onChanged: (s) => setState(() {}),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
|
|
||||||
// Post options
|
// Post options
|
||||||
@ -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;
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user