Skip to content

Commit 95f65d5

Browse files
committed
#534 Fix warnings?
1 parent 62e12e1 commit 95f65d5

File tree

5 files changed

+35
-69
lines changed

5 files changed

+35
-69
lines changed

SwiftMessages/BaseView.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,11 @@ open class BaseView: UIView, BackgroundViewable, MarginAdjustable {
280280

281281
private var layoutConstraints: [NSLayoutConstraint] = []
282282
private var regularWidthLayoutConstraints: [NSLayoutConstraint] = []
283+
284+
open override func layoutSubviews() {
285+
super.layoutSubviews()
286+
updateShadowPath()
287+
}
283288
}
284289

285290
/*
@@ -334,11 +339,6 @@ extension BaseView {
334339
// Update the layer's `shadowPath` without animation
335340
layer.shadowPath = shadowPath }
336341
}
337-
338-
open override func layoutSubviews() {
339-
super.layoutSubviews()
340-
updateShadowPath()
341-
}
342342
}
343343

344344
/*

SwiftMessages/MarginAdjustable+Extensions.swift

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -13,25 +13,8 @@ extension MarginAdjustable where Self: UIView {
1313
var layoutMargins: UIEdgeInsets = layoutMarginAdditions
1414
var safeAreaInsets: UIEdgeInsets = {
1515
guard respectSafeArea else { return .zero }
16-
if #available(iOS 11, *) {
17-
insetsLayoutMarginsFromSafeArea = false
18-
return self.safeAreaInsets
19-
} else {
20-
#if SWIFTMESSAGES_APP_EXTENSIONS
21-
let application: UIApplication? = nil
22-
#else
23-
let application: UIApplication? = UIApplication.shared
24-
#endif
25-
if !context.safeZoneConflicts.isDisjoint(with: [.statusBar]),
26-
let app = application,
27-
app.statusBarOrientation == .portrait || app.statusBarOrientation == .portraitUpsideDown {
28-
let frameInWindow = convert(bounds, to: window)
29-
let top = max(0, 20 - frameInWindow.minY)
30-
return UIEdgeInsets(top: top, left: 0, bottom: 0, right: 0)
31-
} else {
32-
return .zero
33-
}
34-
}
16+
insetsLayoutMarginsFromSafeArea = false
17+
return self.safeAreaInsets
3518
}()
3619
if !context.safeZoneConflicts.isDisjoint(with: .overStatusBar) {
3720
safeAreaInsets.top = 0

SwiftMessages/PhysicsAnimation.swift

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,7 @@ public class PhysicsAnimation: NSObject, Animator {
9393
guard let adjustable = messageView as? MarginAdjustable & UIView,
9494
let context = context else { return }
9595
adjustable.preservesSuperviewLayoutMargins = false
96-
if #available(iOS 11, *) {
97-
adjustable.insetsLayoutMarginsFromSafeArea = false
98-
}
96+
adjustable.insetsLayoutMarginsFromSafeArea = false
9997
adjustable.layoutMargins = adjustable.defaultMarginAdjustment(context: context)
10098
}
10199

SwiftMessages/Presenter.swift

Lines changed: 26 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ class Presenter: NSObject {
236236
}
237237

238238
private func safeZoneConflicts() -> SafeZoneConflicts {
239-
guard let window = maskingView.window else { return [] }
239+
guard let _ = maskingView.window else { return [] }
240240
let windowLevel: UIWindow.Level = {
241241
if let vc = presentationContext.viewControllerValue() as? WindowViewController {
242242
return vc.config.windowLevel ?? .normal
@@ -253,47 +253,34 @@ class Presenter: NSObject {
253253
if let vc = presentationContext.viewControllerValue() as? UITabBarController { return vc.sm_isVisible(view: vc.tabBar) }
254254
return false
255255
}()
256-
if #available(iOS 11, *) {
257-
if windowLevel > .normal {
258-
// TODO seeing `maskingView.safeAreaInsets.top` value of 20 on
259-
// iPhone 8 with status bar window level. This seems like an iOS bug since
260-
// the message view's window is above the status bar. Applying a special rule
261-
// to allow the animator to revove this amount from the layout margins if needed.
262-
// This may need to be reworked if any future device has a legitimate 20pt top safe area,
263-
// such as with a potentially smaller notch.
264-
if maskingView.safeAreaInsets.top == 20 {
265-
return [.overStatusBar]
266-
} else {
267-
var conflicts: SafeZoneConflicts = []
268-
if maskingView.safeAreaInsets.top > 0 {
269-
conflicts.formUnion(.sensorNotch)
270-
}
271-
if maskingView.safeAreaInsets.bottom > 0 {
272-
conflicts.formUnion(.homeIndicator)
273-
}
274-
return conflicts
256+
if windowLevel > .normal {
257+
// TODO seeing `maskingView.safeAreaInsets.top` value of 20 on
258+
// iPhone 8 with status bar window level. This seems like an iOS bug since
259+
// the message view's window is above the status bar. Applying a special rule
260+
// to allow the animator to revove this amount from the layout margins if needed.
261+
// This may need to be reworked if any future device has a legitimate 20pt top safe area,
262+
// such as with a potentially smaller notch.
263+
if maskingView.safeAreaInsets.top == 20 {
264+
return [.overStatusBar]
265+
} else {
266+
var conflicts: SafeZoneConflicts = []
267+
if maskingView.safeAreaInsets.top > 0 {
268+
conflicts.formUnion(.sensorNotch)
275269
}
270+
if maskingView.safeAreaInsets.bottom > 0 {
271+
conflicts.formUnion(.homeIndicator)
272+
}
273+
return conflicts
276274
}
277-
var conflicts: SafeZoneConflicts = []
278-
if !underNavigationBar {
279-
conflicts.formUnion(.sensorNotch)
280-
}
281-
if !underTabBar {
282-
conflicts.formUnion(.homeIndicator)
283-
}
284-
return conflicts
285-
} else {
286-
#if SWIFTMESSAGES_APP_EXTENSIONS
287-
return []
288-
#else
289-
if UIApplication.shared.isStatusBarHidden { return [] }
290-
if (windowLevel > UIWindow.Level.normal) || underNavigationBar { return [] }
291-
let statusBarFrame = UIApplication.shared.statusBarFrame
292-
let statusBarWindowFrame = window.convert(statusBarFrame, from: nil)
293-
let statusBarViewFrame = maskingView.convert(statusBarWindowFrame, from: nil)
294-
return statusBarViewFrame.intersects(maskingView.bounds) ? SafeZoneConflicts.statusBar : []
295-
#endif
296275
}
276+
var conflicts: SafeZoneConflicts = []
277+
if !underNavigationBar {
278+
conflicts.formUnion(.sensorNotch)
279+
}
280+
if !underTabBar {
281+
conflicts.formUnion(.homeIndicator)
282+
}
283+
return conflicts
297284
}
298285

299286
private func getPresentationContext() throws -> PresentationContext {

SwiftMessages/TopBottomAnimation.swift

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -130,9 +130,7 @@ public class TopBottomAnimation: NSObject, Animator {
130130
guard let adjustable = messageView as? MarginAdjustable & UIView,
131131
let context = context else { return }
132132
adjustable.preservesSuperviewLayoutMargins = false
133-
if #available(iOS 11, *) {
134-
adjustable.insetsLayoutMarginsFromSafeArea = false
135-
}
133+
adjustable.insetsLayoutMarginsFromSafeArea = false
136134
var layoutMargins = adjustable.defaultMarginAdjustment(context: context)
137135
switch style {
138136
case .top:

0 commit comments

Comments
 (0)