diff options
author | Iván Ávalos <avalos@disroot.org> | 2022-02-08 22:01:58 -0600 |
---|---|---|
committer | Iván Ávalos <avalos@disroot.org> | 2022-02-08 22:01:58 -0600 |
commit | 58a310156bd09ac536f65aa12122ea1f045c0116 (patch) | |
tree | 4e1f2f263e283d907b42aeb43d332acd1df33848 /iosApp/iosApp/Details/Commands/UnitCommandsViewModel.swift | |
parent | 17add53388caa3f5b21c8666e1e667fe42639af5 (diff) | |
download | etbsa-trackermap-mobile-58a310156bd09ac536f65aa12122ea1f045c0116.tar.gz etbsa-trackermap-mobile-58a310156bd09ac536f65aa12122ea1f045c0116.tar.bz2 etbsa-trackermap-mobile-58a310156bd09ac536f65aa12122ea1f045c0116.zip |
- Disable button when no command is selected.
- Add confirmation for sending command.
Diffstat (limited to 'iosApp/iosApp/Details/Commands/UnitCommandsViewModel.swift')
-rw-r--r-- | iosApp/iosApp/Details/Commands/UnitCommandsViewModel.swift | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/iosApp/iosApp/Details/Commands/UnitCommandsViewModel.swift b/iosApp/iosApp/Details/Commands/UnitCommandsViewModel.swift index aac82c9..d7298c4 100644 --- a/iosApp/iosApp/Details/Commands/UnitCommandsViewModel.swift +++ b/iosApp/iosApp/Details/Commands/UnitCommandsViewModel.swift @@ -25,11 +25,19 @@ class UnitCommandsViewModel: ObservableObject { @Published var selected: Command? @Published var selectedId: Int = 0 { didSet { - selected = commands.first(where: { + if let selected = commands.first(where: { Int(truncating: $0.id!) == selectedId - }) + }) { + self.selected = selected + notSelected = false + } else { + self.selected = nil + notSelected = true + } } } + @Published var notSelected: Bool = true + @Published var showConfirmation: Bool = false func fetchCommands(id: Int32) { commandsController.fetchCommands(deviceId: id) { commands, error in |