// // ContentView.swift // Juick // // Created by Vitaly Takmazov on 14.05.2023. // Copyright © 2023 com.juick. All rights reserved. // import SwiftUI struct ContentView: View { @Environment(\.horizontalSizeClass) private var size 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 { ForEach(tabs, id: \.title) { tab in FeedView(tab).tabItem { Image(tab.imageName) } } } ): AnyView( NavigationView { VStack { List { ForEach(tabs, id: \.title) { tab in NavigationLink(destination: FeedView(tab), label: { HStack { Image(tab.imageName) Text(tab.title) }.padding() }) } } }.screenTitle(title: "Juick") } ) view } } struct ContentView_Previews: PreviewProvider { static var previews: some View { NavigationView { ContentView() } } }