Skip to content

Commit

Permalink
Add label titles to alignment and font size picker
Browse files Browse the repository at this point in the history
  • Loading branch information
danielsaidi committed Mar 4, 2024
1 parent e8aa17f commit 5dcb98d
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 34 deletions.
4 changes: 1 addition & 3 deletions Sources/RichTextKit/Alignment/RichTextAlignment+Picker.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
}
Expand Down
47 changes: 27 additions & 20 deletions Sources/RichTextKit/Fonts/RichTextFont+Picker.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
}
Expand Down
15 changes: 5 additions & 10 deletions Sources/RichTextKit/Fonts/RichTextFont+SizePicker.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
}
Expand Down Expand Up @@ -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()
}
}

Expand Down
2 changes: 1 addition & 1 deletion Sources/RichTextKit/Sharing/RichTextNSSharingMenu.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 5dcb98d

Please sign in to comment.