Skip to content

Commit 8fe43a5

Browse files
committed
Update the watchOS example to remove the hack to bind presentationMode, this is SwiftUI's bug and no workaround after 6.2...
1 parent 776e18f commit 8fe43a5

File tree

1 file changed

+1
-9
lines changed

1 file changed

+1
-9
lines changed

Example/SDWebImageSwiftUIDemo/DetailView.swift

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ struct DetailView: View {
4040
@State var isAnimating: Bool = true
4141
@State var lastScale: CGFloat = 1.0
4242
@State var scale: CGFloat = 1.0
43-
@Environment(\.presentationMode) var presentationMode
4443
@EnvironmentObject var settings: UserSettings
4544

4645
var body: some View {
@@ -94,15 +93,8 @@ struct DetailView: View {
9493
#endif
9594
#if os(watchOS)
9695
return contentView()
97-
// SwiftUI's bug workaround (watchOS 6.1)
98-
// If use `.focusable(true)` here, after pop the Detail view, the Content view's List does not get focus again
99-
// After some debug, I found that the pipeline to change focus becomes:
100-
// Detail Pop (resign focus) -> Content Appear (List view become focus) -> Detail Disappear (become focus again) -> End
101-
// Even you use `onDisappear`, it's too late because `.focusable` is called firstly
102-
// Sadly, Content view's List focus is managed by SwiftUI (a UICollectionView actually), call `focusable` on Content view does nothing as well
103-
// So, here we must use environment or binding, to not become focus during pop :)
104-
.focusable(self.presentationMode.wrappedValue.isPresented)
10596
.scaleEffect(self.scale)
97+
.focusable(true)
10698
.digitalCrownRotation($scale, from: 0.5, through: 2, by: 0.1, sensitivity: .low, isHapticFeedbackEnabled: false)
10799
#endif
108100
}

0 commit comments

Comments
 (0)