Files
NativeScript/apps/automated/app/ui/label/label-tests-native.android.ts
Nathan Walker 1e6fccf272 chore: cleanup
2020-07-23 14:03:37 -07:00

31 lines
1.1 KiB
TypeScript

import * as labelModule from '@nativescript/core/ui/label';
import * as enums from '@nativescript/core/ui/enums';
import * as colorModule from '@nativescript/core/color';
export function getNativeTextAlignment(label: labelModule.Label): string {
var gravity = label.android.getGravity();
if ((gravity & android.view.Gravity.HORIZONTAL_GRAVITY_MASK) === android.view.Gravity.LEFT) {
return enums.TextAlignment.left;
}
if ((gravity & android.view.Gravity.HORIZONTAL_GRAVITY_MASK) === android.view.Gravity.CENTER_HORIZONTAL) {
return enums.TextAlignment.center;
}
if ((gravity & android.view.Gravity.HORIZONTAL_GRAVITY_MASK) === android.view.Gravity.RIGHT) {
return enums.TextAlignment.right;
}
return 'unexpected value';
}
export function getNativeBackgroundColor(label: labelModule.Label): colorModule.Color {
var bkg = <any>label.android.getBackground();
if (bkg instanceof org.nativescript.widgets.BorderDrawable) {
return new colorModule.Color((<org.nativescript.widgets.BorderDrawable>bkg).getBackgroundColor());
} else {
return new colorModule.Color(bkg.backgroundColor);
}
}