Hide delete option for files not owned by the user

This commit is contained in:
Neeraj Gupta 2021-09-15 10:00:53 +05:30
parent 128c207e55
commit 2b4cbf8131
No known key found for this signature in database
GPG key ID: 3C5A1684DC1729E1

View file

@ -85,6 +85,7 @@ class FadingAppBarState extends State<FadingAppBar> {
AppBar _buildAppBar() { AppBar _buildAppBar() {
final List<Widget> actions = []; final List<Widget> actions = [];
// only show fav option for files owned by the user
if (widget.file.ownerID == null || widget.file.ownerID == widget.userId) { if (widget.file.ownerID == null || widget.file.ownerID == widget.userId) {
actions.add(_getFavoriteButton()); actions.add(_getFavoriteButton());
} }
@ -109,22 +110,26 @@ class FadingAppBarState extends State<FadingAppBar> {
), ),
); );
} }
items.add( // only show delete option for files owned by the user
PopupMenuItem( if (widget.file.ownerID == null ||
value: 2, widget.file.ownerID == widget.userId) {
child: Row( items.add(
children: [ PopupMenuItem(
Icon(Platform.isAndroid value: 2,
? Icons.delete_outline child: Row(
: CupertinoIcons.delete), children: [
Padding( Icon(Platform.isAndroid
padding: EdgeInsets.all(8), ? Icons.delete_outline
), : CupertinoIcons.delete),
Text("delete"), Padding(
], padding: EdgeInsets.all(8),
),
Text("delete"),
],
),
), ),
), );
); }
return items; return items;
}, },
onSelected: (value) { onSelected: (value) {