CityExploreApp / City Sights App / Views / Denied / LocationDeniedView.swift
LocationDeniedView.swift
Raw
//
//  LocationDeniedView.swift
//  City Sights App
//
//  Created by Milos Ilic on 18.1.23..
//

import SwiftUI

struct LocationDeniedView: View {
    
    let backgroundColor = Color(red: 34/255, green: 141/255, blue: 138/255)
    
    var body: some View {
        
        VStack {
            
            Spacer()
            
            Text("Whoops!")
                .bold()
                .font(.title)
                .foregroundColor(.white)
                .padding()
            
            VStack {
                Text("We need to access your location to provide you with the best sights in the city.")
                Text("You can change your decision at any time in Settings")
            }
            .multilineTextAlignment(.center)
            .padding()
            .foregroundColor(.white)
            
            Spacer()
            
            Button {
                
                // Open settings by getting the settings url
                if let url = URL(string: UIApplication.openSettingsURLString) {
                    
                    if UIApplication.shared.canOpenURL(url) {
                        
                        // If we can open this settings url, then open in
                        UIApplication.shared.open(url)
                    }
                    
                }
                
                
            } label: {
                
                
                ZStack {
                    
                    Rectangle()
                        .foregroundColor(.white)
                        .frame(height: 48)
                        .cornerRadius(10)
                    
                    Text("Go to Settings")
                        .bold()
                        .foregroundColor(backgroundColor)
                    
                }
                .padding()
               
            }

           Spacer()
            
            
        }
        .background(backgroundColor)
        .ignoresSafeArea(.all, edges: .all)
        
        
    }
}

struct LocationDeniedView_Previews: PreviewProvider {
    static var previews: some View {
        LocationDeniedView()
    }
}