mirror of
https://gitlab.com/comunic/comunicmobile
synced 2024-11-25 06:19: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(
|
||||
children: <Widget>[
|
||||
// Post text content
|
||||
TextField(
|
||||
controller: _postTextController,
|
||||
minLines: 3,
|
||||
maxLines: 10,
|
||||
decoration: InputDecoration(hintText: tr("Create a new post...")),
|
||||
onChanged: (s) => setState(() {}),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(left: 8.0, right: 8.0),
|
||||
child: TextField(
|
||||
controller: _postTextController,
|
||||
minLines: 3,
|
||||
maxLines: 10,
|
||||
decoration: InputDecoration(hintText: tr("Create a new post...")),
|
||||
onChanged: (s) => setState(() {}),
|
||||
),
|
||||
),
|
||||
|
||||
// Post options
|
||||
@ -88,13 +91,23 @@ class _PostCreateFormWidgetState extends State<PostCreateFormWidget> {
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: <Widget>[
|
||||
// Text post button
|
||||
_PostOptionWidget(
|
||||
icon: Icons.text_format,
|
||||
selected: postKind == PostKind.TEXT,
|
||||
onTap: _resetPostSelection),
|
||||
|
||||
// Include image button
|
||||
_PostOptionWidget(
|
||||
icon: Icons.image,
|
||||
selected: hasImage,
|
||||
selected: postKind == PostKind.IMAGE,
|
||||
onTap: _pickImageForPost,
|
||||
),
|
||||
|
||||
Expanded(
|
||||
child: Container(),
|
||||
),
|
||||
|
||||
// Post visibility level
|
||||
_PostOptionWidget(
|
||||
icon: PostVisibilityLevelsMapIcons[_postVisibilityLevel],
|
||||
@ -132,12 +145,21 @@ class _PostCreateFormWidgetState extends State<PostCreateFormWidget> {
|
||||
setState(() => _postVisibilityLevel = newLevel);
|
||||
}
|
||||
|
||||
/// Remove all data attached to the post (image, etc...)
|
||||
void _resetPostSelection() {
|
||||
setState(() {
|
||||
_postImage = null;
|
||||
});
|
||||
}
|
||||
|
||||
/// Pick an image for the new post
|
||||
Future<void> _pickImageForPost() async {
|
||||
final image = await pickImage(context);
|
||||
|
||||
if (image == null) return;
|
||||
|
||||
_resetPostSelection();
|
||||
|
||||
setState(() {
|
||||
this._postImage = image;
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user