Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

overrideUserInterfaceStyle #104

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Sources/Components/Elements/GradientLayerNode.swift
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ open class GradientLayerNode : ASDisplayNode {
open override var supportsLayerBacking: Bool {
return false
}

public var gradientLayer: CAGradientLayer {
view.layer as! CAGradientLayer
}
Expand Down
15 changes: 15 additions & 0 deletions Sources/Components/Tools/NamedDisplayCellNodeBase.swift
Original file line number Diff line number Diff line change
Expand Up @@ -74,4 +74,19 @@ open class NamedDisplayCellNodeBase: ASCellNode {
}
}

open var overrideUserinterfaceStyle: UIUserInterfaceStyle = .unspecified

open override func setPrimitiveTraitCollection(_ traitCollection: ASPrimitiveTraitCollection) {

// 🤷🏻‍♂️
// texture does not support for UIView.overrideUserinterfaceStyle
var _traitCollection = traitCollection
if case .unspecified = overrideUserinterfaceStyle {

} else {
_traitCollection.userInterfaceStyle = overrideUserinterfaceStyle
}
super.setPrimitiveTraitCollection(_traitCollection)
}

}
31 changes: 31 additions & 0 deletions Sources/Components/Tools/NamedDisplayNodeBase.swift
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,21 @@ open class NamedDisplayNodeBase: ASDisplayNode {
}
}

open var overrideUserinterfaceStyle: UIUserInterfaceStyle = .unspecified

open override func setPrimitiveTraitCollection(_ traitCollection: ASPrimitiveTraitCollection) {

// 🤷🏻‍♂️
// texture does not support for UIView.overrideUserinterfaceStyle
var _traitCollection = traitCollection
if case .unspecified = overrideUserinterfaceStyle {

} else {
_traitCollection.userInterfaceStyle = overrideUserinterfaceStyle
}
super.setPrimitiveTraitCollection(_traitCollection)
}

}

/// An object from Abstract base class
Expand Down Expand Up @@ -131,4 +146,20 @@ open class NamedDisplayControlNodeBase: ASControlNode {
handler(self, action)
}
}

open var overrideUserinterfaceStyle: UIUserInterfaceStyle = .unspecified

open override func setPrimitiveTraitCollection(_ traitCollection: ASPrimitiveTraitCollection) {

// 🤷🏻‍♂️
// texture does not support for UIView.overrideUserinterfaceStyle
var _traitCollection = traitCollection
if case .unspecified = overrideUserinterfaceStyle {

} else {
_traitCollection.userInterfaceStyle = overrideUserinterfaceStyle
}
super.setPrimitiveTraitCollection(_traitCollection)
}

}