Skip to content

Commit

Permalink
Move more views to UILibrary
Browse files Browse the repository at this point in the history
- Refactor about to single coordinator + platform views
- Refactor debug log to single view + content views
- Take out debug log routes from about routes
- Rename Settings* to Preferences*
- Reuse empty modifier in debug log
- Fix a visual bug in .themeTrailingValue()
  • Loading branch information
keeshux committed Nov 23, 2024
1 parent a301806 commit f4dc0ff
Show file tree
Hide file tree
Showing 29 changed files with 464 additions and 422 deletions.
2 changes: 1 addition & 1 deletion Passepartout/App/Platforms/App+macOS.swift
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ extension PassepartoutApp {
.defaultSize(width: 600, height: 400)

Settings {
SettingsView(profileManager: context.profileManager)
PreferencesView(profileManager: context.profileManager)
.frame(minWidth: 300, minHeight: 300)
.withEnvironment(from: context, theme: theme)
.environmentObject(settings)
Expand Down
2 changes: 1 addition & 1 deletion Passepartout/Library/Sources/AppUIMain/Domain/Issue.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
// along with Passepartout. If not, see <http://www.gnu.org/licenses/>.
//

#if os(iOS)
#if os(iOS) || os(tvOS)

import CommonLibrary
import Foundation
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
//
// AboutCoordinator.swift
// Passepartout
//
// Created by Davide De Rosa on 8/22/24.
// Copyright (c) 2024 Davide De Rosa. All rights reserved.
//
// https://github.com/passepartoutvpn
//
// This file is part of Passepartout.
//
// Passepartout is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Passepartout is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Passepartout. If not, see <http://www.gnu.org/licenses/>.
//

import CommonLibrary
import PassepartoutKit
import SwiftUI
import UILibrary

struct AboutCoordinator: View {

@EnvironmentObject
private var iapManager: IAPManager

@Environment(\.dismiss)
private var dismiss

let profileManager: ProfileManager

let tunnel: ExtendedTunnel

@State
private var path = NavigationPath()

@State
private var navigationRoute: AboutCoordinatorRoute?

var body: some View {
AboutContentView(
profileManager: profileManager,
isRestricted: iapManager.isRestricted,
path: $path,
navigationRoute: $navigationRoute,
linkContent: linkView(to:),
aboutDestination: pushDestination(for:),
logDestination: pushDestination(for:)
)
}
}

extension AboutCoordinator {
func linkView(to route: AboutCoordinatorRoute) -> some View {
NavigationLink(title(for: route), value: route)
}

func title(for route: AboutCoordinatorRoute) -> String {
switch route {
case .credits:
return Strings.Views.About.Credits.title

case .diagnostics:
return Strings.Views.Diagnostics.title

case .donate:
return Strings.Views.Donate.title

case .links:
return Strings.Views.About.Links.title
}
}

@ViewBuilder
func pushDestination(for item: AboutCoordinatorRoute?) -> some View {
switch item {
case .credits:
CreditsView()

case .diagnostics:
DiagnosticsView(profileManager: profileManager, tunnel: tunnel)

case .donate:
DonateView()

case .links:
LinksView()

default:
Text(Strings.Global.noSelection)
.themeEmptyMessage()
}
}

@ViewBuilder
func pushDestination(for item: DebugLogRoute?) -> some View {
switch item {
case .app(let title):
DebugLogView(withAppParameters: Constants.shared.log) {
DebugLogContentView(lines: $0)
}
.navigationTitle(title)

case .tunnel(let title, let url):
if let url {
DebugLogView(withURL: url) {
DebugLogContentView(lines: $0)
}
.navigationTitle(title)
} else {
DebugLogView(withTunnel: tunnel, parameters: Constants.shared.log) {
DebugLogContentView(lines: $0)
}
.navigationTitle(title)
}

default:
Text(Strings.Global.noSelection)
.themeEmptyMessage()
}
}
}

#Preview {
AboutCoordinator(
profileManager: .mock,
tunnel: .mock
)
.withMockEnvironment()
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
//
// AboutRouterView+iOS.swift
// AboutCoordinatorRoute.swift
// Passepartout
//
// Created by Davide De Rosa on 8/26/24.
// Created by Davide De Rosa on 11/23/24.
// Copyright (c) 2024 Davide De Rosa. All rights reserved.
//
// https://github.com/passepartoutvpn
Expand All @@ -23,21 +23,14 @@
// along with Passepartout. If not, see <http://www.gnu.org/licenses/>.
//

#if os(iOS)
import Foundation

import CommonLibrary
import SwiftUI
enum AboutCoordinatorRoute: Hashable {
case credits

extension AboutRouterView {
var body: some View {
AboutView(
profileManager: profileManager,
navigationRoute: $navigationRoute
)
.navigationDestination(for: NavigationRoute.self, destination: pushDestination)
.themeNavigationDetail()
.themeNavigationStack(closable: true, path: $path)
}
}
case diagnostics

case donate

#endif
case links
}

This file was deleted.

76 changes: 0 additions & 76 deletions Passepartout/Library/Sources/AppUIMain/Views/About/AboutView.swift

This file was deleted.

Loading

0 comments on commit f4dc0ff

Please sign in to comment.