From 2b4cbf8131ad3ffd7f1b2dd222a87c19df948e6d Mon Sep 17 00:00:00 2001 From: Neeraj Gupta <254676+ua741@users.noreply.github.com> Date: Wed, 15 Sep 2021 10:00:53 +0530 Subject: [PATCH] Hide delete option for files not owned by the user --- lib/ui/fading_app_bar.dart | 35 ++++++++++++++++++++--------------- 1 file changed, 20 insertions(+), 15 deletions(-) diff --git a/lib/ui/fading_app_bar.dart b/lib/ui/fading_app_bar.dart index ed798227b..88c1d7e6c 100644 --- a/lib/ui/fading_app_bar.dart +++ b/lib/ui/fading_app_bar.dart @@ -85,6 +85,7 @@ class FadingAppBarState extends State { AppBar _buildAppBar() { final List actions = []; + // only show fav option for files owned by the user if (widget.file.ownerID == null || widget.file.ownerID == widget.userId) { actions.add(_getFavoriteButton()); } @@ -109,22 +110,26 @@ class FadingAppBarState extends State { ), ); } - items.add( - PopupMenuItem( - value: 2, - child: Row( - children: [ - Icon(Platform.isAndroid - ? Icons.delete_outline - : CupertinoIcons.delete), - Padding( - padding: EdgeInsets.all(8), - ), - Text("delete"), - ], + // only show delete option for files owned by the user + if (widget.file.ownerID == null || + widget.file.ownerID == widget.userId) { + items.add( + PopupMenuItem( + value: 2, + child: Row( + children: [ + Icon(Platform.isAndroid + ? Icons.delete_outline + : CupertinoIcons.delete), + Padding( + padding: EdgeInsets.all(8), + ), + Text("delete"), + ], + ), ), - ), - ); + ); + } return items; }, onSelected: (value) {