Skip to content

Commit

Permalink
1.1.2 RC
Browse files Browse the repository at this point in the history
  • Loading branch information
Constantin Clerc committed Feb 22, 2024
1 parent 20880f3 commit 4de4b23
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 78 deletions.
4 changes: 2 additions & 2 deletions Geranium.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -835,7 +835,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 1.1.1;
MARKETING_VERSION = 1.1.2;
PRODUCT_BUNDLE_IDENTIFIER = live.cclerc.geranium;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_EMIT_LOC_STRINGS = YES;
Expand Down Expand Up @@ -874,7 +874,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 1.1.1;
MARKETING_VERSION = 1.1.2;
PRODUCT_BUNDLE_IDENTIFIER = live.cclerc.geranium;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_EMIT_LOC_STRINGS = YES;
Expand Down
37 changes: 0 additions & 37 deletions Geranium/LocSim/LocSimManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -73,40 +73,3 @@ extension LocationModel: CLLocationManagerDelegate {
self.authorisationStatus = status
}
}


func extractCoordinates(from url: String) -> (latitude: Double, longitude: Double)? {
var latitude: Double = 0.0
var longitude: Double = 0.0

if url.contains("maps.google") {
// Extracting coordinates from Google Maps link
if let range = url.range(of: #"@([-+]?\d*\.\d+),([-+]?\d*\.\d+)"#, options: .regularExpression) {
let coordinates = url[range]
.dropFirst()
.split(separator: ",")
.map { Double($0)! }
if coordinates.count == 2 {
latitude = coordinates[0]
longitude = coordinates[1]
}
}
} else if url.contains("maps.apple") {
// Extracting coordinates from Apple Maps link
if let range = url.range(of: #"&ll=([-+]?\d*\.\d+),([-+]?\d*\.\d+)&"#, options: .regularExpression) {
let coordinates = url[range]
.dropFirst(4)
.dropLast(1)
.split(separator: ",")
.map { Double($0)! }
if coordinates.count == 2 {
latitude = coordinates[0]
longitude = coordinates[1]
}
}
} else {
return nil // Unsupported URL
}

return (latitude, longitude)
}
42 changes: 3 additions & 39 deletions Geranium/LocSim/LocSimView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ struct LocSimView: View {
@State private var appliedCust: Bool = false
@State private var latTemp = ""
@State private var longTemp = ""
@State private var stringTemp = ""
@State private var urldetected = false
var body: some View {
if #available(iOS 16.0, *) {
NavigationStack {
Expand All @@ -41,7 +39,6 @@ struct LocSimView: View {
CLLocationManager().requestAlwaysAuthorization()
}
}
.ignoresSafeArea(.keyboard)
.onAppear {
LocationModel().requestAuthorisation()
}
Expand Down Expand Up @@ -113,25 +110,8 @@ struct LocSimView: View {
}
}
.alert("Enter your coordinates", isPresented: $appliedCust) {
if let url = UIPasteboard.general.string {
if url.contains("maps.google") || url.contains("maps.apple") {
TextField("Enter your URL here...", text: $stringTemp)
.onChange(of: stringTemp) { newValue in
var coordinates = extractCoordinates(from: stringTemp)
lat = coordinates!.latitude
long = coordinates!.longitude
urldetected = true
}
}
else {
TextField("Latitude", text: $latTemp)
TextField("Longitude", text: $longTemp)
}
}
else {
TextField("Latitude", text: $latTemp)
TextField("Longitude", text: $longTemp)
}
TextField("Latitude", text: $latTemp)
TextField("Longitude", text: $longTemp)
Button("OK", action: submit)
} message: {
Text("The location will be simulated on device\nPro tip: Press wherever on the map to move there.")
Expand All @@ -141,24 +121,8 @@ struct LocSimView: View {
}
}
func submit() {
if !latTemp.isEmpty, !longTemp.isEmpty, !urldetected {
if !latTemp.isEmpty, !longTemp.isEmpty {
LocSimManager.startLocSim(location: .init(latitude: Double(latTemp) ?? 0.0, longitude: Double(longTemp) ?? 0.0))
AlertKitAPI.present(
title: "Started !",
icon: .done,
style: .iOS17AppleMusic,
haptic: .success
)
}
if urldetected {
LocSimManager.startLocSim(location: .init(latitude: lat, longitude: long))
urldetected = false
AlertKitAPI.present(
title: "Started !",
icon: .done,
style: .iOS17AppleMusic,
haptic: .success
)
}
else {
UIApplication.shared.alert(body: "Those are empty coordinates mate !")
Expand Down

0 comments on commit 4de4b23

Please sign in to comment.