aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--iosApp/iosApp.xcodeproj/project.pbxproj20
-rw-r--r--iosApp/iosApp.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved8
-rw-r--r--iosApp/iosApp.xcodeproj/project.xcworkspace/xcuserdata/avalos.xcuserdatad/UserInterfaceState.xcuserstatebin47744 -> 57937 bytes
-rw-r--r--iosApp/iosApp/Devices/DevicesView.swift41
-rw-r--r--iosApp/iosApp/Map/MapView.swift23
-rw-r--r--iosApp/iosApp/Units/UnitsView.swift66
-rw-r--r--iosApp/iosApp/iOSApp.swift7
7 files changed, 88 insertions, 77 deletions
diff --git a/iosApp/iosApp.xcodeproj/project.pbxproj b/iosApp/iosApp.xcodeproj/project.pbxproj
index a0d5793..501d272 100644
--- a/iosApp/iosApp.xcodeproj/project.pbxproj
+++ b/iosApp/iosApp.xcodeproj/project.pbxproj
@@ -12,9 +12,9 @@
2152FB042600AC8F00CF470E /* iOSApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2152FB032600AC8F00CF470E /* iOSApp.swift */; };
7555FF83242A565900829871 /* RootView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7555FF82242A565900829871 /* RootView.swift */; };
E33A236027A4FD2C00DD647F /* MapView.swift in Sources */ = {isa = PBXBuildFile; fileRef = E33A235F27A4FD2C00DD647F /* MapView.swift */; };
- E33A236327A5014600DD647F /* SwiftUIX in Frameworks */ = {isa = PBXBuildFile; productRef = E33A236227A5014600DD647F /* SwiftUIX */; };
E33A236527A530F300DD647F /* SmallLabelStyle.swift in Sources */ = {isa = PBXBuildFile; fileRef = E33A236427A530F300DD647F /* SmallLabelStyle.swift */; };
E33A236727A64E4500DD647F /* MarkerTransformations.swift in Sources */ = {isa = PBXBuildFile; fileRef = E33A236627A64E4500DD647F /* MarkerTransformations.swift */; };
+ E33A236A27A6898700DD647F /* SwiftUIX in Frameworks */ = {isa = PBXBuildFile; productRef = E33A236927A6898700DD647F /* SwiftUIX */; };
E38F241527A242870069FC45 /* Inject.swift in Sources */ = {isa = PBXBuildFile; fileRef = E38F241427A242870069FC45 /* Inject.swift */; };
E38F241727A242C70069FC45 /* Resolver.swift in Sources */ = {isa = PBXBuildFile; fileRef = E38F241627A242C70069FC45 /* Resolver.swift */; };
E38F241C27A26DD70069FC45 /* RootViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = E38F241B27A26DD70069FC45 /* RootViewModel.swift */; };
@@ -54,7 +54,7 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
- E33A236327A5014600DD647F /* SwiftUIX in Frameworks */,
+ E33A236A27A6898700DD647F /* SwiftUIX in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -176,7 +176,7 @@
);
name = iosApp;
packageProductDependencies = (
- E33A236227A5014600DD647F /* SwiftUIX */,
+ E33A236927A6898700DD647F /* SwiftUIX */,
);
productName = iosApp;
productReference = 7555FF7B242A565900829871 /* iosApp.app */;
@@ -208,7 +208,7 @@
);
mainGroup = 7555FF72242A565900829871;
packageReferences = (
- E33A236127A5014600DD647F /* XCRemoteSwiftPackageReference "SwiftUIX" */,
+ E33A236827A6898700DD647F /* XCRemoteSwiftPackageReference "SwiftUIX" */,
);
productRefGroup = 7555FF7C242A565900829871 /* Products */;
projectDirPath = "";
@@ -477,20 +477,20 @@
/* End XCConfigurationList section */
/* Begin XCRemoteSwiftPackageReference section */
- E33A236127A5014600DD647F /* XCRemoteSwiftPackageReference "SwiftUIX" */ = {
+ E33A236827A6898700DD647F /* XCRemoteSwiftPackageReference "SwiftUIX" */ = {
isa = XCRemoteSwiftPackageReference;
- repositoryURL = "https://github.com/SwiftUIX/SwiftUIX";
+ repositoryURL = "https://github.com/ivan-avalos/SwiftUIX";
requirement = {
- kind = upToNextMajorVersion;
- minimumVersion = 0.1.1;
+ branch = master;
+ kind = branch;
};
};
/* End XCRemoteSwiftPackageReference section */
/* Begin XCSwiftPackageProductDependency section */
- E33A236227A5014600DD647F /* SwiftUIX */ = {
+ E33A236927A6898700DD647F /* SwiftUIX */ = {
isa = XCSwiftPackageProductDependency;
- package = E33A236127A5014600DD647F /* XCRemoteSwiftPackageReference "SwiftUIX" */;
+ package = E33A236827A6898700DD647F /* XCRemoteSwiftPackageReference "SwiftUIX" */;
productName = SwiftUIX;
};
/* End XCSwiftPackageProductDependency section */
diff --git a/iosApp/iosApp.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/iosApp/iosApp.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved
index c8ce63d..9e38855 100644
--- a/iosApp/iosApp.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved
+++ b/iosApp/iosApp.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved
@@ -3,11 +3,11 @@
"pins": [
{
"package": "SwiftUIX",
- "repositoryURL": "https://github.com/SwiftUIX/SwiftUIX",
+ "repositoryURL": "https://github.com/ivan-avalos/SwiftUIX",
"state": {
- "branch": null,
- "revision": "eb6a23fc4cc79545e40a8cf5c82119684750194f",
- "version": "0.1.1"
+ "branch": "master",
+ "revision": "9b02351a947aa5ac1d2b3a5d576f9591960a89fc",
+ "version": null
}
}
]
diff --git a/iosApp/iosApp.xcodeproj/project.xcworkspace/xcuserdata/avalos.xcuserdatad/UserInterfaceState.xcuserstate b/iosApp/iosApp.xcodeproj/project.xcworkspace/xcuserdata/avalos.xcuserdatad/UserInterfaceState.xcuserstate
index 95d87bd..1ceca8b 100644
--- a/iosApp/iosApp.xcodeproj/project.xcworkspace/xcuserdata/avalos.xcuserdatad/UserInterfaceState.xcuserstate
+++ b/iosApp/iosApp.xcodeproj/project.xcworkspace/xcuserdata/avalos.xcuserdatad/UserInterfaceState.xcuserstate
Binary files differ
diff --git a/iosApp/iosApp/Devices/DevicesView.swift b/iosApp/iosApp/Devices/DevicesView.swift
index 07951fd..48458ca 100644
--- a/iosApp/iosApp/Devices/DevicesView.swift
+++ b/iosApp/iosApp/Devices/DevicesView.swift
@@ -12,33 +12,24 @@ struct DevicesView: View {
@StateObject var unitsViewModel: UnitsViewModel
var body: some View {
- List(selection: $unitsViewModel.selectedUnit) {
- ForEach(unitsViewModel.units, id: \.device.id) { unit in
- DeviceRow(unit: unit, callback: { action in
- switch action {
- case .details:
- print ("Selected details of \(unit.device.name)")
- case .reports:
- print ("Selected reports of \(unit.device.name)")
- case .commands:
- print ("Selected commands of \(unit.device.name)")
- }
- })
- }
- }
-
- .navigationTitle("devices")
- .toolbar {
- ToolbarItem(placement: .navigationBarLeading) {
- Button(action: unitsViewModel.toggleDisplayMode) {
- Image(systemName: "map")
+ List(unitsViewModel.units, id: \.device.id) { unit in
+ DeviceRow(unit: unit, callback: { action in
+ switch action {
+ case .details:
+ print ("Selected details of \(unit.device.name)")
+ case .reports:
+ print ("Selected reports of \(unit.device.name)")
+ case .commands:
+ print ("Selected commands of \(unit.device.name)")
}
- }
- ToolbarItem(placement: .navigationBarTrailing) {
- Button(action: {}) {
- Image(systemName: "person")
+ })
+ .onTapGesture {
+ unitsViewModel.searchQuery = ""
+ unitsViewModel.isEditing = false
+ unitsViewModel.unitsDisplayMode = .map
+ unitsViewModel.selectedUnit = unit
+ UIApplication.shared.endEditing()
}
- }
}
}
}
diff --git a/iosApp/iosApp/Map/MapView.swift b/iosApp/iosApp/Map/MapView.swift
index 3530946..8732ef4 100644
--- a/iosApp/iosApp/Map/MapView.swift
+++ b/iosApp/iosApp/Map/MapView.swift
@@ -12,26 +12,13 @@ struct MapView: View {
@StateObject var unitsViewModel: UnitsViewModel
var body: some View {
- ZStack {
+ VStack {
Text("Unimplemented!")
- }
- .navigationTitle("map")
- .toolbar {
- ToolbarItem(placement: .navigationBarLeading) {
- Button(action: unitsViewModel.toggleDisplayMode) {
- Image(systemName: "list.bullet")
- }
- }
- ToolbarItem(placement: .navigationBarTrailing) {
- Button(action: {}) {
- Image(systemName: "square.stack.3d.up")
- }
- }
- ToolbarItem(placement: .navigationBarTrailing) {
- Button(action: {}) {
- Image(systemName: "person")
- }
+ if let deviceName = unitsViewModel.selectedUnit?.device.name {
+ Text("Selected: \(deviceName)")
+ .padding()
}
+
}
}
}
diff --git a/iosApp/iosApp/Units/UnitsView.swift b/iosApp/iosApp/Units/UnitsView.swift
index fd673a6..fc4952f 100644
--- a/iosApp/iosApp/Units/UnitsView.swift
+++ b/iosApp/iosApp/Units/UnitsView.swift
@@ -15,29 +15,55 @@ struct UnitsView: View {
var body: some View {
NavigationView {
- ZStack {
- switch unitsViewModel.unitsDisplayMode {
- case .list:
- DevicesView(unitsViewModel: unitsViewModel)
- case .map:
- MapView(unitsViewModel: unitsViewModel)
+ TabView(selection: $unitsViewModel.unitsDisplayMode, content: {
+ MapView(unitsViewModel: unitsViewModel)
+ .tabItem {
+ Image(systemName: "map")
+ Text("map")
+ }
+ .tag(UnitsViewModel.UnitsDisplayMode.map)
+ DevicesView(unitsViewModel: unitsViewModel)
+ .tabItem {
+ Image(systemName: "list.bullet")
+ Text("devices")
+ }
+ .tag(UnitsViewModel.UnitsDisplayMode.list)
+ })
+ .navigationTitle(getNavigationTitle(unitsViewModel.unitsDisplayMode))
+ .navigationBarTitleDisplayMode(.inline)
+ .navigationSearchBar {
+ SearchBar(NSLocalizedString("search", comment: ""),
+ text: $unitsViewModel.searchQuery,
+ isEditing: $unitsViewModel.isEditing,
+ onCommit: {})
+ .showsCancelButton(unitsViewModel.isEditing)
+ .onCancel {
+ unitsViewModel.searchQuery = ""
+ }
+ }
+ .navigationSearchBarHiddenWhenScrolling(false)
+ .toolbar {
+ ToolbarItem(placement: .navigationBarTrailing) {
+ Button(action: {}) {
+ Image(systemName: "square.stack.3d.up")
+ }
+ .visible(unitsViewModel.unitsDisplayMode == .map)
+ }
+ ToolbarItem(placement: .navigationBarTrailing) {
+ Button(action: {}) {
+ Image(systemName: "person")
+ }
+ }
}
- }
- .navigationBarTitleDisplayMode(.inline)
- .navigationSearchBar {
- searchBar()
- }
}
}
- private func searchBar () -> SearchBar {
- SearchBar(NSLocalizedString("search", comment: ""),
- text: $unitsViewModel.searchQuery,
- isEditing: $unitsViewModel.isEditing,
- onCommit: {})
- .showsCancelButton(unitsViewModel.isEditing)
- .onCancel {
- unitsViewModel.searchQuery = ""
- }
+ private func getNavigationTitle(_ unitDisplayMode: UnitsViewModel.UnitsDisplayMode) -> LocalizedStringKey {
+ switch unitDisplayMode {
+ case .list:
+ return "devices"
+ case .map:
+ return "map"
+ }
}
}
diff --git a/iosApp/iosApp/iOSApp.swift b/iosApp/iosApp/iOSApp.swift
index 88eb146..9b21276 100644
--- a/iosApp/iosApp/iOSApp.swift
+++ b/iosApp/iosApp/iOSApp.swift
@@ -52,3 +52,10 @@ struct iOSApp: App {
}
}
}
+
+// Source: https://stackoverflow.com/questions/56491386
+extension UIApplication {
+ func endEditing() {
+ sendAction(#selector(UIResponder.resignFirstResponder), to: nil, from: nil, for: nil)
+ }
+}