Last active
November 9, 2021 22:00
-
-
Save vikingosegundo/e922bb9d0c367ddc6e81baf1bee509e5 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import SwiftUI | |
struct ContentView: View { | |
init(viewState: ViewState, rootHandler: @escaping (Message) -> ()) { | |
self.viewState = viewState | |
self.rootHandler = rootHandler | |
self.tabColor = tabColors[0] | |
} | |
var body: some View { | |
TabView { | |
Dashboard(rootHandler).tabItem { Label("Dashboard", systemImage:"squareshape") }.onAppear(perform: { tabColor = tabColors[0] }) | |
Lights (rootHandler).tabItem { Label("Lights", systemImage:"lightbulb" ) }.onAppear(perform: { tabColor = tabColors[1] }) | |
Rooms (rootHandler).tabItem { Label("Rooms", systemImage:"bed.double" ) }.onAppear(perform: { tabColor = tabColors[2] }) | |
Shop (rootHandler).tabItem { Label("Shop", systemImage:"cart" ) }.onAppear(perform: { tabColor = tabColors[3] }) | |
Settings (rootHandler).tabItem { Label("Settings", systemImage:"gear" ) }.onAppear(perform: { tabColor = tabColors[4] }) | |
} | |
.accentColor(tabColor ?? tabColors[0]) | |
.environmentObject(viewState) | |
} | |
@State private var animationCompletion: CGFloat = 0.0 | |
@State private var tabColor: Color! | |
@ObservedObject | |
private var viewState : ViewState | |
private let rootHandler: (Message) -> () | |
} | |
fileprivate | |
let tabColors = [ | |
Color(hue:0.305, saturation:0.45, brightness:0.75), | |
Color(hue:0.511, saturation:0.45, brightness:0.75), | |
Color(hue:0.602, saturation:0.45, brightness:0.75), | |
Color(hue:0.755, saturation:0.45, brightness:0.75), | |
Color(hue:0.638, saturation:0.45, brightness:0.75), | |
Color(hue:0.111, saturation:0.45, brightness:0.75), | |
] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment