Untitled

mail@pastecode.io avatarunknown
plain_text
2 months ago
1.5 kB
0
Indexable
Never
//
//  ContentView.swift
//  bitti
//
//  Created by Doğancan Mavideniz on 4.08.2023.
//

import SwiftUI
import FGRoute
import CoreLocation


class LocationManager: NSObject, ObservableObject, CLLocationManagerDelegate {
    private var locationManager = CLLocationManager()

    override init() {
        super.init()
        locationManager.delegate = self
    }

    func requestLocationPermission() {
        if CLLocationManager.locationServicesEnabled() {
            locationManager.requestWhenInUseAuthorization()
        }
    }

    func locationManager(_ manager: CLLocationManager, didChangeAuthorization status: CLAuthorizationStatus) {
        // Handle authorization status changes here
    }
}

struct LocationPermissionView: View {
    @StateObject private var locationManager = LocationManager()
    @State var emreasd: Bool = false
    var body: some View {
        
        
        VStack {
            Text("Location Permission")
                .font(.title)
                .padding()

            Button("tikla") {
                emreasd.toggle()
            }
            if emreasd {
                Text(FGRoute.getSSID() == nil ? "N/A" : FGRoute.getSSID())
                Text(FGRoute.getBSSID())
                Text(FGRoute.getIPAddress())
                Text(FGRoute.getGatewayIP())
                Text(FGRoute.getNetmask())
                Text(FGRoute.getDestination())
            }
            
            
        }.onAppear(){
            locationManager.requestLocationPermission()
        }
    }
}