Add headers to active/inactive profile sections

Hide inactive section if empty.
This commit is contained in:
Davide De Rosa 2022-04-25 16:04:56 +02:00
parent 339183c156
commit ac1239daa8
3 changed files with 19 additions and 4 deletions

View File

@ -467,6 +467,8 @@ internal enum L10n {
internal static let port = L10n.tr("Localizable", "global.strings.port") internal static let port = L10n.tr("Localizable", "global.strings.port")
/// Private key /// Private key
internal static let privateKey = L10n.tr("Localizable", "global.strings.private_key") internal static let privateKey = L10n.tr("Localizable", "global.strings.private_key")
/// Profiles
internal static let profiles = L10n.tr("Localizable", "global.strings.profiles")
/// Protocol /// Protocol
internal static let `protocol` = L10n.tr("Localizable", "global.strings.protocol") internal static let `protocol` = L10n.tr("Localizable", "global.strings.protocol")
/// Protocols /// Protocols
@ -698,6 +700,10 @@ internal enum L10n {
/// No profiles /// No profiles
internal static let noProfiles = L10n.tr("Localizable", "organizer.empty.no_profiles") internal static let noProfiles = L10n.tr("Localizable", "organizer.empty.no_profiles")
} }
internal enum Sections {
/// In use
internal static let active = L10n.tr("Localizable", "organizer.sections.active")
}
} }
internal enum Paywall { internal enum Paywall {

View File

@ -74,14 +74,21 @@ extension OrganizerView {
private var mainView: some View { private var mainView: some View {
List { List {
activeHeaders.map { headers in activeHeaders.map { headers in
Section { Section(
header: Text(L10n.Organizer.Sections.active)
) {
ForEach(headers, content: profileButton(forHeader:)) ForEach(headers, content: profileButton(forHeader:))
.onDelete(perform: removeActiveProfile) .onDelete(perform: removeActiveProfile)
} }
} }
Section { let headers = otherHeaders
ForEach(otherHeaders, content: profileButton(forHeader:)) if !headers.isEmpty {
.onDelete(perform: removeOtherProfiles) Section(
header: Text(L10n.Global.Strings.profiles)
) {
ForEach(headers, content: profileButton(forHeader:))
.onDelete(perform: removeOtherProfiles)
}
} }
}.themeAnimation(on: profileManager.headers) }.themeAnimation(on: profileManager.headers)
} }

View File

@ -15,6 +15,7 @@
"global.strings.add" = "Add"; "global.strings.add" = "Add";
"global.strings.default" = "Default"; "global.strings.default" = "Default";
"global.strings.name" = "Name"; "global.strings.name" = "Name";
"global.strings.profiles" = "Profiles";
"global.strings.provider" = "Provider"; "global.strings.provider" = "Provider";
"global.strings.providers" = "Providers"; "global.strings.providers" = "Providers";
"global.strings.configuration" = "Configuration"; "global.strings.configuration" = "Configuration";
@ -113,6 +114,7 @@
/* MARK: OrganizerView */ /* MARK: OrganizerView */
"organizer.sections.active" = "In use";
"organizer.empty.no_profiles" = "No profiles"; "organizer.empty.no_profiles" = "No profiles";
"organizer.alerts.reddit.message" = "Did you know that Passepartout has a subreddit? Subscribe for updates or to discuss issues, features, new platforms or whatever you like.\n\nIt's also a great way to show you care about this project."; "organizer.alerts.reddit.message" = "Did you know that Passepartout has a subreddit? Subscribe for updates or to discuss issues, features, new platforms or whatever you like.\n\nIt's also a great way to show you care about this project.";