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:
parent
414f81b32f
commit
b326507417
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user