@@ -12,7 +12,7 @@ extension UIApplication {
1212 @objc final public class func configureLinearNetworkActivityIndicatorIfNeeded( ) {
1313 #if !targetEnvironment(macCatalyst)
1414 if #available( iOS 11 . 0 , * ) {
15- // detect iPhone X
15+ // detect notch
1616 if let window = shared. windows. first, window. safeAreaInsets. bottom > 0.0 {
1717 if UIDevice . current. userInterfaceIdiom != . pad {
1818 configureLinearNetworkActivityIndicator ( )
@@ -65,7 +65,30 @@ extension UIApplication {
6565 indicatorWindow? . windowLevel = UIWindow . Level. statusBar + 1
6666 indicatorWindow? . isUserInteractionEnabled = false
6767
68- let indicator = FTLinearActivityIndicator ( frame: CGRect ( x: indicatorWindow!. frame. width - 74 , y: 6 , width: 44 , height: 4 ) )
68+ // notched iPhones differ in corner radius and right notch width
69+ // => lookup margin from right window edge, and width
70+ let layout : [ String : ( CGFloat , CGFloat ) ] = [
71+ " iPhone10,3 " : ( 74 , 44 ) , // iPhone X
72+ " iPhone10,6 " : ( 74 , 44 ) , // iPhone X
73+ " iPhone11,2 " : ( 74 , 44 ) , // Phone Xs
74+ " iPhone11,4 " : ( 74 , 44 ) , // iPhone Xs Max
75+ " iPhone11,6 " : ( 74 , 44 ) , // iPhone Xs Max
76+ " iPhone11,8 " : ( 70 , 40 ) , // iPhone XR
77+ " iPhone12,1 " : ( 70 , 40 ) , // iPhone 11
78+ " iPhone12,3 " : ( 60 , 34 ) , // iPhone 11 Pro
79+ " iPhone12,5 " : ( 74 , 44 ) , // iPhone 11 Pro Max
80+ " iPhone13,1 " : ( 60 , 30 ) , // iPhone 12 Mini
81+ " iPhone13,2 " : ( 72 , 34 ) , // iPhone 12
82+ " iPhone13,3 " : ( 72 , 34 ) , // iPhone 12 Pro
83+ " iPhone13,4 " : ( 80 , 42 ) , // iPhone 12 Pro Max
84+ ]
85+ let modelName = UIDevice . current. ftModelName
86+ let config = layout [ modelName] ?? ( 74 , 44 )
87+
88+ let x = indicatorWindow!. frame. width - config. 0
89+ let width = config. 1
90+
91+ let indicator = FTLinearActivityIndicator ( frame: CGRect ( x: x, y: 7 , width: width, height: 4.5 ) )
6992 indicator. isUserInteractionEnabled = false
7093 indicator. hidesWhenStopped = false
7194 indicator. startAnimating ( )
0 commit comments