forked from Expensify/App
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathreact-native+0.73.2+001+NumberOfLines.patch
968 lines (904 loc) · 46.7 KB
/
react-native+0.73.2+001+NumberOfLines.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
diff --git a/node_modules/react-native/Libraries/Components/TextInput/AndroidTextInputNativeComponent.js b/node_modules/react-native/Libraries/Components/TextInput/AndroidTextInputNativeComponent.js
index 55b770d..4073836 100644
--- a/node_modules/react-native/Libraries/Components/TextInput/AndroidTextInputNativeComponent.js
+++ b/node_modules/react-native/Libraries/Components/TextInput/AndroidTextInputNativeComponent.js
@@ -179,6 +179,13 @@ export type NativeProps = $ReadOnly<{|
*/
numberOfLines?: ?Int32,
+ /**
+ * Sets the maximum number of lines for a `TextInput`. Use it with multiline set to
+ * `true` to be able to fill the lines.
+ * @platform android
+ */
+ maximumNumberOfLines?: ?Int32,
+
/**
* When `false`, if there is a small amount of space available around a text input
* (e.g. landscape orientation on a phone), the OS may choose to have the user edit
diff --git a/node_modules/react-native/Libraries/Components/TextInput/RCTTextInputViewConfig.js b/node_modules/react-native/Libraries/Components/TextInput/RCTTextInputViewConfig.js
index 88d3cc8..664d37d 100644
--- a/node_modules/react-native/Libraries/Components/TextInput/RCTTextInputViewConfig.js
+++ b/node_modules/react-native/Libraries/Components/TextInput/RCTTextInputViewConfig.js
@@ -144,6 +144,8 @@ const RCTTextInputViewConfig = {
placeholder: true,
autoCorrect: true,
multiline: true,
+ numberOfLines: true,
+ maximumNumberOfLines: true,
textContentType: true,
maxLength: true,
autoCapitalize: true,
diff --git a/node_modules/react-native/Libraries/Components/TextInput/TextInput.d.ts b/node_modules/react-native/Libraries/Components/TextInput/TextInput.d.ts
index 2c0c099..5cb6bf1 100644
--- a/node_modules/react-native/Libraries/Components/TextInput/TextInput.d.ts
+++ b/node_modules/react-native/Libraries/Components/TextInput/TextInput.d.ts
@@ -695,11 +695,29 @@ export interface TextInputProps
*/
maxLength?: number | undefined;
+ /**
+ * Sets the maximum number of lines for a TextInput.
+ * Use it with multiline set to true to be able to fill the lines.
+ */
+ maxNumberOfLines?: number | undefined;
+
/**
* If true, the text input can be multiple lines. The default value is false.
*/
multiline?: boolean | undefined;
+ /**
+ * Sets the number of lines for a TextInput.
+ * Use it with multiline set to true to be able to fill the lines.
+ */
+ numberOfLines?: number | undefined;
+
+ /**
+ * Sets the number of rows for a TextInput.
+ * Use it with multiline set to true to be able to fill the lines.
+ */
+ rows?: number | undefined;
+
/**
* Callback that is called when the text input is blurred
*/
diff --git a/node_modules/react-native/Libraries/Components/TextInput/TextInput.flow.js b/node_modules/react-native/Libraries/Components/TextInput/TextInput.flow.js
index 9adbfe9..dc52051 100644
--- a/node_modules/react-native/Libraries/Components/TextInput/TextInput.flow.js
+++ b/node_modules/react-native/Libraries/Components/TextInput/TextInput.flow.js
@@ -366,26 +366,12 @@ type AndroidProps = $ReadOnly<{|
*/
inlineImagePadding?: ?number,
- /**
- * Sets the number of lines for a `TextInput`. Use it with multiline set to
- * `true` to be able to fill the lines.
- * @platform android
- */
- numberOfLines?: ?number,
-
/**
* Sets the return key to the label. Use it instead of `returnKeyType`.
* @platform android
*/
returnKeyLabel?: ?string,
- /**
- * Sets the number of rows for a `TextInput`. Use it with multiline set to
- * `true` to be able to fill the lines.
- * @platform android
- */
- rows?: ?number,
-
/**
* When `false`, it will prevent the soft keyboard from showing when the field is focused.
* Defaults to `true`.
@@ -680,12 +666,24 @@ export type Props = $ReadOnly<{|
*/
maxLength?: ?number,
+ /**
+ * Sets the maximum number of lines for a `TextInput`. Use it with multiline set to
+ * `true` to be able to fill the lines.
+ */
+ maxNumberOfLines?: ?number,
+
/**
* If `true`, the text input can be multiple lines.
* The default value is `false`.
*/
multiline?: ?boolean,
+ /**
+ * Sets the number of lines for a `TextInput`. Use it with multiline set to
+ * `true` to be able to fill the lines.
+ */
+ numberOfLines?: ?number,
+
/**
* Callback that is called when the text input is blurred.
*/
@@ -847,6 +845,13 @@ export type Props = $ReadOnly<{|
*/
returnKeyType?: ?ReturnKeyType,
+ /**
+ * Sets the number of rows for a `TextInput`. Use it with multiline set to
+ * `true` to be able to fill the lines.
+ */
+ rows?: ?number,
+
+
/**
* If `true`, the text input obscures the text entered so that sensitive text
* like passwords stay secure. The default value is `false`. Does not work with 'multiline={true}'.
diff --git a/node_modules/react-native/Libraries/Components/TextInput/TextInput.js b/node_modules/react-native/Libraries/Components/TextInput/TextInput.js
index 481938f..3ce7422 100644
--- a/node_modules/react-native/Libraries/Components/TextInput/TextInput.js
+++ b/node_modules/react-native/Libraries/Components/TextInput/TextInput.js
@@ -413,7 +413,6 @@ type AndroidProps = $ReadOnly<{|
/**
* Sets the number of lines for a `TextInput`. Use it with multiline set to
* `true` to be able to fill the lines.
- * @platform android
*/
numberOfLines?: ?number,
@@ -426,10 +425,15 @@ type AndroidProps = $ReadOnly<{|
/**
* Sets the number of rows for a `TextInput`. Use it with multiline set to
* `true` to be able to fill the lines.
- * @platform android
*/
rows?: ?number,
+ /**
+ * Sets the maximum number of lines the TextInput can have.
+ */
+ maxNumberOfLines?: ?number,
+
+
/**
* When `false`, it will prevent the soft keyboard from showing when the field is focused.
* Defaults to `true`.
@@ -1102,6 +1106,9 @@ function InternalTextInput(props: Props): React.Node {
accessibilityState,
id,
tabIndex,
+ rows,
+ numberOfLines,
+ maxNumberOfLines,
selection: propsSelection,
...otherProps
} = props;
@@ -1460,6 +1467,8 @@ function InternalTextInput(props: Props): React.Node {
focusable={tabIndex !== undefined ? !tabIndex : focusable}
mostRecentEventCount={mostRecentEventCount}
nativeID={id ?? props.nativeID}
+ numberOfLines={props.rows ?? props.numberOfLines}
+ maximumNumberOfLines={maxNumberOfLines}
onBlur={_onBlur}
onKeyPressSync={props.unstable_onKeyPressSync}
onChange={_onChange}
@@ -1515,6 +1524,7 @@ function InternalTextInput(props: Props): React.Node {
mostRecentEventCount={mostRecentEventCount}
nativeID={id ?? props.nativeID}
numberOfLines={props.rows ?? props.numberOfLines}
+ maximumNumberOfLines={maxNumberOfLines}
onBlur={_onBlur}
onChange={_onChange}
onFocus={_onFocus}
diff --git a/node_modules/react-native/Libraries/Text/Text.js b/node_modules/react-native/Libraries/Text/Text.js
index d737ccc..beee7ce 100644
--- a/node_modules/react-native/Libraries/Text/Text.js
+++ b/node_modules/react-native/Libraries/Text/Text.js
@@ -17,7 +17,11 @@ import flattenStyle from '../StyleSheet/flattenStyle';
import processColor from '../StyleSheet/processColor';
import Platform from '../Utilities/Platform';
import TextAncestor from './TextAncestor';
-import {NativeText, NativeVirtualText} from './TextNativeComponent';
+import {
+ CONTAINS_MAX_NUMBER_OF_LINES_RENAME,
+ NativeText,
+ NativeVirtualText,
+} from './TextNativeComponent';
import * as React from 'react';
import {useContext, useMemo, useState} from 'react';
@@ -56,6 +60,7 @@ const Text: React.AbstractComponent<
onStartShouldSetResponder,
pressRetentionOffset,
suppressHighlighting,
+ numberOfLines,
...restProps
} = props;
@@ -195,14 +200,34 @@ const Text: React.AbstractComponent<
}
}
- let numberOfLines = restProps.numberOfLines;
+ let numberOfLinesValue = numberOfLines;
if (numberOfLines != null && !(numberOfLines >= 0)) {
console.error(
`'numberOfLines' in <Text> must be a non-negative number, received: ${numberOfLines}. The value will be set to 0.`,
);
- numberOfLines = 0;
+ numberOfLinesValue = 0;
}
+ const numberOfLinesProps = useMemo((): {
+ maximumNumberOfLines?: ?number,
+ numberOfLines?: ?number,
+ } => {
+ // FIXME: Current logic is breaking all Text components.
+ // if (CONTAINS_MAX_NUMBER_OF_LINES_RENAME) {
+ // return {
+ // maximumNumberOfLines: numberOfLinesValue,
+ // };
+ // } else {
+ // return {
+ // numberOfLines: numberOfLinesValue,
+ // };
+ // }
+ return {
+ maximumNumberOfLines: numberOfLinesValue,
+ };
+ }, [numberOfLinesValue]);
+
+
const hasTextAncestor = useContext(TextAncestor);
const _accessible = Platform.select({
@@ -251,7 +276,6 @@ const Text: React.AbstractComponent<
isHighlighted={isHighlighted}
isPressable={isPressable}
nativeID={id ?? nativeID}
- numberOfLines={numberOfLines}
ref={forwardedRef}
selectable={_selectable}
selectionColor={selectionColor}
@@ -262,6 +286,7 @@ const Text: React.AbstractComponent<
<NativeText
{...restProps}
{...eventHandlersForText}
+ {...numberOfLinesProps}
accessibilityLabel={ariaLabel ?? accessibilityLabel}
accessibilityState={nativeTextAccessibilityState}
accessible={
@@ -274,7 +299,6 @@ const Text: React.AbstractComponent<
ellipsizeMode={ellipsizeMode ?? 'tail'}
isHighlighted={isHighlighted}
nativeID={id ?? nativeID}
- numberOfLines={numberOfLines}
ref={forwardedRef}
selectable={_selectable}
selectionColor={selectionColor}
diff --git a/node_modules/react-native/Libraries/Text/Text/RCTTextViewManager.mm b/node_modules/react-native/Libraries/Text/Text/RCTTextViewManager.mm
index 7fec0b7..7b53c80 100644
--- a/node_modules/react-native/Libraries/Text/Text/RCTTextViewManager.mm
+++ b/node_modules/react-native/Libraries/Text/Text/RCTTextViewManager.mm
@@ -26,7 +26,7 @@ @implementation RCTTextViewManager {
RCT_EXPORT_MODULE(RCTText)
-RCT_REMAP_SHADOW_PROPERTY(numberOfLines, maximumNumberOfLines, NSInteger)
+RCT_EXPORT_SHADOW_PROPERTY(maximumNumberOfLines, NSInteger)
RCT_REMAP_SHADOW_PROPERTY(ellipsizeMode, lineBreakMode, NSLineBreakMode)
RCT_REMAP_SHADOW_PROPERTY(adjustsFontSizeToFit, adjustsFontSizeToFit, BOOL)
RCT_REMAP_SHADOW_PROPERTY(minimumFontScale, minimumFontScale, CGFloat)
diff --git a/node_modules/react-native/Libraries/Text/TextInput/Multiline/RCTMultilineTextInputViewManager.mm b/node_modules/react-native/Libraries/Text/TextInput/Multiline/RCTMultilineTextInputViewManager.mm
index e729bb7..7d019df 100644
--- a/node_modules/react-native/Libraries/Text/TextInput/Multiline/RCTMultilineTextInputViewManager.mm
+++ b/node_modules/react-native/Libraries/Text/TextInput/Multiline/RCTMultilineTextInputViewManager.mm
@@ -7,6 +7,8 @@
#import <React/RCTMultilineTextInputView.h>
#import <React/RCTMultilineTextInputViewManager.h>
+#import <React/RCTUITextView.h>
+#import <React/RCTBaseTextInputShadowView.h>
@implementation RCTMultilineTextInputViewManager
@@ -17,8 +19,21 @@ - (UIView *)view
return [[RCTMultilineTextInputView alloc] initWithBridge:self.bridge];
}
+- (RCTShadowView *)shadowView
+{
+ RCTBaseTextInputShadowView *shadowView = (RCTBaseTextInputShadowView *)[super shadowView];
+
+ shadowView.maximumNumberOfLines = 0;
+ shadowView.exactNumberOfLines = 0;
+
+ return shadowView;
+}
+
#pragma mark - Multiline <TextInput> (aka TextView) specific properties
RCT_REMAP_VIEW_PROPERTY(dataDetectorTypes, backedTextInputView.dataDetectorTypes, UIDataDetectorTypes)
+RCT_EXPORT_SHADOW_PROPERTY(maximumNumberOfLines, NSInteger)
+RCT_REMAP_SHADOW_PROPERTY(numberOfLines, exactNumberOfLines, NSInteger)
+
@end
diff --git a/node_modules/react-native/Libraries/Text/TextInput/RCTBaseTextInputShadowView.h b/node_modules/react-native/Libraries/Text/TextInput/RCTBaseTextInputShadowView.h
index 8f4cf7e..6238ebc 100644
--- a/node_modules/react-native/Libraries/Text/TextInput/RCTBaseTextInputShadowView.h
+++ b/node_modules/react-native/Libraries/Text/TextInput/RCTBaseTextInputShadowView.h
@@ -16,6 +16,7 @@ NS_ASSUME_NONNULL_BEGIN
@property (nonatomic, copy, nullable) NSString *text;
@property (nonatomic, copy, nullable) NSString *placeholder;
@property (nonatomic, assign) NSInteger maximumNumberOfLines;
+@property (nonatomic, assign) NSInteger exactNumberOfLines;
@property (nonatomic, copy, nullable) RCTDirectEventBlock onContentSizeChange;
- (void)uiManagerWillPerformMounting;
diff --git a/node_modules/react-native/Libraries/Text/TextInput/RCTBaseTextInputShadowView.mm b/node_modules/react-native/Libraries/Text/TextInput/RCTBaseTextInputShadowView.mm
index 1f06b79..48172ce 100644
--- a/node_modules/react-native/Libraries/Text/TextInput/RCTBaseTextInputShadowView.mm
+++ b/node_modules/react-native/Libraries/Text/TextInput/RCTBaseTextInputShadowView.mm
@@ -218,7 +218,22 @@ - (NSAttributedString *)measurableAttributedText
- (CGSize)sizeThatFitsMinimumSize:(CGSize)minimumSize maximumSize:(CGSize)maximumSize
{
- NSAttributedString *attributedText = [self measurableAttributedText];
+ NSMutableAttributedString *attributedText = [[self measurableAttributedText] mutableCopy];
+
+ /*
+ * The block below is responsible for setting the exact height of the view in lines
+ * Unfortunatelly, iOS doesn't export any easy way to do it. So we set maximumNumberOfLines
+ * prop and then add random lines at the front. However, they are only used for layout
+ * so they are not visible on the screen.
+ */
+ if (self.exactNumberOfLines) {
+ NSMutableString *newLines = [NSMutableString stringWithCapacity:self.exactNumberOfLines];
+ for (NSUInteger i = 0UL; i < self.exactNumberOfLines; ++i) {
+ [newLines appendString:@"\n"];
+ }
+ [attributedText insertAttributedString:[[NSAttributedString alloc] initWithString:newLines attributes:self.textAttributes.effectiveTextAttributes] atIndex:0];
+ _maximumNumberOfLines = self.exactNumberOfLines;
+ }
if (!_textStorage) {
_textContainer = [NSTextContainer new];
diff --git a/node_modules/react-native/Libraries/Text/TextInput/Singleline/RCTSinglelineTextInputViewManager.mm b/node_modules/react-native/Libraries/Text/TextInput/Singleline/RCTSinglelineTextInputViewManager.mm
index 413ac42..56d039c 100644
--- a/node_modules/react-native/Libraries/Text/TextInput/Singleline/RCTSinglelineTextInputViewManager.mm
+++ b/node_modules/react-native/Libraries/Text/TextInput/Singleline/RCTSinglelineTextInputViewManager.mm
@@ -19,6 +19,7 @@ - (RCTShadowView *)shadowView
RCTBaseTextInputShadowView *shadowView = (RCTBaseTextInputShadowView *)[super shadowView];
shadowView.maximumNumberOfLines = 1;
+ shadowView.exactNumberOfLines = 0;
return shadowView;
}
diff --git a/node_modules/react-native/Libraries/Text/TextNativeComponent.js b/node_modules/react-native/Libraries/Text/TextNativeComponent.js
index 0d59904..3216e43 100644
--- a/node_modules/react-native/Libraries/Text/TextNativeComponent.js
+++ b/node_modules/react-native/Libraries/Text/TextNativeComponent.js
@@ -9,6 +9,7 @@
*/
import {createViewConfig} from '../NativeComponent/ViewConfig';
+import getNativeComponentAttributes from '../ReactNative/getNativeComponentAttributes';
import UIManager from '../ReactNative/UIManager';
import createReactNativeComponentClass from '../Renderer/shims/createReactNativeComponentClass';
import {type HostComponent} from '../Renderer/shims/ReactNativeTypes';
@@ -18,6 +19,7 @@ import {type TextProps} from './TextProps';
type NativeTextProps = $ReadOnly<{
...TextProps,
+ maximumNumberOfLines?: ?number,
isHighlighted?: ?boolean,
selectionColor?: ?ProcessedColorValue,
onClick?: ?(event: PressEvent) => mixed,
@@ -31,7 +33,7 @@ const textViewConfig = {
validAttributes: {
isHighlighted: true,
isPressable: true,
- numberOfLines: true,
+ maximumNumberOfLines: true,
ellipsizeMode: true,
allowFontScaling: true,
dynamicTypeRamp: true,
@@ -73,6 +75,12 @@ export const NativeText: HostComponent<NativeTextProps> =
createViewConfig(textViewConfig),
): any);
+const jestIsDefined = typeof jest !== 'undefined';
+export const CONTAINS_MAX_NUMBER_OF_LINES_RENAME: boolean = jestIsDefined
+ ? true
+ : getNativeComponentAttributes('RCTText')?.NativeProps
+ ?.maximumNumberOfLines === 'number';
+
export const NativeVirtualText: HostComponent<NativeTextProps> =
!global.RN$Bridgeless && !UIManager.hasViewManagerConfig('RCTVirtualText')
? NativeText
diff --git a/node_modules/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/ViewDefaults.java b/node_modules/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/ViewDefaults.java
index 8cab407..ad5fa96 100644
--- a/node_modules/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/ViewDefaults.java
+++ b/node_modules/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/ViewDefaults.java
@@ -12,5 +12,6 @@ public class ViewDefaults {
public static final float FONT_SIZE_SP = 14.0f;
public static final int LINE_HEIGHT = 0;
- public static final int NUMBER_OF_LINES = Integer.MAX_VALUE;
+ public static final int NUMBER_OF_LINES = -1;
+ public static final int MAXIMUM_NUMBER_OF_LINES = Integer.MAX_VALUE;
}
diff --git a/node_modules/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/ViewProps.java b/node_modules/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/ViewProps.java
index fa6eae3..f524753 100644
--- a/node_modules/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/ViewProps.java
+++ b/node_modules/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/ViewProps.java
@@ -96,6 +96,7 @@ public class ViewProps {
public static final String LETTER_SPACING = "letterSpacing";
public static final String NEEDS_OFFSCREEN_ALPHA_COMPOSITING = "needsOffscreenAlphaCompositing";
public static final String NUMBER_OF_LINES = "numberOfLines";
+ public static final String MAXIMUM_NUMBER_OF_LINES = "maximumNumberOfLines";
public static final String ELLIPSIZE_MODE = "ellipsizeMode";
public static final String ADJUSTS_FONT_SIZE_TO_FIT = "adjustsFontSizeToFit";
public static final String MINIMUM_FONT_SCALE = "minimumFontScale";
diff --git a/node_modules/react-native/ReactAndroid/src/main/java/com/facebook/react/views/text/ReactBaseTextShadowNode.java b/node_modules/react-native/ReactAndroid/src/main/java/com/facebook/react/views/text/ReactBaseTextShadowNode.java
index d2c2d6e..e4dec5d 100644
--- a/node_modules/react-native/ReactAndroid/src/main/java/com/facebook/react/views/text/ReactBaseTextShadowNode.java
+++ b/node_modules/react-native/ReactAndroid/src/main/java/com/facebook/react/views/text/ReactBaseTextShadowNode.java
@@ -311,6 +311,7 @@ public abstract class ReactBaseTextShadowNode extends LayoutShadowNode {
protected @Nullable Role mRole = null;
protected int mNumberOfLines = UNSET;
+ protected int mMaxNumberOfLines = UNSET;
protected int mTextAlign = Gravity.NO_GRAVITY;
protected int mTextBreakStrategy =
(Build.VERSION.SDK_INT < Build.VERSION_CODES.M) ? 0 : Layout.BREAK_STRATEGY_HIGH_QUALITY;
@@ -395,6 +396,12 @@ public abstract class ReactBaseTextShadowNode extends LayoutShadowNode {
markUpdated();
}
+ @ReactProp(name = ViewProps.MAXIMUM_NUMBER_OF_LINES, defaultInt = UNSET)
+ public void setMaxNumberOfLines(int numberOfLines) {
+ mMaxNumberOfLines = numberOfLines == 0 ? UNSET : numberOfLines;
+ markUpdated();
+ }
+
@ReactProp(name = ViewProps.LINE_HEIGHT, defaultFloat = Float.NaN)
public void setLineHeight(float lineHeight) {
mTextAttributes.setLineHeight(lineHeight);
diff --git a/node_modules/react-native/ReactAndroid/src/main/java/com/facebook/react/views/text/ReactTextAnchorViewManager.java b/node_modules/react-native/ReactAndroid/src/main/java/com/facebook/react/views/text/ReactTextAnchorViewManager.java
index f683c24..b5f6f7d 100644
--- a/node_modules/react-native/ReactAndroid/src/main/java/com/facebook/react/views/text/ReactTextAnchorViewManager.java
+++ b/node_modules/react-native/ReactAndroid/src/main/java/com/facebook/react/views/text/ReactTextAnchorViewManager.java
@@ -49,8 +49,8 @@ public abstract class ReactTextAnchorViewManager<T extends View, C extends React
}
// maxLines can only be set in master view (block), doesn't really make sense to set in a span
- @ReactProp(name = ViewProps.NUMBER_OF_LINES, defaultInt = ViewDefaults.NUMBER_OF_LINES)
- public void setNumberOfLines(ReactTextView view, int numberOfLines) {
+ @ReactProp(name = ViewProps.MAXIMUM_NUMBER_OF_LINES, defaultInt = ViewDefaults.MAXIMUM_NUMBER_OF_LINES)
+ public void setMaxNumberOfLines(ReactTextView view, int numberOfLines) {
view.setNumberOfLines(numberOfLines);
}
diff --git a/node_modules/react-native/ReactAndroid/src/main/java/com/facebook/react/views/text/ReactTextShadowNode.java b/node_modules/react-native/ReactAndroid/src/main/java/com/facebook/react/views/text/ReactTextShadowNode.java
index a66950c..e1dc365 100644
--- a/node_modules/react-native/ReactAndroid/src/main/java/com/facebook/react/views/text/ReactTextShadowNode.java
+++ b/node_modules/react-native/ReactAndroid/src/main/java/com/facebook/react/views/text/ReactTextShadowNode.java
@@ -82,7 +82,7 @@ public class ReactTextShadowNode extends ReactBaseTextShadowNode {
int minimumFontSize =
(int) Math.max(mMinimumFontScale * initialFontSize, PixelUtil.toPixelFromDIP(4));
while (currentFontSize > minimumFontSize
- && (mNumberOfLines != UNSET && layout.getLineCount() > mNumberOfLines
+ && (mMaxNumberOfLines != UNSET && layout.getLineCount() > mMaxNumberOfLines
|| heightMode != YogaMeasureMode.UNDEFINED && layout.getHeight() > height)) {
// TODO: We could probably use a smarter algorithm here. This will require 0(n)
// measurements
@@ -124,9 +124,9 @@ public class ReactTextShadowNode extends ReactBaseTextShadowNode {
}
final int lineCount =
- mNumberOfLines == UNSET
+ mMaxNumberOfLines == UNSET
? layout.getLineCount()
- : Math.min(mNumberOfLines, layout.getLineCount());
+ : Math.min(mMaxNumberOfLines, layout.getLineCount());
// Instead of using `layout.getWidth()` (which may yield a significantly larger width for
// text that is wrapping), compute width using the longest line.
diff --git a/node_modules/react-native/ReactAndroid/src/main/java/com/facebook/react/views/text/ReactTextView.java b/node_modules/react-native/ReactAndroid/src/main/java/com/facebook/react/views/text/ReactTextView.java
index 4af5729..64474af 100644
--- a/node_modules/react-native/ReactAndroid/src/main/java/com/facebook/react/views/text/ReactTextView.java
+++ b/node_modules/react-native/ReactAndroid/src/main/java/com/facebook/react/views/text/ReactTextView.java
@@ -90,7 +90,7 @@ public class ReactTextView extends AppCompatTextView implements ReactCompoundVie
mReactBackgroundManager = new ReactViewBackgroundManager(this);
- mNumberOfLines = ViewDefaults.NUMBER_OF_LINES;
+ mNumberOfLines = ViewDefaults.MAXIMUM_NUMBER_OF_LINES;
mAdjustsFontSizeToFit = false;
mLinkifyMaskType = 0;
mNotifyOnInlineViewLayout = false;
@@ -579,7 +579,7 @@ public class ReactTextView extends AppCompatTextView implements ReactCompoundVie
}
public void setNumberOfLines(int numberOfLines) {
- mNumberOfLines = numberOfLines == 0 ? ViewDefaults.NUMBER_OF_LINES : numberOfLines;
+ mNumberOfLines = numberOfLines == 0 ? ViewDefaults.MAXIMUM_NUMBER_OF_LINES : numberOfLines;
setMaxLines(mNumberOfLines);
}
@@ -621,7 +621,7 @@ public class ReactTextView extends AppCompatTextView implements ReactCompoundVie
public void updateView() {
@Nullable
TextUtils.TruncateAt ellipsizeLocation =
- mNumberOfLines == ViewDefaults.NUMBER_OF_LINES || mAdjustsFontSizeToFit
+ mNumberOfLines == ViewDefaults.MAXIMUM_NUMBER_OF_LINES || mAdjustsFontSizeToFit
? null
: mEllipsizeLocation;
setEllipsize(ellipsizeLocation);
diff --git a/node_modules/react-native/ReactAndroid/src/main/java/com/facebook/react/views/text/TextLayoutManager.java b/node_modules/react-native/ReactAndroid/src/main/java/com/facebook/react/views/text/TextLayoutManager.java
index ffd5b2f..e9a8b0b 100644
--- a/node_modules/react-native/ReactAndroid/src/main/java/com/facebook/react/views/text/TextLayoutManager.java
+++ b/node_modules/react-native/ReactAndroid/src/main/java/com/facebook/react/views/text/TextLayoutManager.java
@@ -19,6 +19,7 @@ import android.text.SpannableStringBuilder;
import android.text.Spanned;
import android.text.StaticLayout;
import android.text.TextPaint;
+import android.text.TextUtils;
import android.util.LayoutDirection;
import android.util.LruCache;
import android.view.View;
@@ -68,6 +69,7 @@ public class TextLayoutManager {
private static final String TEXT_BREAK_STRATEGY_KEY = "textBreakStrategy";
private static final String HYPHENATION_FREQUENCY_KEY = "android_hyphenationFrequency";
private static final String MAXIMUM_NUMBER_OF_LINES_KEY = "maximumNumberOfLines";
+ private static final String NUMBER_OF_LINES_KEY = "numberOfLines";
private static final LruCache<ReadableNativeMap, Spannable> sSpannableCache =
new LruCache<>(spannableCacheSize);
private static final ConcurrentHashMap<Integer, Spannable> sTagToSpannableCache =
@@ -395,6 +397,48 @@ public class TextLayoutManager {
? paragraphAttributes.getInt(MAXIMUM_NUMBER_OF_LINES_KEY)
: UNSET;
+ int numberOfLines =
+ paragraphAttributes.hasKey(NUMBER_OF_LINES_KEY)
+ ? paragraphAttributes.getInt(NUMBER_OF_LINES_KEY)
+ : UNSET;
+
+ int lines = layout.getLineCount();
+ if (numberOfLines != UNSET && numberOfLines != 0 && numberOfLines >= lines && text.length() > 0) {
+ int numberOfEmptyLines = numberOfLines - lines;
+ SpannableStringBuilder ssb = new SpannableStringBuilder();
+
+ // for some reason a newline on end causes issues with computing height so we add a character
+ if (text.toString().endsWith("\n")) {
+ ssb.append("A");
+ }
+
+ for (int i = 0; i < numberOfEmptyLines; ++i) {
+ ssb.append("\nA");
+ }
+
+ Object[] spans = text.getSpans(0, 0, Object.class);
+ for (Object span : spans) { // It's possible we need to set exl-exl
+ ssb.setSpan(span, 0, ssb.length(), text.getSpanFlags(span));
+ };
+
+ text = new SpannableStringBuilder(TextUtils.concat(text, ssb));
+ boring = null;
+ layout = createLayout(
+ text,
+ boring,
+ width,
+ widthYogaMeasureMode,
+ includeFontPadding,
+ textBreakStrategy,
+ hyphenationFrequency);
+ }
+
+
+ if (numberOfLines != UNSET && numberOfLines != 0) {
+ maximumNumberOfLines = numberOfLines;
+ }
+
+
int calculatedLineCount =
maximumNumberOfLines == UNSET || maximumNumberOfLines == 0
? layout.getLineCount()
diff --git a/node_modules/react-native/ReactAndroid/src/main/java/com/facebook/react/views/text/TextLayoutManagerMapBuffer.java b/node_modules/react-native/ReactAndroid/src/main/java/com/facebook/react/views/text/TextLayoutManagerMapBuffer.java
index 8cd5764..35a2e9e 100644
--- a/node_modules/react-native/ReactAndroid/src/main/java/com/facebook/react/views/text/TextLayoutManagerMapBuffer.java
+++ b/node_modules/react-native/ReactAndroid/src/main/java/com/facebook/react/views/text/TextLayoutManagerMapBuffer.java
@@ -20,6 +20,7 @@ import android.text.SpannableStringBuilder;
import android.text.Spanned;
import android.text.StaticLayout;
import android.text.TextPaint;
+import android.text.TextUtils;
import android.util.LayoutDirection;
import android.util.LruCache;
import android.view.View;
@@ -66,6 +67,7 @@ public class TextLayoutManagerMapBuffer {
public static final short PA_KEY_ADJUST_FONT_SIZE_TO_FIT = 3;
public static final short PA_KEY_INCLUDE_FONT_PADDING = 4;
public static final short PA_KEY_HYPHENATION_FREQUENCY = 5;
+ public static final short PA_KEY_NUMBER_OF_LINES = 6;
private static final boolean ENABLE_MEASURE_LOGGING = ReactBuildConfig.DEBUG && false;
@@ -417,6 +419,46 @@ public class TextLayoutManagerMapBuffer {
? paragraphAttributes.getInt(PA_KEY_MAX_NUMBER_OF_LINES)
: UNSET;
+ int numberOfLines =
+ paragraphAttributes.contains(PA_KEY_NUMBER_OF_LINES)
+ ? paragraphAttributes.getInt(PA_KEY_NUMBER_OF_LINES)
+ : UNSET;
+
+ int lines = layout.getLineCount();
+ if (numberOfLines != UNSET && numberOfLines != 0 && numberOfLines > lines && text.length() > 0) {
+ int numberOfEmptyLines = numberOfLines - lines;
+ SpannableStringBuilder ssb = new SpannableStringBuilder();
+
+ // for some reason a newline on end causes issues with computing height so we add a character
+ if (text.toString().endsWith("\n")) {
+ ssb.append("A");
+ }
+
+ for (int i = 0; i < numberOfEmptyLines; ++i) {
+ ssb.append("\nA");
+ }
+
+ Object[] spans = text.getSpans(0, 0, Object.class);
+ for (Object span : spans) { // It's possible we need to set exl-exl
+ ssb.setSpan(span, 0, ssb.length(), text.getSpanFlags(span));
+ };
+
+ text = new SpannableStringBuilder(TextUtils.concat(text, ssb));
+ boring = null;
+ layout = createLayout(
+ text,
+ boring,
+ width,
+ widthYogaMeasureMode,
+ includeFontPadding,
+ textBreakStrategy,
+ hyphenationFrequency);
+ }
+
+ if (numberOfLines != UNSET && numberOfLines != 0) {
+ maximumNumberOfLines = numberOfLines;
+ }
+
int calculatedLineCount =
maximumNumberOfLines == UNSET || maximumNumberOfLines == 0
? layout.getLineCount()
diff --git a/node_modules/react-native/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactEditText.java b/node_modules/react-native/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactEditText.java
index 081f2b8..0659179 100644
--- a/node_modules/react-native/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactEditText.java
+++ b/node_modules/react-native/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactEditText.java
@@ -546,9 +546,15 @@ public class ReactEditText extends AppCompatEditText {
* android.widget.TextView#isMultilineInputType(int)}} Source: {@Link <a
* href='https://android.googlesource.com/platform/frameworks/base/+/jb-release/core/java/android/widget/TextView.java'>TextView.java</a>}
*/
- if (isMultiline()) {
- setSingleLine(false);
- }
+ if (isMultiline()) {
+ // we save max lines as setSingleLines overwrites it
+ // https://android.googlesource.com/platform/frameworks/base/+/master/core/java/android/widget/TextView.java#10671
+ int maxLines = getMaxLines();
+ setSingleLine(false);
+ if (maxLines != -1) {
+ setMaxLines(maxLines);
+ }
+ }
// We override the KeyListener so that all keys on the soft input keyboard as well as hardware
// keyboards work. Some KeyListeners like DigitsKeyListener will display the keyboard but not
diff --git a/node_modules/react-native/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactTextInputLocalData.java b/node_modules/react-native/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactTextInputLocalData.java
index a850510..c59be1d 100644
--- a/node_modules/react-native/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactTextInputLocalData.java
+++ b/node_modules/react-native/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactTextInputLocalData.java
@@ -41,9 +41,9 @@ public final class ReactTextInputLocalData {
public void apply(EditText editText) {
editText.setText(mText);
editText.setTextSize(TypedValue.COMPLEX_UNIT_PX, mTextSize);
+ editText.setInputType(mInputType);
editText.setMinLines(mMinLines);
editText.setMaxLines(mMaxLines);
- editText.setInputType(mInputType);
editText.setHint(mPlaceholder);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
editText.setBreakStrategy(mBreakStrategy);
diff --git a/node_modules/react-native/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactTextInputManager.java b/node_modules/react-native/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactTextInputManager.java
index 8496a7d..e4d975b 100644
--- a/node_modules/react-native/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactTextInputManager.java
+++ b/node_modules/react-native/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactTextInputManager.java
@@ -736,9 +736,18 @@ public class ReactTextInputManager extends BaseViewManager<ReactEditText, Layout
@ReactProp(name = ViewProps.NUMBER_OF_LINES, defaultInt = 1)
public void setNumLines(ReactEditText view, int numLines) {
+ view.setInputType(view.getInputType() | InputType.TYPE_TEXT_FLAG_MULTI_LINE);
view.setLines(numLines);
}
+ @ReactProp(name = ViewProps.MAXIMUM_NUMBER_OF_LINES, defaultInt = 1)
+ public void setMaxNumLines(ReactEditText view, int numLines) {
+ if ((view.getInputType() & InputType.TYPE_TEXT_FLAG_MULTI_LINE) == 0) {
+ view.setInputType(view.getInputType() | InputType.TYPE_TEXT_FLAG_MULTI_LINE);
+ }
+ view.setMaxLines(numLines);
+ }
+
@ReactProp(name = "maxLength")
public void setMaxLength(ReactEditText view, @Nullable Integer maxLength) {
InputFilter[] currentFilters = view.getFilters();
diff --git a/node_modules/react-native/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactTextInputShadowNode.java b/node_modules/react-native/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactTextInputShadowNode.java
index 8c123d7..f2bbd81 100644
--- a/node_modules/react-native/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactTextInputShadowNode.java
+++ b/node_modules/react-native/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactTextInputShadowNode.java
@@ -116,6 +116,10 @@ public class ReactTextInputShadowNode extends ReactBaseTextShadowNode
if (mNumberOfLines != UNSET) {
editText.setLines(mNumberOfLines);
+ } else {
+ if (mMaxNumberOfLines != UNSET) {
+ editText.setMaxLines(mMaxNumberOfLines);
+ }
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M
diff --git a/node_modules/react-native/ReactCommon/react/renderer/attributedstring/ParagraphAttributes.cpp b/node_modules/react-native/ReactCommon/react/renderer/attributedstring/ParagraphAttributes.cpp
index f2317ba..10f342c 100644
--- a/node_modules/react-native/ReactCommon/react/renderer/attributedstring/ParagraphAttributes.cpp
+++ b/node_modules/react-native/ReactCommon/react/renderer/attributedstring/ParagraphAttributes.cpp
@@ -16,6 +16,7 @@ namespace facebook::react {
bool ParagraphAttributes::operator==(const ParagraphAttributes& rhs) const {
return std::tie(
+ numberOfLines,
maximumNumberOfLines,
ellipsizeMode,
textBreakStrategy,
@@ -23,6 +24,7 @@ bool ParagraphAttributes::operator==(const ParagraphAttributes& rhs) const {
includeFontPadding,
android_hyphenationFrequency) ==
std::tie(
+ rhs.numberOfLines,
rhs.maximumNumberOfLines,
rhs.ellipsizeMode,
rhs.textBreakStrategy,
@@ -42,6 +44,7 @@ bool ParagraphAttributes::operator!=(const ParagraphAttributes& rhs) const {
#if RN_DEBUG_STRING_CONVERTIBLE
SharedDebugStringConvertibleList ParagraphAttributes::getDebugProps() const {
return {
+ debugStringConvertibleItem("numberOfLines", numberOfLines),
debugStringConvertibleItem("maximumNumberOfLines", maximumNumberOfLines),
debugStringConvertibleItem("ellipsizeMode", ellipsizeMode),
debugStringConvertibleItem("textBreakStrategy", textBreakStrategy),
diff --git a/node_modules/react-native/ReactCommon/react/renderer/attributedstring/ParagraphAttributes.h b/node_modules/react-native/ReactCommon/react/renderer/attributedstring/ParagraphAttributes.h
index d73f863..1f85b22 100644
--- a/node_modules/react-native/ReactCommon/react/renderer/attributedstring/ParagraphAttributes.h
+++ b/node_modules/react-native/ReactCommon/react/renderer/attributedstring/ParagraphAttributes.h
@@ -29,6 +29,11 @@ class ParagraphAttributes : public DebugStringConvertible {
public:
#pragma mark - Fields
+ /*
+ * Number of lines which paragraph takes.
+ */
+ int numberOfLines{};
+
/*
* Maximum number of lines which paragraph can take.
* Zero value represents "no limit".
@@ -89,6 +94,7 @@ struct hash<facebook::react::ParagraphAttributes> {
size_t operator()(
const facebook::react::ParagraphAttributes& attributes) const {
return facebook::react::hash_combine(
+ attributes.numberOfLines,
attributes.maximumNumberOfLines,
attributes.ellipsizeMode,
attributes.textBreakStrategy,
diff --git a/node_modules/react-native/ReactCommon/react/renderer/attributedstring/conversions.h b/node_modules/react-native/ReactCommon/react/renderer/attributedstring/conversions.h
index 445e452..3f0bb36 100644
--- a/node_modules/react-native/ReactCommon/react/renderer/attributedstring/conversions.h
+++ b/node_modules/react-native/ReactCommon/react/renderer/attributedstring/conversions.h
@@ -692,10 +692,16 @@ inline ParagraphAttributes convertRawProp(
const ParagraphAttributes& defaultParagraphAttributes) {
auto paragraphAttributes = ParagraphAttributes{};
- paragraphAttributes.maximumNumberOfLines = convertRawProp(
+ paragraphAttributes.numberOfLines = convertRawProp(
context,
rawProps,
"numberOfLines",
+ sourceParagraphAttributes.numberOfLines,
+ defaultParagraphAttributes.numberOfLines);
+ paragraphAttributes.maximumNumberOfLines = convertRawProp(
+ context,
+ rawProps,
+ "maximumNumberOfLines",
sourceParagraphAttributes.maximumNumberOfLines,
defaultParagraphAttributes.maximumNumberOfLines);
paragraphAttributes.ellipsizeMode = convertRawProp(
@@ -770,6 +776,7 @@ inline std::string toString(const AttributedString::Range& range) {
inline folly::dynamic toDynamic(
const ParagraphAttributes& paragraphAttributes) {
auto values = folly::dynamic::object();
+ values("numberOfLines", paragraphAttributes.numberOfLines);
values("maximumNumberOfLines", paragraphAttributes.maximumNumberOfLines);
values("ellipsizeMode", toString(paragraphAttributes.ellipsizeMode));
values("textBreakStrategy", toString(paragraphAttributes.textBreakStrategy));
@@ -979,6 +986,7 @@ constexpr static MapBuffer::Key PA_KEY_TEXT_BREAK_STRATEGY = 2;
constexpr static MapBuffer::Key PA_KEY_ADJUST_FONT_SIZE_TO_FIT = 3;
constexpr static MapBuffer::Key PA_KEY_INCLUDE_FONT_PADDING = 4;
constexpr static MapBuffer::Key PA_KEY_HYPHENATION_FREQUENCY = 5;
+constexpr static MapBuffer::Key PA_KEY_NUMBER_OF_LINES = 6;
inline MapBuffer toMapBuffer(const ParagraphAttributes& paragraphAttributes) {
auto builder = MapBufferBuilder();
@@ -996,6 +1004,8 @@ inline MapBuffer toMapBuffer(const ParagraphAttributes& paragraphAttributes) {
builder.putString(
PA_KEY_HYPHENATION_FREQUENCY,
toString(paragraphAttributes.android_hyphenationFrequency));
+ builder.putInt(
+ PA_KEY_NUMBER_OF_LINES, paragraphAttributes.numberOfLines);
return builder.build();
}
diff --git a/node_modules/react-native/ReactCommon/react/renderer/components/textinput/androidtextinput/react/renderer/components/androidtextinput/AndroidTextInputProps.cpp b/node_modules/react-native/ReactCommon/react/renderer/components/textinput/androidtextinput/react/renderer/components/androidtextinput/AndroidTextInputProps.cpp
index 116284f..5749c57 100644
--- a/node_modules/react-native/ReactCommon/react/renderer/components/textinput/androidtextinput/react/renderer/components/androidtextinput/AndroidTextInputProps.cpp
+++ b/node_modules/react-native/ReactCommon/react/renderer/components/textinput/androidtextinput/react/renderer/components/androidtextinput/AndroidTextInputProps.cpp
@@ -56,6 +56,10 @@ AndroidTextInputProps::AndroidTextInputProps(
"numberOfLines",
sourceProps.numberOfLines,
{0})),
+ maximumNumberOfLines(CoreFeatures::enablePropIteratorSetter? sourceProps.maximumNumberOfLines : convertRawProp(context, rawProps,
+ "maximumNumberOfLines",
+ sourceProps.maximumNumberOfLines,
+ {0})),
disableFullscreenUI(CoreFeatures::enablePropIteratorSetter? sourceProps.disableFullscreenUI : convertRawProp(context, rawProps,
"disableFullscreenUI",
sourceProps.disableFullscreenUI,
@@ -281,6 +285,12 @@ void AndroidTextInputProps::setProp(
value,
paragraphAttributes,
maximumNumberOfLines,
+ "maximumNumberOfLines");
+ REBUILD_FIELD_SWITCH_CASE(
+ paDefaults,
+ value,
+ paragraphAttributes,
+ numberOfLines,
"numberOfLines");
REBUILD_FIELD_SWITCH_CASE(
paDefaults, value, paragraphAttributes, ellipsizeMode, "ellipsizeMode");
@@ -323,6 +333,7 @@ void AndroidTextInputProps::setProp(
}
switch (hash) {
+ RAW_SET_PROP_SWITCH_CASE_BASIC(maximumNumberOfLines);
RAW_SET_PROP_SWITCH_CASE_BASIC(autoComplete);
RAW_SET_PROP_SWITCH_CASE_BASIC(returnKeyLabel);
RAW_SET_PROP_SWITCH_CASE_BASIC(numberOfLines);
@@ -422,6 +433,7 @@ void AndroidTextInputProps::setProp(
// TODO T53300085: support this in codegen; this was hand-written
folly::dynamic AndroidTextInputProps::getDynamic() const {
folly::dynamic props = folly::dynamic::object();
+ props["maximumNumberOfLines"] = maximumNumberOfLines;
props["autoComplete"] = autoComplete;
props["returnKeyLabel"] = returnKeyLabel;
props["numberOfLines"] = numberOfLines;
diff --git a/node_modules/react-native/ReactCommon/react/renderer/components/textinput/androidtextinput/react/renderer/components/androidtextinput/AndroidTextInputProps.h b/node_modules/react-native/ReactCommon/react/renderer/components/textinput/androidtextinput/react/renderer/components/androidtextinput/AndroidTextInputProps.h
index 43cbb68..0bf63e7 100644
--- a/node_modules/react-native/ReactCommon/react/renderer/components/textinput/androidtextinput/react/renderer/components/androidtextinput/AndroidTextInputProps.h
+++ b/node_modules/react-native/ReactCommon/react/renderer/components/textinput/androidtextinput/react/renderer/components/androidtextinput/AndroidTextInputProps.h
@@ -81,6 +81,7 @@ class AndroidTextInputProps final : public ViewProps, public BaseTextProps {
std::string autoComplete{};
std::string returnKeyLabel{};
int numberOfLines{0};
+ int maximumNumberOfLines{0};
bool disableFullscreenUI{false};
std::string textBreakStrategy{};
SharedColor underlineColorAndroid{};
diff --git a/node_modules/react-native/ReactCommon/react/renderer/textlayoutmanager/platform/ios/react/renderer/textlayoutmanager/RCTTextLayoutManager.mm b/node_modules/react-native/ReactCommon/react/renderer/textlayoutmanager/platform/ios/react/renderer/textlayoutmanager/RCTTextLayoutManager.mm
index 368c334..ef9ec17 100644
--- a/node_modules/react-native/ReactCommon/react/renderer/textlayoutmanager/platform/ios/react/renderer/textlayoutmanager/RCTTextLayoutManager.mm
+++ b/node_modules/react-native/ReactCommon/react/renderer/textlayoutmanager/platform/ios/react/renderer/textlayoutmanager/RCTTextLayoutManager.mm
@@ -244,26 +244,49 @@ - (void)getRectWithAttributedString:(AttributedString)attributedString
#pragma mark - Private
-- (NSTextStorage *)_textStorageForNSAttributesString:(NSAttributedString *)attributedString
+- (NSTextStorage *)_textStorageForNSAttributesString:(NSAttributedString *)inputAttributedString
paragraphAttributes:(ParagraphAttributes)paragraphAttributes
size:(CGSize)size
{
- NSTextContainer *textContainer = [[NSTextContainer alloc] initWithSize:size];
+NSMutableAttributedString *attributedString = [ inputAttributedString mutableCopy];
+ /*
+ * The block below is responsible for setting the exact height of the view in lines
+ * Unfortunatelly, iOS doesn't export any easy way to do it. So we set maximumNumberOfLines
+ * prop and then add random lines at the front. However, they are only used for layout
+ * so they are not visible on the screen. This method is used for drawing only for Paragraph component
+ * but we set exact height in lines only on TextInput that doesn't use it.
+ */
+ if (paragraphAttributes.numberOfLines) {
+ paragraphAttributes.maximumNumberOfLines = paragraphAttributes.numberOfLines;
+ NSMutableString *newLines = [NSMutableString stringWithCapacity: paragraphAttributes.numberOfLines];
+ for (NSUInteger i = 0UL; i < paragraphAttributes.numberOfLines; ++i) {
+ // K is added on purpose. New line seems to be not enough for NTtextContainer
+ [newLines appendString:@"K\n"];
+ }
+ NSDictionary<NSAttributedStringKey, id> * attributesOfFirstCharacter = [inputAttributedString attributesAtIndex:0 effectiveRange:NULL];
- textContainer.lineFragmentPadding = 0.0; // Note, the default value is 5.
- textContainer.lineBreakMode = paragraphAttributes.maximumNumberOfLines > 0
- ? RCTNSLineBreakModeFromEllipsizeMode(paragraphAttributes.ellipsizeMode)
- : NSLineBreakByClipping;
- textContainer.maximumNumberOfLines = paragraphAttributes.maximumNumberOfLines;
+ [attributedString insertAttributedString:[[NSAttributedString alloc] initWithString:newLines attributes:attributesOfFirstCharacter] atIndex:0];
+ }
+
+ NSTextContainer *textContainer = [NSTextContainer new];
NSLayoutManager *layoutManager = [NSLayoutManager new];
layoutManager.usesFontLeading = NO;
[layoutManager addTextContainer:textContainer];
- NSTextStorage *textStorage = [[NSTextStorage alloc] initWithAttributedString:attributedString];
+ NSTextStorage *textStorage = [NSTextStorage new];
[textStorage addLayoutManager:layoutManager];
+ textContainer.lineFragmentPadding = 0.0; // Note, the default value is 5.
+ textContainer.lineBreakMode = paragraphAttributes.maximumNumberOfLines > 0
+ ? RCTNSLineBreakModeFromEllipsizeMode(paragraphAttributes.ellipsizeMode)
+ : NSLineBreakByClipping;
+ textContainer.size = size;
+ textContainer.maximumNumberOfLines = paragraphAttributes.maximumNumberOfLines;
+
+ [textStorage replaceCharactersInRange:(NSRange){0, textStorage.length} withAttributedString:attributedString];
+
if (paragraphAttributes.adjustsFontSizeToFit) {
CGFloat minimumFontSize = !isnan(paragraphAttributes.minimumFontSize) ? paragraphAttributes.minimumFontSize : 4.0;
CGFloat maximumFontSize = !isnan(paragraphAttributes.maximumFontSize) ? paragraphAttributes.maximumFontSize : 96.0;