Skip to content

Commit

Permalink
feat: custom text selection color
Browse files Browse the repository at this point in the history
  • Loading branch information
mopsicus committed Aug 28, 2024
1 parent 860f672 commit d9af197
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,10 @@ private void Create(int id, JSONObject data) {
int caretColor_g = (int) (255.0f * data.getDouble("caret_color_g"));
int caretColor_b = (int) (255.0f * data.getDouble("caret_color_b"));
int caretColor_a = (int) (255.0f * data.getDouble("caret_color_a"));
int highlightColor_r = (int) (255.0f * data.getDouble("highlight_color_r"));
int highlightColor_g = (int) (255.0f * data.getDouble("highlight_color_g"));
int highlightColor_b = (int) (255.0f * data.getDouble("highlight_color_b"));
int highlightColor_a = (int) (255.0f * data.getDouble("highlight_color_a"));
String contentType = data.getString("content_type");
String inputType = data.optString("input_type");
String keyboardType = data.optString("keyboard_type");
Expand Down Expand Up @@ -402,6 +406,7 @@ private void Create(int id, JSONObject data) {
edit.setTextColor(Color.argb(textColor_a, textColor_r, textColor_g, textColor_b));
edit.setBackgroundColor(Color.argb(backColor_a, backColor_r, backColor_g, backColor_b));
edit.setHintTextColor(Color.argb(placeHolderColor_a, placeHolderColor_r, placeHolderColor_g, placeHolderColor_b));
edit.setHighlightColor(Color.argb(highlightColor_a, highlightColor_r, highlightColor_g, highlightColor_b));
if (!customFont.equals("default")) {
try {
Typeface face = Typeface.createFromAsset(Plugin.activity.getAssets(), String.format("%s.ttf", customFont));
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

All notable changes to this project will be documented in this file.

## [2.0.3] - 2024-08-28
- ### Added
- Custom text selection color (Android)

## [2.0.2] - 2024-08-27
- ### Added
- Custom caret/cursor/handles color
Expand Down
1 change: 1 addition & 0 deletions Documentation~/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ Many options from `TMP Input Field` will be applied to the native field. You can
- placeholder text
- placeholder text color
- cursor/caret color
- text selection color (Android, for iOS uses cursor/caret color)
- character limit
- font size
- text align
Expand Down
Binary file modified Plugins/Android/Mobileinput.aar
Binary file not shown.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ In the inspector, you can edit several options that will be applied to the nativ
- placeholder text
- placeholder text color
- cursor/caret color
- text selection color (Android)
- character limit
- font size
- text align
Expand Down
1 change: 1 addition & 0 deletions README.ru.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ public class Bootstrap : MonoBehaviour {
- цвет текста
- цвет текста подсказки
- цвет курсора/каретки
- цвет выделения текста (Android)
- текст подсказки
- лимит символов
- размер шрифта
Expand Down
8 changes: 7 additions & 1 deletion Runtime/MobileInputField.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ struct MobileInputConfig {
public Color BackgroundColor;
public bool ChangeCaret;
public Color CaretColor;
public Color HighlightColor;
public string ContentType;
public string InputType;
public string KeyboardType;
Expand Down Expand Up @@ -425,6 +426,7 @@ void PrepareNativeEdit() {
_config.Placeholder = placeHolder.text;
_config.PlaceholderColor = placeHolder.color;
_config.CaretColor = _inputObject.caretColor;
_config.HighlightColor = _inputObject.selectionColor;
_config.ChangeCaret = _inputObject.customCaretColor;
_config.CharacterLimit = _inputObject.characterLimit;
var rect = GetScreenRectFromRectTransform(_inputObjectText.rectTransform);
Expand Down Expand Up @@ -582,7 +584,11 @@ void CreateNativeEdit() {
data["caret_color_r"] = InvariantCultureString(_config.CaretColor.r);
data["caret_color_g"] = InvariantCultureString(_config.CaretColor.g);
data["caret_color_b"] = InvariantCultureString(_config.CaretColor.b);
data["caret_color_a"] = InvariantCultureString(_config.CaretColor.a);
data["caret_color_a"] = InvariantCultureString(_config.CaretColor.a);
data["highlight_color_r"] = InvariantCultureString(_config.HighlightColor.r);
data["highlight_color_g"] = InvariantCultureString(_config.HighlightColor.g);
data["highlight_color_b"] = InvariantCultureString(_config.HighlightColor.b);
data["highlight_color_a"] = InvariantCultureString(_config.HighlightColor.a);
data["caret_color"] = _config.ChangeCaret;
data["multiline"] = _config.Multiline;
data["input_type"] = _config.InputType;
Expand Down

0 comments on commit d9af197

Please sign in to comment.