add ToolbarTab and sheet destinations

This commit is contained in:
Duong Thai 2024-03-07 11:15:26 +07:00
parent b246e01f02
commit fea9bf3b6b
2 changed files with 16 additions and 8 deletions

View file

@ -11,6 +11,7 @@ import SwiftSoup
import DesignSystem
import RSS
import Env
import Network
@MainActor
public struct RSSTab: View {
@ -20,17 +21,18 @@ public struct RSSTab: View {
@Environment(\.managedObjectContext) private var moContext
@State private var isLoading = true
@Environment(RouterPath.self) private var routerPath
@Environment(Client.self) private var client
@State private var routerPath = RouterPath()
@State private var showAlert = false
public init() {}
public var body: some View {
NavigationStack {
if isLoading {
ProgressView()
} else {
List {
List {
if isLoading {
ProgressView()
} else {
ForEach(items) { item in
Button(action: {
if let url = item.url {
@ -48,8 +50,14 @@ public struct RSSTab: View {
Text("rss.item.url.unavailable.message")
}
}
.listStyle(PlainListStyle())
}
}
.withSheetDestinations(sheetDestinations: $routerPath.presentedSheet)
.toolbar {
if client.isAuth {
ToolbarTab(routerPath: $routerPath)
}
.listStyle(PlainListStyle())
}
}
// TODO: remove this
@ -109,5 +117,7 @@ public struct RSSTab: View {
isLoading = false
}
.withSafariRouter()
.environment(routerPath)
}
}

View file

@ -78,8 +78,6 @@ enum Tab: Int, Identifiable, Hashable, CaseIterable, Codable {
EmptyView()
case .rss:
RSSTab()
.withSafariRouter()
.environment(Self.routerPath)
}
}