mirror of
https://github.com/Iconica-Development/flutter_timeline.git
synced 2025-05-19 02:23:46 +02:00
fix: add post deletion in the timeline userstory
This commit is contained in:
parent
25264ba44b
commit
013e82e61d
4 changed files with 18 additions and 43 deletions
|
@ -15,6 +15,7 @@
|
||||||
- fix the avatar size to match the new design
|
- fix the avatar size to match the new design
|
||||||
- Add the iconbutton for image uploading back to the ReactionBottom
|
- Add the iconbutton for image uploading back to the ReactionBottom
|
||||||
- Fix category key is correctly used for saving timeline posts and category title is shown everywhere
|
- Fix category key is correctly used for saving timeline posts and category title is shown everywhere
|
||||||
|
- Fix when clicking on post delete in the post screen of the userstory it will now navigate back to the timeline and delete the post
|
||||||
|
|
||||||
## 3.0.1
|
## 3.0.1
|
||||||
|
|
||||||
|
|
|
@ -154,7 +154,13 @@ List<GoRoute> getTimelineStoryRoutes({
|
||||||
options: config.optionsBuilder(context),
|
options: config.optionsBuilder(context),
|
||||||
service: service,
|
service: service,
|
||||||
post: post!,
|
post: post!,
|
||||||
onPostDelete: () => config.onPostDelete?.call(context, post),
|
onPostDelete: () async =>
|
||||||
|
config.onPostDelete?.call(context, post) ??
|
||||||
|
() async {
|
||||||
|
await service.postService.deletePost(post);
|
||||||
|
if (!context.mounted) return;
|
||||||
|
context.go(TimelineUserStoryRoutes.timelineHome);
|
||||||
|
}.call(),
|
||||||
onUserTap: (user) => config.onUserTap?.call(context, user),
|
onUserTap: (user) => config.onUserTap?.call(context, user),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -132,7 +132,12 @@ Widget _postDetailScreenRoute({
|
||||||
post: post,
|
post: post,
|
||||||
onPostDelete: () async =>
|
onPostDelete: () async =>
|
||||||
config.onPostDelete?.call(context, post) ??
|
config.onPostDelete?.call(context, post) ??
|
||||||
await config.service.postService.deletePost(post),
|
() async {
|
||||||
|
await config.service.postService.deletePost(post);
|
||||||
|
if (context.mounted) {
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
}
|
||||||
|
}.call(),
|
||||||
onUserTap: (user) => config.onUserTap?.call(context, user),
|
onUserTap: (user) => config.onUserTap?.call(context, user),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,7 @@ import 'package:flutter_timeline_view/src/widgets/reaction_bottom.dart';
|
||||||
import 'package:flutter_timeline_view/src/widgets/tappable_image.dart';
|
import 'package:flutter_timeline_view/src/widgets/tappable_image.dart';
|
||||||
import 'package:intl/intl.dart';
|
import 'package:intl/intl.dart';
|
||||||
|
|
||||||
class TimelinePostScreen extends StatelessWidget {
|
class TimelinePostScreen extends StatefulWidget {
|
||||||
const TimelinePostScreen({
|
const TimelinePostScreen({
|
||||||
required this.userId,
|
required this.userId,
|
||||||
required this.service,
|
required this.service,
|
||||||
|
@ -47,47 +47,10 @@ class TimelinePostScreen extends StatelessWidget {
|
||||||
final bool? isOverviewScreen;
|
final bool? isOverviewScreen;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) => _TimelinePostScreen(
|
State<TimelinePostScreen> createState() => _TimelinePostScreenState();
|
||||||
userId: userId,
|
|
||||||
service: service,
|
|
||||||
options: options,
|
|
||||||
post: post,
|
|
||||||
onPostDelete: onPostDelete,
|
|
||||||
onUserTap: onUserTap,
|
|
||||||
isOverviewScreen: isOverviewScreen,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class _TimelinePostScreen extends StatefulWidget {
|
class _TimelinePostScreenState extends State<TimelinePostScreen> {
|
||||||
const _TimelinePostScreen({
|
|
||||||
required this.userId,
|
|
||||||
required this.service,
|
|
||||||
required this.options,
|
|
||||||
required this.post,
|
|
||||||
required this.onPostDelete,
|
|
||||||
this.onUserTap,
|
|
||||||
this.isOverviewScreen,
|
|
||||||
});
|
|
||||||
|
|
||||||
final String userId;
|
|
||||||
|
|
||||||
final TimelineService service;
|
|
||||||
|
|
||||||
final TimelineOptions options;
|
|
||||||
|
|
||||||
final TimelinePost post;
|
|
||||||
|
|
||||||
final Function(String userId)? onUserTap;
|
|
||||||
|
|
||||||
final VoidCallback onPostDelete;
|
|
||||||
|
|
||||||
final bool? isOverviewScreen;
|
|
||||||
|
|
||||||
@override
|
|
||||||
State<_TimelinePostScreen> createState() => _TimelinePostScreenState();
|
|
||||||
}
|
|
||||||
|
|
||||||
class _TimelinePostScreenState extends State<_TimelinePostScreen> {
|
|
||||||
TimelinePost? post;
|
TimelinePost? post;
|
||||||
bool isLoading = true;
|
bool isLoading = true;
|
||||||
|
|
||||||
|
@ -231,7 +194,7 @@ class _TimelinePostScreenState extends State<_TimelinePostScreen> {
|
||||||
if (widget.options.allowAllDeletion ||
|
if (widget.options.allowAllDeletion ||
|
||||||
post.creator?.userId == widget.userId)
|
post.creator?.userId == widget.userId)
|
||||||
PopupMenuButton(
|
PopupMenuButton(
|
||||||
onSelected: (value) => widget.onPostDelete(),
|
onSelected: (value) => widget.onPostDelete.call(),
|
||||||
itemBuilder: (BuildContext context) =>
|
itemBuilder: (BuildContext context) =>
|
||||||
<PopupMenuEntry<String>>[
|
<PopupMenuEntry<String>>[
|
||||||
PopupMenuItem<String>(
|
PopupMenuItem<String>(
|
||||||
|
|
Loading…
Reference in a new issue