mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-16 03:31:45 +08:00
BackgroundRepeat enum
This commit is contained in:
@ -6,7 +6,7 @@ import { Background } from "ui/styling/background";
|
||||
import {
|
||||
ViewBase, getEventOrGestureName, Observable, EventData, Style,
|
||||
Property, InheritedProperty, CssProperty, ShorthandProperty, InheritedCssProperty,
|
||||
gestureFromString, isIOS, traceEnabled, traceWrite, traceCategories, traceNotifyEvent, printUnregisteredProperties
|
||||
gestureFromString, isIOS, traceEnabled, traceWrite, traceCategories, traceNotifyEvent, printUnregisteredProperties, makeParser, makeValidator
|
||||
} from "./view-base";
|
||||
import { observe as gestureObserve, GesturesObserver, GestureTypes, GestureEventData } from "ui/gestures";
|
||||
import { Font, parseFont, FontStyle, FontWeight } from "ui/styling/font";
|
||||
@ -1464,8 +1464,18 @@ export const backgroundColorProperty = new CssProperty<Style, Color>({
|
||||
});
|
||||
backgroundColorProperty.register(Style);
|
||||
|
||||
export const backgroundRepeatProperty = new CssProperty<Style, string>({
|
||||
name: "backgroundRepeat", cssName: "background-repeat", valueChanged: (target, newValue) => {
|
||||
export type BackgroundRepeat = "repeat" | "repeat-x" | "repeat-y" | "no-repeat";
|
||||
export namespace BackgroundRepeat {
|
||||
export const REPEAT: "repeat" = "repeat";
|
||||
export const REPEAT_X: "repeat-x" = "repeat-x";
|
||||
export const REPEAT_Y: "repeat-y" = "repeat-y";
|
||||
export const NO_REPEAT: "no-repeat" = "no-repeat";
|
||||
export const isValid = makeValidator<BackgroundRepeat>(REPEAT, REPEAT_X, REPEAT_Y, NO_REPEAT);
|
||||
export const parse = makeParser(isValid, undefined);
|
||||
}
|
||||
|
||||
export const backgroundRepeatProperty = new CssProperty<Style, BackgroundRepeat>({
|
||||
name: "backgroundRepeat", cssName: "background-repeat", valueConverter: BackgroundRepeat.parse, valueChanged: (target, newValue) => {
|
||||
let background = target.backgroundInternal;
|
||||
target.backgroundInternal = background.withRepeat(newValue);
|
||||
}
|
||||
|
12
tns-core-modules/ui/core/view.d.ts
vendored
12
tns-core-modules/ui/core/view.d.ts
vendored
@ -712,7 +712,7 @@ declare module "ui/core/view" {
|
||||
|
||||
export const backgroundColorProperty: CssProperty<Style, Color>;
|
||||
export const backgroundImageProperty: CssProperty<Style, string>;
|
||||
export const backgroundRepeatProperty: CssProperty<Style, string>;
|
||||
export const backgroundRepeatProperty: CssProperty<Style, BackgroundRepeat>;
|
||||
export const backgroundSizeProperty: CssProperty<Style, string>;
|
||||
export const backgroundPositionProperty: CssProperty<Style, string>;
|
||||
|
||||
@ -764,4 +764,14 @@ declare module "ui/core/view" {
|
||||
|
||||
export const backgroundInternalProperty: CssProperty<Style, Background>;
|
||||
export const fontInternalProperty: InheritedCssProperty<Style, Font>;
|
||||
|
||||
export type BackgroundRepeat = "repeat" | "repeat-x" | "repeat-y" | "no-repeat";
|
||||
export namespace BackgroundRepeat {
|
||||
export const REPEAT: "repeat";
|
||||
export const REPEAT_X: "repeat-x";
|
||||
export const REPEAT_Y: "repeat-y";
|
||||
export const NO_REPEAT: "no-repeat";
|
||||
export function isValid(value: any): boolean;
|
||||
export function parse(value: string): BackgroundRepeat;
|
||||
}
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
import { Background as BackgroundDefinition, BackgroundDrawParams } from "ui/styling/background";
|
||||
import { Color, layout } from "ui/core/view";
|
||||
import { Color, layout, BackgroundRepeat } from "ui/core/view";
|
||||
import { ImageSource } from "image-source";
|
||||
import cssValue = require("css-value");
|
||||
|
||||
@ -17,7 +17,7 @@ export class Background implements BackgroundDefinition {
|
||||
|
||||
public color: Color;
|
||||
public image: ImageSource;
|
||||
public repeat: "repeat" | "repeat-x" | "repeat-y" | "no-repeat";
|
||||
public repeat: BackgroundRepeat;
|
||||
public position: string;
|
||||
public size: string;
|
||||
public borderTopColor: Color;
|
||||
@ -71,7 +71,7 @@ export class Background implements BackgroundDefinition {
|
||||
return clone;
|
||||
}
|
||||
|
||||
public withRepeat(value: "repeat" | "repeat-x" | "repeat-y" | "no-repeat"): Background {
|
||||
public withRepeat(value: BackgroundRepeat): Background {
|
||||
let clone = this.clone();
|
||||
clone.repeat = value;
|
||||
return clone;
|
||||
|
6
tns-core-modules/ui/styling/background.d.ts
vendored
6
tns-core-modules/ui/styling/background.d.ts
vendored
@ -1,6 +1,6 @@
|
||||
declare module "ui/styling/background" {
|
||||
import { ImageSource } from "image-source";
|
||||
import { View, Color } from "ui/core/view";
|
||||
import { View, Color, BackgroundRepeat } from "ui/core/view";
|
||||
|
||||
export interface BackgroundDrawParams {
|
||||
repeatX: boolean;
|
||||
@ -15,7 +15,7 @@ declare module "ui/styling/background" {
|
||||
public static default: Background;
|
||||
public color: Color;
|
||||
public image: ImageSource;
|
||||
public repeat: "repeat" | "repeat-x" | "repeat-y" | "no-repeat";
|
||||
public repeat: BackgroundRepeat;
|
||||
public position: string;
|
||||
public size: string;
|
||||
public borderTopColor: Color;
|
||||
@ -34,7 +34,7 @@ declare module "ui/styling/background" {
|
||||
|
||||
public withColor(value: Color): Background;
|
||||
public withImage(value: ImageSource): Background;
|
||||
public withRepeat(value: string): Background;
|
||||
public withRepeat(value: BackgroundRepeat): Background;
|
||||
public withPosition(value: string): Background;
|
||||
public withSize(value: string): Background;
|
||||
public withBorderTopColor(value: Color): Background;
|
||||
|
4
tns-core-modules/ui/styling/style.d.ts
vendored
4
tns-core-modules/ui/styling/style.d.ts
vendored
@ -1,5 +1,5 @@
|
||||
declare module "ui/styling/style" {
|
||||
import { Length, PercentLength, Color, Background, Font, ViewBase, Observable } from "ui/core/view";
|
||||
import { Length, PercentLength, Color, Background, Font, ViewBase, Observable, BackgroundRepeat} from "ui/core/view";
|
||||
import { TextAlignment, TextDecoration, TextTransform, WhiteSpace } from "ui/text-base";
|
||||
import { FontStyle, FontWeight } from "ui/styling/font";
|
||||
|
||||
@ -56,7 +56,7 @@ declare module "ui/styling/style" {
|
||||
|
||||
public backgroundColor: Color;
|
||||
public backgroundImage: string;
|
||||
public backgroundRepeat: "repeat" | "repeat-x" | "repeat-y" | "no-repeat";;
|
||||
public backgroundRepeat: BackgroundRepeat;
|
||||
public backgroundSize: string;
|
||||
public backgroundPosition: string;
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { Style as StyleDefinition } from "ui/styling/style";
|
||||
import { Length, PercentLength, Color, Background, Font, ViewBase } from "ui/core/view";
|
||||
import { Length, PercentLength, Color, Background, Font, ViewBase, BackgroundRepeat } from "ui/core/view";
|
||||
import { Observable } from "data/observable";
|
||||
import { resetStyleProperties } from "ui/core/properties";
|
||||
|
||||
@ -35,7 +35,7 @@ export class Style extends Observable implements StyleDefinition {
|
||||
|
||||
public backgroundColor: Color;
|
||||
public backgroundImage: string;
|
||||
public backgroundRepeat: "repeat" | "repeat-x" | "repeat-y" | "no-repeat";
|
||||
public backgroundRepeat: BackgroundRepeat;
|
||||
public backgroundSize: string;
|
||||
public backgroundPosition: string;
|
||||
|
||||
|
Reference in New Issue
Block a user