Skip to content

Commit

Permalink
Make format toolbar render great on iOS, iPadOS and macOS
Browse files Browse the repository at this point in the history
  • Loading branch information
danielsaidi committed Feb 15, 2024
1 parent 5aa68af commit 91ea919
Show file tree
Hide file tree
Showing 6 changed files with 180 additions and 82 deletions.
1 change: 1 addition & 0 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ By deprecating these functions, we can simplify the library in 1.0, and focus mo
* The library once again builds on visionOS.

* `RichTextAlignment` now behaves better.
* `RichTextAlignment.Picker` now uses provided values.
* `RichTextCoordinator` now handles indentation changes.

### 🗑️ Deprecations
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public extension RichTextAlignment {

public var body: some View {
SwiftUI.Picker("", selection: $selection) {
ForEach(RichTextAlignment.allCases) { value in
ForEach(values) { value in
value.label
.labelStyle(.iconOnly)
}
Expand Down
1 change: 1 addition & 0 deletions Sources/RichTextKit/Fonts/RichTextFont+SizePicker.swift
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ public extension RichTextFont {
.tag($0)
}
}
.labelsHidden()
.accessibilityLabel(RTKL10n.fontSize.text)
}
}
Expand Down
3 changes: 2 additions & 1 deletion Sources/RichTextKit/Fonts/RichTextFont+SizePickerStack.swift
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ public extension RichTextFont {
HStack(spacing: 3) {
picker
stepper
}.overlay(macShortcutOverlay)
}
.overlay(macShortcutOverlay)
#endif
}
}
Expand Down
13 changes: 4 additions & 9 deletions Sources/RichTextKit/Format/RichTextFormatSidebar.swift
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,15 @@ public struct RichTextFormatSidebar: View {

public var body: some View {
VStack(alignment: .leading, spacing: spacing) {
SidebarSection(title: RTKL10n.font.text) {
SidebarSection {
RichTextFont.Picker(selection: $context.fontName, fontSize: 12)
HStack {
RichTextStyle.ToggleGroup(context: context)
RichTextFont.SizePickerStack(context: context)
}
}

SidebarSection(title: nil) {
SidebarSection {
RichTextAlignment.Picker(selection: $context.textAlignment)
.pickerStyle(.segmented)
HStack {
Expand All @@ -73,7 +73,7 @@ public struct RichTextFormatSidebar: View {
}
}

SidebarSection(title: nil) {
SidebarSection {
VStack(spacing: 4) {
ForEach(colorPickers) {
RichTextColor.Picker(
Expand Down Expand Up @@ -107,16 +107,11 @@ private extension RichTextFormatSidebar {

private struct SidebarSection<Content: View>: View {

let title: String?

@ViewBuilder
let content: () -> Content

var body: some View {
VStack(alignment: .leading, spacing: 10) {
if let title {
Text(title).font(.headline)
}
content()
Divider()
}
Expand All @@ -137,7 +132,7 @@ struct RichTextFormatSidebar_Previews: PreviewProvider {

static var previews: some View {
Preview()
.frame(width: 250)
.frame(width: 350)
}
}
#endif
Loading

0 comments on commit 91ea919

Please sign in to comment.