feat: add config setting to configure navigation after post creation

This commit is contained in:
Vick Top 2024-03-07 10:01:18 +01:00
parent 90e35e657e
commit 4569f25f4b
2 changed files with 13 additions and 1 deletions

View file

@ -107,7 +107,14 @@ List<GoRoute> getTimelineStoryRoutes({
onPostCreated: (post) async {
await config.service.postService.createPost(post);
if (context.mounted) {
if (config.afterPostCreationGoHome) {
context.go(TimelineUserStoryRoutes.timelineHome);
} else {
context.go(
TimelineUserStoryRoutes.timelinePostOverview,
extra: post,
);
}
}
},
onPostOverview: (post) async => context.push(

View file

@ -55,6 +55,7 @@ class TimelineUserStoryConfiguration {
this.onPostDelete,
this.filterEnabled = false,
this.postWidgetBuilder,
this.afterPostCreationGoHome = false,
this.enablePostOverviewScreen = false,
});
@ -88,4 +89,8 @@ class TimelineUserStoryConfiguration {
/// Boolean to enable timeline post overview screen before submitting
final bool enablePostOverviewScreen;
/// Boolean to enable redirect to home after post creation.
/// If false, it will redirect to created post screen
final bool afterPostCreationGoHome;
}