import React from 'react';
import {Image,NativeModules,} from 'react-native';
import { ELocation, SuggestedSearchAtlas } from 'mappls-map-react-native/javascript/modules/restApi/models/AutoSuggestModel';

export interface PlaceWidgetProps {
  autoSuggestBaseUrl?:string,
  location?:[number,number],
  historyCount?:number,
  zoom?:number,
  saveHistory?:boolean,
  pod?:string,
  backgroundColor?:string,
  tokenizeAddress?:boolean,
  toolbarColor?:string,
  hint?:string,
  filter?:string,
  attributionVerticalAlignment?: any;
  attributionHorizontalAlignment?:any;
  logoSize?:number;
  userAddedLocationEnable?:boolean;
  enableTextSearch?:boolean;
  minCharactersForSearch?:number;
  statusBarColor?:string;
  toolbarTintColor?:string;
  showPoweredByText?:boolean;
  hyperLocal?:boolean;
  bridge?:boolean;
  isShowCurrentLocation?: boolean;
  currentLocationTextColor?:string;
  debounce?: number;
  favoritePlaces?:Array<MapplsFavoritePlace>;
  favoriteCount?:number;
  resultBackgroundColor?:string;
  placeNameTextColor?:string;
  addressTextColor?:string;
  savedPlaceNameTextColor?:string;
  favoritePlaceNameTextColor?:string;
  distanceTextColor?:string;
  errorBackgroundColor?:string;
  errorTextColor?:string;
  hintColor?:string;
  poweredByTextColor?:string;
  attributionBackgroundColor?:string;
  currentLocationBackground?:string;
  responseLang?:string;
}

interface MapplsFavoritePlace {
  placeName?:string;
  placeAddress?:string;
  mapplsPin?:string;
  latitude?:number;
  longitude?:number;
  otherInfo?:any;
}

interface AutocompleteResult {
  eLocation:ELocation;
  suggestedSearch:SuggestedSearchAtlas;
  isRequestForCurrentLocation: boolean;
  mapplsFavoritePlace:MapplsFavoritePlace;
}
const Components = {

 //map bottom logo
  mapLogo: () => {
    return (
      <Image
        source={require('../assets/mappls_maps_logo_icon.png')}
        style={{height: 22, width: 190, left: 10}}
        resizeMode="contain"
      />
    );
  },

  openPlaceWidget:async (props:PlaceWidgetProps={}):Promise<AutocompleteResult>=>{
    if(props.tokenizeAddress===undefined){
      props.tokenizeAddress=true
    }
  const response = await  NativeModules.MapplsReactNativePlacePicker.openPlaceWidget(props);
  return JSON.parse(response)
  }
  
};

export default Components;
