mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-15 19:26:42 +08:00
propagate inheritable values only on child added. (#3926)
segmented bar createNativeView returns the nativeView
This commit is contained in:
@ -111,8 +111,8 @@ export class CssAnimationProperty<T extends Style, U> {
|
||||
export function initNativeView(view: ViewBase): void;
|
||||
export function resetNativeView(view: ViewBase): void;
|
||||
export function resetCSSProperties(style: Style): void;
|
||||
export function propagateInheritableProperties(view: ViewBase): void;
|
||||
export function propagateInheritableCssProperties(style: Style): void;
|
||||
export function propagateInheritableProperties(view: ViewBase, childView: ViewBase): void;
|
||||
export function propagateInheritableCssProperties(parentStyle: Style, childStyle: Style): void;
|
||||
export function clearInheritedProperties(view: ViewBase): void;
|
||||
|
||||
export function makeValidator<T>(...values: T[]): (value: any) => value is T;
|
||||
|
@ -1065,46 +1065,28 @@ export function resetCSSProperties(style: Style): void {
|
||||
}
|
||||
}
|
||||
|
||||
export function propagateInheritableProperties(view: ViewBase): void {
|
||||
export function propagateInheritableProperties(view: ViewBase, child: ViewBase): void {
|
||||
const inheritablePropertyValues = inheritablePropertyValuesOn(view);
|
||||
if (inheritablePropertyValues.length === 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
view.eachChild((child) => {
|
||||
for (let pair of inheritablePropertyValues) {
|
||||
const prop = pair.property;
|
||||
const sourceKey = prop.sourceKey;
|
||||
const currentValueSource: number = child[sourceKey] || ValueSource.Default;
|
||||
if (currentValueSource <= ValueSource.Inherited) {
|
||||
prop.setInheritedValue.call(child, pair.value);
|
||||
}
|
||||
for (let pair of inheritablePropertyValues) {
|
||||
const prop = pair.property;
|
||||
const sourceKey = prop.sourceKey;
|
||||
const currentValueSource: number = child[sourceKey] || ValueSource.Default;
|
||||
if (currentValueSource <= ValueSource.Inherited) {
|
||||
prop.setInheritedValue.call(child, pair.value);
|
||||
}
|
||||
|
||||
return true;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export function propagateInheritableCssProperties(style: Style): void {
|
||||
const view = style.view;
|
||||
const inheritableCssPropertyValues = inheritableCssPropertyValuesOn(style);
|
||||
if (inheritableCssPropertyValues.length === 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
view.eachChild((child) => {
|
||||
for (let pair of inheritableCssPropertyValues) {
|
||||
const prop = pair.property;
|
||||
const sourceKey = prop.sourceKey;
|
||||
const style = child.style;
|
||||
const currentValueSource: number = style[sourceKey] || ValueSource.Default;
|
||||
if (currentValueSource <= ValueSource.Inherited) {
|
||||
prop.setInheritedValue.call(style, pair.value, ValueSource.Inherited);
|
||||
}
|
||||
export function propagateInheritableCssProperties(parentStyle: Style, childStyle: Style): void {
|
||||
const inheritableCssPropertyValues = inheritableCssPropertyValuesOn(parentStyle);
|
||||
for (let pair of inheritableCssPropertyValues) {
|
||||
const prop = pair.property;
|
||||
const sourceKey = prop.sourceKey;
|
||||
const currentValueSource: number = childStyle[sourceKey] || ValueSource.Default;
|
||||
if (currentValueSource <= ValueSource.Inherited) {
|
||||
prop.setInheritedValue.call(childStyle, pair.value, ValueSource.Inherited);
|
||||
}
|
||||
|
||||
return true;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export function makeValidator<T>(...values: T[]): (value: any) => value is T {
|
||||
|
@ -534,14 +534,14 @@ export abstract class ViewBase extends Observable implements ViewBaseDefinition
|
||||
}
|
||||
|
||||
public _addViewCore(view: ViewBase, atIndex?: number) {
|
||||
propagateInheritableProperties(this);
|
||||
propagateInheritableProperties(this, view);
|
||||
|
||||
const styleScope = this._styleScope;
|
||||
if (styleScope) {
|
||||
view._setStyleScope(styleScope);
|
||||
}
|
||||
|
||||
propagateInheritableCssProperties(this.style);
|
||||
propagateInheritableCssProperties(this.style, view.style);
|
||||
|
||||
if (this._context) {
|
||||
view._setupUI(this._context, atIndex);
|
||||
|
@ -92,6 +92,10 @@ function initializeNativeClasses(): void {
|
||||
export class SegmentedBarItem extends SegmentedBarItemBase {
|
||||
nativeView: android.widget.TextView;
|
||||
|
||||
public createNativeView(): android.widget.TextView {
|
||||
return this.nativeView;
|
||||
}
|
||||
|
||||
public setupNativeView(tabIndex: number): void {
|
||||
// TabHost.TabSpec.setIndicator DOES NOT WORK once the title has been set.
|
||||
// http://stackoverflow.com/questions/2935781/modify-tab-indicator-dynamically-in-android
|
||||
|
Reference in New Issue
Block a user