New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[TIMOB-16512] Android: added padding to TextField #7908
Conversation
Please add docs, thanks! |
Thank you. Please also add the |
Will FT now and merge, looks all good! Maybe we should think of moving the padding to a more clean way (on both iOS and Android) with something like this: var field = Ti.UI.createTextField({
padding: {
left: 10,
right: 10,
top: 10,
bottom: 10
}
}); Does that make sense to you? So we would handle it like we do with listSeparatorInsets and other "bounds-like" API's. But that should be covered in a separate ticket. |
@hansemannn sounds like a good idea and looks better. Should I change it for this PR or leave it like this for the moment so it's the same on iOS? |
Let's leave like it is for now and I'll file a ticket for it the next days. Thanks! |
You know what, let's do that change in this PR, I will setup one for iOS and we merge both for 5.4.0. Otherwise, we would change and deprecate the whole thing in 5.5.0 / 6.0.0 again and that produces even more work. |
Ok, I'll get the android part ready |
Changed it ;) I've added |
|
||
- name: bottom | ||
type: Number | ||
summary: Bottom padding |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
iOS only allows left and right padding because an input should always be vertically centered. We should consider doing the same with Android, so we don't need to handle different behaviors across platforms. Also please deprecate the old properties.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done!
- syntex:
padding: {left:10,right:10}
- updated example on jira
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TextArea will still be TOP/LEFT, TextField is always vertically aligned
Alright! Now you decide: Are you fine with me cherry-picking your commits and setup a new PR including iOS and Android to have the platforms combinded in one PR, or do you want me to merge yours first and setup another one? 😊 |
See ti-slack: if its less work with cherry-picking feel free to create a new PR with iOS and Android! |
Tested and reviewed this with app.js var win = Ti.UI.createWindow({
layout: "vertical",
backgroundColor: "#fff"
});
var t1 = Ti.UI.createTextField({
value: "lllllllllmmmmmmmmmmmmmmlllllllllll",
padding: {
left: 20,
right: 0
},
width: 100,
height: Ti.UI.SIZE,
borderColor: "#000",
color: "#000",
borderWidth: 1,
top: 10
});
var t2 = Ti.UI.createTextField({
value: "lllllllllmmmmmmmmmmmmmmlllllllllll",
padding: {
right: 20,
left: 0
},
width: 100,
height: Ti.UI.SIZE,
borderColor: "#000",
color: "#000",
borderWidth: 1,
top: 10
});
var t3 = Ti.UI.createTextField({
value: "lllllllllmmmmmmmmmmmmmmlllllllllll",
padding: {
left: 20,
right: 20
},
width: 100,
height: Ti.UI.SIZE,
borderColor: "#000",
color: "#000",
borderWidth: 1,
top: 10
});
var t4 = Ti.UI.createTextField({
value: "lllllllllmmmmmmmmmmmmmmlllllllllll",
width: 100,
height: 100,
borderColor: "#000",
color: "#000",
borderWidth: 1,
top: 10
});
win.add(t1);
win.add(t2);
win.add(t3);
win.add(t4);
win.open();
t4.padding = {left: 50, right: 50}; Code working fine and looks good. Is there a link for iOS PR? |
I think we should push this for 6.0.0. That way, we won't need to rush this. @hansemannn |
Code reviewed and tested. Approved |
since: "5.4.0" | ||
notes: Use padding instead | ||
|
||
- name: paddingRight |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So paddingLeft
and paddingRight
haven't been documented for Ti.UI.TextArea
before? EDIT: It haven't been available for iOS before, so we don't need to deprecate it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So paddingLeft
and paddingRight
haven't been documented for Ti.UI.TextArea
before?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So paddingLeft
and paddingRight
haven't been documented for Ti.UI.TextArea
before?
Just a note, this will be for 6.0.0. |
int paddingRight = 0; | ||
|
||
if (d.containsKey(TiC.PROPERTY_LEFT)) { | ||
paddingLeft = TiConvert.toInt(d, TiC.PROPERTY_LEFT); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use TiConvert methods that with a fall back default in case the input is invalid like null and such. Something like this TiConvert.toInt(d, TiC.PROPERTY_LEFT, someDefaultValue).
paddingLeft = tv.getPaddingLeft(); | ||
} | ||
if (d.containsKey(TiC.PROPERTY_RIGHT)) { | ||
paddingRight = TiConvert.toInt(d, TiC.PROPERTY_RIGHT); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here
@hieupham007 This looks like it's good to go. |
Merging |
Can one of the admins verify this patch? |
@hansemannn was the iOS part merged into 6.0.0? I've tried to set |
👍 |
@jpriebe see this comment: #7908 (comment) |
Thanks, guys. I was mistakenly looking at TiUIEditText instead of TiUIText. After some experimentation, I have been able to get padding to work on android, but I have found that vertical padding of 0 doesn't really mean 0 from a visual standpoint. It looks like there is about 12dp of padding on top and bottom that can't be removed. That was leading me to believe that padding didn't work. When you try to set the size of a text field to something slightly smaller than the default (e.g. 30dp), the padding remains, and the text is cut off. I guess the bottom line is that there's no way to create a compact TextField on android. (I know, it violates all sorts of usability guidelines to create something that small, but I think there are some legitimate applications. |
JIRA: https://jira.appcelerator.org/browse/TIMOB-16512
Updating the #5492 PR so can be used with the current branch again. All the credit goes to @bijupmb .