SwiftUI implementation is fragile, system appearance with
`preferredColorScheme(nil)` is buggy.
Instead, rely on:
- iOS: UIKit → UIWindow.overrideUserInterfaceStyle
- macOS: AppKit → NSApp.appearance
Amends #1077Fixes#1199
The recursive modifiers are overkill. Instead:
- Wrap module routes into a static route type (ProfileRoute)
- Iterate over ModuleDestinationProviding looking for the module that
handles the route
- Return destination views from that module
This way, only `navigationDestination(for: ProfileRoute.self)` is needed
on the parent.
Some useful shortcuts can be replicated in the main profile screen.
Requirements:
- Modules implementing `ModuleDestinationProviding` return a
`navigationDestination()` to navigate to module-specific routes (e.g.
OpenVPN credentials). This was done in #1166
- In order to navigate to the module routes from the main
`ProfileCoordinator` view, it must have a `navigationDestination()`
attached for each of the modules, without knowing the concrete route
types
Here is how this is accomplished in a generic fashion:
1. `ProfileEditor.navigationDestinations()` iterates over each
`ModuleDestinationProviding` to return a list of
`navigationDestination()`, [implemented as a
`ViewModifier`](https://github.com/passepartoutvpn/passepartout/pull/1167/files#diff-11dfcbc4f6c173b133fe8eb4c54710f2ac7161cd38126735c655a8c56a62b8c0R29)
2. With this in place, module routes can be pushed with a
`NavigationLink` from the main profile view
3. Lastly, in the profile view, we add a section for each module
implementing `ModuleShortcutsProviding`, where the module may return a
list of convenient shortcuts, e.g. in the form of the `NavigationLink`
in 2
Start with some OpenVPN entries:
- Provider server
- Credentials (if needed)
Some refactoring was necessary:
- Load ModulePreferences in the module destinations via
ModulePreferencesModifier, rather than in the module view (may revisit
later)
- Due to the above, move "Remote endpoints" from "Configuration" to a
separate destination (also less messy)
- Group complex module views (OpenVPN/WireGuard) into folders
- Reuse `ProviderServerRow` for consistency across modules/shortcuts
Decouple destinations from the module view so that one can navigate to
them from any point of the app. Affects only OpenVPN for now.
Preparation for "profile shortcuts".