Skip to content
Location Message preview
Rendered from the SwiftUI source on this page.

Location Message

From syxUI — written for both platforms, not translated between them.

A shared-location message with a map snapshot and address.

Chat · SwiftUI · iOS 17

  • chat
  • swiftui

The actual source

ChatLocationMessage.swift
// Location Message · syxUI · https://syxui.dev/components/chat-location
// Free in any project. Keep this line and credit syxUI where a person can read it.

import SwiftUI

// Location message
struct ChatLocationMessage: View {
    var body: some View {
        HStack {
            Spacer(minLength: 40)
            VStack(alignment: .leading, spacing: 0) {
                ZStack {
                    LinearGradient(colors: [Color(red: 0.82, green: 0.88, blue: 0.82), Color(red: 0.72, green: 0.82, blue: 0.88)], startPoint: .top, endPoint: .bottom)
                    Path { p in
                        p.move(to: CGPoint(x: 0, y: 60)); p.addLine(to: CGPoint(x: 90, y: 30))
                        p.addLine(to: CGPoint(x: 150, y: 90)); p.addLine(to: CGPoint(x: 230, y: 50))
                    }.stroke(.white.opacity(0.7), lineWidth: 5)
                    Image(systemName: "mappin.circle.fill").font(.system(size: 30)).foregroundStyle(Color(red: 0.9, green: 0.24, blue: 0.22))
                }
                .frame(width: 220, height: 120)
                VStack(alignment: .leading, spacing: 1) {
                    Text("Current Location").font(.system(size: 14, weight: .semibold))
                    Text("123 Market St, San Francisco").font(.system(size: 12)).foregroundStyle(.secondary)
                }
                .padding(.horizontal, 12).padding(.vertical, 9).frame(width: 220, alignment: .leading)
            }
            .background(Color(.systemGray6)).clipShape(RoundedRectangle(cornerRadius: 18, style: .continuous))
        }
    }
}
iOS 17 · No dependencies

Dependencies

SwiftUI
No external dependencies

Requires iOS 17