Inform about use of profile name in Shortcuts (#954)

Now that Siri is superseded by the more general Shortcuts automations,
add an informational footer below the "Name" field of the profile
editor.
This commit is contained in:
Davide 2024-11-27 15:30:15 +01:00 committed by GitHub
parent b4caa26a47
commit 8f778faa5d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
9 changed files with 79 additions and 14 deletions

View File

@ -0,0 +1,41 @@
//
// ProfileNameSection.swift
// Passepartout
//
// Created by Davide De Rosa on 11/27/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 SwiftUI
import UILibrary
struct ProfileNameSection: View {
@Binding
var name: String
var body: some View {
NameSection(
name: $name,
placeholder: Strings.Placeholders.Profile.name,
footer: Strings.Views.Profile.Sections.Name.footer
)
}
}

View File

@ -53,9 +53,8 @@ struct ProfileEditView: View, Routable {
var body: some View {
debugChanges()
return List {
NameSection(
name: $profileEditor.profile.name,
placeholder: Strings.Placeholders.Profile.name
ProfileNameSection(
name: $profileEditor.profile.name
)
modulesSection
StorageSection(

View File

@ -38,9 +38,8 @@ struct ProfileGeneralView: View {
var body: some View {
Form {
NameSection(
name: $profileEditor.profile.name,
placeholder: Strings.Placeholders.Profile.name
ProfileNameSection(
name: $profileEditor.profile.name
)
StorageSection(
profileEditor: profileEditor,

View File

@ -98,7 +98,7 @@ private extension ProviderContentModifier {
HStack {
lastUpdatedString.map {
Text($0)
.foregroundStyle(.secondary)
.themeFooter()
}
Spacer()
RefreshInfrastructureButton(apis: apis, providerId: providerId)

View File

@ -804,6 +804,12 @@ public enum Strings {
/// Add module
public static let addModule = Strings.tr("Localizable", "views.profile.rows.add_module", fallback: "Add module")
}
public enum Sections {
public enum Name {
/// Use this name to create your VPN automations from the Shortcuts app.
public static let footer = Strings.tr("Localizable", "views.profile.sections.name.footer", fallback: "Use this name to create your VPN automations from the Shortcuts app.")
}
}
}
public enum Providers {
/// Clear filters

View File

@ -99,6 +99,7 @@
"views.preferences.erase_icloud" = "Erase iCloud store";
"views.preferences.erase_icloud.footer" = "To erase the iCloud store securely, do so on all your synced devices. This will not affect local profiles.";
"views.profile.sections.name.footer" = "Use this name to create your VPN automations from the Shortcuts app.";
"views.profile.rows.add_module" = "Add module";
"views.profile.module_list.section.footer" = "Drag modules to rearrange them, as their order determines priority.";
"views.profile.alerts.purchase.buttons.ok" = "Save anyway";

View File

@ -91,8 +91,7 @@ extension ThemeRowWithFooterModifier {
footer.map {
Text($0)
.foregroundStyle(.secondary)
.font(.subheadline)
.themeFooter()
.frame(maxWidth: .infinity, alignment: .leading)
}
}

View File

@ -143,6 +143,11 @@ extension View {
modifier(ThemeRowWithFooterModifier(footer: footer))
}
public func themeFooter() -> some View {
foregroundStyle(.secondary)
.font(.subheadline)
}
public func themeSectionWithSingleRow(header: String? = nil, footer: String, above: Bool = false) -> some View {
Group {
if above {

View File

@ -25,21 +25,36 @@
import SwiftUI
struct NameSection: View {
public struct NameSection: View {
@Binding
var name: String
private var name: String
let placeholder: String
private let placeholder: String
var body: some View {
private let footer: String?
public init(name: Binding<String>, placeholder: String, footer: String? = nil) {
_name = name
self.placeholder = placeholder
self.footer = footer
}
public var body: some View {
debugChanges()
return Group {
ThemeTextField(Strings.Global.Nouns.name, text: $name, placeholder: placeholder)
.labelsHidden()
.themeManualInput()
#if os(macOS)
footer.map {
Text($0)
.themeFooter()
}
#endif
}
.themeSection(header: Strings.Global.Nouns.name)
.themeSection(header: Strings.Global.Nouns.name, footer: footer)
}
}