Skip to content

Commit

Permalink
fix(android): textfield padding (#13279)
Browse files Browse the repository at this point in the history
* fix(android): textfield padding

* add test

Co-authored-by: Sebastian Klaus <sebastian@lightapps.de>
  • Loading branch information
m1ga and caspahouzer committed Jul 11, 2022
1 parent a742403 commit dcdfce5
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 6 deletions.
Expand Up @@ -310,10 +310,10 @@ private void updateTextField()

private void setTextPadding(HashMap<String, Object> d)
{
int paddingLeft = textInputLayout.getPaddingLeft();
int paddingRight = textInputLayout.getPaddingRight();
int paddingTop = textInputLayout.getPaddingTop();
int paddingBottom = textInputLayout.getPaddingBottom();
int paddingLeft = tv.getPaddingLeft();
int paddingRight = tv.getPaddingRight();
int paddingTop = tv.getPaddingTop();
int paddingBottom = tv.getPaddingBottom();

if (d.containsKey(TiC.PROPERTY_LEFT)) {
paddingLeft = TiConvert.toInt(d.get(TiC.PROPERTY_LEFT), 0);
Expand All @@ -330,8 +330,7 @@ private void setTextPadding(HashMap<String, Object> d)
if (d.containsKey(TiC.PROPERTY_BOTTOM)) {
paddingBottom = TiConvert.toInt(d.get(TiC.PROPERTY_BOTTOM), 0);
}

textInputLayout.setPadding(paddingLeft, paddingTop, paddingRight, paddingBottom);
tv.setPadding(paddingLeft, paddingTop, paddingRight, paddingBottom);
}

@Override
Expand Down
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
37 changes: 37 additions & 0 deletions tests/Resources/ti.ui.textfield.test.js
Expand Up @@ -144,6 +144,43 @@ describe('Titanium.UI.TextField', () => {
win.open();
});

it.android('android padding (visual check)', function (finish) {
this.timeout(5000);
const textField = Ti.UI.createTextField({
value: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec nec ullamcorper massa, eget tempor sapien. Phasellus nisi metus, tempus a magna nec, ultricies rutrum lacus. Aliquam sit amet augue suscipit, dignissim tellus eu, consectetur elit. Praesent ligula velit, blandit vel urna sit amet, suscipit euismod nunc.',
width: 100,
height: 40,
backgroundColor: 'white',
color: 'black',
padding: {
top: 10,
bottom: 10
}
});
const bgView = Ti.UI.createView({
width: 200,
height: 100,
backgroundColor: 'red'
});
win = Ti.UI.createWindow({
backgroundColor: '#eee'
});
bgView.add(textField);
win.add(bgView);

win.addEventListener('postlayout', function postlayout() { // FIXME: Support once!
win.removeEventListener('postlayout', postlayout); // only run once
try {
should(textField).matchImage('snapshots/textfieldPadding.png');
} catch (err) {
return finish(err);
}
finish();
});

win.open();
});

describe('.hintText', () => {
let textField;
beforeEach(() => {
Expand Down

0 comments on commit dcdfce5

Please sign in to comment.