comparison Simoleon/ContentView.swift @ 173:ad8c6567539d

restart project
author Dennis Concepcion Martin <dennisconcepcionmartin@gmail.com>
date Tue, 26 Oct 2021 13:09:17 +0200
parents f4e0c414cf6d
children a1443bd115d9
comparison
equal deleted inserted replaced
172:9b0486301fbf 173:ad8c6567539d
1 // 1 //
2 // ContentView.swift 2 // ContentView.swift
3 // Simoleon 3 // Simoleon
4 // 4 //
5 // Created by Dennis Concepción Martín on 15/07/2021. 5 // Created by Dennis Concepción Martín on 26/10/21.
6 // 6 //
7 7
8 import SwiftUI 8 import SwiftUI
9 import CoreData
9 10
10 struct ContentView: View { 11 struct ContentView: View {
11 @State private var tab: Tab = .convert
12
13 private enum Tab {
14 case convert, favorites, settings
15 }
16
17 @ViewBuilder var adjustedView: some View {
18
19 // MARK: - iPad
20 if UIDevice.current.userInterfaceIdiom == .pad {
21 NavigationView {
22 Sidebar()
23 ConversionView()
24 }
25 } else {
26 // MARK: - iPhone
27 TabView(selection: $tab) {
28 ConversionView()
29 .tabItem {
30 Label("Convert", systemImage: "arrow.counterclockwise.circle")
31 }
32 .tag(Tab.convert)
33
34 FavoritesView()
35 .tabItem {
36 Label("Favorites", systemImage: "star")
37 }
38 .tag(Tab.favorites)
39
40 AboutView()
41 .tabItem {
42 Label("About", systemImage: "info.circle")
43 }
44 .tag(Tab.settings)
45 }
46 }
47 }
48
49 var body: some View { 12 var body: some View {
50 adjustedView 13 Text("Hello world")
51 } 14 }
52 } 15 }
53 16
54 struct ContentView_Previews: PreviewProvider { 17 struct ContentView_Previews: PreviewProvider {
55 static var previews: some View { 18 static var previews: some View {
56 ContentView() 19 ContentView().environment(\.managedObjectContext, PersistenceController.preview.container.viewContext)
57 } 20 }
58 } 21 }