Skip to content

Commit

Permalink
🚸 (UIExplorer): Add robot connection to sidebar
Browse files Browse the repository at this point in the history
  • Loading branch information
ladislas committed Dec 7, 2023
1 parent 522ba4a commit 7cbe2e3
Showing 1 changed file with 26 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,22 @@ import SwiftUI
class NavigationViewViewModel: ObservableObject {
@Published var isDesignSystemAppleExpanded: Bool = false
@Published var isDesignSystemLekaExpanded: Bool = false

@Published var isRobotConnectionPresented: Bool = false

@Published var isRobotConnect: Bool = false

private var cancellables: Set<AnyCancellable> = []

init() {
Robot.shared.isConnected
.receive(on: DispatchQueue.main)
.sink { [weak self] isConnected in
guard let self else { return }
self.isRobotConnect = isConnected
}
.store(in: &cancellables)
}
}

struct NavigationView: View {
Expand All @@ -25,6 +41,13 @@ struct NavigationView: View {
List(selection: $navigation.selectedCategory) {
CategoryLabel(category: .home)

Button {
viewModel.isRobotConnectionPresented.toggle()
} label: {
Label(viewModel.isRobotConnect ? "Disconnect robot" : "Connect robot", systemImage: "link")
.foregroundStyle(viewModel.isRobotConnect ? .green : .orange)
}

Section("Activities") {
CategoryLabel(category: .activities)
}
Expand Down Expand Up @@ -92,6 +115,9 @@ struct NavigationView: View {
.onAppear {
preferedColorScheme = colorScheme
}
.fullScreenCover(isPresented: $viewModel.isRobotConnectionPresented) {
RobotConnectionView(viewModel: RobotConnectionViewModel())
}
}

struct CategoryLabel: View {
Expand Down

0 comments on commit 7cbe2e3

Please sign in to comment.