2024-08-17 08:50:44 +00:00
|
|
|
import AVFoundation
|
|
|
|
import MobileCoreServices
|
|
|
|
import Photos
|
|
|
|
import SwiftUI
|
|
|
|
|
|
|
|
struct MediaPickerView: View {
|
2024-08-17 10:39:40 +00:00
|
|
|
@State private var selectedItems: [String] = []
|
2024-08-17 08:50:44 +00:00
|
|
|
|
|
|
|
var body: some View {
|
|
|
|
let columns = Array(repeating: GridItem(.flexible(), spacing: 0), count: 3)
|
|
|
|
|
|
|
|
VStack(spacing: 0) {
|
|
|
|
// List of media
|
|
|
|
ScrollView(showsIndicators: false) {
|
|
|
|
LazyVGrid(columns: columns, spacing: 0) {
|
|
|
|
// For camera
|
2024-08-17 10:39:40 +00:00
|
|
|
CameraCellPreview()
|
2024-08-17 08:50:44 +00:00
|
|
|
|
|
|
|
// For gallery
|
2024-08-17 11:22:47 +00:00
|
|
|
GalleryView()
|
2024-08-17 08:50:44 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Send panel
|
|
|
|
Rectangle()
|
|
|
|
.foregroundColor(.Material.Shape.black)
|
|
|
|
.frame(maxWidth: .infinity)
|
|
|
|
.frame(height: self.selectedItems.isEmpty ? 0 : 50)
|
|
|
|
.overlay {
|
|
|
|
HStack {
|
|
|
|
Text(L10n.Attachment.Send.media)
|
|
|
|
.foregroundColor(.Material.Text.white)
|
|
|
|
.font(.body1)
|
|
|
|
Image(systemName: "arrow.up.circle")
|
|
|
|
.foregroundColor(.Material.Text.white)
|
|
|
|
.font(.body1)
|
|
|
|
.padding(.leading, 8)
|
|
|
|
}
|
|
|
|
.padding()
|
|
|
|
}
|
|
|
|
.clipped()
|
|
|
|
.onTapGesture {
|
|
|
|
// store.dispatch(.sharingAction(.shareMedia(ids: selectedItems)))
|
|
|
|
// store.dispatch(.sharingAction(.showSharing(false)))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|