Skip to content

Commit

Permalink
Commit
Browse files Browse the repository at this point in the history
  • Loading branch information
VishalNandoriya authored and Mac-Vishal committed Jul 7, 2017
1 parent 646f613 commit 1dec4ff
Show file tree
Hide file tree
Showing 19 changed files with 1,369 additions and 0 deletions.
400 changes: 400 additions & 0 deletions GooglePlacesClone.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions GooglePlacesClone.xcworkspace/contents.xcworkspacedata

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file added GooglePlacesClone/.DS_Store
Binary file not shown.
63 changes: 63 additions & 0 deletions GooglePlacesClone/AppDelegate.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
//
// AppDelegate.swift
// GooglePlacesClone
//
// Created by Mac-Vishal on 07/07/17.
// Copyright © 2017 Vishal. All rights reserved.
//

import UIKit

import GooglePlaces
import GoogleMaps

internal let kMapsAPIKey = "AIzaSyByMPkzUpCKOVMnIuYzvWfMz8_VxVFZcP8"

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {

var window: UIWindow?


func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {

if kMapsAPIKey.isEmpty {

let bundleId = Bundle.main.bundleIdentifier!
let msg = "Configure API keys inside Appdelegate.swift for your bundle `\(bundleId)`, " +
"see README.GooglePlacesClone for more information"
print(msg)
}

//Configure API key
GMSPlacesClient.provideAPIKey(kMapsAPIKey)
GMSServices.provideAPIKey(kMapsAPIKey)

return true
}

func applicationWillResignActive(_ application: UIApplication) {
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
// Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game.
}

func applicationDidEnterBackground(_ application: UIApplication) {
// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}

func applicationWillEnterForeground(_ application: UIApplication) {
// Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background.
}

func applicationDidBecomeActive(_ application: UIApplication) {
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}

func applicationWillTerminate(_ application: UIApplication) {
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}


}

68 changes: 68 additions & 0 deletions GooglePlacesClone/Assets.xcassets/AppIcon.appiconset/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
{
"images" : [
{
"idiom" : "iphone",
"size" : "29x29",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "29x29",
"scale" : "3x"
},
{
"idiom" : "iphone",
"size" : "40x40",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "40x40",
"scale" : "3x"
},
{
"idiom" : "iphone",
"size" : "60x60",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "60x60",
"scale" : "3x"
},
{
"idiom" : "ipad",
"size" : "29x29",
"scale" : "1x"
},
{
"idiom" : "ipad",
"size" : "29x29",
"scale" : "2x"
},
{
"idiom" : "ipad",
"size" : "40x40",
"scale" : "1x"
},
{
"idiom" : "ipad",
"size" : "40x40",
"scale" : "2x"
},
{
"idiom" : "ipad",
"size" : "76x76",
"scale" : "1x"
},
{
"idiom" : "ipad",
"size" : "76x76",
"scale" : "2x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
77 changes: 77 additions & 0 deletions GooglePlacesClone/AutoCompleteVC.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
//
// AutoCompleteVC.swift
// GooglePlaces
//
// Created by Mac-Vishal on 07/07/17.
// Copyright © 2017 Vishal. All rights reserved.
//

import UIKit
import GooglePlacePicker
class AutoCompleteVC: UIViewController {

@IBOutlet var lblName:UILabel!
@IBOutlet var lblAddress:UILabel!
@IBOutlet var lblLatitude:UILabel!
@IBOutlet var lblLongitude:UILabel!
@IBOutlet var indicatorView:UIActivityIndicatorView!

@IBOutlet var viewContainer:UIView!

override func viewDidLoad() {
super.viewDidLoad()

self.getAutocompletePicker()

}
func getAutocompletePicker() {
let autocompleteController = GMSAutocompleteViewController()
autocompleteController.delegate = self
present(autocompleteController, animated: true, completion: nil)
}
@IBAction func refresh(sender: UIButton)
{
self.viewContainer.isHidden = true
self.getAutocompletePicker()
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
}

}
extension AutoCompleteVC: GMSAutocompleteViewControllerDelegate {

func viewController(_ viewController: GMSAutocompleteViewController, didAutocompleteWith place: GMSPlace) {
self.viewContainer.isHidden = false
self.indicatorView.isHidden = true
self.lblName.text = place.name
self.lblAddress.text = place.formattedAddress?.components(separatedBy: ", ")
.joined(separator: "\n")
self.lblLatitude.text = String(place.coordinate.latitude)
self.lblLongitude.text = String(place.coordinate.longitude)
dismiss(animated: true, completion: nil)
}

func viewController(_ viewController: GMSAutocompleteViewController, didFailAutocompleteWithError error: Error) {
self.viewContainer.isHidden = true

print("Error: ", error.localizedDescription)
}

// User canceled the operation.
func wasCancelled(_ viewController: GMSAutocompleteViewController) {
dismiss(animated: true, completion: nil)
self.viewContainer.isHidden = true
self.indicatorView.isHidden = true
}

// Turn the network activity indicator on and off again.
func didRequestAutocompletePredictions(_ viewController: GMSAutocompleteViewController) {
UIApplication.shared.isNetworkActivityIndicatorVisible = true
}

func didUpdateAutocompletePredictions(_ viewController: GMSAutocompleteViewController) {
UIApplication.shared.isNetworkActivityIndicatorVisible = false
}

}
27 changes: 27 additions & 0 deletions GooglePlacesClone/Base.lproj/LaunchScreen.storyboard
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="11134" systemVersion="15F34" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="01J-lp-oVM">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="11106"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
<!--View Controller-->
<scene sceneID="EHf-IW-A2E">
<objects>
<viewController id="01J-lp-oVM" sceneMemberID="viewController">
<layoutGuides>
<viewControllerLayoutGuide type="top" id="Llm-lL-Icb"/>
<viewControllerLayoutGuide type="bottom" id="xb3-aO-Qok"/>
</layoutGuides>
<view key="view" contentMode="scaleToFill" id="Ze5-6b-2t3">
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</view>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="iYj-Kq-Ea1" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="53" y="375"/>
</scene>
</scenes>
</document>
Loading

0 comments on commit 1dec4ff

Please sign in to comment.