More string cleanups
This commit is contained in:
@ -1,8 +1,10 @@
|
||||
#if os(iOS)
|
||||
import CoreData
|
||||
import Foundation
|
||||
import Models
|
||||
import Services
|
||||
import SwiftUI
|
||||
import Transmission
|
||||
import Views
|
||||
|
||||
// swiftlint:disable file_length type_body_length
|
||||
@ -13,11 +15,19 @@
|
||||
@Environment(\.colorScheme) private var colorScheme: ColorScheme
|
||||
@Environment(\.dismiss) private var dismiss
|
||||
|
||||
let delete: (_: NSManagedObjectID) -> Void
|
||||
let archive: (_: NSManagedObjectID) -> Void
|
||||
let viewArticle: (_: NSManagedObjectID) -> Void
|
||||
|
||||
@State var showVoiceSheet = false
|
||||
@State var tabIndex: Int = 0
|
||||
@State var showLabelsModal = false
|
||||
@State var showNotebookView = false
|
||||
|
||||
@State var showOperationToast = false
|
||||
@State var operationStatus: OperationStatus = .none
|
||||
@State var operationMessage: String?
|
||||
|
||||
var playPauseButtonImage: String {
|
||||
switch audioController.state {
|
||||
case .playing:
|
||||
@ -80,7 +90,7 @@
|
||||
var toolbarItems: some ToolbarContent {
|
||||
ToolbarItemGroup(placement: .barTrailing) {
|
||||
Button(
|
||||
action: { delete() },
|
||||
action: { performDelete() },
|
||||
label: {
|
||||
Image
|
||||
.toolbarTrash
|
||||
@ -89,7 +99,7 @@
|
||||
).padding(.trailing, 5)
|
||||
|
||||
Button(
|
||||
action: { archive() },
|
||||
action: { performArchive() },
|
||||
label: {
|
||||
if audioController.itemAudioProperties?.isArchived ?? false {
|
||||
Image
|
||||
@ -102,41 +112,37 @@
|
||||
}
|
||||
}
|
||||
).padding(.trailing, 5)
|
||||
|
||||
Menu(content: {
|
||||
Button(
|
||||
action: { performViewArticle() },
|
||||
label: {
|
||||
Text("View article")
|
||||
}
|
||||
)
|
||||
}, label: {
|
||||
Image
|
||||
.utilityMenu
|
||||
.foregroundColor(ThemeManager.currentTheme.toolbarColor)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func viewArticle() {
|
||||
func performViewArticle() {
|
||||
if let objectID = audioController.itemAudioProperties?.objectID {
|
||||
NSNotification.pushReaderItem(objectID: objectID)
|
||||
DispatchQueue.main.asyncAfter(deadline: .now() + .milliseconds(100)) {
|
||||
dismiss()
|
||||
}
|
||||
viewArticle(objectID)
|
||||
}
|
||||
}
|
||||
|
||||
func delete() {
|
||||
func performDelete() {
|
||||
if let objectID = audioController.itemAudioProperties?.objectID {
|
||||
audioController.stop()
|
||||
dismiss()
|
||||
DispatchQueue.main.asyncAfter(deadline: .now() + .milliseconds(100)) {
|
||||
removeLibraryItemAction(dataService: dataService, objectID: objectID)
|
||||
}
|
||||
delete(objectID)
|
||||
}
|
||||
}
|
||||
|
||||
func archive() {
|
||||
if let objectID = audioController.itemAudioProperties?.objectID,
|
||||
let isArchived = audioController.itemAudioProperties?.isArchived
|
||||
{
|
||||
if isArchived {
|
||||
audioController.stop()
|
||||
dismiss()
|
||||
DispatchQueue.main.asyncAfter(deadline: .now() + .milliseconds(100)) {
|
||||
dataService.archiveLink(objectID: objectID, archived: !isArchived)
|
||||
}
|
||||
} else {
|
||||
dataService.archiveLink(objectID: objectID, archived: !isArchived)
|
||||
}
|
||||
func performArchive() {
|
||||
if let objectID = audioController.itemAudioProperties?.objectID {
|
||||
archive(objectID)
|
||||
}
|
||||
}
|
||||
|
||||
@ -376,6 +382,13 @@
|
||||
|
||||
func playerContent(_: LinkedItemAudioProperties) -> some View {
|
||||
ZStack {
|
||||
WindowLink(level: .alert, transition: .move(edge: .bottom), isPresented: $showOperationToast) {
|
||||
OperationToast(operationMessage: $operationMessage, showOperationToast: $showOperationToast, operationStatus: $operationStatus)
|
||||
.offset(y: -90)
|
||||
} label: {
|
||||
EmptyView()
|
||||
}.buttonStyle(.plain)
|
||||
|
||||
if audioController.playbackError {
|
||||
Text("There was an error playing back your audio.").foregroundColor(Color.red).font(.footnote)
|
||||
}
|
||||
|
||||
@ -198,8 +198,31 @@ struct AnimatingCellHeight: AnimatableModifier {
|
||||
.sheet(item: $viewModel.itemForHighlightsView) { item in
|
||||
NotebookView(viewModel: NotebookViewModel(item: item), hasHighlightMutations: $hasHighlightMutations)
|
||||
}
|
||||
.sheet(isPresented: $showAddFeedView) {
|
||||
NavigationView {
|
||||
LibraryAddFeedView(dismiss: {
|
||||
showAddFeedView = false
|
||||
}, toastOperationHandler: nil)
|
||||
}
|
||||
}
|
||||
.fullScreenCover(isPresented: $showExpandedAudioPlayer) {
|
||||
ExpandedAudioPlayer()
|
||||
ExpandedAudioPlayer(
|
||||
delete: {
|
||||
showExpandedAudioPlayer = false
|
||||
audioController.stop()
|
||||
viewModel.removeLibraryItem(dataService: dataService, objectID: $0)
|
||||
},
|
||||
archive: {
|
||||
showExpandedAudioPlayer = false
|
||||
audioController.stop()
|
||||
viewModel.setLinkArchived(dataService: dataService, objectID: $0, archived: true)
|
||||
},
|
||||
viewArticle: { itemID in
|
||||
if let article = try? dataService.viewContext.existingObject(with: itemID) as? Models.LibraryItem {
|
||||
viewModel.pushFeedItem(item: article)
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
.toolbar {
|
||||
toolbarItems
|
||||
@ -301,13 +324,11 @@ struct AnimatingCellHeight: AnimatableModifier {
|
||||
Button(action: {
|
||||
viewModel.bulkAction(dataService: dataService, action: .archive, items: Array(selection))
|
||||
isEditMode = .inactive
|
||||
}, label: { Image(systemName: "archivebox") })
|
||||
.padding(.trailing, 10)
|
||||
}, label: { Image.toolbarArchive })
|
||||
Button(action: {
|
||||
viewModel.bulkAction(dataService: dataService, action: .delete, items: Array(selection))
|
||||
isEditMode = .inactive
|
||||
}, label: { Image(systemName: "trash") })
|
||||
.padding(.trailing, 10)
|
||||
}, label: { Image.toolbarTrash })
|
||||
Spacer()
|
||||
Text("\(selection.count) selected").font(.footnote)
|
||||
Spacer()
|
||||
@ -729,13 +750,6 @@ struct AnimatingCellHeight: AnimatableModifier {
|
||||
shouldScrollToTop = true
|
||||
}
|
||||
}
|
||||
.sheet(isPresented: $showAddFeedView) {
|
||||
NavigationView {
|
||||
LibraryAddFeedView(dismiss: {
|
||||
showAddFeedView = false
|
||||
}, toastOperationHandler: nil)
|
||||
}
|
||||
}
|
||||
.alert("The Feature Section will be removed from your library. You can add it back from the filter settings in your profile.",
|
||||
isPresented: $showHideFeatureAlert) {
|
||||
Button("OK", role: .destructive) {
|
||||
|
||||
Reference in New Issue
Block a user