1
0
mirror of https://gitlab.com/comunic/comunicmobile synced 2024-12-26 04:48:51 +00:00

Automatically reset post create form

This commit is contained in:
Pierre HUBERT 2020-04-17 10:41:10 +02:00
parent 414f81b32f
commit b326507417

View File

@ -64,9 +64,7 @@ class _PostCreateFormWidgetState extends State<PostCreateFormWidget> {
void initState() {
super.initState();
_postVisibilityLevel = widget.postTarget == PostTarget.GROUP_PAGE
? PostVisibilityLevel.GROUP_MEMBERS
: PostVisibilityLevel.FRIENDS;
_resetForm();
}
@override
@ -134,6 +132,18 @@ class _PostCreateFormWidgetState extends State<PostCreateFormWidget> {
);
}
/// Reset the form
void _resetForm() {
setState(() {
_postVisibilityLevel = widget.postTarget == PostTarget.GROUP_PAGE
? PostVisibilityLevel.GROUP_MEMBERS
: PostVisibilityLevel.FRIENDS;
_postTextController.text = "";
_resetPostSelection();
});
}
/// Change post visibility level
Future<void> _changeVisibilityLevel() async {
final newLevel = await showPostVisibilityPicker(
@ -185,6 +195,7 @@ class _PostCreateFormWidgetState extends State<PostCreateFormWidget> {
showSimpleSnack(context, tr("The post has been successfully created!"));
this._resetForm();
widget.onCreated();
} catch (e) {
setState(() => _isCreating = false);