Focus on selected media in viewer
This commit is contained in:
parent
00b5e07acd
commit
d995b7c996
|
@ -1,7 +1,7 @@
|
||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
public struct MediaAttachement: Codable, Identifiable {
|
public struct MediaAttachement: Codable, Identifiable, Hashable {
|
||||||
public struct Meta: Codable {
|
public struct Meta: Codable, Equatable {
|
||||||
public let width: Int?
|
public let width: Int?
|
||||||
public let height: Int?
|
public let height: Int?
|
||||||
public let size: String?
|
public let size: String?
|
||||||
|
@ -14,6 +14,10 @@ public struct MediaAttachement: Codable, Identifiable {
|
||||||
case image, gifv
|
case image, gifv
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public func hash(into hasher: inout Hasher) {
|
||||||
|
hasher.combine(id)
|
||||||
|
}
|
||||||
|
|
||||||
public let id: String
|
public let id: String
|
||||||
public let type: String
|
public let type: String
|
||||||
public var supportedType: SupportedType? {
|
public var supportedType: SupportedType? {
|
||||||
|
|
|
@ -31,23 +31,8 @@ public struct StatusMediaPreviewView: View {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.sheet(item: $selectedMediaSheetManager.selectedAttachement) { attachement in
|
.sheet(item: $selectedMediaSheetManager.selectedAttachement) { selectedAttachement in
|
||||||
VStack {
|
makeSelectedAttachementsSheet(selectedAttachement: selectedAttachement)
|
||||||
Spacer()
|
|
||||||
AsyncImage(
|
|
||||||
url: attachement.url,
|
|
||||||
content: { image in
|
|
||||||
image
|
|
||||||
.resizable()
|
|
||||||
.aspectRatio(contentMode: .fit)
|
|
||||||
},
|
|
||||||
placeholder: {
|
|
||||||
ProgressView()
|
|
||||||
.frame(maxWidth: 80, maxHeight: 80)
|
|
||||||
}
|
|
||||||
)
|
|
||||||
Spacer()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -85,4 +70,32 @@ public struct StatusMediaPreviewView: View {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private func makeSelectedAttachementsSheet(selectedAttachement: MediaAttachement) -> some View {
|
||||||
|
var attachements = attachements
|
||||||
|
attachements.removeAll(where: { $0.id == selectedAttachement.id })
|
||||||
|
attachements.insert(selectedAttachement, at: 0)
|
||||||
|
return TabView {
|
||||||
|
ForEach(attachements) { attachement in
|
||||||
|
VStack {
|
||||||
|
Spacer()
|
||||||
|
AsyncImage(
|
||||||
|
url: attachement.url,
|
||||||
|
content: { image in
|
||||||
|
image
|
||||||
|
.resizable()
|
||||||
|
.aspectRatio(contentMode: .fit)
|
||||||
|
},
|
||||||
|
placeholder: {
|
||||||
|
ProgressView()
|
||||||
|
.frame(maxWidth: 80, maxHeight: 80)
|
||||||
|
}
|
||||||
|
)
|
||||||
|
Spacer()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.tabViewStyle(.page(indexDisplayMode: .always))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue