1
0
mirror of https://gitlab.com/comunic/comunicmobile synced 2024-11-26 06:49:22 +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() { void initState() {
super.initState(); super.initState();
_postVisibilityLevel = widget.postTarget == PostTarget.GROUP_PAGE _resetForm();
? PostVisibilityLevel.GROUP_MEMBERS
: PostVisibilityLevel.FRIENDS;
} }
@override @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 /// Change post visibility level
Future<void> _changeVisibilityLevel() async { Future<void> _changeVisibilityLevel() async {
final newLevel = await showPostVisibilityPicker( final newLevel = await showPostVisibilityPicker(
@ -185,6 +195,7 @@ class _PostCreateFormWidgetState extends State<PostCreateFormWidget> {
showSimpleSnack(context, tr("The post has been successfully created!")); showSimpleSnack(context, tr("The post has been successfully created!"));
this._resetForm();
widget.onCreated(); widget.onCreated();
} catch (e) { } catch (e) {
setState(() => _isCreating = false); setState(() => _isCreating = false);