Skip to content

Commit ce3497c

Browse files
committed
The default vertical paddings are unnecessary for an uneditable label.
1 parent e3e06bc commit ce3497c

1 file changed

Lines changed: 10 additions & 4 deletions

File tree

Sources/ResizingTextView/ResizingTextView.swift

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -138,10 +138,16 @@ public struct ResizingTextView: View, Equatable {
138138
.opacity(isFocused && isEditable ? 1 : 0).scaleEffect(isFocused && isEditable ? 1 : 1.03))
139139
#elseif os(iOS)
140140
ZStack(alignment: .topLeading) {
141-
142-
/// HACK: In iOS 17, the last sentence of a non-editable text may not be drawn if the textContainerInset is `.zero`. To avoid it, we add this 0.00...1 value to the insets.
143-
let defaultTextContainerInset = UIEdgeInsets(top: 8, left: 0.00000001, bottom: 8, right: 0.00000001)
144-
let effectiveTextContainerInset = textContainerInset ?? defaultTextContainerInset
141+
/// HACK: In iOS 17, the last sentence of a non-editable text may not be drawn if the textContainerInset is `.zero`. To avoid it, we add this 0.00...1 value to the
142+
let defaultInsetsForiOS17Bug = UIEdgeInsets(top: 0.00000001, left: 0.00000001, bottom: 0.00000001, right: 0.00000001)
143+
let defaultVerticalPadding: CGFloat = isEditable ? 8 : 0
144+
let defaultInsets = UIEdgeInsets(
145+
top: defaultInsetsForiOS17Bug.top + defaultVerticalPadding,
146+
left: defaultInsetsForiOS17Bug.left,
147+
bottom: defaultInsetsForiOS17Bug.bottom + defaultVerticalPadding,
148+
right: defaultInsetsForiOS17Bug.right
149+
)
150+
let effectiveTextContainerInset = textContainerInset ?? defaultInsets
145151

146152
TextView(
147153
$text,

0 commit comments

Comments
 (0)