mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
Cleanup type symbol usage by consolidating to manage in one spot. This makes them easier to use as well by providing a single rollup of all the common type symbol's used throughout core.
28 lines
864 B
TypeScript
28 lines
864 B
TypeScript
import * as labelModule from '@nativescript/core/ui/label';
|
|
import { Enums } from '@nativescript/core';
|
|
import * as colorModule from '@nativescript/core/color';
|
|
import { getColor } from '../../ui-helper';
|
|
|
|
export function getNativeTextAlignment(label: labelModule.Label): string {
|
|
switch (label.ios.textAlignment) {
|
|
case NSTextAlignment.Left:
|
|
return CoreTypes.TextAlignment.left;
|
|
case NSTextAlignment.Center:
|
|
return CoreTypes.TextAlignment.center;
|
|
case NSTextAlignment.Right:
|
|
return CoreTypes.TextAlignment.right;
|
|
default:
|
|
return 'unexpected value';
|
|
}
|
|
}
|
|
|
|
export function getNativeBackgroundColor(label: labelModule.Label): colorModule.Color {
|
|
var layer = (<UILabel>label.ios).layer;
|
|
if (!layer || !layer.backgroundColor) {
|
|
return undefined;
|
|
}
|
|
var uiColor = UIColor.colorWithCGColor(layer.backgroundColor);
|
|
|
|
return getColor(uiColor);
|
|
}
|