[ios] Fix issues with routing options

Signed-off-by: Yannik Bloscheck <git@yannikbloscheck.com>
This commit is contained in:
Yannik Bloscheck
2025-07-10 15:29:28 +02:00
parent 7e63d98cb7
commit 7e2b05573f
6 changed files with 117 additions and 5 deletions

View File

@@ -9,6 +9,13 @@ import UIKit
profileBridgeController.view.backgroundColor = .systemGroupedBackground
return profileBridgeController
}
/// The `RoutingOptionsView` for presentation in an alert
@objc static func routingOptions() -> UIViewController {
let routinOptionsBridgeController = UIHostingController(rootView: RoutingOptionsView())
routinOptionsBridgeController.view.backgroundColor = .systemGroupedBackground
return routinOptionsBridgeController
}
}

View File

@@ -605,6 +605,10 @@ NSString *const kSettingsSegue = @"Map2Settings";
[self.navigationController pushViewController:descriptionViewController animated:YES];
}
- (void)openDrivingOptions {
[self presentViewController:BridgeControllers.routingOptions animated:YES completion:nil];
}
- (void)processMyPositionStateModeEvent:(MWMMyPositionMode)mode {
self.currentPositionMode = mode;
[MWMLocationManager setMyPositionMode:mode];

View File

@@ -16,6 +16,7 @@
272F1F3D2E0EE0C800FA52EF /* ProfileView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 272F1F3C2E0EE0C400FA52EF /* ProfileView.swift */; };
272F1F462E0EEF9400FA52EF /* SafariView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 272F1F452E0EEF8B00FA52EF /* SafariView.swift */; };
2765D1D02E13F9C20005CA2B /* BridgeControllers.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2765D1CD2E13F9BC0005CA2B /* BridgeControllers.swift */; };
27768F482E1FF8880086784A /* RoutingOptionsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 27768F472E1FF8830086784A /* RoutingOptionsView.swift */; };
279367562E1BE16300AA5C3D /* Settings.swift in Sources */ = {isa = PBXBuildFile; fileRef = 279367552E1BE16300AA5C3D /* Settings.swift */; };
2793675A2E1BE17300AA5C3D /* SettingsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 279367592E1BE17300AA5C3D /* SettingsView.swift */; };
27AF184C2E1D5B2D00CD41E2 /* SettingsNavigationView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 27AF184B2E1D5A2700CD41E2 /* SettingsNavigationView.swift */; };
@@ -775,6 +776,7 @@
272F1F3C2E0EE0C400FA52EF /* ProfileView.swift */ = {isa = PBXFileReference; indentWidth = 4; lastKnownFileType = sourcecode.swift; path = ProfileView.swift; sourceTree = "<group>"; tabWidth = 4; };
272F1F452E0EEF8B00FA52EF /* SafariView.swift */ = {isa = PBXFileReference; indentWidth = 4; lastKnownFileType = sourcecode.swift; path = SafariView.swift; sourceTree = "<group>"; tabWidth = 4; };
2765D1CD2E13F9BC0005CA2B /* BridgeControllers.swift */ = {isa = PBXFileReference; indentWidth = 4; lastKnownFileType = sourcecode.swift; path = BridgeControllers.swift; sourceTree = "<group>"; tabWidth = 4; };
27768F472E1FF8830086784A /* RoutingOptionsView.swift */ = {isa = PBXFileReference; indentWidth = 4; lastKnownFileType = sourcecode.swift; path = RoutingOptionsView.swift; sourceTree = "<group>"; tabWidth = 4; };
279367552E1BE16300AA5C3D /* Settings.swift */ = {isa = PBXFileReference; indentWidth = 4; lastKnownFileType = sourcecode.swift; path = Settings.swift; sourceTree = "<group>"; tabWidth = 4; };
279367592E1BE17300AA5C3D /* SettingsView.swift */ = {isa = PBXFileReference; indentWidth = 4; lastKnownFileType = sourcecode.swift; name = SettingsView.swift; path = UI/Settings/SettingsView.swift; sourceTree = SOURCE_ROOT; tabWidth = 4; };
27AF184B2E1D5A2700CD41E2 /* SettingsNavigationView.swift */ = {isa = PBXFileReference; indentWidth = 4; lastKnownFileType = sourcecode.swift; path = SettingsNavigationView.swift; sourceTree = "<group>"; tabWidth = 4; };
@@ -1946,6 +1948,14 @@
path = Model;
sourceTree = "<group>";
};
27768F442E1FF8620086784A /* Routing */ = {
isa = PBXGroup;
children = (
27768F472E1FF8830086784A /* RoutingOptionsView.swift */,
);
path = Routing;
sourceTree = "<group>";
};
27AF185B2E1DB64B00CD41E2 /* Settings Types */ = {
isa = PBXGroup;
children = (
@@ -3611,6 +3621,7 @@
F6E2FBFB1E097B9F0083EBEC /* UI */ = {
isa = PBXGroup;
children = (
27768F442E1FF8620086784A /* Routing */,
ED9857022C4ECFFC00694F6C /* MailComposer */,
ED43B8B92C12061600D07BAA /* DocumentPicker */,
ED99667C2B94FBC20083CE55 /* ColorPicker */,
@@ -4611,6 +4622,7 @@
EDC4E34C2C5D1BEF009286A2 /* RecentlyDeletedCategoriesViewModel.swift in Sources */,
F62607FD207B790300176C5A /* SpinnerAlert.swift in Sources */,
3444DFD21F17620C00E73099 /* MWMMapWidgetsHelper.mm in Sources */,
27768F482E1FF8880086784A /* RoutingOptionsView.swift in Sources */,
3472B5E1200F86C800DC6CD5 /* MWMEditorHelper.mm in Sources */,
99F3EB1123F418C900C713F8 /* PlacePageBuilder.swift in Sources */,
4735008A23A83CF700661A95 /* DownloadedMapsDataSource.swift in Sources */,

View File

@@ -287,7 +287,9 @@ import Combine
return RoutingOptions().avoidToll
}
set {
RoutingOptions().avoidToll = newValue
var routingOptions = RoutingOptions()
routingOptions.avoidToll = newValue
routingOptions.save()
}
}
@@ -298,7 +300,9 @@ import Combine
return RoutingOptions().avoidDirty
}
set {
RoutingOptions().avoidDirty = newValue
var routingOptions = RoutingOptions()
routingOptions.avoidDirty = newValue
routingOptions.save()
}
}
@@ -309,7 +313,9 @@ import Combine
return RoutingOptions().avoidFerry
}
set {
RoutingOptions().avoidFerry = newValue
var routingOptions = RoutingOptions()
routingOptions.avoidFerry = newValue
routingOptions.save()
}
}
@@ -320,7 +326,9 @@ import Combine
return RoutingOptions().avoidMotorway
}
set {
RoutingOptions().avoidMotorway = newValue
var routingOptions = RoutingOptions()
routingOptions.avoidMotorway = newValue
routingOptions.save()
}
}

