From 5dcb98d19401af57a844f7b9332f5f13720b330d Mon Sep 17 00:00:00 2001 From: Daniel Saidi Date: Mon, 4 Mar 2024 15:09:04 +0100 Subject: [PATCH] Add label titles to alignment and font size picker --- .../Alignment/RichTextAlignment+Picker.swift | 4 +- .../Fonts/RichTextFont+Picker.swift | 47 +++++++++++-------- .../Fonts/RichTextFont+SizePicker.swift | 15 ++---- .../Sharing/RichTextNSSharingMenu.swift | 2 +- 4 files changed, 34 insertions(+), 34 deletions(-) diff --git a/Sources/RichTextKit/Alignment/RichTextAlignment+Picker.swift b/Sources/RichTextKit/Alignment/RichTextAlignment+Picker.swift index 5f62258be..fb7860ada 100644 --- a/Sources/RichTextKit/Alignment/RichTextAlignment+Picker.swift +++ b/Sources/RichTextKit/Alignment/RichTextAlignment+Picker.swift @@ -39,14 +39,12 @@ public extension RichTextAlignment { private var selection: RichTextAlignment public var body: some View { - SwiftUI.Picker("", selection: $selection) { + SwiftUI.Picker(RTKL10n.textAlignment.text, selection: $selection) { ForEach(values) { value in value.label .labelStyle(.iconOnly) } } - .labelsHidden() - .accessibilityLabel(RTKL10n.textAlignment.text) } } } diff --git a/Sources/RichTextKit/Fonts/RichTextFont+Picker.swift b/Sources/RichTextKit/Fonts/RichTextFont+Picker.swift index 9f2ac32ef..682e0f012 100644 --- a/Sources/RichTextKit/Fonts/RichTextFont+Picker.swift +++ b/Sources/RichTextKit/Fonts/RichTextFont+Picker.swift @@ -118,27 +118,34 @@ extension View { func withPreviewPickerStyles() -> some View { NavigationView { - VStack(spacing: 10) { - self.label("Default") - self.pickerStyle(.automatic).label(".automatic") - self.pickerStyle(.inline).label(".inline") - #if iOS || macOS - self.pickerStyle(.menu).label(".menu") - #endif - if #available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *) { - pickerStyle(.navigationLink).label(".navigationLink") + #if macOS + Color.clear + #endif + ScrollView { + VStack(spacing: 10) { + self.label("Default") + self.pickerStyle(.automatic).label(".automatic") + self.pickerStyle(.inline).label(".inline") + #if iOS || macOS + self.pickerStyle(.menu).label(".menu") + #endif + #if iOS + if #available(iOS 16.0, *) { + pickerStyle(.navigationLink).label(".navigationLink") + } + #endif + #if iOS || macOS + if #available(iOS 17.0, macOS 14.0, watchOS 10.0, *) { + pickerStyle(.palette).label(".palette") + } + #endif + #if iOS || macOS || os(tvOS) || os(visionOS) + self.pickerStyle(.segmented).label(".segmented") + #endif + #if iOS + pickerStyle(.wheel).label(".wheel") + #endif } - #if iOS || macOS - if #available(iOS 17.0, macOS 14.0, watchOS 10.0, *) { - pickerStyle(.palette).label(".palette") - } - #endif - #if iOS || macOS || os(tvOS) || os(visionOS) - self.pickerStyle(.segmented).label(".segmented") - #endif - #if iOS || macOS - pickerStyle(.wheel).label(".wheel") - #endif } } } diff --git a/Sources/RichTextKit/Fonts/RichTextFont+SizePicker.swift b/Sources/RichTextKit/Fonts/RichTextFont+SizePicker.swift index 62ea0c307..533c22016 100644 --- a/Sources/RichTextKit/Fonts/RichTextFont+SizePicker.swift +++ b/Sources/RichTextKit/Fonts/RichTextFont+SizePicker.swift @@ -42,14 +42,12 @@ public extension RichTextFont { private var selection: CGFloat public var body: some View { - SwiftUI.Picker("", selection: $selection) { + SwiftUI.Picker(RTKL10n.fontSize.text, selection: $selection) { ForEach(values, id: \.self) { text(for: $0) .tag($0) } } - .labelsHidden() - .accessibilityLabel(RTKL10n.fontSize.text) } } } @@ -89,13 +87,10 @@ struct RichTextFont_SizePicker_Previews: PreviewProvider { private var selection: CGFloat = 36.0 var body: some View { - List { - HStack { - RichTextFont.SizePicker( - selection: $selection - ) - } - } + RichTextFont.SizePicker( + selection: $selection + ) + .withPreviewPickerStyles() } } diff --git a/Sources/RichTextKit/Sharing/RichTextNSSharingMenu.swift b/Sources/RichTextKit/Sharing/RichTextNSSharingMenu.swift index 5b73dac3b..c1c8cc220 100644 --- a/Sources/RichTextKit/Sharing/RichTextNSSharingMenu.swift +++ b/Sources/RichTextKit/Sharing/RichTextNSSharingMenu.swift @@ -25,7 +25,7 @@ public struct RichTextNSSharingMenu: View { #if macOS public init( title: String = RTKL10n.menuShareAs.text, - icon: Image = .richTextActionShare, + icon: Image = .richTextShare, formats: [RichTextDataFormat] = RichTextDataFormat.libraryFormats, formatAction: @escaping (RichTextDataFormat) -> URL?, pdfAction: (() -> URL?)? = nil