add add-new-feed for manager

This commit is contained in:
Duong Thai 2024-03-13 14:41:13 +07:00
parent 22aa840b0f
commit d9438cfe15
2 changed files with 25 additions and 7 deletions

View file

@ -16,6 +16,9 @@ public struct RSSAddNewFeed: View {
@State private var feed: RSSFeed? = nil
@State private var downloadingTask: Task<(), Never>? = nil
public enum Context { case manager, sheet }
let context: Context
public var body: some View {
NavigationStack {
Form {
@ -35,12 +38,14 @@ public struct RSSAddNewFeed: View {
.navigationTitle("rss.addNewFeed.title")
.navigationBarTitleDisplayMode(.inline)
.toolbar {
ToolbarItem(placement: .topBarLeading) {
Button {
dismiss()
feed?.managedObjectContext?.rollback()
} label: {
Image(systemName: "xmark")
if self.context == .sheet {
ToolbarItem(placement: .topBarLeading) {
Button {
dismiss()
feed?.managedObjectContext?.rollback()
} label: {
Image(systemName: "xmark")
}
}
}
@ -77,7 +82,9 @@ public struct RSSAddNewFeed: View {
}
}
public init() {}
public init(context: Context = .sheet) {
self.context = context
}
private struct IndicatorView: View {
@Binding var state: MachineState

View file

@ -7,6 +7,7 @@
import SwiftUI
import DesignSystem
import Env
public struct RSSFeedManager: View {
@Environment(\.dismiss) private var dismiss
@ -14,6 +15,8 @@ public struct RSSFeedManager: View {
@FetchRequest(sortDescriptors: [SortDescriptor(\.title, order: .reverse)])
private var feeds: FetchedResults<RSSFeed>
@State private var routerPath = RouterPath()
public var body: some View {
NavigationStack{
List {
@ -39,6 +42,14 @@ public struct RSSFeedManager: View {
}
}
ToolbarItem(placement: .navigationBarTrailing) {
NavigationLink {
RSSAddNewFeed(context: .manager)
} label: {
Image(systemName: "plus")
}
}
ToolbarItem(placement: .topBarTrailing) {
Button("rss.rssFeedManager.action.done") {
dismiss()