2022-11-20 15:39:06 +00:00
|
|
|
import SwiftUI
|
2022-11-21 08:31:32 +00:00
|
|
|
import Timeline
|
|
|
|
import Network
|
2022-11-20 15:39:06 +00:00
|
|
|
|
|
|
|
@main
|
|
|
|
struct IceCubesAppApp: App {
|
2022-11-21 12:52:13 +00:00
|
|
|
@State private var tabs: [String] = ["mastodon.social"]
|
|
|
|
@State private var isServerSelectDisplayed: Bool = false
|
|
|
|
@State private var newServerURL: String = ""
|
2022-11-21 08:31:32 +00:00
|
|
|
|
2022-11-20 15:39:06 +00:00
|
|
|
var body: some Scene {
|
|
|
|
WindowGroup {
|
2022-11-21 12:52:13 +00:00
|
|
|
TabView {
|
|
|
|
ForEach(tabs, id: \.self) { tab in
|
|
|
|
NavigationStack {
|
|
|
|
TimelineView(kind: .pub)
|
|
|
|
.environmentObject(Client(server: tab))
|
|
|
|
.toolbar {
|
|
|
|
ToolbarItem(placement: .navigationBarTrailing) {
|
|
|
|
Button {
|
|
|
|
isServerSelectDisplayed.toggle()
|
|
|
|
} label: {
|
|
|
|
Image(systemName: "globe")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
.alert("Connect to another server", isPresented: $isServerSelectDisplayed) {
|
|
|
|
TextField(tab, text: $newServerURL)
|
|
|
|
Button("Connect", action: {
|
|
|
|
tabs.append(newServerURL)
|
|
|
|
newServerURL = ""
|
|
|
|
})
|
|
|
|
Button("Cancel", role: .cancel, action: {})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
.tabItem {
|
|
|
|
Label(tab, systemImage: "globe")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2022-11-20 15:39:06 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|