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.contacts" = "Contacts";
"Attachment.Send.media" = "Send media";
"Attachment.Send.location" = "Send location";

View file

@ -5,47 +5,44 @@ import SwiftUI
struct AttachmentLocationPickerView: View {
@State var region = MKCoordinateRegion()
@State var userInteracting = false
var body: some View {
ZStack {
if userInteracting {
Map(
coordinateRegion: $region,
interactionModes: .all,
showsUserLocation: false,
userTrackingMode: .constant(.none)
)
.overlay {
VStack {
Spacer()
HStack {
Spacer()
Image(systemName: "location.north.circle.fill")
.resizable()
.frame(width: 30, height: 30)
.foregroundColor(.Material.Elements.active)
.padding()
.tappablePadding(.symmetric(10)) {
userInteracting = false
}
}
}
}
} else {
VStack(spacing: 0) {
// Map
Map(
coordinateRegion: $region,
interactionModes: .all,
showsUserLocation: false,
userTrackingMode: .constant(.follow)
)
.gesture(DragGesture().onChanged { _ in
userInteracting = true
})
}
.overlay {
Image(systemName: "mappin")
.font(.system(size: 30))
.foregroundColor(.Material.Elements.active)
}
// Send panel
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
}
}
}