aboutsummaryrefslogtreecommitdiff
path: root/iosApp/iosApp/Details
diff options
context:
space:
mode:
Diffstat (limited to 'iosApp/iosApp/Details')
-rw-r--r--iosApp/iosApp/Details/Commands/UnitCommandsViewModel.swift12
-rw-r--r--iosApp/iosApp/Details/DetailsView.swift5
2 files changed, 15 insertions, 2 deletions
diff --git a/iosApp/iosApp/Details/Commands/UnitCommandsViewModel.swift b/iosApp/iosApp/Details/Commands/UnitCommandsViewModel.swift
index d7298c4..8e1da00 100644
--- a/iosApp/iosApp/Details/Commands/UnitCommandsViewModel.swift
+++ b/iosApp/iosApp/Details/Commands/UnitCommandsViewModel.swift
@@ -21,6 +21,7 @@ import shared
class UnitCommandsViewModel: ObservableObject {
@Inject var commandsController: CommandsController
+ var deviceId: Int32? = nil
@Published var commands = [Command]()
@Published var selected: Command?
@Published var selectedId: Int = 0 {
@@ -29,6 +30,9 @@ class UnitCommandsViewModel: ObservableObject {
Int(truncating: $0.id!) == selectedId
}) {
self.selected = selected
+ if let id = deviceId {
+ self.selected?.deviceId = KotlinInt(int: id)
+ }
notSelected = false
} else {
self.selected = nil
@@ -40,6 +44,7 @@ class UnitCommandsViewModel: ObservableObject {
@Published var showConfirmation: Bool = false
func fetchCommands(id: Int32) {
+ deviceId = id
commandsController.fetchCommands(deviceId: id) { commands, error in
print("We've got the commands! \(commands ?? [])")
self.commands = commands ?? []
@@ -48,7 +53,12 @@ class UnitCommandsViewModel: ObservableObject {
func sendCommand() {
if let command = selected {
- commandsController.sendCommand(command: command) { _, error in }
+ commandsController.sendCommand(command: command) { _, error in
+ if let error = error {
+ print("There is a fucking error")
+ print(error.localizedDescription)
+ }
+ }
}
}
}
diff --git a/iosApp/iosApp/Details/DetailsView.swift b/iosApp/iosApp/Details/DetailsView.swift
index 2c7418b..c869369 100644
--- a/iosApp/iosApp/Details/DetailsView.swift
+++ b/iosApp/iosApp/Details/DetailsView.swift
@@ -40,6 +40,8 @@ struct DetailsView: View {
UnitReportsView(unit: unit)
case .commands:
UnitCommandsView(unit: unit)
+ default:
+ EmptyView()
}
} else {
LoadingView()
@@ -48,7 +50,7 @@ struct DetailsView: View {
.navigationBarTitleView(
Picker(selection: $action) {
Text("details").tag(DeviceRow.Action.details)
- Text("reports").tag(DeviceRow.Action.reports)
+ //Text("reports").tag(DeviceRow.Action.reports)
Text("commands").tag(DeviceRow.Action.commands)
} label: {
EmptyView()
@@ -62,6 +64,7 @@ struct DetailsView: View {
let type = Marker.companion
.categoryToMarkerType(category: category)
Image(MarkerTransformations.markerTypeToImageName(markerType: type))
+ .sizeToFit()
} else {
EmptyView()
}