//
//  SwiftUIExample.swift
//  Navvo Maps SDK for iOS — minimal SwiftUI example.
//
//  Requires iOS 14+ for `.ignoresSafeArea()`; the NavvoMap view itself
//  supports iOS 13+.
//

import SwiftUI
import NavvoMaps

struct MapScreen: View {
    @State private var camera = CameraPosition(target: LatLng(31.95, 35.91), zoom: 12)
    @State private var style: NavvoMapStyle = .standard

    private let markers = [
        NavvoMarker(
            id: "downtown",
            position: LatLng(31.9539, 35.9106),
            title: "Downtown Amman"
        )
    ]

    var body: some View {
        ZStack(alignment: .topTrailing) {
            NavvoMap(style: style, camera: $camera, markers: markers)
                .onNavvoTap { coordinate in
                    print("Tapped \(coordinate)")
                }
                .onNavvoMarkerTap { marker in
                    print("Marker: \(marker.title ?? "?")")
                }
                .onNavvoCameraIdle { position in
                    print("Camera idle at zoom \(position.zoom)")
                }
                .ignoresSafeArea()

            Picker("Style", selection: $style) {
                Text("Standard").tag(NavvoMapStyle.standard)
                Text("Dark").tag(NavvoMapStyle.dark)
                Text("Satellite").tag(NavvoMapStyle.satellite)
            }
            .pickerStyle(.segmented)
            .padding()
        }
        .onAppear {
            NavvoMaps.configure(apiKey: "nvvo_YOUR_KEY")
        }
    }
}
