This commit is contained in:
fmodf 2024-07-04 17:01:30 +02:00
parent dfa048e918
commit 170c0daa5b
3 changed files with 47 additions and 38 deletions

View file

@ -66,4 +66,5 @@
"Attachment.Tab.location" = "Location"; "Attachment.Tab.location" = "Location";
"Attachment.Tab.contacts" = "Contacts"; "Attachment.Tab.contacts" = "Contacts";
"Attachment.Send.media" = "Send media"; "Attachment.Send.media" = "Send media";
"Attachment.Send.location" = "Send location";

View file

@ -5,47 +5,44 @@ import SwiftUI
struct AttachmentLocationPickerView: View { struct AttachmentLocationPickerView: View {
@State var region = MKCoordinateRegion() @State var region = MKCoordinateRegion()
@State var userInteracting = false
var body: some View { var body: some View {
ZStack { VStack(spacing: 0) {
if userInteracting { // Map
Map( Map(
coordinateRegion: $region, coordinateRegion: $region,
interactionModes: .all, interactionModes: .all,
showsUserLocation: false, showsUserLocation: false,
userTrackingMode: .constant(.none) userTrackingMode: .constant(.follow)
) )
.overlay { .overlay {
VStack { Image(systemName: "mappin")
Spacer() .font(.system(size: 30))
HStack { .foregroundColor(.Material.Elements.active)
Spacer()
Image(systemName: "location.north.circle.fill")
.resizable()
.frame(width: 30, height: 30)
.foregroundColor(.Material.Elements.active)
.padding()
.tappablePadding(.symmetric(10)) {
userInteracting = false
}
}
}
}
} else {
Map(
coordinateRegion: $region,
interactionModes: .all,
showsUserLocation: false,
userTrackingMode: .constant(.follow)
)
.gesture(DragGesture().onChanged { _ in
userInteracting = true
})
} }
Image(systemName: "mappin")
.font(.system(size: 30)) // Send panel
.foregroundColor(.Material.Elements.active) Rectangle()
.foregroundColor(.Material.Shape.black)
.frame(maxWidth: .infinity)
.frame(height: 50)
.overlay {
HStack {
Text(L10n.Attachment.Send.location)
.foregroundColor(.Material.Text.white)
.font(.body1)
Image(systemName: "arrow.up.circle")
.foregroundColor(.Material.Text.white)
.font(.body1)
.padding(.leading, 8)
}
.padding()
}
.clipped()
.onTapGesture {
// TODO: Send location
print("Send location")
}
} }
} }
} }

View file

@ -0,0 +1,11 @@
import SwiftUI
public extension View {
@ViewBuilder func `if`<Content: View>(_ condition: @autoclosure () -> Bool, transform: (Self) -> Content) -> some View {
if condition() {
transform(self)
} else {
self
}
}
}