mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-16 11:42:04 +08:00
Merge pull request #974 from NativeScript/switch-css
Switch color and background-color css support added
This commit is contained in:
@ -3,6 +3,8 @@ import helper = require("../helper");
|
||||
import viewModule = require("ui/core/view");
|
||||
import bindable = require("ui/core/bindable");
|
||||
import observable = require("data/observable");
|
||||
import color = require("color");
|
||||
import platform = require("platform");
|
||||
// <snippet module="ui/switch" title="switch">
|
||||
// # Switch
|
||||
// Using a switch requires the Switch module.
|
||||
@ -51,6 +53,31 @@ export function test_default_native_values() {
|
||||
helper.buildUIAndRunTest(mySwitch, testAction);
|
||||
}
|
||||
|
||||
// Uncomment this when find way to check android Drawable color set by setColorFilter() method.
|
||||
if (platform.device.os === platform.platformNames.ios) {
|
||||
exports.test_set_color = function () {
|
||||
var mySwitch = new switchModule.Switch();
|
||||
mySwitch.color = new color.Color("red");
|
||||
|
||||
function testAction(views: Array<viewModule.View>) {
|
||||
TKUnit.assert(mySwitch.color.ios.isEqual(mySwitch.ios.thumbTintColor), "mySwitch.color");
|
||||
};
|
||||
|
||||
helper.buildUIAndRunTest(mySwitch, testAction);
|
||||
}
|
||||
|
||||
exports.test_set_backgroundColor = function () {
|
||||
var mySwitch = new switchModule.Switch();
|
||||
mySwitch.backgroundColor = new color.Color("red");
|
||||
|
||||
function testAction(views: Array<viewModule.View>) {
|
||||
TKUnit.assert(CGColorEqualToColor(mySwitch.backgroundColor.ios.CGColor, mySwitch.ios.onTintColor.CGColor), "mySwitch.color");
|
||||
};
|
||||
|
||||
helper.buildUIAndRunTest(mySwitch, testAction);
|
||||
}
|
||||
}
|
||||
|
||||
export function test_set_TNS_checked_updates_native_checked() {
|
||||
var mySwitch = new switchModule.Switch();
|
||||
function testAction(views: Array<viewModule.View>) {
|
||||
|
6
apps/ui-tests-app/pages/switchandprogress.xml
Normal file
6
apps/ui-tests-app/pages/switchandprogress.xml
Normal file
@ -0,0 +1,6 @@
|
||||
<Page>
|
||||
<StackLayout>
|
||||
<Progress value="45" color="red" backgroundColor="green" />
|
||||
<Switch color="red" backgroundColor="green" />
|
||||
</StackLayout>
|
||||
</Page>
|
Reference in New Issue
Block a user