From dc85557d4096fb8bd3561c1ae0da404c6707ecd2 Mon Sep 17 00:00:00 2001 From: Thomas Ricouard Date: Fri, 16 Aug 2024 07:24:19 +0200 Subject: [PATCH] Tweak to notifications policy --- .../NotificationsPolicyView.swift | 50 ++++++++----------- 1 file changed, 21 insertions(+), 29 deletions(-) diff --git a/Packages/Notifications/Sources/Notifications/NotificationsPolicyView.swift b/Packages/Notifications/Sources/Notifications/NotificationsPolicyView.swift index f9ca2904..fe0749f0 100644 --- a/Packages/Notifications/Sources/Notifications/NotificationsPolicyView.swift +++ b/Packages/Notifications/Sources/Notifications/NotificationsPolicyView.swift @@ -25,12 +25,8 @@ struct NotificationsPolicyView: View { })) { pickerMenu } label: { - VStack(alignment: .leading) { - Text("notifications.content-filter.peopleYouDontFollow") - Text("Until you manually approve them") - .foregroundStyle(.secondary) - .font(.footnote) - } + makePickerLabel(title: "notifications.content-filter.peopleYouDontFollow", + subtitle: "Until you manually approve them") } Picker(selection: .init(get: { @@ -41,12 +37,8 @@ struct NotificationsPolicyView: View { })) { pickerMenu } label: { - VStack(alignment: .leading) { - Text("notifications.content-filter.peopleNotFollowingYou") - Text("And following you for less than 3 days") - .foregroundStyle(.secondary) - .font(.footnote) - } + makePickerLabel(title: "notifications.content-filter.peopleNotFollowingYou", + subtitle: "And following you for less than 3 days") } Picker(selection: .init(get: { @@ -57,12 +49,8 @@ struct NotificationsPolicyView: View { })) { pickerMenu } label: { - VStack(alignment: .leading) { - Text("notifications.content-filter.newAccounts") - Text("Created within the past 30 days") - .foregroundStyle(.secondary) - .font(.footnote) - } + makePickerLabel(title: "notifications.content-filter.newAccounts", + subtitle: "Created within the past 30 days") } Picker(selection: .init(get: { @@ -73,12 +61,8 @@ struct NotificationsPolicyView: View { })) { pickerMenu } label: { - VStack(alignment: .leading) { - Text("notifications.content-filter.privateMentions") - Text("Unless it's in reply to your own mention or if you follow the sender") - .foregroundStyle(.secondary) - .font(.footnote) - } + makePickerLabel(title: "notifications.content-filter.privateMentions", + subtitle: "Unless it's in reply to your own mention or if you follow the sender") } Picker(selection: .init(get: { @@ -90,10 +74,8 @@ struct NotificationsPolicyView: View { pickerMenu } label: { VStack(alignment: .leading) { - Text("Moderated accounts") - Text("Limited by server moderators") - .foregroundStyle(.secondary) - .font(.footnote) + makePickerLabel(title: "Moderated accounts", + subtitle: "Limited by server moderators") } } } @@ -112,7 +94,7 @@ struct NotificationsPolicyView: View { } .redacted(reason: policy == nil ? .placeholder : []) } - .presentationDetents([.medium]) + .presentationDetents([.height(500)]) .presentationBackground(.thinMaterial) } @@ -121,6 +103,16 @@ struct NotificationsPolicyView: View { Text(policy.rawValue.capitalized) } } + + private func makePickerLabel(title: LocalizedStringKey, subtitle: LocalizedStringKey) -> some View { + VStack(alignment: .leading) { + Text(title) + .font(.callout) + Text(subtitle) + .foregroundStyle(.secondary) + .font(.footnote) + } + } private func getPolicy() async { defer {