View File

@@ -0,0 +1,81 @@
import SwiftUI
/// View for the routing options
struct RoutingOptionsView: View {
// MARK: - Properties
/// The dismiss action of the environment
@Environment(\.dismiss) private var dismiss
/// If toll roads should be avoided during routing
@State var shouldAvoidTollRoadsWhileRouting: Bool = false
/// If unpaved roads should be avoided during routing
@State var shouldAvoidUnpavedRoadsWhileRouting: Bool = false
/// If ferries should be avoided during routing
@State var shouldAvoidFerriesWhileRouting: Bool = false
/// If motorways should be avoided during routing
@State var shouldAvoidMotorwaysWhileRouting: Bool = false
/// The actual view
var body: some View {
NavigationView {
List {
Section {
Toggle("avoid_tolls", isOn: $shouldAvoidTollRoadsWhileRouting)
.tint(.accent)
Toggle("avoid_unpaved", isOn: $shouldAvoidUnpavedRoadsWhileRouting)
.tint(.accent)
Toggle("avoid_ferry", isOn: $shouldAvoidFerriesWhileRouting)
.tint(.accent)
Toggle("avoid_motorways", isOn: $shouldAvoidMotorwaysWhileRouting)
.tint(.accent)
}
}
.navigationTitle(String(localized: "driving_options_title"))
.navigationBarTitleDisplayMode(.inline)
.toolbar {
ToolbarItem(placement: .confirmationAction) {
Button {
dismiss()
} label: {
Text("close")
}
}
}
}
.navigationViewStyle(StackNavigationViewStyle())
.onAppear {
shouldAvoidTollRoadsWhileRouting = Settings.shouldAvoidTollRoadsWhileRouting
shouldAvoidUnpavedRoadsWhileRouting = Settings.shouldAvoidUnpavedRoadsWhileRouting
shouldAvoidFerriesWhileRouting = Settings.shouldAvoidFerriesWhileRouting
shouldAvoidMotorwaysWhileRouting = Settings.shouldAvoidMotorwaysWhileRouting
}
.onChange(of: shouldAvoidTollRoadsWhileRouting) { changedShouldAvoidTollRoadsWhileRouting in
Settings.shouldAvoidTollRoadsWhileRouting = changedShouldAvoidTollRoadsWhileRouting
}
.onChange(of: shouldAvoidUnpavedRoadsWhileRouting) { changedShouldAvoidUnpavedRoadsWhileRouting in
Settings.shouldAvoidUnpavedRoadsWhileRouting = changedShouldAvoidUnpavedRoadsWhileRouting
}
.onChange(of: shouldAvoidUnpavedRoadsWhileRouting) { changedShouldAvoidUnpavedRoadsWhileRouting in
Settings.shouldAvoidUnpavedRoadsWhileRouting = changedShouldAvoidUnpavedRoadsWhileRouting
}
.onChange(of: shouldAvoidFerriesWhileRouting) { changedShouldAvoidFerriesWhileRouting in
Settings.shouldAvoidFerriesWhileRouting = changedShouldAvoidFerriesWhileRouting
}
.onChange(of: shouldAvoidMotorwaysWhileRouting) { changedShouldAvoidMotorwaysWhileRouting in
Settings.shouldAvoidMotorwaysWhileRouting = changedShouldAvoidMotorwaysWhileRouting
}
.accentColor(.alternativeAccent)
}
}

View File

@@ -1,6 +1,6 @@
import SwiftUI
/// View for thenavigation settings
/// View for the navigation settings
struct SettingsNavigationView: View {
// MARK: - Properties