Protocols
The following protocols are available globally.
-
A protocol should only be adopted by
Crystal
class.// Determine the concrete theme type. extension Crystal: CrystalDetermined { public typealias Theme: AppTheme }
Although this protocol is designed for
See moreCrystal
class,Crystal
class does not conform toCrystalDetermined
protocol by default. When using this library, it’s your responsibility to makeCrystal
class conform toCrystalDetermined
protocol, in order to determine the concrete theme type.Declaration
Swift
public protocol CrystalDetermined : Crystal
-
A type that has crystal extensions. You can use
cst
property 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