@@ -364,6 +364,8 @@ struct _Text: View, Equatable {
364
364
let textDecoration = textEnvironment. textDecoration
365
365
let textAlign = EnvironmentValues . shared. multilineTextAlignment. asTextAlign ( )
366
366
let maxLines = max ( 1 , EnvironmentValues . shared. lineLimit ?? Int . MAX_VALUE)
367
+ let reservesSpace = EnvironmentValues . shared. lineLimitReservesSpace ?? false
368
+ let minLines = reservesSpace ? maxLines : 1
367
369
let redaction = EnvironmentValues . shared. redactionReasons
368
370
let styleInfo = Text . styleInfo ( textEnvironment: textEnvironment, redaction: redaction, context: context)
369
371
let animatable = styleInfo. style. asAnimatable ( context: context)
@@ -390,7 +392,7 @@ struct _Text: View, Equatable {
390
392
}
391
393
}
392
394
}
393
- options = Material3TextOptions ( annotatedText: annotatedText, modifier: modifier, color: styleInfo. color ?? androidx. compose. ui. graphics. Color. Unspecified, maxLines: maxLines, style: animatable. value, textDecoration: textDecoration, textAlign: textAlign, onTextLayout: { layoutResult. value = $0 } )
395
+ options = Material3TextOptions ( annotatedText: annotatedText, modifier: modifier, color: styleInfo. color ?? androidx. compose. ui. graphics. Color. Unspecified, maxLines: maxLines, minLines : minLines , style: animatable. value, textDecoration: textDecoration, textAlign: textAlign, onTextLayout: { layoutResult. value = $0 } )
394
396
} else {
395
397
var text : String
396
398
if let interpolations {
@@ -403,14 +405,15 @@ struct _Text: View, Equatable {
403
405
} else if styleInfo. isLowercased {
404
406
text = text. lowercased ( )
405
407
}
406
- options = Material3TextOptions ( text: text, modifier: context. modifier, color: styleInfo. color ?? androidx. compose. ui. graphics. Color. Unspecified, maxLines: maxLines, style: animatable. value, textDecoration: textDecoration, textAlign: textAlign)
408
+ options = Material3TextOptions ( text: text, modifier: context. modifier, color: styleInfo. color ?? androidx. compose. ui. graphics. Color. Unspecified, maxLines: maxLines, minLines : minLines , style: animatable. value, textDecoration: textDecoration, textAlign: textAlign)
407
409
}
408
410
if let updateOptions = EnvironmentValues . shared. _material3Text {
409
411
options = updateOptions ( options)
410
412
}
411
413
if let annotatedText = options. annotatedText, let onTextLayout = options. onTextLayout {
412
414
androidx. compose. material3. Text ( text: annotatedText, modifier: options. modifier, color: options. color, fontSize: options. fontSize, fontStyle: options. fontStyle, fontWeight: options. fontWeight, fontFamily: options. fontFamily, letterSpacing: options. letterSpacing, textDecoration: options. textDecoration, textAlign: options. textAlign, lineHeight: options. lineHeight, overflow: options. overflow, softWrap: options. softWrap, maxLines: options. maxLines, minLines: options. minLines, onTextLayout: onTextLayout, style: options. style)
413
415
} else {
416
+ logger. info ( " text \( options. text) reservesSpace \( reservesSpace) maxLines \( maxLines) minLines \( minLines) " )
414
417
androidx. compose. material3. Text ( text: options. text ?? " " , modifier: options. modifier, color: options. color, fontSize: options. fontSize, fontStyle: options. fontStyle, fontWeight: options. fontWeight, fontFamily: options. fontFamily, letterSpacing: options. letterSpacing, textDecoration: options. textDecoration, textAlign: options. textAlign, lineHeight: options. lineHeight, overflow: options. overflow, softWrap: options. softWrap, maxLines: options. maxLines, minLines: options. minLines, onTextLayout: options. onTextLayout, style: options. style)
415
418
}
416
419
}
@@ -649,9 +652,13 @@ extension View {
649
652
return self
650
653
}
651
654
652
- @ available ( * , unavailable )
655
+ // SKIP @bridge
653
656
public func lineLimit( _ limit: Int , reservesSpace: Bool ) -> some View {
657
+ #if SKIP
658
+ return environment ( \. lineLimit, limit) . environment ( \. lineLimitReservesSpace, reservesSpace)
659
+ #else
654
660
return self
661
+ #endif
655
662
}
656
663
657
664
@available ( * , unavailable)
0 commit comments