@@ -2,17 +2,19 @@ import ATProtoKit
2
2
import DesignSystem
3
3
import Models
4
4
import NukeUI
5
+ import Router
5
6
import SwiftUI
6
7
7
8
struct PostRowImagesView : View {
8
- @Namespace private var namespace
9
9
@Environment ( \. isQuote) var isQuote
10
+ @Environment ( Router . self) var router
11
+
12
+ @Namespace private var namespace
10
13
11
14
let quoteMaxSize : CGFloat = 100
12
-
13
15
let images : AppBskyLexicon . Embed . ImagesDefinition . View
14
- @State private var firstImageSize : CGSize ?
15
16
17
+ @State private var firstImageSize : CGSize ?
16
18
@State private var isMediaExpanded : Bool = false
17
19
18
20
var body : some View {
@@ -26,12 +28,13 @@ struct PostRowImagesView: View {
26
28
)
27
29
}
28
30
}
29
- . padding ( . bottom, images. images. count > 1 && !isQuote ? 15 : 0 )
31
+ . padding ( . bottom, images. images. count > 1 && !isQuote ? CGFloat ( images . images . count ) * 7 : 0 )
30
32
. onTapGesture {
31
- isMediaExpanded. toggle ( )
32
- }
33
- . fullScreenCover ( isPresented: $isMediaExpanded) {
34
- expandedView
33
+ router. presentedSheet = . fullScreenMedia(
34
+ images: images. images. map ( \. fullSizeImageURL) ,
35
+ preloadedImage: images. images. first? . thumbnailImageURL,
36
+ namespace: namespace
37
+ )
35
38
}
36
39
}
37
40
@@ -51,15 +54,14 @@ struct PostRowImagesView: View {
51
54
image
52
55
. resizable ( )
53
56
. scaledToFill ( )
54
- . frame ( width: finalWidth, height: finalHeight)
55
57
. aspectRatio ( contentMode: . fit)
56
58
} else {
57
59
RoundedRectangle ( cornerRadius: 8 )
58
60
. fill ( . thinMaterial)
59
- . frame ( width: finalWidth, height: finalHeight)
60
61
}
61
62
}
62
63
. processors ( [ . resize( size: . init( width: finalWidth, height: finalHeight) ) ] )
64
+ . frame ( width: finalWidth, height: finalHeight)
63
65
. matchedTransitionSource ( id: image. fullSizeImageURL, in: namespace)
64
66
. glowingRoundedRectangle ( )
65
67
. onAppear {
@@ -72,29 +74,4 @@ struct PostRowImagesView: View {
72
74
isQuote ? 1 : ( firstImageSize? . width ?? width) / ( firstImageSize? . height ?? height) ,
73
75
contentMode: . fit)
74
76
}
75
-
76
- private var expandedView : some View {
77
- ScrollView ( . horizontal) {
78
- LazyHStack {
79
- ForEach ( images. images, id: \. thumbnailImageURL) { image in
80
- LazyImage ( url: image. fullSizeImageURL) { state in
81
- if let image = state. image {
82
- image
83
- . resizable ( )
84
- . scaledToFill ( )
85
- . aspectRatio ( contentMode: . fit)
86
- } else {
87
- RoundedRectangle ( cornerRadius: 8 )
88
- . fill ( . thinMaterial)
89
- }
90
- }
91
- . containerRelativeFrame ( [ . horizontal, . vertical] )
92
- }
93
- }
94
- . scrollTargetLayout ( )
95
- }
96
- . scrollContentBackground ( . hidden)
97
- . scrollTargetBehavior ( . viewAligned)
98
- . navigationTransition ( . zoom( sourceID: images. images [ 0 ] . fullSizeImageURL, in: namespace) )
99
- }
100
77
}
0 commit comments