summaryrefslogtreecommitdiff
path: root/JuickNext/View/ContentView.swift
blob: 7f5db899f728710714e776b367c9b209e9131373 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
//
//  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()
        }
    }
}