File tree Expand file tree Collapse file tree 5 files changed +15
-29
lines changed
DiffableTextStylesXNumeric
DiffableTextViewsXiOS/Helpers Expand file tree Collapse file tree 5 files changed +15
-29
lines changed Original file line number Diff line number Diff line change @@ -78,6 +78,15 @@ extension NumericTextFormat {
7878 try parseStrategy. parse ( characters)
7979 }
8080
81+ //=------------------------------------------------------------------------=
82+ // MARK: Autocorrect
83+ //=------------------------------------------------------------------------=
84+
85+ /// The format should always round towards zero.
86+ @inlinable func autocorrect( ) -> Self {
87+ self . rounded ( . towardZero)
88+ }
89+
8190 //=------------------------------------------------------------------------=
8291 // MARK: Transformations
8392 //=------------------------------------------------------------------------=
Original file line number Diff line number Diff line change @@ -29,16 +29,8 @@ import Foundation
2929 //=------------------------------------------------------------------------=
3030
3131 @inlinable init ( _ format: Format ) {
32- self . format = format
33- self . scheme = format. scheme ( )
34- }
35-
36- //=------------------------------------------------------------------------=
37- // MARK: Accessors
38- //=------------------------------------------------------------------------=
39-
40- @inlinable var locale : Locale {
41- format. locale
32+ self . format = format. autocorrect ( )
33+ self . scheme = self . format. scheme ( )
4234 }
4335
4436 //=------------------------------------------------------------------------=
@@ -69,18 +61,3 @@ import Foundation
6961 lhs. format == rhs. format
7062 }
7163}
72-
73- //=----------------------------------------------------------------------------=
74- // MARK: + Currency
75- //=----------------------------------------------------------------------------=
76-
77- extension Adapter where Format: Formats . Currency {
78-
79- //=------------------------------------------------------------------------=
80- // MARK: Accessors
81- //=------------------------------------------------------------------------=
82-
83- @inlinable var currencyCode : String {
84- format. currencyCode
85- }
86- }
Original file line number Diff line number Diff line change @@ -29,7 +29,7 @@ extension NumericTextStyle where Format: NumericTextFormatXCurrency {
2929 //=------------------------------------------------------------------------=
3030
3131 @inlinable public var currencyCode : String {
32- self . adapter . currencyCode
32+ format . currencyCode
3333 }
3434}
3535
Original file line number Diff line number Diff line change @@ -44,7 +44,7 @@ public struct _NumericTextStyle<Format: NumericTextFormat>: DiffableTextStyle {
4444 //=------------------------------------------------------------------------=
4545
4646 @inlinable var format : Format {
47- adapter. format. rounded ( . towardZero )
47+ adapter. format
4848 }
4949
5050 @inlinable var scheme : Scheme {
@@ -60,7 +60,7 @@ public struct _NumericTextStyle<Format: NumericTextFormat>: DiffableTextStyle {
6060 //=------------------------------------------------------------------------=
6161
6262 @inlinable public var locale : Locale {
63- adapter . locale
63+ format . locale
6464 }
6565
6666 @inlinable public func locale( _ locale: Locale ) -> Self {
Original file line number Diff line number Diff line change @@ -31,7 +31,7 @@ extension NSTextAlignment {
3131 }
3232
3333 //=------------------------------------------------------------------------=
34- // MARK: Initializers - Helpers
34+ // MARK: Initializers - Static
3535 //=------------------------------------------------------------------------=
3636
3737 @inlinable static func adaptive( _ layout: UIUserInterfaceLayoutDirection ,
You can’t perform that action at this time.
0 commit comments