diff --git a/README.md b/README.md index 0fae7d0..42cd1a7 100644 --- a/README.md +++ b/README.md @@ -24,7 +24,7 @@ Hope you find it useful and happy coding! 🎉🎉🎉 | Name | Type | Description | Default | |:----------------|:--------------|:-------------------------------|:-------------------------| | `controller` | TextEditingController | Controlling the text being edited (https://api.flutter.dev/flutter/material/TextField/controller.html) | null | -| `decoration` | BoxDecoration | Controls the BoxDecoration of the box behind the text input. (https://api.flutter.dev/flutter/cupertino/CupertinoTextField/decoration.html) | null | +| `cursorColor` | Color | The color of the cursor (https://api.flutter.dev/flutter/material/TextField/cursorColor.html) | null | `decoration` | BoxDecoration | Controls the BoxDecoration of the box behind the text input. (https://api.flutter.dev/flutter/cupertino/CupertinoTextField/decoration.html) | null | | `style` | TextStyle | The style to use for the text being edited [Only `fontSize`, `fontWeight`, `color` are supported] (https://api.flutter.dev/flutter/material/TextField/style.html) | null | | `placeholderStyle`| TextStyle | The style to use for the placeholder text. [Only `fontSize`, `fontWeight`, `color` are supported] (https://api.flutter.dev/flutter/cupertino/CupertinoTextField/placeholderStyle.html) | null | | `placeholder` | String | Placeholder text when text entry is empty (https://api.flutter.dev/flutter/cupertino/CupertinoTextField/placeholder.html) | null | @@ -35,8 +35,8 @@ Hope you find it useful and happy coding! 🎉🎉🎉 | `onSubmitted` | ValueChanged\ | Called when the user indicates that they are done editing the text in the field (https://api.flutter.dev/flutter/material/TextField/onSubmitted.html) | null | | `focusNode` | FocusNode | Defines the keyboard focus for this widget (https://api.flutter.dev/flutter/material/TextField/focusNode.html) | null | | `textAlign` | TextAlign | How the text should be aligned horizontally (https://api.flutter.dev/flutter/material/TextField/textAlign.html) | TextAlign.start | -| `minLines` | int | Minimum number of lines of text input widget | 1 | | `maxLines` | int | The maximum number of lines to show at one time, wrapping if necessary (https://api.flutter.dev/flutter/material/TextField/maxLines.html) | 1 | +| `minLines` | int | Minimum number of lines of text input widget | 1 | ## More examples diff --git a/example/lib/main.dart b/example/lib/main.dart index 928b1d1..7917afb 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -49,6 +49,7 @@ class HomePage extends StatelessWidget { DemoItem( title: 'Flutter CupertinoTextField Example Usage', child: CupertinoTextField( + cursorColor: Colors.black87, decoration: BoxDecoration( border: Border.all( color: Colors.black87, @@ -73,6 +74,7 @@ class HomePage extends StatelessWidget { title: 'NativeTextInput Example Usage', child: Platform.isIOS ? NativeTextInput( + cursorColor: Colors.black87, decoration: BoxDecoration( border: Border.all( color: Colors.black87, diff --git a/ios/Classes/NativeTextInput.m b/ios/Classes/NativeTextInput.m index 9ddfb58..5353a1f 100644 --- a/ios/Classes/NativeTextInput.m +++ b/ios/Classes/NativeTextInput.m @@ -36,6 +36,11 @@ - (instancetype)initWithFrame:(CGRect)frame if (@available(iOS 10.0, *)) { _textView.textContentType = [self textContentTypeFromString:args[@"textContentType"]]; } + if (args[@"cursorColor"] && ![args[@"cursorColor"] isKindOfClass:[NSNull class]]) { + NSDictionary* fontColor = args[@"cursorColor"]; + _textView.tintColor = [UIColor colorWithRed:[fontColor[@"red"] floatValue]/255.0 green:[fontColor[@"green"] floatValue]/255.0 blue:[fontColor[@"blue"] floatValue]/255.0 alpha:[fontColor[@"alpha"] floatValue]/255.0]; + } + _delegate = [[NativeTextInputDelegate alloc] initWithChannel:_channel arguments:args ]; _textView.delegate = _delegate; diff --git a/lib/flutter_native_text_input.dart b/lib/flutter_native_text_input.dart index c91d621..2d30576 100644 --- a/lib/flutter_native_text_input.dart +++ b/lib/flutter_native_text_input.dart @@ -73,6 +73,7 @@ class NativeTextInput extends StatefulWidget { const NativeTextInput({ Key? key, this.controller, + this.cursorColor, this.decoration, this.style, this.placeholderStyle, @@ -84,8 +85,8 @@ class NativeTextInput extends StatefulWidget { this.onSubmitted, this.focusNode, this.textAlign = TextAlign.start, - this.minLines = 1, this.maxLines = 1, + this.minLines = 1, }) : super(key: key); /// Controls the text being edited. @@ -93,6 +94,8 @@ class NativeTextInput extends StatefulWidget { /// If null, this widget will create its own [TextEditingController]. final TextEditingController? controller; + final Color? cursorColor; + final BoxDecoration? decoration; final TextStyle? style; @@ -270,6 +273,18 @@ class _NativeTextInputState extends State { }; } + if (widget.cursorColor != null) { + params = { + ...params, + "cursorColor": { + "red": widget.cursorColor?.red, + "green": widget.cursorColor?.green, + "blue": widget.cursorColor?.blue, + "alpha": widget.cursorColor?.alpha, + }, + }; + } + return params; }