Unverified Commit 68fb0089 authored by Bryan Oltman's avatar Bryan Oltman Committed by GitHub

Add textDirection property to CupertinoTextField and CupertinoTextFormFieldRow (#86482)

parent 5af58e22
......@@ -251,6 +251,7 @@ class CupertinoTextField extends StatefulWidget {
this.strutStyle,
this.textAlign = TextAlign.start,
this.textAlignVertical,
this.textDirection,
this.readOnly = false,
ToolbarOptions? toolbarOptions,
this.showCursor,
......@@ -404,6 +405,7 @@ class CupertinoTextField extends StatefulWidget {
this.strutStyle,
this.textAlign = TextAlign.start,
this.textAlignVertical,
this.textDirection,
this.readOnly = false,
ToolbarOptions? toolbarOptions,
this.showCursor,
......@@ -608,6 +610,9 @@ class CupertinoTextField extends StatefulWidget {
/// {@macro flutter.material.InputDecorator.textAlignVertical}
final TextAlignVertical? textAlignVertical;
/// {@macro flutter.widgets.editableText.textDirection}
final TextDirection? textDirection;
/// {@macro flutter.widgets.editableText.readOnly}
final bool readOnly;
......@@ -819,6 +824,7 @@ class CupertinoTextField extends StatefulWidget {
properties.add(DiagnosticsProperty<ScrollPhysics>('scrollPhysics', scrollPhysics, defaultValue: null));
properties.add(EnumProperty<TextAlign>('textAlign', textAlign, defaultValue: TextAlign.start));
properties.add(DiagnosticsProperty<TextAlignVertical>('textAlignVertical', textAlignVertical, defaultValue: null));
properties.add(EnumProperty<TextDirection>('textDirection', textDirection, defaultValue: null));
}
}
......@@ -1176,6 +1182,7 @@ class _CupertinoTextFieldState extends State<CupertinoTextField> with Restoratio
style: textStyle,
strutStyle: widget.strutStyle,
textAlign: widget.textAlign,
textDirection: widget.textDirection,
autofocus: widget.autofocus,
obscuringCharacter: widget.obscuringCharacter,
obscureText: widget.obscureText,
......
......@@ -144,6 +144,7 @@ class CupertinoTextFormFieldRow extends FormField<String> {
TextInputAction? textInputAction,
TextStyle? style,
StrutStyle? strutStyle,
TextDirection? textDirection,
TextAlign textAlign = TextAlign.start,
TextAlignVertical? textAlignVertical,
bool autofocus = false,
......@@ -238,6 +239,7 @@ class CupertinoTextFormFieldRow extends FormField<String> {
textAlign: textAlign,
textAlignVertical: textAlignVertical,
textCapitalization: textCapitalization,
textDirection: textDirection,
autofocus: autofocus,
toolbarOptions: toolbarOptions,
readOnly: readOnly,
......
......@@ -4779,4 +4779,32 @@ void main() {
expect(disabledColor, isSameColorAs(const Color(0xFFFAFAFA)));
},
);
testWidgets('textDirection is passed to EditableText', (WidgetTester tester) async {
await tester.pumpWidget(
const CupertinoApp(
home: Center(
child: CupertinoTextField(
textDirection: TextDirection.ltr,
),
),
),
);
final EditableText ltrWidget = tester.widget(find.byType(EditableText));
expect(ltrWidget.textDirection, TextDirection.ltr);
await tester.pumpWidget(
const CupertinoApp(
home: Center(
child: CupertinoTextField(
textDirection: TextDirection.rtl,
),
),
),
);
final EditableText rtlWidget = tester.widget(find.byType(EditableText));
expect(rtlWidget.textDirection, TextDirection.rtl);
});
}
......@@ -458,4 +458,38 @@ void main() {
final Text errorText = tester.widget(errorTextFinder);
expect(errorText.data, 'Enter Value');
});
testWidgets('Passes textDirection to underlying CupertinoTextField', (WidgetTester tester) async {
await tester.pumpWidget(
CupertinoApp(
home: Center(
child: CupertinoTextFormFieldRow(
textDirection: TextDirection.ltr,
),
),
),
);
final Finder ltrTextFieldFinder = find.byType(CupertinoTextField);
expect(ltrTextFieldFinder, findsOneWidget);
final CupertinoTextField ltrTextFieldWidget = tester.widget(ltrTextFieldFinder);
expect(ltrTextFieldWidget.textDirection, TextDirection.ltr);
await tester.pumpWidget(
CupertinoApp(
home: Center(
child: CupertinoTextFormFieldRow(
textDirection: TextDirection.rtl,
),
),
),
);
final Finder rtlTextFieldFinder = find.byType(CupertinoTextField);
expect(rtlTextFieldFinder, findsOneWidget);
final CupertinoTextField rtlTextFieldWidget = tester.widget(rtlTextFieldFinder);
expect(rtlTextFieldWidget.textDirection, TextDirection.rtl);
});
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment