From 2088d0196956a9321f1dc2afaf82125bd1775a90 Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Wed, 15 May 2024 10:43:24 +0300 Subject: Regular size layout --- JuickNext/View/ContentView.swift | 48 ++++++++++++++++++++++++++++++++-------- 1 file changed, 39 insertions(+), 9 deletions(-) (limited to 'JuickNext/View/ContentView.swift') diff --git a/JuickNext/View/ContentView.swift b/JuickNext/View/ContentView.swift index 22e74e0..3912c59 100644 --- a/JuickNext/View/ContentView.swift +++ b/JuickNext/View/ContentView.swift @@ -11,26 +11,56 @@ import SwiftUI struct ContentView: View { @Environment(\.horizontalSizeClass) private var size - let today = FeedView("Today", url: "https://api.juick.com/messages?popular=1") - let discussions = FeedView("Discussions", url: "https://api.juick.com/messages/discussions") - let discover = FeedView("Discover", url: "https://api.juick.com/messages") + 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") + + @State private var showFeed : Bool = false + @State private var selectedFeed: Feed? = nil + var body: some View { let view = (size == .compact) ? AnyView(TabView { - today.tabItem { + FeedView(today).tabItem { Image("ei-clock") } - discussions.tabItem { + FeedView(discussions).tabItem { Image("ei-bell") } - discover.tabItem { + FeedView(discover).tabItem { Image("Discover") } }): AnyView(NavigationView { + let tabs = [today, discussions, discover] VStack { - Text("Discussions") - Text("Discover") - Text("Chats") + List { + ForEach(tabs, id: \.title) { + tab in + Button(action: { + selectedFeed = tab + showFeed.toggle() + }, label: { + Text(tab.title) + }) + } + }.background { + if let feed = selectedFeed { + NavigationLink( + destination: FeedView(feed), + isActive: $showFeed, + label: { + VStack { + Text(feed.title) + } + }) + } else { + EmptyView() + } + } + }.toolbar { + ToolbarItem(placement: .principal) { + Text("Juick") + } } }) view -- cgit v1.2.3