From bca82068bd127914ddd751e39f417dea3ea6cc14 Mon Sep 17 00:00:00 2001 From: Jackson Harper Date: Thu, 20 Oct 2022 12:26:34 +0800 Subject: [PATCH] Fix alert/row flicker when removing items on iOS This also updates the message to be consistent with Web. --- .../App/Views/Home/HomeFeedViewIOS.swift | 67 ++++++++++--------- 1 file changed, 34 insertions(+), 33 deletions(-) diff --git a/apple/OmnivoreKit/Sources/App/Views/Home/HomeFeedViewIOS.swift b/apple/OmnivoreKit/Sources/App/Views/Home/HomeFeedViewIOS.swift index 37f7df362..17662712f 100644 --- a/apple/OmnivoreKit/Sources/App/Views/Home/HomeFeedViewIOS.swift +++ b/apple/OmnivoreKit/Sources/App/Views/Home/HomeFeedViewIOS.swift @@ -323,8 +323,10 @@ import Views itemToRemove = item confirmationShown = true }, - label: { Label("Delete", systemImage: "trash") } - ) + label: { + Label("Remove Item", systemImage: "trash") + } + ).tint(.red) if FeatureFlag.enableSnooze { Button { viewModel.itemToSnoozeID = item.id @@ -340,26 +342,23 @@ import Views } .swipeActions(edge: .trailing, allowsFullSwipe: true) { if !item.isArchived { - Button { + Button(action: { withAnimation(.linear(duration: 0.4)) { viewModel.setLinkArchived(dataService: dataService, objectID: item.objectID, archived: true) } - } label: { + }, label: { Label("Archive", systemImage: "archivebox") - }.tint(.green) + }).tint(.green) } else { - Button { + Button(action: { withAnimation(.linear(duration: 0.4)) { viewModel.setLinkArchived(dataService: dataService, objectID: item.objectID, archived: false) } - } label: { + }, label: { Label("Unarchive", systemImage: "tray.and.arrow.down.fill") - }.tint(.indigo) + }).tint(.indigo) } - } - .swipeActions(edge: .trailing, allowsFullSwipe: true) { Button( - role: .destructive, action: { itemToRemove = item confirmationShown = true @@ -367,17 +366,7 @@ import Views label: { Image(systemName: "trash") } - ) - }.alert("Are you sure?", isPresented: $confirmationShown) { - Button("Remove Link", role: .destructive) { - if let itemToRemove = itemToRemove { - withAnimation { - viewModel.removeLink(dataService: dataService, objectID: itemToRemove.objectID) - } - } - self.itemToRemove = nil - } - Button("Cancel", role: .cancel) { self.itemToRemove = nil } + ).tint(.red) } .swipeActions(edge: .leading, allowsFullSwipe: true) { if FeatureFlag.enableSnooze { @@ -393,6 +382,18 @@ import Views } .padding(.top, 0) .listStyle(PlainListStyle()) + .alert("Are you sure you want to remove this item? All associated notes and highlights will be deleted.", + isPresented: $confirmationShown) { + Button("Remove Item") { + if let itemToRemove = itemToRemove { + withAnimation { + viewModel.removeLink(dataService: dataService, objectID: itemToRemove.objectID) + } + } + self.itemToRemove = nil + } + Button("Cancel", role: .cancel) { self.itemToRemove = nil } + } } } } @@ -448,17 +449,6 @@ import Views isContextMenuOpen: $isContextMenuOpen, viewModel: viewModel ) - .alert("Are you sure?", isPresented: $confirmationShown) { - Button("Remove Link", role: .destructive) { - if let itemToRemove = itemToRemove { - withAnimation { - viewModel.removeLink(dataService: dataService, objectID: itemToRemove.objectID) - } - } - self.itemToRemove = nil - } - Button("Cancel", role: .cancel) { self.itemToRemove = nil } - } } } .padding() @@ -483,6 +473,17 @@ import Views } } } + .alert("Are you sure you want to remove this item? All associated notes and highlights will be deleted.", isPresented: $confirmationShown) { + Button("Remove Item", role: .destructive) { + if let itemToRemove = itemToRemove { + withAnimation { + viewModel.removeLink(dataService: dataService, objectID: itemToRemove.objectID) + } + } + self.itemToRemove = nil + } + Button("Cancel", role: .cancel) { self.itemToRemove = nil } + } } }