Protocols
The following protocols are available globally.
-
A protocol should only be adopted by
Crystalclass.// Determine the concrete theme type. extension Crystal: CrystalDetermined { public typealias Theme: AppTheme }Although this protocol is designed for
See moreCrystalclass,Crystalclass does not conform toCrystalDeterminedprotocol by default. When using this library, it’s your responsibility to makeCrystalclass conform toCrystalDeterminedprotocol, in order to determine the concrete theme type.Declaration
Swift
public protocol CrystalDetermined : Crystal -
A type that has crystal extensions. You can use
cstproperty to get extension methods.// Make `UIView` conform to `CrystalCompatible`. extension UIView: CrystalCompatible { public typealias Theme: AppTheme }When conforming to
See moreCrystalCompatible, you have to determine the concrete theme type in the conformance.Declaration
Swift
public protocol CrystalCompatible : AnyObject -
Represent a theme type.
// A concrete theme type. struct AppTheme: CrystalThemeType { var textColor: UIColor? static var light: AppTheme { return AppTheme(textColor: .blue) } public static var entry: CrystalThemeType { return Self.light } }Conform to this protocol to make your concrete theme type. You should only create one concrete theme type to satisfy Crystal, otherwise some inconsistent errors may occur.
See moreDeclaration
Swift
public protocol CrystalThemeType
View on GitHub
Install in Dash
Protocols Reference