Skip to content

Commit

Permalink
Merge pull request #33 from boostcamp3-iOS/develop
Browse files Browse the repository at this point in the history
20190128
  • Loading branch information
presto95 authored Jan 28, 2019
2 parents 26f972b + 07e89eb commit 80abcaf
Show file tree
Hide file tree
Showing 112 changed files with 5,362 additions and 354 deletions.
107 changes: 28 additions & 79 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,17 +1,38 @@

# Created by https://www.gitignore.io/api/xcode,swift
# Edit at https://www.gitignore.io/?templates=xcode,swift
# Created by https://www.gitignore.io/api/git,xcode
# Edit at https://www.gitignore.io/?templates=git,xcode

### Git ###
# Created by git for backups. To disable backups in Git:
# $ git config --global mergetool.keepBackup false
*.orig

# Created by git when using merge tools for conflicts
*.BACKUP.*
*.BASE.*
*.LOCAL.*
*.REMOTE.*
*_BACKUP_*.txt
*_BASE_*.txt
*_LOCAL_*.txt
*_REMOTE_*.txt

### Swift ###
### Xcode ###
# Xcode
#
# gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore

## Build generated
## User settings
xcuserdata/

## compatibility with Xcode 8 and earlier (ignoring not required starting Xcode 9)
*.xcscmblueprint
*.xccheckout

## compatibility with Xcode 3 and earlier (ignoring not required starting Xcode 4)
build/
DerivedData/

## Various settings
*.moved-aside
*.pbxuser
!default.pbxuser
*.mode1v3
Expand All @@ -20,78 +41,6 @@ DerivedData/
!default.mode2v3
*.perspectivev3
!default.perspectivev3
xcuserdata/

## Other
*.moved-aside
*.xccheckout
*.xcscmblueprint

## Obj-C/Swift specific
*.hmap
*.ipa
*.dSYM.zip
*.dSYM

## Playgrounds
timeline.xctimeline
playground.xcworkspace

# Swift Package Manager
#
# Add this line if you want to avoid checking in source code from Swift Package Manager dependencies.
# Packages/
# Package.pins
# Package.resolved
.build/

# CocoaPods
#
# We recommend against adding the Pods directory to your .gitignore. However
# you should judge for yourself, the pros and cons are mentioned at:
# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
#
# Pods/
#
# Add this line if you want to avoid checking in source code from the Xcode workspace
# *.xcworkspace

# Carthage
#
# Add this line if you want to avoid checking in source code from Carthage dependencies.
# Carthage/Checkouts

Carthage/Build

# fastlane
#
# It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the
# screenshots whenever they are needed.
# For more information about the recommended setup visit:
# https://docs.fastlane.tools/best-practices/source-control/#source-control

fastlane/report.xml
fastlane/Preview.html
fastlane/screenshots/**/*.png
fastlane/test_output

# Code Injection
#
# After new code Injection tools there's a generated folder /iOSInjectionProject
# https://github.com/johnno1962/injectionforxcode

iOSInjectionProject/

### Xcode ###
# Xcode
#
# gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore

## User settings

## compatibility with Xcode 8 and earlier (ignoring not required starting Xcode 9)

## compatibility with Xcode 3 and earlier (ignoring not required starting Xcode 4)

### Xcode Patch ###
*.xcodeproj/*
Expand All @@ -101,4 +50,4 @@ iOSInjectionProject/
/*.gcno
**/xcshareddata/WorkspaceSettings.xcsettings

# End of https://www.gitignore.io/api/xcode,swift
# End of https://www.gitignore.io/api/git,xcode
14 changes: 11 additions & 3 deletions .swiftlint.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,18 @@
disabled_rules:
- leading_whitespace
- trailing_whitespace
- nesting

excluded:
FineDust/Supporting Files/AppDelegate.swift
- FineDust/Supporting Files/AppDelegate.swift
- FineDust/Supporting Files/GeoConverter.swift

line_length:
warning: 99
error: 120
warning: 99
error: 120

identifier_name:
excluded:
- x
- y
- dx
693 changes: 563 additions & 130 deletions FineDust.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

11 changes: 0 additions & 11 deletions FineDust/Base.lproj/Main.storyboard

This file was deleted.

