diff options
author | Iván Ávalos <avalos@disroot.org> | 2022-02-07 01:43:27 -0600 |
---|---|---|
committer | Iván Ávalos <avalos@disroot.org> | 2022-02-07 01:43:27 -0600 |
commit | 4f0129a70bafeca1d9e565ba2076213eb183c779 (patch) | |
tree | 08f9acf0c7c4233c260feeffb0b0d454d3ab0e9b /iosApp/iosApp/Details/Commands/UnitCommandsView.swift | |
parent | 8d040f0f02b9462d82fd03041529fdea423f02d3 (diff) | |
download | etbsa-trackermap-mobile-4f0129a70bafeca1d9e565ba2076213eb183c779.tar.gz etbsa-trackermap-mobile-4f0129a70bafeca1d9e565ba2076213eb183c779.tar.bz2 etbsa-trackermap-mobile-4f0129a70bafeca1d9e565ba2076213eb183c779.zip |
Finished details view and implemented commands view
Diffstat (limited to 'iosApp/iosApp/Details/Commands/UnitCommandsView.swift')
-rw-r--r-- | iosApp/iosApp/Details/Commands/UnitCommandsView.swift | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/iosApp/iosApp/Details/Commands/UnitCommandsView.swift b/iosApp/iosApp/Details/Commands/UnitCommandsView.swift index fade29b..9e4b280 100644 --- a/iosApp/iosApp/Details/Commands/UnitCommandsView.swift +++ b/iosApp/iosApp/Details/Commands/UnitCommandsView.swift @@ -19,10 +19,31 @@ import SwiftUI import shared struct UnitCommandsView: View { + @ObservedObject var unitCommandsViewModel = UnitCommandsViewModel() + var unit: UnitInformation + init(unit: UnitInformation) { + self.unit = unit + unitCommandsViewModel.fetchCommands(id: unit.device.id) + } + var body: some View { - - Text(/*@START_MENU_TOKEN@*/"Hello, World!"/*@END_MENU_TOKEN@*/) + VStack { + List { + Picker("commands", selection: $unitCommandsViewModel.selectedId) { + ForEach(unitCommandsViewModel.commands, id: \.id) { command in + Text(command.description_ ?? "\(command.id!)") + .tag(Int(truncating: command.id!)) + } + }.pickerStyle(InlinePickerStyle()) + + Button { + unitCommandsViewModel.sendCommand() + } label: { + Label("send-command", systemImage: "paperplane") + } + } + } } } |