Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/random music #13

Merged
merged 11 commits into from
Apr 27, 2022
16 changes: 5 additions & 11 deletions LiarGame/Application/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,28 +9,22 @@ import UIKit

@main
class AppDelegate: UIResponder, UIApplicationDelegate {



func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
func application(_: UIApplication, didFinishLaunchingWithOptions _: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
return true
true
}

// MARK: UISceneSession Lifecycle

func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration {
func application(_: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options _: UIScene.ConnectionOptions) -> UISceneConfiguration {
// Called when a new scene session is being created.
// Use this method to select a configuration to create the new scene with.
return UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role)
UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role)
}

func application(_ application: UIApplication, didDiscardSceneSessions sceneSessions: Set<UISceneSession>) {
func application(_: UIApplication, didDiscardSceneSessions _: Set<UISceneSession>) {
// Called when the user discards a scene session.
// If any sessions were discarded while the application was not running, this will be called shortly after application:didFinishLaunchingWithOptions.
// Use this method to release any resources that were specific to the discarded scenes, as they will not return.
}


}

20 changes: 7 additions & 13 deletions LiarGame/Application/SceneDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,51 +8,45 @@
import UIKit

class SceneDelegate: UIResponder, UIWindowSceneDelegate {

var window: UIWindow?


func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
func scene(_ scene: UIScene, willConnectTo _: UISceneSession, options _: UIScene.ConnectionOptions) {
// Use this method to optionally configure and attach the UIWindow `window` to the provided UIWindowScene `scene`.
// If using a storyboard, the `window` property will automatically be initialized and attached to the scene.
// This delegate does not imply the connecting scene or session are new (see `application:configurationForConnectingSceneSession` instead).
guard let windowScene = (scene as? UIWindowScene) else { return }

window = UIWindow(windowScene: windowScene) // SceneDelegate의 프로퍼티에 설정해줌
let mainViewController = SplashViewController() // 맨 처음 보여줄 ViewController
window?.rootViewController = mainViewController
window?.makeKeyAndVisible()

}

func sceneDidDisconnect(_ scene: UIScene) {
func sceneDidDisconnect(_: UIScene) {
// Called as the scene is being released by the system.
// This occurs shortly after the scene enters the background, or when its session is discarded.
// Release any resources associated with this scene that can be re-created the next time the scene connects.
// The scene may re-connect later, as its session was not necessarily discarded (see `application:didDiscardSceneSessions` instead).
}

func sceneDidBecomeActive(_ scene: UIScene) {
func sceneDidBecomeActive(_: UIScene) {
// Called when the scene has moved from an inactive state to an active state.
// Use this method to restart any tasks that were paused (or not yet started) when the scene was inactive.
}

func sceneWillResignActive(_ scene: UIScene) {
func sceneWillResignActive(_: UIScene) {
// Called when the scene will move from an active state to an inactive state.
// This may occur due to temporary interruptions (ex. an incoming phone call).
}

func sceneWillEnterForeground(_ scene: UIScene) {
func sceneWillEnterForeground(_: UIScene) {
// Called as the scene transitions from the background to the foreground.
// Use this method to undo the changes made on entering the background.
}

func sceneDidEnterBackground(_ scene: UIScene) {
func sceneDidEnterBackground(_: UIScene) {
// Called as the scene transitions from the foreground to the background.
// Use this method to save data, release shared resources, and store enough scene-specific state information
// to restore the scene back to its current state.
}


}

3 changes: 1 addition & 2 deletions LiarGame/Sources/Model/LiarGameModeModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@

import Foundation


enum LiarGameMode{
enum LiarGameMode {
case normal
case stupid
}
56 changes: 28 additions & 28 deletions LiarGame/Sources/Model/Music.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,32 +7,32 @@

import Foundation

struct Music: Codable {
let title: String
let artist: String
/// youtube video ID
let id: String
let startedAt: String

/** Music 생성자

들어오는 배열의 구조:
[title, artist,id, startedAt]

- title: 노래 제목
- artist: 가수
- id: 유튜브 동영상 id
- startedAt: 첫 재생 시각

길이가 맞지 않을 경우 `return nil`
*/
init?(from array: [String]) {
guard array.count == 4 else { return nil }

self.title = array[0]
self.artist = array[1]
self.id = array[2]
self.startedAt = array[3]
}
}
struct Music: Codable, Equatable {
let title: String
let artist: String
/// youtube video ID
let id: String
let startedAt: Float

/** Music 생성자

들어오는 배열의 구조:
[title, artist,id, startedAt]

- title: 노래 제목
- artist: 가수
- id: 유튜브 동영상 id
- startedAt: 첫 재생 시각

길이가 맞지 않을 경우 `return nil`
*/
init?(from array: [String]) {
guard array.count == 4,
let startedAt = Float(array[3]) else { return nil }

title = array[0]
artist = array[1]
id = array[2]
self.startedAt = startedAt
}
}
5 changes: 1 addition & 4 deletions LiarGame/Sources/Model/MusicSheetDTO.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,8 @@
import Foundation

// MARK: - MusicSheetDTO

struct MusicSheetDTO: Decodable {
let range, majorDimension: String
let values: [[String]]
}




32 changes: 18 additions & 14 deletions LiarGame/Sources/Reactor/HomeReactor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,38 +7,42 @@

import Foundation
import ReactorKit
import RxSwift
import RxCocoa
import RxSwift


final class HomeReactor: Reactor{
enum Action{
case updateMode(String?)
final class HomeReactor: Reactor {
enum Action {
case updateMode(GameMode)
}
enum Mutation{
case setMode(String?)

enum Mutation {
case setMode(GameMode)
}
struct State{
var mode: String?

struct State {
var mode: GameMode?
}

let initialState = State()



enum GameMode {
case liarGame
case randomMusicQuiz
}

func mutate(action: Action) -> Observable<Mutation> {
switch action {
case let .updateMode(mode):
return Observable.just(Mutation.setMode(mode))
}
}

func reduce(state: State, mutation: Mutation) -> State {
switch mutation {
case let .setMode(mode):
var newState = state
newState.mode = mode
return newState

}
}
}
23 changes: 11 additions & 12 deletions LiarGame/Sources/Reactor/LiarGameModeReactor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,31 +7,31 @@

import Foundation
import ReactorKit
import RxSwift
import RxCocoa
import RxSwift

final class LiarGameModeReactor: Reactor{
enum Action{
final class LiarGameModeReactor: Reactor {
enum Action {
case selectMode(LiarGameMode?)
}
enum Mutation{

enum Mutation {
case setMode(LiarGameMode?)
}
struct State{

struct State {
var mode: LiarGameMode?
}
let initialState: State = State()


let initialState: State = .init()

func mutate(action: Action) -> Observable<Mutation> {
switch action {
case let .selectMode(mode):
return Observable.just(Mutation.setMode(mode))
}
}

func reduce(state: State, mutation: Mutation) -> State {
switch mutation {
case let .setMode(mode):
Expand All @@ -40,5 +40,4 @@ final class LiarGameModeReactor: Reactor{
return newState
}
}

}
Loading