mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
feat: System css classes for modals (#8155)
* feat: update modal views CSS classes * chore: fix failing test
This commit is contained in:
committed by
GitHub
parent
2bb7ad9d01
commit
7b78f3b0c6
@@ -7,7 +7,7 @@ import { Page } from "../../page";
|
||||
|
||||
// Types.
|
||||
import { Property, CssProperty, CssAnimationProperty, InheritedProperty, Style, clearInheritedProperties, propagateInheritableProperties, propagateInheritableCssProperties, initNativeView } from "../properties";
|
||||
import { getModalRootViewCssClass, getRootViewCssClasses } from "../../../css/system-classes";
|
||||
import { getSystemCssClasses, MODAL_ROOT_VIEW_CSS_CLASS, ROOT_VIEW_CSS_CLASS } from "../../../css/system-classes";
|
||||
import { Source } from "../../../utils/debug";
|
||||
import { Binding, BindingOptions, Observable, WrappedValue, PropertyChangeData, traceEnabled, traceWrite, traceCategories } from "../bindable";
|
||||
import { isIOS, isAndroid } from "../../../platform";
|
||||
@@ -1045,21 +1045,21 @@ export const classNameProperty = new Property<ViewBase, string>({
|
||||
name: "className",
|
||||
valueChanged(view: ViewBase, oldValue: string, newValue: string) {
|
||||
const cssClasses = view.cssClasses;
|
||||
const rootViewsCssClasses = getSystemCssClasses();
|
||||
|
||||
const modalViewCssClass = getModalRootViewCssClass();
|
||||
const rootViewCssClasses = getRootViewCssClasses();
|
||||
|
||||
const shouldAddModalRootViewCssClass = cssClasses.has(modalViewCssClass);
|
||||
const shouldAddRootViewCssClasses = cssClasses.has(rootViewCssClasses[0]);
|
||||
const shouldAddModalRootViewCssClasses = cssClasses.has(MODAL_ROOT_VIEW_CSS_CLASS);
|
||||
const shouldAddRootViewCssClasses = cssClasses.has(ROOT_VIEW_CSS_CLASS);
|
||||
|
||||
cssClasses.clear();
|
||||
|
||||
if (shouldAddModalRootViewCssClass) {
|
||||
cssClasses.add(modalViewCssClass);
|
||||
if (shouldAddModalRootViewCssClasses) {
|
||||
cssClasses.add(MODAL_ROOT_VIEW_CSS_CLASS);
|
||||
} else if (shouldAddRootViewCssClasses) {
|
||||
rootViewCssClasses.forEach(c => cssClasses.add(c));
|
||||
cssClasses.add(ROOT_VIEW_CSS_CLASS);
|
||||
}
|
||||
|
||||
rootViewsCssClasses.forEach(c => cssClasses.add(c));
|
||||
|
||||
if (typeof newValue === "string" && newValue !== "") {
|
||||
newValue.split(" ").forEach(c => cssClasses.add(c));
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ import {
|
||||
fromString as gestureFromString
|
||||
} from "../../gestures";
|
||||
|
||||
import { getModalRootViewCssClass } from "../../../css/system-classes";
|
||||
import { getSystemCssClasses, MODAL_ROOT_VIEW_CSS_CLASS } from "../../../css/system-classes";
|
||||
import { Builder } from "../../builder";
|
||||
import { sanitizeModuleName } from "../../builder/module-name-sanitizer";
|
||||
import { StyleScope } from "../../styling/style-scope";
|
||||
@@ -372,8 +372,9 @@ export abstract class ViewCommon extends ViewBase implements ViewDefinition {
|
||||
protected _showNativeModalView(parent: ViewCommon, options: ShowModalOptions) {
|
||||
_rootModalViews.push(this);
|
||||
|
||||
const modalRootViewCssClass = getModalRootViewCssClass();
|
||||
this.cssClasses.add(modalRootViewCssClass);
|
||||
this.cssClasses.add(MODAL_ROOT_VIEW_CSS_CLASS);
|
||||
const modalRootViewCssClasses = getSystemCssClasses();
|
||||
modalRootViewCssClasses.forEach(c => this.cssClasses.add(c));
|
||||
|
||||
parent._modal = this;
|
||||
this._modalParent = parent;
|
||||
|
||||
Reference in New Issue
Block a user