File tree Expand file tree Collapse file tree 4 files changed +73
-0
lines changed
Sources/DiffableTextViewsXiOS Expand file tree Collapse file tree 4 files changed +73
-0
lines changed Original file line number Diff line number Diff line change @@ -59,6 +59,7 @@ public struct DiffableTextField<Style: DiffableTextStyleXiOS>: UIViewRepresentab
5959 let uiView = BasicTextField ( )
6060 uiView. delegate = context. coordinator
6161 uiView. font = UIFont ( DiffableTextFont . body. monospaced ( ) )
62+ uiView. setTextAlignment ( context. environment)
6263 uiView. setContentHuggingPriority ( . defaultHigh, for: . vertical)
6364 uiView. setContentCompressionResistancePriority ( . defaultLow, for: . horizontal)
6465 //=--------------------------------------=
Original file line number Diff line number Diff line change 1+ //=----------------------------------------------------------------------------=
2+ // This source file is part of the DiffableTextViews open source project.
3+ //
4+ // Copyright (c) 2022 Oscar Byström Ericsson
5+ // Licensed under Apache License, Version 2.0
6+ //
7+ // See http://www.apache.org/licenses/LICENSE-2.0 for license information.
8+ //=----------------------------------------------------------------------------=
9+
10+ #if canImport(UIKit)
11+
12+ import UIKit
13+
14+ //*============================================================================*
15+ // MARK: * UIView
16+ //*============================================================================*
17+
18+ extension UIView {
19+
20+ //=------------------------------------------------------------------------=
21+ // MARK: Accessors
22+ //=------------------------------------------------------------------------=
23+
24+ @inlinable var userInterfaceLayoutDirection : UIUserInterfaceLayoutDirection {
25+ UIView . userInterfaceLayoutDirection ( for: semanticContentAttribute)
26+ }
27+ }
28+
29+ #endif
Original file line number Diff line number Diff line change 1+ //=----------------------------------------------------------------------------=
2+ // This source file is part of the DiffableTextViews open source project.
3+ //
4+ // Copyright (c) 2022 Oscar Byström Ericsson
5+ // Licensed under Apache License, Version 2.0
6+ //
7+ // See http://www.apache.org/licenses/LICENSE-2.0 for license information.
8+ //=----------------------------------------------------------------------------=
9+
10+ #if canImport(UIKit)
11+
12+ import SwiftUI
13+ import UIKit
14+
15+ //*============================================================================*
16+ // MARK: * UITextField x Alignment
17+ //*============================================================================*
18+
19+ extension UITextField {
20+
21+ //=------------------------------------------------------------------------=
22+ // MARK: Transformations
23+ //=------------------------------------------------------------------------=
24+
25+ @inlinable func setTextAlignment( _ environment: EnvironmentValues ) {
26+ self . setTextAlignment ( environment. multilineTextAlignment)
27+ }
28+
29+ @inlinable func setTextAlignment( _ newValue: TextAlignment ) {
30+ switch newValue {
31+ case . leading: textAlignment = ( userInterfaceLayoutDirection == . leftToRight) ? . left : . right
32+ case . trailing: textAlignment = ( userInterfaceLayoutDirection == . leftToRight) ? . right : . left
33+ case . center: textAlignment = . center
34+ }
35+ }
36+ }
37+
38+ #endif
Original file line number Diff line number Diff line change 99
1010#if canImport(UIKit)
1111
12+ import SwiftUI
1213import UIKit
1314
1415//*============================================================================*
@@ -29,6 +30,10 @@ public extension ProxyTextField.Text {
2930 // MARK: Transformations
3031 //=------------------------------------------------------------------------=
3132
33+ @inlinable func alignment( _ alignment: TextAlignment ) {
34+ wrapped. setTextAlignment ( alignment)
35+ }
36+
3237 @inlinable func color( _ color: UIColor ) {
3338 wrapped. textColor = color
3439 }
You can’t perform that action at this time.
0 commit comments