-
Notifications
You must be signed in to change notification settings - Fork 2
/
Constant.swift
63 lines (48 loc) · 2.23 KB
/
Constant.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
//=----------------------------------------------------------------------------=
// This source file is part of the DiffableTextViews open source project.
//
// Copyright (c) 2022 Oscar Byström Ericsson
// Licensed under Apache License, Version 2.0
//
// See http://www.apache.org/licenses/LICENSE-2.0 for license information.
//=----------------------------------------------------------------------------=
import Foundation
//*============================================================================*
// MARK: * Constant
//*============================================================================*
/// Prevents style transformations.
///
/// Use this modifier to ignore the environment.
///
public struct ConstantTextStyle<Base: DiffableTextStyle>: WrapperTextStyle {
public typealias Cache = Base.Cache
public typealias Value = Base.Value
//=------------------------------------------------------------------------=
// MARK: State
//=------------------------------------------------------------------------=
public var base: Base
//=------------------------------------------------------------------------=
// MARK: Initializers
//=------------------------------------------------------------------------=
@inlinable public init(_ base: Base) { self.base = base }
//=------------------------------------------------------------------------=
// MARK: Transformations
//=------------------------------------------------------------------------=
@inlinable public func locale(_ locale: Locale) -> Self { self }
}
//*============================================================================*
// MARK: * Constant x Style
//*============================================================================*
public extension DiffableTextStyle {
typealias Constant = ConstantTextStyle<Self>
//=------------------------------------------------------------------------=
// MARK: Transformations
//=------------------------------------------------------------------------=
/// Prevents style transformations.
///
/// Use this modifier to ignore the environment.
///
@inlinable func constant() -> Constant {
Constant(self)
}
}