Settings UI cleanup, stop audio when archiving/deleting

This commit is contained in:
Jackson Harper
2023-12-23 17:14:24 +08:00
parent 66a6c5ddc3
commit 98ad40fa6b
7 changed files with 86 additions and 25 deletions

View File

@ -55,7 +55,8 @@
.aspectRatio(contentMode: .fit)
.font(Font.title.weight(.light))
}
))
).buttonStyle(.plain)
)
}
}
@ -78,6 +79,7 @@
}
}
)
.buttonStyle(.plain)
.background(Color.clear)
.buttonStyle(PlainButtonStyle())
}

View File

@ -125,7 +125,7 @@ struct ApplyLabelsView: View {
label: {
HStack {
let trimmedLabelName = viewModel.labelSearchFilter.trimmingCharacters(in: .whitespacesAndNewlines)
Image(systemName: "tag").foregroundColor(.blue)
Image.addLink.foregroundColor(.blue).foregroundColor(.blue)
Text(
viewModel.labelSearchFilter.count > 0 ?
"Create: \"\(trimmedLabelName)\" label" :

View File

@ -34,8 +34,6 @@ struct LabelsView: View {
}
Section("Label settings") {
Toggle("Hide system labels", isOn: $hideSystemLabels)
}.onChange(of: hideSystemLabels) { newValue in
PublicValet.hideLabels = newValue
}
}
.navigationTitle(LocalText.labelsGeneric)
@ -54,11 +52,13 @@ struct LabelsView: View {
}
Button(LocalText.cancelGeneric, role: .cancel) { self.labelToRemove = nil }
}
// .onChange(of: hideSystemLabels) { _ in
// Task {
// await viewModel.loadLabels(dataService: dataService, item: nil)
// }
// }
.onChange(of: hideSystemLabels) { newValue in
PublicValet.hideLabels = newValue
Task {
await viewModel.loadLabels(dataService: dataService, item: nil)
}
}
.onReceive(NotificationCenter.default.publisher(for: Notification.Name("ScrollToTop"))) { _ in
dismiss()
}
@ -72,25 +72,19 @@ struct LabelsView: View {
Button(
action: { viewModel.showCreateLabelModal = true },
label: {
HStack {
Label(title: {
let trimmedLabelName = viewModel.labelSearchFilter.trimmingCharacters(in: .whitespacesAndNewlines)
Image(systemName: "tag").foregroundColor(.blue)
Text(
viewModel.labelSearchFilter.count > 0 && viewModel.labelSearchFilter != ZWSP ?
"Create: \"\(trimmedLabelName)\" label" :
LocalText.createLabelMessage
).foregroundColor(.blue)
.font(Font.system(size: 14))
Spacer()
}
)
}, icon: {
Image.addLink
})
}
)
.buttonStyle(PlainButtonStyle())
.disabled(viewModel.isLoading)
#if os(iOS)
.listRowSeparator(.hidden, edges: .bottom)
#endif
.padding(.vertical, 10)
}
}

View File

@ -149,11 +149,11 @@
Button(
action: { viewModel.showCreateSheet = true },
label: {
HStack {
Image(systemName: "plus.circle.fill").foregroundColor(.green)
Label(title: {
Text(LocalText.clubsCreate)
Spacer()
}
}, icon: {
Image.addLink
})
}
)
}

View File

@ -63,6 +63,14 @@ struct PushNotificationDevicesView: View {
}
private var innerBody: some View {
if viewModel.devices.isEmpty {
AnyView(Text("No devices registered"))
} else {
AnyView(deviceList)
}
}
private var deviceList: some View {
List {
Section(header: Text(LocalText.devicesTokensTitle)) {
ForEach(viewModel.devices) { device in

View File

@ -460,6 +460,54 @@ struct SubscriptionSettingsView: View {
}
}
var feedRow: some View {
VStack {
Text("Feed URL")
.frame(maxWidth: .infinity, alignment: .leading)
Text(subscription.url ?? "")
.foregroundColor(Color.appGrayText)
.frame(maxWidth: .infinity, alignment: .leading)
.lineLimit(1)
}
.contextMenu(ContextMenu(menuItems: {
Button(action: {
#if os(iOS)
UIPasteboard.general.string = subscription.url
#endif
#if os(macOS)
let pasteBoard = NSPasteboard.general
pasteBoard.clearContents()
pasteBoard.writeObjects([subscription.url as NSString])
#endif
}, label: { Text("Copy URL") })
}))
}
var emailRow: some View {
VStack {
Text("Received by")
.frame(maxWidth: .infinity, alignment: .leading)
Text(subscription.newsletterEmailAddress ?? "")
.foregroundColor(Color.appGrayText)
.frame(maxWidth: .infinity, alignment: .leading)
.lineLimit(1)
}
.contextMenu(ContextMenu(menuItems: {
Button(action: {
#if os(iOS)
UIPasteboard.general.string = subscription.newsletterEmailAddress
#endif
#if os(macOS)
let pasteBoard = NSPasteboard.general
pasteBoard.clearContents()
pasteBoard.writeObjects([subscription.newsletterEmailAddress as NSString])
#endif
}, label: { Text("Copy Address") })
}))
}
var labelRuleRow: some View {
HStack {
Text("Add Labels")
@ -472,7 +520,7 @@ struct SubscriptionSettingsView: View {
} else {
Text("Create Rule")
}
})
}).tint(Color.blue)
} else {
ProgressView()
}
@ -511,6 +559,13 @@ struct SubscriptionSettingsView: View {
// }
folderRow
labelRuleRow
if subscription.type == .feed {
feedRow
}
if subscription.type == .newsletter {
emailRow
}
}.listStyle(.insetGrouped)
Spacer()

View File

@ -455,9 +455,11 @@ struct WebReaderContainerView: View {
.fullScreenCover(isPresented: $showExpandedAudioPlayer) {
ExpandedAudioPlayer(delete: { _ in
showExpandedAudioPlayer = false
audioController.stop()
delete()
}, archive: { _ in
showExpandedAudioPlayer = false
audioController.stop()
archive()
}, viewArticle: { _ in
showExpandedAudioPlayer = false