//
//  CustomMethods.swift
//  AwesomeProject3
//
//  Created by Macbook Pro on 03/07/2023.
//

import Foundation




  

@objc(CustomMethods) class CustomMethods: NSObject {
  @objc static func requiresMainQueueSetup() -> Bool { return true }
  
  
  @objc public func AddMarker( _ param: String) {
    
    
    let myObject = MyObjectiveCClass()
    myObject.addMarker(param)
    
  }
  
  
  @objc public func AddCustomMarker( _ param: String) {
    
    
    let myObject = MyObjectiveCClass()
    myObject.addCustomMarker(param)
    
  }
    
@objc public func AddCustomMarkerW( _ param: String, base64String: String) {


   let myObject = MyObjectiveCClass()
    myObject.addCustomMarkerW(param, base64String: base64String)
}
  
  
  @objc public func SetCameraAnim(
    _ latlng: String) {
    
  
    let myObject = MyObjectiveCClass()
    myObject.setCameraAnim(latlng)
      //showAlert()
  }
  
  
  
    @objc public func passStringArray(
        _ nsArray: [Any], colorr: String, widthh: String) {
          
          
            
        
        let myObject = MyObjectiveCClass()
            myObject.passStringArray(nsArray , colorr: colorr, widthh: widthh)
            
            
         
      }
  
  
  @objc public func callbackToRN(_ param: String){
    RNEventEmitter.emitter.sendEvent(withName: "onReady", body: [param])
  }

  @objc public func simpleMethodWithParams(
    _ param: String,
    callback: RCTResponseSenderBlock
  ) {
    callback(["CustomMethods.simpleMethodWithParams('\(param)')"])
  }
  @objc public func throwError() throws {
    //throw createError(message: "CustomMethods.throwError()")
  }
  @objc public func resolvePromise(
    _ resolve: RCTPromiseResolveBlock,
    rejecter reject: RCTPromiseRejectBlock
  ) -> Void {
    resolve("CustomMethods.resolvePromise()")
  }
  @objc public func rejectPromise(
    _ resolve: RCTPromiseResolveBlock,
    rejecter reject: RCTPromiseRejectBlock
  ) -> Void {
    reject("0", "CustomMethods.rejectPromise()", nil)
  }
  
  
  func showAlert() {
    // Create the alert controller
        let alertController = UIAlertController(title: "Alert", message: "This is a simple alert.", preferredStyle: .alert)
        
        // Create the OK action
        let okAction = UIAlertAction(title: "OK", style: .default) { _ in
            // Handle OK button tap
            // You can perform any additional actions here
        }
        
        // Add the OK action to the alert controller
        alertController.addAction(okAction)
        
        // Present the alert controller
        UIApplication.shared.keyWindow?.rootViewController?.present(alertController, animated: true, completion: nil)
  }
    
    
    @objc public func removeAllMarkers() {
        let myObject = MyObjectiveCClass()
        myObject.removeAllMarkers()
    }
    
    @objc public func removeAllPolyLines() {
        let myObject = MyObjectiveCClass()
        myObject.removeAllPolyLines()
    }
}
