@@ -42,39 +42,77 @@ extension ScreenCompatible {
4242
4343extension ScreenWrapper {
4444
45- public func width( _ types: Screen . Width ... , is value: Base ) -> Self {
45+ public func width( _ types: Screen . Width ... , is value: Base ) -> Self {
46+ return width ( types, is: value, zoomed: value)
47+ }
48+ public func width( _ types: Screen . Width ... , is value: Base , zoomed: Base ) -> Self {
49+ return width ( types, is: value, zoomed: zoomed)
50+ }
51+ private func width( _ types: [ Screen . Width ] , is value: Base , zoomed: Base ) -> Self {
4652 for type in types where Screen . Width. current == type {
47- self . value = value
53+ self . value = Screen . isZoomedMode ? zoomed : value
4854 }
4955 return self
5056 }
5157
5258 public func height( _ types: Screen . Height ... , is value: Base ) -> Self {
59+ return height ( types, is: value, zoomed: value)
60+ }
61+ public func height( _ types: Screen . Height ... , is value: Base , zoomed: Base ) -> Self {
62+ return height ( types, is: value, zoomed: zoomed)
63+ }
64+ private func height( _ types: [ Screen . Height ] , is value: Base , zoomed: Base ) -> Self {
5365 for type in types where Screen . Height. current == type {
54- self . value = value
66+ self . value = Screen . isZoomedMode ? zoomed : value
5567 }
5668 return self
5769 }
5870
5971 public func inch( _ types: Screen . Inch ... , is value: Base ) -> Self {
72+ return inch ( types, is: value, zoomed: value)
73+ }
74+ public func inch( _ types: Screen . Inch ... , is value: Base , zoomed: Base ) -> Self {
75+ return inch ( types, is: value, zoomed: zoomed)
76+ }
77+ private func inch( _ types: [ Screen . Inch ] , is value: Base , zoomed: Base ) -> Self {
6078 for type in types where Screen . Inch. current == type {
61- self . value = value
79+ self . value = Screen . isZoomedMode ? zoomed : value
6280 }
6381 return self
6482 }
6583
6684 public func level( _ types: Screen . Level ... , is value: Base ) -> Self {
85+ return level ( types, is: value, zoomed: value)
86+ }
87+ public func level( _ types: Screen . Level ... , is value: Base , zoomed: Base ) -> Self {
88+ return level ( types, is: value, zoomed: zoomed)
89+ }
90+ private func level( _ types: [ Screen . Level ] , is value: Base , zoomed: Base ) -> Self {
6791 for type in types where Screen . Level. current == type {
68- self . value = value
92+ self . value = Screen . isZoomedMode ? zoomed : value
6993 }
7094 return self
7195 }
7296}
7397
7498public enum Screen {
7599
76- public static var size : CGSize = UIScreen . main. bounds. size
77- public static var scale : CGFloat = UIScreen . main. scale
100+ public static var isZoomedMode : Bool {
101+ UIScreen . main. scale != UIScreen . main. nativeScale
102+ }
103+
104+ static var size : CGSize {
105+ UIScreen . main. bounds. size
106+ }
107+ static var nativeSize : CGSize {
108+ UIScreen . main. nativeBounds. size
109+ }
110+ static var scale : CGFloat {
111+ UIScreen . main. scale
112+ }
113+ static var nativeScale : CGFloat {
114+ UIScreen . main. nativeScale
115+ }
78116
79117 public enum Width : CGFloat {
80118 case unknown = - 1
@@ -85,7 +123,7 @@ public enum Screen {
85123 case _428 = 428
86124
87125 public static var current : Width {
88- return Width ( rawValue: size . width) ?? . unknown
126+ return Width ( rawValue: nativeSize . width / scale ) ?? . unknown
89127 }
90128 }
91129
@@ -101,7 +139,7 @@ public enum Screen {
101139 case _926 = 926
102140
103141 public static var current : Height {
104- return Height ( rawValue: size . height) ?? . unknown
142+ return Height ( rawValue: nativeSize . height / scale ) ?? . unknown
105143 }
106144 }
107145
@@ -118,7 +156,7 @@ public enum Screen {
118156 case _6_7 = 6.7
119157
120158 public static var current : Inch {
121- switch ( size . width, size . height, scale) {
159+ switch ( nativeSize . width / scale , nativeSize . height / scale , scale) {
122160 case ( 320 , 480 , 2 ) :
123161 return . _3_5
124162
@@ -162,7 +200,7 @@ public enum Screen {
162200 case full
163201
164202 public static var current : Level {
165- switch ( size . width, size . height) {
203+ switch ( nativeSize . width / scale , nativeSize . height / scale ) {
166204 case ( 320 , 480 ) :
167205 return . compact
168206
0 commit comments