mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-16 11:42:04 +08:00
Merge pull request #307 from NativeScript/view-backgroundImage
backgroundImage exposed to View
This commit is contained in:
@ -203,6 +203,17 @@ export function test_parse_ShouldParseSubProperties() {
|
||||
TKUnit.assert(sw.visibility === "collapsed", "Expected result: collapsed; Actual result: " + sw.visibility + "; type: " + typeof (sw.visibility));
|
||||
};
|
||||
|
||||
export function test_parse_CanBindBackgroundImage() {
|
||||
var p = <page.Page>builder.parse("<Page><StackLayout backgroundImage='{{ myProp }}' /></Page>");
|
||||
var expected = "~/logo.png"
|
||||
var obj = new observable.Observable();
|
||||
obj.set("myProp", expected);
|
||||
p.bindingContext = obj;
|
||||
var sw = <stackLayoutModule.StackLayout>p.content;
|
||||
|
||||
TKUnit.assert(sw.backgroundImage === expected, "Expected result: " + expected + "; Actual result: " + sw.backgroundImage);
|
||||
};
|
||||
|
||||
export function test_parse_ShouldParseCustomComponentWithoutXml() {
|
||||
var p = <page.Page>builder.parse('<Page xmlns:customControls="xml-declaration/mymodule"><customControls:MyControl /></Page>');
|
||||
var ctrl = p.content;
|
||||
|
@ -77,25 +77,25 @@ function onCssClassPropertyChanged(data: dependencyObservable.PropertyChangeData
|
||||
}
|
||||
}
|
||||
|
||||
var idProperty = new dependencyObservable.Property(
|
||||
var idProperty = new dependencyObservable.Property(
|
||||
"id",
|
||||
"View",
|
||||
new proxy.PropertyMetadata(undefined, dependencyObservable.PropertyMetadataSettings.AffectsStyle)
|
||||
);
|
||||
|
||||
var cssClassProperty = new dependencyObservable.Property(
|
||||
var cssClassProperty = new dependencyObservable.Property(
|
||||
"cssClass",
|
||||
"View",
|
||||
new proxy.PropertyMetadata(undefined, dependencyObservable.PropertyMetadataSettings.AffectsStyle, onCssClassPropertyChanged)
|
||||
);
|
||||
|
||||
var isEnabledProperty = new dependencyObservable.Property(
|
||||
var isEnabledProperty = new dependencyObservable.Property(
|
||||
"isEnabled",
|
||||
"View",
|
||||
new proxy.PropertyMetadata(true)
|
||||
);
|
||||
|
||||
var isUserInteractionEnabledProperty = new dependencyObservable.Property(
|
||||
var isUserInteractionEnabledProperty = new dependencyObservable.Property(
|
||||
"isUserInteractionEnabled",
|
||||
"View",
|
||||
new proxy.PropertyMetadata(true)
|
||||
@ -202,6 +202,13 @@ export class View extends proxy.ProxyObject implements definition.View {
|
||||
this.style.backgroundColor = value;
|
||||
}
|
||||
|
||||
get backgroundImage(): string {
|
||||
return this.style.backgroundImage;
|
||||
}
|
||||
set backgroundImage(value: string) {
|
||||
this.style.backgroundImage = value;
|
||||
}
|
||||
|
||||
get minWidth(): number {
|
||||
return this.style.minWidth;
|
||||
}
|
||||
@ -299,7 +306,7 @@ export class View extends proxy.ProxyObject implements definition.View {
|
||||
set paddingBottom(value: number) {
|
||||
this.style.paddingBottom = value;
|
||||
}
|
||||
|
||||
|
||||
get horizontalAlignment(): string {
|
||||
return this.style.horizontalAlignment;
|
||||
}
|
||||
|
7
ui/core/view.d.ts
vendored
7
ui/core/view.d.ts
vendored
@ -138,7 +138,12 @@ declare module "ui/core/view" {
|
||||
* Gets or sets the background color of the view.
|
||||
*/
|
||||
backgroundColor: color.Color;
|
||||
|
||||
|
||||
/**
|
||||
* Gets or sets the background image of the view.
|
||||
*/
|
||||
backgroundImage: string;
|
||||
|
||||
/**
|
||||
* Gets or sets the minimum width the view may grow to.
|
||||
*/
|
||||
|
Reference in New Issue
Block a user