wip
This commit is contained in:
parent
57ba06a94e
commit
21b4e772d8
|
@ -58,3 +58,11 @@
|
|||
"ServerConnectingIndicator.State.connecting" = "Connecting to server";
|
||||
"ServerConnectingIndicator.State.connected" = "Connected";
|
||||
"ServerConnectingIndicator.State.error" = "Server unreachable. Check internet connection and server name";
|
||||
|
||||
// MARK: Attachments
|
||||
"Attachment.Prompt.main" = "Select attachment";
|
||||
"Attachment.Tab.media" = "Media";
|
||||
"Attachment.Tab.files" = "Files";
|
||||
"Attachment.Tab.location" = "Location";
|
||||
"Attachment.Tab.contacts" = "Contacts";
|
||||
|
||||
|
|
|
@ -1,16 +0,0 @@
|
|||
import SwiftUI
|
||||
|
||||
struct AttachmentPickerScreen: View {
|
||||
@EnvironmentObject var store: AppStore
|
||||
|
||||
var body: some View {
|
||||
VStack {
|
||||
Button {
|
||||
store.dispatch(.conversationAction(.showAttachmentPicker(false)))
|
||||
} label: {
|
||||
Text("Back")
|
||||
}
|
||||
Text("Do It")
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
import SwiftUI
|
||||
|
||||
struct AttachmentContactsPickerView: View {
|
||||
var body: some View {
|
||||
Text("Contact Picker")
|
||||
// Implement your contact picker here
|
||||
}
|
||||
}
|
|
@ -0,0 +1,48 @@
|
|||
import SwiftUI
|
||||
import UIKit
|
||||
|
||||
struct AttachmentFilesPickerView: View {
|
||||
@State private var isPickerPresented = false
|
||||
|
||||
var body: some View {
|
||||
Button(action: {
|
||||
isPickerPresented = true
|
||||
}) {
|
||||
Text("Select Files")
|
||||
}
|
||||
.sheet(isPresented: $isPickerPresented) {
|
||||
DocumentPicker()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct DocumentPicker: UIViewControllerRepresentable {
|
||||
func makeUIViewController(context: UIViewControllerRepresentableContext<DocumentPicker>) -> UIDocumentPickerViewController {
|
||||
let picker = UIDocumentPickerViewController(documentTypes: ["public.item"], in: .import)
|
||||
picker.delegate = context.coordinator
|
||||
picker.allowsMultipleSelection = true
|
||||
return picker
|
||||
}
|
||||
|
||||
func updateUIViewController(_: UIDocumentPickerViewController, context _: UIViewControllerRepresentableContext<DocumentPicker>) {}
|
||||
|
||||
func makeCoordinator() -> Coordinator {
|
||||
Coordinator(self)
|
||||
}
|
||||
|
||||
class Coordinator: NSObject, UIDocumentPickerDelegate {
|
||||
var parent: DocumentPicker
|
||||
|
||||
init(_ parent: DocumentPicker) {
|
||||
self.parent = parent
|
||||
}
|
||||
|
||||
func documentPicker(_: UIDocumentPickerViewController, didPickDocumentsAt _: [URL]) {
|
||||
// Handle the selected files
|
||||
}
|
||||
|
||||
func documentPickerWasCancelled(_: UIDocumentPickerViewController) {
|
||||
// Handle cancellation
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
import SwiftUI
|
||||
|
||||
struct AttachmentHeader: View {
|
||||
@EnvironmentObject var store: AppStore
|
||||
|
||||
var body: some View {
|
||||
ZStack {
|
||||
// bg
|
||||
Color.Main.backgroundDark
|
||||
.ignoresSafeArea()
|
||||
|
||||
// title
|
||||
Text(L10n.Attachment.Prompt.main)
|
||||
.font(.head2)
|
||||
.foregroundColor(Color.Main.black)
|
||||
|
||||
HStack {
|
||||
Spacer()
|
||||
Image(systemName: "xmark")
|
||||
.foregroundColor(Color.Tango.orangeMedium)
|
||||
.tappablePadding(.symmetric(12)) {
|
||||
store.dispatch(.conversationAction(.showAttachmentPicker(false)))
|
||||
}
|
||||
}
|
||||
.padding(.horizontal, 16)
|
||||
}
|
||||
.frame(height: 44)
|
||||
}
|
||||
}
|
|
@ -0,0 +1,44 @@
|
|||
import MapKit
|
||||
import SwiftUI
|
||||
import UIKit
|
||||
|
||||
struct AttachmentLocationPickerView: View {
|
||||
@State private var region = MKCoordinateRegion(
|
||||
center: CLLocationCoordinate2D(latitude: 34.011_286, longitude: -116.166_868),
|
||||
span: MKCoordinateSpan(latitudeDelta: 0.2, longitudeDelta: 0.2)
|
||||
)
|
||||
|
||||
var body: some View {
|
||||
MapView(coordinateRegion: $region)
|
||||
}
|
||||
}
|
||||
|
||||
struct MapView: UIViewRepresentable {
|
||||
@Binding var coordinateRegion: MKCoordinateRegion
|
||||
|
||||
func makeUIView(context: Context) -> MKMapView {
|
||||
let mapView = MKMapView()
|
||||
mapView.delegate = context.coordinator
|
||||
return mapView
|
||||
}
|
||||
|
||||
func updateUIView(_ uiView: MKMapView, context _: Context) {
|
||||
uiView.setRegion(coordinateRegion, animated: true)
|
||||
}
|
||||
|
||||
func makeCoordinator() -> Coordinator {
|
||||
Coordinator(self)
|
||||
}
|
||||
|
||||
class Coordinator: NSObject, MKMapViewDelegate {
|
||||
var parent: MapView
|
||||
|
||||
init(_ parent: MapView) {
|
||||
self.parent = parent
|
||||
}
|
||||
|
||||
func mapView(_ mapView: MKMapView, regionDidChangeAnimated _: Bool) {
|
||||
parent.coordinateRegion = mapView.region
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,62 @@
|
|||
import SwiftUI
|
||||
import UIKit
|
||||
|
||||
struct AttachmentMediaPickerView: View {
|
||||
@State private var isPickerPresented = false
|
||||
@State private var mediaType: UIImagePickerController.SourceType = .photoLibrary
|
||||
|
||||
var body: some View {
|
||||
VStack {
|
||||
Button(action: {
|
||||
mediaType = .photoLibrary
|
||||
isPickerPresented = true
|
||||
}) {
|
||||
Text("Select from Photo Library")
|
||||
}
|
||||
|
||||
Button(action: {
|
||||
mediaType = .camera
|
||||
isPickerPresented = true
|
||||
}) {
|
||||
Text("Take Photo or Video")
|
||||
}
|
||||
}
|
||||
.sheet(isPresented: $isPickerPresented) {
|
||||
ImagePicker(sourceType: mediaType)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct ImagePicker: UIViewControllerRepresentable {
|
||||
var sourceType: UIImagePickerController.SourceType
|
||||
|
||||
func makeUIViewController(context: UIViewControllerRepresentableContext<ImagePicker>) -> UIImagePickerController {
|
||||
let picker = UIImagePickerController()
|
||||
picker.sourceType = sourceType
|
||||
picker.allowsEditing = true
|
||||
picker.delegate = context.coordinator
|
||||
return picker
|
||||
}
|
||||
|
||||
func updateUIViewController(_: UIImagePickerController, context _: UIViewControllerRepresentableContext<ImagePicker>) {}
|
||||
|
||||
func makeCoordinator() -> Coordinator {
|
||||
Coordinator(self)
|
||||
}
|
||||
|
||||
class Coordinator: NSObject, UINavigationControllerDelegate, UIImagePickerControllerDelegate {
|
||||
var parent: ImagePicker
|
||||
|
||||
init(_ parent: ImagePicker) {
|
||||
self.parent = parent
|
||||
}
|
||||
|
||||
func imagePickerController(_: UIImagePickerController, didFinishPickingMediaWithInfo _: [UIImagePickerController.InfoKey: Any]) {
|
||||
// Handle the selected media
|
||||
}
|
||||
|
||||
func imagePickerControllerDidCancel(_: UIImagePickerController) {
|
||||
// Handle cancellation
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,27 @@
|
|||
import SwiftUI
|
||||
|
||||
struct AttachmentPickerScreen: View {
|
||||
@EnvironmentObject var store: AppStore
|
||||
|
||||
@State private var selectedTab: AttachmentTab = .media
|
||||
|
||||
var body: some View {
|
||||
ZStack {
|
||||
// Background color
|
||||
Color.Main.backgroundLight
|
||||
.ignoresSafeArea()
|
||||
|
||||
// Content
|
||||
VStack(spacing: 0) {
|
||||
// Header
|
||||
AttachmentHeader()
|
||||
|
||||
// Pickers
|
||||
Spacer()
|
||||
|
||||
// Tab bar
|
||||
AttachmentTabBar(selectedTab: $selectedTab)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,85 @@
|
|||
import SwiftUI
|
||||
|
||||
enum AttachmentTab: Int, CaseIterable {
|
||||
case media
|
||||
case files
|
||||
case location
|
||||
case contacts
|
||||
}
|
||||
|
||||
struct AttachmentTabBar: View {
|
||||
@Binding var selectedTab: AttachmentTab
|
||||
|
||||
var body: some View {
|
||||
VStack(spacing: 0) {
|
||||
Rectangle()
|
||||
.frame(maxWidth: .infinity)
|
||||
.frame(height: 0.2)
|
||||
.foregroundColor(.Main.separator)
|
||||
HStack(spacing: 0) {
|
||||
AttachmentTabBarButton(tab: .media, selected: $selectedTab)
|
||||
AttachmentTabBarButton(tab: .files, selected: $selectedTab)
|
||||
AttachmentTabBarButton(tab: .location, selected: $selectedTab)
|
||||
AttachmentTabBarButton(tab: .contacts, selected: $selectedTab)
|
||||
}
|
||||
.background(Color.Main.backgroundDark)
|
||||
}
|
||||
.frame(height: 50)
|
||||
}
|
||||
}
|
||||
|
||||
private struct AttachmentTabBarButton: View {
|
||||
let tab: AttachmentTab
|
||||
@Binding var selected: AttachmentTab
|
||||
|
||||
var body: some View {
|
||||
ZStack {
|
||||
VStack(spacing: 2) {
|
||||
buttonImg
|
||||
.foregroundColor(selected == tab ? .Material.greenDark500 : .Main.gray)
|
||||
.font(.system(size: 24, weight: .light))
|
||||
.symbolRenderingMode(.hierarchical)
|
||||
Text(buttonTitle)
|
||||
.font(.sub1)
|
||||
.foregroundColor(selected == tab ? .Main.black : .Main.gray)
|
||||
}
|
||||
Rectangle()
|
||||
.foregroundColor(.white.opacity(0.01))
|
||||
.onTapGesture {
|
||||
selected = tab
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var buttonImg: Image {
|
||||
switch tab {
|
||||
case .media:
|
||||
return Image(systemName: "photo.on.rectangle.angled")
|
||||
|
||||
case .files:
|
||||
return Image(systemName: "doc.on.doc")
|
||||
|
||||
case .location:
|
||||
return Image(systemName: "location.circle")
|
||||
|
||||
case .contacts:
|
||||
return Image(systemName: "person.crop.circle")
|
||||
}
|
||||
}
|
||||
|
||||
var buttonTitle: String {
|
||||
switch tab {
|
||||
case .media:
|
||||
return L10n.Attachment.Tab.media
|
||||
|
||||
case .files:
|
||||
return L10n.Attachment.Tab.files
|
||||
|
||||
case .location:
|
||||
return L10n.Attachment.Tab.location
|
||||
|
||||
case .contacts:
|
||||
return L10n.Attachment.Tab.contacts
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue