mirror of
https://github.com/Dimillian/IceCubesApp.git
synced 2024-11-25 09:41:02 +00:00
Focus on selected media in viewer
This commit is contained in:
parent
00b5e07acd
commit
d995b7c996
2 changed files with 36 additions and 19 deletions
|
@ -1,7 +1,7 @@
|
|||
import Foundation
|
||||
|
||||
public struct MediaAttachement: Codable, Identifiable {
|
||||
public struct Meta: Codable {
|
||||
public struct MediaAttachement: Codable, Identifiable, Hashable {
|
||||
public struct Meta: Codable, Equatable {
|
||||
public let width: Int?
|
||||
public let height: Int?
|
||||
public let size: String?
|
||||
|
@ -14,6 +14,10 @@ public struct MediaAttachement: Codable, Identifiable {
|
|||
case image, gifv
|
||||
}
|
||||
|
||||
public func hash(into hasher: inout Hasher) {
|
||||
hasher.combine(id)
|
||||
}
|
||||
|
||||
public let id: String
|
||||
public let type: String
|
||||
public var supportedType: SupportedType? {
|
||||
|
|
|
@ -31,23 +31,8 @@ public struct StatusMediaPreviewView: View {
|
|||
}
|
||||
}
|
||||
}
|
||||
.sheet(item: $selectedMediaSheetManager.selectedAttachement) { attachement in
|
||||
VStack {
|
||||
Spacer()
|
||||
AsyncImage(
|
||||
url: attachement.url,
|
||||
content: { image in
|
||||
image
|
||||
.resizable()
|
||||
.aspectRatio(contentMode: .fit)
|
||||
},
|
||||
placeholder: {
|
||||
ProgressView()
|
||||
.frame(maxWidth: 80, maxHeight: 80)
|
||||
}
|
||||
)
|
||||
Spacer()
|
||||
}
|
||||
.sheet(item: $selectedMediaSheetManager.selectedAttachement) { selectedAttachement in
|
||||
makeSelectedAttachementsSheet(selectedAttachement: selectedAttachement)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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 a new issue