Skip to content

Commit 959555a

Browse files
committed
Regroup module extensions
Move OpenVPNView.Subroute to OpenVPNModule for explicit prefix.
1 parent 8e5141f commit 959555a

File tree

8 files changed

+52
-54
lines changed

8 files changed

+52
-54
lines changed
Lines changed: 1 addition & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//
2-
// OpenVPNModule+Extensions.swift
2+
// OpenVPN+Previews.swift
33
// Passepartout
44
//
55
// Created by Davide De Rosa on 2/17/24.
@@ -25,42 +25,6 @@
2525

2626
import PassepartoutKit
2727
import SwiftUI
28-
import UILibrary
29-
30-
extension OpenVPNModule.Builder: ModuleViewProviding {
31-
public func moduleView(with parameters: ModuleViewParameters) -> some View {
32-
OpenVPNView(module: self, parameters: parameters)
33-
}
34-
}
35-
36-
extension OpenVPNModule: ProviderServerCoordinatorSupporting {
37-
}
38-
39-
// MARK: - Shortcuts
40-
41-
extension OpenVPNModule.Builder: ModuleShortcutsProviding {
42-
public var isVisible: Bool {
43-
providerSelection != nil || configurationBuilder?.authUserPass == true
44-
}
45-
46-
@ViewBuilder
47-
public func moduleShortcutsView(editor: ProfileEditor, path: Binding<NavigationPath>) -> some View {
48-
if let providerSelection {
49-
// ProviderNameRow(id: providerSelection.id)
50-
NavigationLink(value: ProfileRoute(OpenVPNView.Subroute.providerServer)) {
51-
ProviderServerRow(selectedEntity: providerSelection.entity)
52-
}
53-
.uiAccessibility(.Profile.providerServerLink)
54-
}
55-
if providerSelection != nil || configurationBuilder?.authUserPass == true {
56-
NavigationLink(value: ProfileRoute(OpenVPNView.Subroute.credentials)) {
57-
Text(Strings.Modules.Openvpn.credentials)
58-
}
59-
}
60-
}
61-
}
62-
63-
// MARK: - Previews
6428

6529
// swiftlint: disable force_try
6630
extension OpenVPN.Configuration.Builder {
Lines changed: 41 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//
2-
// OpenVPNModule+Destination.swift
2+
// OpenVPNModule+UI.swift
33
// Passepartout
44
//
55
// Created by Davide De Rosa on 2/12/25.
@@ -28,7 +28,18 @@ import CommonUtils
2828
import PassepartoutKit
2929
import SwiftUI
3030

31-
extension OpenVPNView {
31+
extension OpenVPNModule.Builder: ModuleViewProviding {
32+
public func moduleView(with parameters: ModuleViewParameters) -> some View {
33+
OpenVPNView(module: self, parameters: parameters)
34+
}
35+
}
36+
37+
extension OpenVPNModule: ProviderServerCoordinatorSupporting {
38+
}
39+
40+
// MARK: - Destination
41+
42+
extension OpenVPNModule {
3243
enum Subroute: Hashable {
3344
case providerServer
3445

@@ -44,23 +55,23 @@ extension OpenVPNView {
4455

4556
extension OpenVPNModule.Builder: ModuleDestinationProviding {
4657
public func handlesRoute(_ route: AnyHashable) -> Bool {
47-
route is OpenVPNView.Subroute
58+
route is OpenVPNModule.Subroute
4859
}
4960

5061
public func moduleDestination(
5162
for route: AnyHashable,
5263
with parameters: ModuleDestinationParameters,
5364
path: Binding<NavigationPath>
5465
) -> some View {
55-
(route as? OpenVPNView.Subroute)
66+
(route as? OpenVPNModule.Subroute)
5667
.map {
5768
DestinationView(route: $0, parameters: parameters, path: path)
5869
}
5970
}
6071
}
6172

6273
private struct DestinationView: View {
63-
let route: OpenVPNView.Subroute
74+
let route: OpenVPNModule.Subroute
6475

6576
let parameters: ModuleDestinationParameters
6677

@@ -112,7 +123,7 @@ private struct DestinationView: View {
112123
OpenVPNView.RemotesView(
113124
endpoints: endpoints,
114125
excludedEndpoints: excludedEndpoints,
115-
remotesRoute: draft.wrappedValue.providerSelection == nil ? ProfileRoute(OpenVPNView.Subroute.editRemotes) : nil
126+
remotesRoute: draft.wrappedValue.providerSelection == nil ? ProfileRoute(OpenVPNModule.Subroute.editRemotes) : nil
116127
)
117128

118129
case .editRemotes:
@@ -172,3 +183,27 @@ private extension DestinationView {
172183
}
173184
}
174185
}
186+
187+
// MARK: - Shortcuts
188+
189+
extension OpenVPNModule.Builder: ModuleShortcutsProviding {
190+
public var isVisible: Bool {
191+
providerSelection != nil || configurationBuilder?.authUserPass == true
192+
}
193+
194+
@ViewBuilder
195+
public func moduleShortcutsView(editor: ProfileEditor, path: Binding<NavigationPath>) -> some View {
196+
if let providerSelection {
197+
// ProviderNameRow(id: providerSelection.id)
198+
NavigationLink(value: ProfileRoute(OpenVPNModule.Subroute.providerServer)) {
199+
ProviderServerRow(selectedEntity: providerSelection.entity)
200+
}
201+
.uiAccessibility(.Profile.providerServerLink)
202+
}
203+
if providerSelection != nil || configurationBuilder?.authUserPass == true {
204+
NavigationLink(value: ProfileRoute(OpenVPNModule.Subroute.credentials)) {
205+
Text(Strings.Modules.Openvpn.credentials)
206+
}
207+
}
208+
}
209+
}

Packages/App/Sources/AppUIMain/Views/Modules/OpenVPN/OpenVPNView.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ private extension OpenVPNView {
9292
ConfigurationView(
9393
isServerPushed: isServerPushed,
9494
configuration: configuration,
95-
credentialsRoute: ProfileRoute(Subroute.credentials)
95+
credentialsRoute: ProfileRoute(OpenVPNModule.Subroute.credentials)
9696
)
9797
} else {
9898
emptyConfigurationView
@@ -111,11 +111,11 @@ private extension OpenVPNView {
111111
}
112112

113113
func remotesLink(with endpoints: [ExtendedEndpoint]) -> some View {
114-
NavigationLink(Strings.Modules.Openvpn.remotes, value: ProfileRoute(Subroute.remotes(endpoints)))
114+
NavigationLink(Strings.Modules.Openvpn.remotes, value: ProfileRoute(OpenVPNModule.Subroute.remotes(endpoints)))
115115
}
116116

117117
func providerConfigurationLink(with configuration: OpenVPN.Configuration) -> some View {
118-
NavigationLink(Strings.Global.Nouns.configuration, value: ProfileRoute(Subroute.providerConfiguration(configuration)))
118+
NavigationLink(Strings.Global.Nouns.configuration, value: ProfileRoute(OpenVPNModule.Subroute.providerConfiguration(configuration)))
119119
}
120120

121121
var importButton: some View {
@@ -129,7 +129,7 @@ private extension OpenVPNView {
129129
providerId: providerId,
130130
providerPreferences: nil,
131131
selectedEntity: providerEntity,
132-
entityDestination: ProfileRoute(Subroute.providerServer),
132+
entityDestination: ProfileRoute(OpenVPNModule.Subroute.providerServer),
133133
paywallReason: $paywallReason,
134134
providerRows: {
135135
moduleGroup(for: providerAccountRows)
@@ -138,7 +138,7 @@ private extension OpenVPNView {
138138
}
139139

140140
var providerAccountRows: [ModuleRow]? {
141-
[.push(caption: Strings.Modules.Openvpn.credentials, route: HashableRoute(ProfileRoute(Subroute.credentials)))]
141+
[.push(caption: Strings.Modules.Openvpn.credentials, route: HashableRoute(ProfileRoute(OpenVPNModule.Subroute.credentials)))]
142142
}
143143
}
144144

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//
2-
// DNSModule+Extensions.swift
2+
// DNSModule+UI.swift
33
// Passepartout
44
//
55
// Created by Davide De Rosa on 2/17/24.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//
2-
// HTTPProxyModule+Extensions.swift
2+
// HTTPProxyModule+UI.swift
33
// Passepartout
44
//
55
// Created by Davide De Rosa on 2/17/24.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//
2-
// IPModule+Extensions.swift
2+
// IPModule+UI.swift
33
// Passepartout
44
//
55
// Created by Davide De Rosa on 2/17/24.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//
2-
// OnDemandModule+Extensions.swift
2+
// OnDemandModule+UI.swift
33
// Passepartout
44
//
55
// Created by Davide De Rosa on 2/23/24.
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//
2-
// WireGuardModule+Extensions.swift
2+
// WireGuardModule+UI.swift
33
// Passepartout
44
//
55
// Created by Davide De Rosa on 7/31/24.
@@ -26,7 +26,6 @@
2626
import CommonUtils
2727
import PassepartoutKit
2828
import SwiftUI
29-
import UILibrary
3029

3130
extension WireGuardModule.Builder: ModuleViewProviding {
3231
public func moduleView(with parameters: ModuleViewParameters) -> some View {

0 commit comments

Comments
 (0)