summaryrefslogtreecommitdiff
path: root/JuickNext/View/ContentView.swift
diff options
context:
space:
mode:
Diffstat (limited to 'JuickNext/View/ContentView.swift')
-rw-r--r--JuickNext/View/ContentView.swift69
1 files changed, 27 insertions, 42 deletions
diff --git a/JuickNext/View/ContentView.swift b/JuickNext/View/ContentView.swift
index 3912c59..7f5db89 100644
--- a/JuickNext/View/ContentView.swift
+++ b/JuickNext/View/ContentView.swift
@@ -11,58 +11,43 @@ import SwiftUI
struct ContentView: View {
@Environment(\.horizontalSizeClass) private var size
- let today = Feed(title: "Today", url: "https://api.juick.com/messages?popular=1")
- let discussions = Feed(title: "Discussions", url: "https://api.juick.com/messages/discussions")
- let discover = Feed(title: "Discover", url: "https://api.juick.com/messages")
+ let today = Feed(title: "Today", url: "https://api.juick.com/messages?popular=1", imageName: "ei-clock")
+ let discussions = Feed(title: "Discussions", url: "https://api.juick.com/messages/discussions", imageName: "ei-bell")
+ let discover = Feed(title: "Discover", url: "https://api.juick.com/messages", imageName: "Discover")
@State private var showFeed : Bool = false
@State private var selectedFeed: Feed? = nil
+
var body: some View {
+ let tabs = [today, discussions, discover]
let view = (size == .compact) ?
- AnyView(TabView {
- FeedView(today).tabItem {
- Image("ei-clock")
- }
- FeedView(discussions).tabItem {
- Image("ei-bell")
- }
- FeedView(discover).tabItem {
- Image("Discover")
- }
- }): AnyView(NavigationView {
- let tabs = [today, discussions, discover]
- VStack {
- List {
- ForEach(tabs, id: \.title) {
- tab in
- Button(action: {
- selectedFeed = tab
- showFeed.toggle()
- }, label: {
- Text(tab.title)
- })
+ AnyView(
+ TabView {
+ ForEach(tabs, id: \.title) {
+ tab in
+ FeedView(tab).tabItem {
+ Image(tab.imageName)
}
- }.background {
- if let feed = selectedFeed {
- NavigationLink(
- destination: FeedView(feed),
- isActive: $showFeed,
- label: {
- VStack {
- Text(feed.title)
- }
+ }
+ }
+ ): AnyView(
+ NavigationView {
+ VStack {
+ List {
+ ForEach(tabs, id: \.title) {
+ tab in
+ NavigationLink(destination: FeedView(tab), label: {
+ HStack {
+ Image(tab.imageName)
+ Text(tab.title)
+ }.padding()
})
- } else {
- EmptyView()
+ }
}
- }
- }.toolbar {
- ToolbarItem(placement: .principal) {
- Text("Juick")
- }
+ }.screenTitle(title: "Juick")
}
- })
+ )
view
}
}