mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-17 04:41:36 +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));
|
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() {
|
export function test_parse_ShouldParseCustomComponentWithoutXml() {
|
||||||
var p = <page.Page>builder.parse('<Page xmlns:customControls="xml-declaration/mymodule"><customControls:MyControl /></Page>');
|
var p = <page.Page>builder.parse('<Page xmlns:customControls="xml-declaration/mymodule"><customControls:MyControl /></Page>');
|
||||||
var ctrl = p.content;
|
var ctrl = p.content;
|
||||||
|
@ -77,25 +77,25 @@ function onCssClassPropertyChanged(data: dependencyObservable.PropertyChangeData
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var idProperty = new dependencyObservable.Property(
|
var idProperty = new dependencyObservable.Property(
|
||||||
"id",
|
"id",
|
||||||
"View",
|
"View",
|
||||||
new proxy.PropertyMetadata(undefined, dependencyObservable.PropertyMetadataSettings.AffectsStyle)
|
new proxy.PropertyMetadata(undefined, dependencyObservable.PropertyMetadataSettings.AffectsStyle)
|
||||||
);
|
);
|
||||||
|
|
||||||
var cssClassProperty = new dependencyObservable.Property(
|
var cssClassProperty = new dependencyObservable.Property(
|
||||||
"cssClass",
|
"cssClass",
|
||||||
"View",
|
"View",
|
||||||
new proxy.PropertyMetadata(undefined, dependencyObservable.PropertyMetadataSettings.AffectsStyle, onCssClassPropertyChanged)
|
new proxy.PropertyMetadata(undefined, dependencyObservable.PropertyMetadataSettings.AffectsStyle, onCssClassPropertyChanged)
|
||||||
);
|
);
|
||||||
|
|
||||||
var isEnabledProperty = new dependencyObservable.Property(
|
var isEnabledProperty = new dependencyObservable.Property(
|
||||||
"isEnabled",
|
"isEnabled",
|
||||||
"View",
|
"View",
|
||||||
new proxy.PropertyMetadata(true)
|
new proxy.PropertyMetadata(true)
|
||||||
);
|
);
|
||||||
|
|
||||||
var isUserInteractionEnabledProperty = new dependencyObservable.Property(
|
var isUserInteractionEnabledProperty = new dependencyObservable.Property(
|
||||||
"isUserInteractionEnabled",
|
"isUserInteractionEnabled",
|
||||||
"View",
|
"View",
|
||||||
new proxy.PropertyMetadata(true)
|
new proxy.PropertyMetadata(true)
|
||||||
@ -202,6 +202,13 @@ export class View extends proxy.ProxyObject implements definition.View {
|
|||||||
this.style.backgroundColor = value;
|
this.style.backgroundColor = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get backgroundImage(): string {
|
||||||
|
return this.style.backgroundImage;
|
||||||
|
}
|
||||||
|
set backgroundImage(value: string) {
|
||||||
|
this.style.backgroundImage = value;
|
||||||
|
}
|
||||||
|
|
||||||
get minWidth(): number {
|
get minWidth(): number {
|
||||||
return this.style.minWidth;
|
return this.style.minWidth;
|
||||||
}
|
}
|
||||||
@ -299,7 +306,7 @@ export class View extends proxy.ProxyObject implements definition.View {
|
|||||||
set paddingBottom(value: number) {
|
set paddingBottom(value: number) {
|
||||||
this.style.paddingBottom = value;
|
this.style.paddingBottom = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
get horizontalAlignment(): string {
|
get horizontalAlignment(): string {
|
||||||
return this.style.horizontalAlignment;
|
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.
|
* Gets or sets the background color of the view.
|
||||||
*/
|
*/
|
||||||
backgroundColor: color.Color;
|
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.
|
* Gets or sets the minimum width the view may grow to.
|
||||||
*/
|
*/
|
||||||
|
Reference in New Issue
Block a user