-
-
Notifications
You must be signed in to change notification settings - Fork 21
Expand file tree
/
Copy pathMainTabView.swift
More file actions
64 lines (58 loc) · 1.93 KB
/
MainTabView.swift
File metadata and controls
64 lines (58 loc) · 1.93 KB
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
62
63
64
//
// MainTabView.swift
// OCKSample
//
// Created by Corey Baker on 9/18/22.
// Copyright © 2022 Network Reconnaissance Lab. All rights reserved.
//
// swiftlint:disable:next line_length
// This was built using tutorial: https://www.hackingwithswift.com/books/ios-swiftui/creating-tabs-with-tabview-and-tabitem
import CareKitStore
import SwiftUI
struct MainTabView: View {
@ObservedObject var loginViewModel: LoginViewModel
@State private var selectedTab = 0
var body: some View {
TabView(selection: $selectedTab) {
CareView()
.tabItem {
if selectedTab == 0 {
Image("carecard-filled")
.renderingMode(.template)
} else {
Image("carecard")
.renderingMode(.template)
}
}
.tag(0)
ContactView()
.tabItem {
if selectedTab == 1 {
Image("phone.bubble.left.fill")
.renderingMode(.template)
} else {
Image("phone.bubble.left")
.renderingMode(.template)
}
}
.tag(1)
ProfileView(loginViewModel: loginViewModel)
.tabItem {
if selectedTab == 2 {
Image("connect-filled")
.renderingMode(.template)
} else {
Image("connect")
.renderingMode(.template)
}
}
.tag(2)
}
}
}
struct MainTabView_Previews: PreviewProvider {
static var previews: some View {
MainTabView(loginViewModel: .init())
.environment(\.careStore, Utility.createPreviewStore())
}
}