62 changes: 62 additions & 0 deletions FineDust/Common/Common.storyboard
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="14460.31" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="IlJ-X8-Ugh">
<device id="retina4_7" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14460.20"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
<!--Main-->
<scene sceneID="O9k-tV-aYt">
<objects>
<viewControllerPlaceholder storyboardIdentifier="Main" storyboardName="Main" id="dfL-ab-jso" sceneMemberID="viewController">
<tabBarItem key="tabBarItem" title="Item" id="o6a-uJ-4rY"/>
</viewControllerPlaceholder>
<placeholder placeholderIdentifier="IBFirstResponder" id="IyA-va-e6X" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="-536" y="-508"/>
</scene>
<!--Statistics-->
<scene sceneID="4P2-Bc-Bb0">
<objects>
<viewControllerPlaceholder storyboardIdentifier="Statistics" storyboardName="Statistics" id="jFQ-9p-ugh" sceneMemberID="viewController">
<tabBarItem key="tabBarItem" title="Item" id="ne2-If-hL7"/>
</viewControllerPlaceholder>
<placeholder placeholderIdentifier="IBFirstResponder" id="frB-eY-6SA" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="-523" y="-387"/>
</scene>
<!--Tab Bar Controller-->
<scene sceneID="5lI-42-cJZ">
<objects>
<tabBarController id="IlJ-X8-Ugh" sceneMemberID="viewController">
<tabBar key="tabBar" contentMode="scaleToFill" insetsLayoutMarginsFromSafeArea="NO" id="9CY-Ak-aqb">
<rect key="frame" x="0.0" y="0.0" width="375" height="49"/>
<autoresizingMask key="autoresizingMask"/>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
</tabBar>
<connections>
<segue destination="dfL-ab-jso" kind="relationship" relationship="viewControllers" id="hdv-dR-dXQ"/>
<segue destination="jFQ-9p-ugh" kind="relationship" relationship="viewControllers" id="ueU-nJ-ZPc"/>
<segue destination="aX8-gk-I2E" kind="relationship" relationship="viewControllers" id="giY-KD-olX"/>
</connections>
</tabBarController>
<placeholder placeholderIdentifier="IBFirstResponder" id="52U-o4-sG3" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="-1159" y="-386"/>
</scene>
<!--Feedback-->
<scene sceneID="6LB-xR-h5z">
<objects>
<viewControllerPlaceholder storyboardIdentifier="Feedback" storyboardName="Feedback" id="aX8-gk-I2E" sceneMemberID="viewController">
<tabBarItem key="tabBarItem" title="Item" id="Kmx-8Q-yYD"/>
</viewControllerPlaceholder>
<placeholder placeholderIdentifier="IBFirstResponder" id="FBl-8w-zEJ" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="-535" y="-283"/>
</scene>
</scenes>
</document>
83 changes: 83 additions & 0 deletions FineDust/Common/Manager/API+FineDust.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
//
// API+FineDust.swift
// FineDust
//
// Created by Presto on 21/01/2019.
// Copyright © 2019 boostcamp3rd. All rights reserved.
//

import Foundation

/// 미세먼지 API 관련 API 정의.
extension API {
/// 측정소 정보 조회.
///
/// - Parameters:
/// - pageNo: 페이지 인덱스.
/// - numOfRows: 한 페이지에 노출되는 정보량.
/// - completion: 컴플리션 핸들러.
func fetchObservatory(
pageNumber pageNo: Int = 1,
numberOfRows numOfRows: Int = 10,
completion: @escaping (ObservatoryResponse?, Error?) -> Void
) {
let urlString = baseURL
.appending("/MsrstnInfoInqireSvc/getNearbyMsrstnList")
.appending("?tmX=\(GeoInfo.shared.x)")
.appending("&tmY=\(GeoInfo.shared.y)")
.appending("&numOfRows=\(numOfRows)")
.appending("&pageNo=\(pageNo)")
.appending("&serviceKey=\(serviceKey)")
.appending("&_returnType=json")
guard let url = URL(string: urlString) else { return }
Network.request(url, method: .get) { data, error in
guard let data = data else {
completion(nil, error)
return
}
do {
let response = try JSONDecoder().decode(ObservatoryResponse.self, from: data)
completion(response, nil)
} catch {
completion(nil, error)
}
}
}
/// 미세먼지 농도 조회.
///
/// - Parameters:
/// - dataTerm: 데이터 기간. daily 또는 month.
/// - pageNo: 페이지 인덱스.
/// - numOfRows: 한 페이지에 노출되는 정보량.
/// - completion: 컴플리션 핸들러.
func fetchFineDustConcentration(
term dataTerm: DataTerm,
pageNumber pageNo: Int = 1,
numberOfRows numOfRows: Int = 10,
completion: @escaping (FineDustResponse?, Error?) -> Void
) {
let observatory = FineDustInfo.shared.observatory.percentEncoded
let urlString = baseURL
.appending("/ArpltnInforInqireSvc/getMsrstnAcctoRltmMesureDnsty")
.appending("?stationName=\(observatory)")
.appending("&dataTerm=\(dataTerm.rawValue)")
.appending("&pageNo=\(pageNo)")
.appending("&numOfRows=\(numOfRows)")
.appending("&serviceKey=\(serviceKey)")
.appending("&ver=1.1")
.appending("&_returnType=json")
guard let url = URL(string: urlString) else { return }
Network.request(url, method: .get) { data, error in
guard let data = data else {
completion(nil, error)
return
}
do {
let response = try JSONDecoder().decode(FineDustResponse.self, from: data)
completion(response, nil)
} catch {
completion(nil, error)
}
}
}
}
31 changes: 31 additions & 0 deletions FineDust/Common/Manager/API.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
//
// API.swift
// FineDust
//
// Created by Presto on 21/01/2019.
// Copyright © 2019 boostcamp3rd. All rights reserved.
//

import Foundation

/// API 정의.
final class API {

// MARK: Singleton Object

/// API의 싱글톤 객체
static let shared = API()

// MARK: Private Initializer

private init() { }

// MARK: Property

/// Base URL.
let baseURL = "http://openapi.airkorea.or.kr/openapi/services/rest"
/// Service Key.
let serviceKey = """
BfJjA4%2BuaBHhfAzyF2Ni6xoVDaf%2FhsZylifmFKdW3kyaZECH6c2Lua05fV%2F%2BYgbzPBaSl0YLZwI%2BW%2FK2xzO7sw%3D%3D
"""
}
Loading

0 comments on commit 80abcaf

Please sign in to comment.