Implements the tvOS zoom using the play/pause button, update the readme
This commit is contained in:
parent
d9ac91675b
commit
ff7f74021e
|
@ -45,7 +45,7 @@ struct DetailView: View {
|
||||||
}
|
}
|
||||||
|
|
||||||
func zoomView() -> some View {
|
func zoomView() -> some View {
|
||||||
#if os(macOS) || os(iOS) || os(tvOS)
|
#if os(macOS) || os(iOS)
|
||||||
return contentView()
|
return contentView()
|
||||||
.scaleEffect(self.scale)
|
.scaleEffect(self.scale)
|
||||||
.gesture(MagnificationGesture(minimumScaleDelta: 0.1).onChanged { value in
|
.gesture(MagnificationGesture(minimumScaleDelta: 0.1).onChanged { value in
|
||||||
|
@ -56,7 +56,22 @@ struct DetailView: View {
|
||||||
}.onEnded { value in
|
}.onEnded { value in
|
||||||
self.lastScaleValue = 1.0
|
self.lastScaleValue = 1.0
|
||||||
})
|
})
|
||||||
#else
|
#endif
|
||||||
|
#if os(tvOS)
|
||||||
|
return contentView()
|
||||||
|
.scaleEffect(self.scale)
|
||||||
|
.focusable(true)
|
||||||
|
.onPlayPauseCommand {
|
||||||
|
switch self.scale {
|
||||||
|
case 1:
|
||||||
|
self.scale = 2
|
||||||
|
case 2:
|
||||||
|
self.scale = 1
|
||||||
|
default: break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#if os(watchOS)
|
||||||
return contentView()
|
return contentView()
|
||||||
// SwiftUI's bug workaround (watchOS 6.1)
|
// SwiftUI's bug workaround (watchOS 6.1)
|
||||||
// If use `.focusable(true)` here, after pop the Detail view, the Content view's List does not get focus again
|
// If use `.focusable(true)` here, after pop the Detail view, the Content view's List does not get focus again
|
||||||
|
|
|
@ -268,7 +268,8 @@ Demo Tips:
|
||||||
1. Use `Switch` (right-click on macOS/force press on watchOS) to switch between `WebImage` and `AnimatedImage`.
|
1. Use `Switch` (right-click on macOS/force press on watchOS) to switch between `WebImage` and `AnimatedImage`.
|
||||||
2. Use `Reload` (right-click on macOS/force press on watchOS) to clear cache.
|
2. Use `Reload` (right-click on macOS/force press on watchOS) to clear cache.
|
||||||
3. Use `Swipe` to delete one image item.
|
3. Use `Swipe` to delete one image item.
|
||||||
4. Clear cache and go to detail page to see progressive loading.
|
4. Pinch gesture (Digital Crown on watchOS, play button on tvOS) to zoom-in detail page image.
|
||||||
|
5. Clear cache and go to detail page to see progressive loading.
|
||||||
|
|
||||||
## Screenshot
|
## Screenshot
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue