-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit f225b80
Showing
24 changed files
with
1,665 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# Scade | ||
.build/ | ||
.target/ | ||
products/ | ||
*.ipa | ||
*.scadeapp | ||
.DS_Store | ||
CMakeLists.txt | ||
fonts/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<projectDescription> | ||
<name>ScadeKaigi2020</name> | ||
<comment></comment> | ||
<projects> | ||
</projects> | ||
<buildSpec> | ||
<buildCommand> | ||
<name>com.scade.sdk.core.ScadeBuilder</name> | ||
<arguments> | ||
</arguments> | ||
</buildCommand> | ||
</buildSpec> | ||
<natures> | ||
<nature>com.scade.sdk.core.ScadeNature</nature> | ||
</natures> | ||
</projectDescription> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
eclipse.preferences.version=1 | ||
scade.project.folders.output=.target | ||
scade.project.folders.resources=res | ||
scade.project.folders.src=src | ||
scade.project.language=Mobile Application Project |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
spm: | ||
- url: | ||
from: | ||
path: | ||
branch: | ||
exact: | ||
revision: | ||
search-paths: [] | ||
linked-libs: [] | ||
|
||
search-paths: [] | ||
linked-libs: [] | ||
|
||
ios: | ||
name: ScadeKaigi2020 | ||
id: com.scade.ScadeKaigi2020 | ||
device-family: iphone # iphone, ipad or universal | ||
supported-interface-orientations: ['portrait'] # portrait, upside_down, landscape_left or landscape_right | ||
supported-interface-orientationsiPad: ['portrait'] | ||
entitlements-file: | ||
app-delegate-file: | ||
export-method: ad-hoc # app-store, enterprise or development | ||
simulator: | ||
os: 12.1 | ||
output: ScadeKaigi2020/.build/ios-simulator | ||
extra-args: | ||
search-paths: [] | ||
linked-libs: [] | ||
device: | ||
os: 12.1 | ||
output: ScadeKaigi2020/.build/ios-device | ||
extra-args: | ||
search-paths: [] | ||
linked-libs: [] | ||
mac: | ||
os: 10.11 | ||
output: ScadeKaigi2020/.build/scade-simulator | ||
extra-args: | ||
search-paths: [] | ||
linked-libs: [] | ||
sign: | ||
provision-profile: /Users/Hiromu.Tsuruta/XcodeApp/profile/appscade.mobileprovision | ||
certificate: /Users/Hiromu.Tsuruta/XcodeApp/profile/appscade.p12 | ||
icons: | ||
iphone: # or ipad, sizes: 20X20, 29X29, 40X40, 60X60, 76X76, 83.5X83.5 | ||
60X60_2X: | ||
76X76_2X: | ||
76X76_3X: | ||
83.5X83.5_2X: | ||
marketing: | ||
1024X1024_1X: | ||
plist: | ||
- key: CFBundleShortVersionString | ||
type: string # string, bool, int, list or dict | ||
value: 1.0 | ||
- key: CFBundleVersion | ||
type: string | ||
value: 1 | ||
- key: NSLocationWhenInUseUsageDescription | ||
type: string | ||
value: | ||
- key: NSCameraUsageDescription | ||
type: string | ||
value: Take pictures from camera | ||
- key: NSPhotoLibraryUsageDescription | ||
type: string | ||
value: Choose a photo from your library | ||
|
||
android: | ||
name: ScadeKaigi2020 | ||
id: com.scade.ScadeKaigi2020 | ||
version-name: 1.0.0 | ||
version-code: 1 | ||
build-type: Debug | ||
key-store-properties: | ||
google-api-key: | ||
manifest-file: | ||
permissions: [] | ||
armeabi-v7a: | ||
output: ScadeKaigi2020/.build/android-armeabi-v7a | ||
extra-args: | ||
search-paths: [] | ||
linked-libs: [] | ||
arm64-v8a: | ||
output: ScadeKaigi2020/.build/android-arm64-v8a | ||
extra-args: | ||
search-paths: [] | ||
linked-libs: [] | ||
x86: | ||
output: ScadeKaigi2020/.build/android-x86 | ||
extra-args: | ||
search-paths: [] | ||
linked-libs: [] | ||
x86_64: | ||
output: ScadeKaigi2020/.build/android-x86_64 | ||
extra-args: | ||
search-paths: [] | ||
linked-libs: [] | ||
intent-filters: | ||
- action: | ||
scheme: | ||
categories: [] | ||
icons: | ||
mdpi: | ||
hdpi: | ||
xhdpi: | ||
xxhdpi: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
|
||
/* https://app.swaggerhub.com/apis/jmatsu/droidkaigi/2020 */ | ||
|
||
struct Constants { | ||
struct API { | ||
static let baseURL: String = "https://api.droidkaigi.jp/2020/" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import Foundation | ||
import ScadeKit | ||
|
||
// MARK: - BaseAPIProtocol | ||
|
||
protocol BaseAPIProtocol { | ||
associatedtype ResponseType | ||
|
||
var method: HTTPMethod { get } | ||
var baseURL: URL { get } | ||
var path: String { get } | ||
var headers: Headers? { get } | ||
} | ||
|
||
extension BaseAPIProtocol { | ||
var baseURL: URL { | ||
return URL(string: Constants.API.baseURL)! | ||
} | ||
var headers: Headers? { | ||
return [ | ||
"Content-Type": "application/json; charset=utf-8", | ||
"User-Agent": "official-app-2020/1.0 gzip" | ||
] | ||
} | ||
} | ||
|
||
// MARK: - BaseRequestProtocol | ||
|
||
protocol BaseRequestProtocol: BaseAPIProtocol { | ||
var parameters: Parameters? { get } | ||
var asURLRequest: URLRequest { get } | ||
} | ||
|
||
extension BaseRequestProtocol { | ||
|
||
var asURLRequest: URLRequest { | ||
var urlRequest: URLRequest = { | ||
let url = baseURL.appendingPathComponent(path) | ||
guard let params = parameters else { return URLRequest(url: url) } | ||
|
||
// todo post | ||
|
||
// get | ||
var compnents = URLComponents(string: url.absoluteString) | ||
compnents?.queryItems = params.map { URLQueryItem(name: $0, value: "\($1)") } | ||
return URLRequest(url: compnents!.url!) | ||
}() | ||
urlRequest.httpMethod = method.rawValue | ||
urlRequest.allHTTPHeaderFields = headers | ||
urlRequest.timeoutInterval = TimeInterval(30) | ||
return urlRequest | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
import Foundation | ||
|
||
// MARK: - API | ||
|
||
final class HttpClient { | ||
|
||
static func call<T, V>(_ request: T, completion: @escaping (APIResult) -> Void) | ||
where T: BaseRequestProtocol, V: Codable, T.ResponseType == V { | ||
|
||
let task = URLSession.shared.dataTask(with: request.asURLRequest) { data, response, error in | ||
if let data = data { | ||
completion(decodeData(request, data)) | ||
} else { | ||
completion(.failure(error ?? ResponseError(description: ""))) | ||
} | ||
} | ||
task.resume() | ||
} | ||
|
||
private static func decodeData<T, V>(_ request: T, _ data: Data) -> APIResult | ||
where T: BaseRequestProtocol, V: Codable, T.ResponseType == V { | ||
|
||
if let result = try? JSONDecoder(type: .convertFromSnakeCase).decode(V.self, from: data) { | ||
return .success(result) | ||
} else { | ||
return .failure(DecodeError(description: String(data: data, encoding: .utf8))) | ||
} | ||
} | ||
} | ||
|
||
// MARK: - ResultType | ||
|
||
enum APIResult { | ||
case success(Codable) | ||
case failure(Error) | ||
} | ||
|
||
// MARK: - Error | ||
|
||
struct ResponseError: Error, CustomStringConvertible { | ||
let description: String | ||
|
||
init(description: String?) { | ||
self.description = "-- Response Error -- \(description ?? "none")" | ||
} | ||
} | ||
|
||
struct DecodeError: Error, CustomStringConvertible { | ||
let description: String | ||
|
||
init(description: String?) { | ||
self.description = "-- Decode Error -- \(description ?? "none")" | ||
} | ||
} | ||
|
||
// MARK: - JSONDecoder Extension | ||
|
||
extension JSONDecoder { | ||
|
||
convenience init(type: JSONDecoder.KeyDecodingStrategy) { | ||
self.init() | ||
self.keyDecodingStrategy = type | ||
} | ||
|
||
} | ||
|
||
// MARK: - Options | ||
|
||
typealias Headers = [String: String] | ||
typealias Parameters = [String: Any] | ||
|
||
struct HTTPMethod: RawRepresentable, Equatable, Hashable { | ||
static let get = HTTPMethod(rawValue: "GET") | ||
static let post = HTTPMethod(rawValue: "POST") | ||
// static let connect = HTTPMethod(rawValue: "CONNECT") | ||
// static let delete = HTTPMethod(rawValue: "DELETE") | ||
// static let head = HTTPMethod(rawValue: "HEAD") | ||
// static let options = HTTPMethod(rawValue: "OPTIONS") | ||
// static let patch = HTTPMethod(rawValue: "PATCH") | ||
// static let put = HTTPMethod(rawValue: "PUT") | ||
// static let trace = HTTPMethod(rawValue: "TRACE") | ||
|
||
let rawValue: String | ||
|
||
init(rawValue: String) { | ||
self.rawValue = rawValue | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import Foundation | ||
|
||
// MARK: - Request | ||
|
||
struct SpeakersRequest: BaseRequestProtocol { | ||
|
||
typealias ResponseType = [Speaker] | ||
|
||
var method: HTTPMethod { | ||
return .get | ||
} | ||
|
||
var path: String { | ||
return "speakers/" | ||
} | ||
|
||
var parameters: Parameters? { | ||
return nil | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import Foundation | ||
|
||
// MARK: - Response | ||
|
||
struct SpeakersResponse: Codable { | ||
var speakers: [Speaker] | ||
} | ||
|
||
struct Speaker: Codable { | ||
let id: String | ||
let firstName: String | ||
let lastName: String | ||
let bio: String | ||
let tagLine: String | ||
let profilePicture: String? | ||
let isTopSpeaker: Bool | ||
let sessions: [String] | ||
let fullName: String | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import Foundation | ||
import ScadeKit | ||
|
||
@objc | ||
protocol Asset: EObjectProtocol { | ||
var videoUrl: String { get } | ||
|
||
var slideUrl: String { get } | ||
} |
13 changes: 13 additions & 0 deletions
13
src/Networks/TimetableService.service.swift/Categories.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import Foundation | ||
import ScadeKit | ||
|
||
@objc | ||
protocol Categories: EObjectProtocol { | ||
var id: Int64 { get } | ||
|
||
var title: Title { get } | ||
|
||
var sort: Int64 { get } | ||
|
||
var items: [Rooms] { get } | ||
} |
13 changes: 13 additions & 0 deletions
13
src/Networks/TimetableService.service.swift/Questions.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import Foundation | ||
import ScadeKit | ||
|
||
@objc | ||
protocol Questions: EObjectProtocol { | ||
var id: Int64 { get } | ||
|
||
var question: Title { get } | ||
|
||
var questionType: String { get } | ||
|
||
var sort: Int64 { get } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import Foundation | ||
import ScadeKit | ||
|
||
@objc | ||
protocol Rooms: EObjectProtocol { | ||
var id: Int64 { get } | ||
|
||
var name: Title { get } | ||
|
||
var sort: Int64 { get } | ||
} |
Oops, something went wrong.