-
Notifications
You must be signed in to change notification settings - Fork 1
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
LiarGame Subject Select View & LiarGame View early Setup #12
Merged
Merged
Changes from 3 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,16 @@ | ||
// | ||
// LiarSubjectModel.swift | ||
// LiarGame | ||
// | ||
// Created by Jay on 2022/04/25. | ||
// | ||
|
||
import Foundation | ||
|
||
enum LiarGameSubject{ | ||
case animal | ||
case exercise | ||
case food | ||
case electronicEquipment | ||
case job | ||
} |
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
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
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
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 |
---|---|---|
|
@@ -6,11 +6,135 @@ | |
// | ||
|
||
import UIKit | ||
import PinLayout | ||
import FlexLayout | ||
import Then | ||
import ReactorKit | ||
|
||
final class LiarGameSubjectViewController: UIViewController{ | ||
final class LiarGameSubjectViewController: UIViewController, View{ | ||
|
||
|
||
|
||
init(reactor: LiarGameSubjectReactor){ | ||
|
||
super.init(nibName: nil, bundle: nil) | ||
self.reactor = reactor | ||
self.view.addSubview(flexLayoutContainer) | ||
|
||
self.flexLayoutContainer.flex.direction(.row).justifyContent(.center).alignItems(.stretch).wrap(.wrap).define{ flex in | ||
flex.addItem(self.animalButton).width(100).height(25).marginTop(100).margin(10) | ||
flex.addItem(self.exerciseButton).width(100).height(25).marginTop(100).margin(10) | ||
flex.addItem(self.foodButton).width(100).height(25).marginTop(100).margin(10) | ||
flex.addItem(self.electronicEquipmentButton).width(100).height(25).marginTop(10).margin(10) | ||
flex.addItem(self.jobButton).width(100).height(25).marginTop(10).margin(10) | ||
} | ||
} | ||
|
||
@available(*, unavailable) | ||
required init?(coder: NSCoder) { fatalError() } | ||
|
||
override func viewDidLayoutSubviews() { | ||
self.flexLayoutContainer.pin.all() | ||
self.flexLayoutContainer.flex.layout() | ||
} | ||
|
||
override func viewDidLoad() { | ||
self.view.backgroundColor = .green | ||
self.setupView() | ||
} | ||
|
||
private let flexLayoutContainer: UIView = UIView() | ||
|
||
|
||
var disposeBag: DisposeBag = DisposeBag() | ||
|
||
private let animalButton: UIButton = UIButton() | ||
private let exerciseButton: UIButton = UIButton() | ||
private let foodButton: UIButton = UIButton() | ||
private let electronicEquipmentButton: UIButton = UIButton() | ||
private let jobButton: UIButton = UIButton() | ||
|
||
|
||
} | ||
extension LiarGameSubjectViewController{ | ||
|
||
func setupView(){ | ||
animalButton.do{ | ||
self.view.addSubview($0) | ||
$0.backgroundColor = .yellow | ||
$0.setTitle("동물", for: .normal) | ||
$0.setTitleColor(.black, for: .normal) | ||
} | ||
exerciseButton.do{ | ||
self.view.addSubview($0) | ||
$0.backgroundColor = .yellow | ||
$0.setTitle("운동", for: .normal) | ||
$0.setTitleColor(.black, for: .normal) | ||
} | ||
foodButton.do{ | ||
self.view.addSubview($0) | ||
$0.backgroundColor = .yellow | ||
$0.setTitle("음식", for: .normal) | ||
$0.setTitleColor(.black, for: .normal) | ||
} | ||
electronicEquipmentButton.do{ | ||
self.view.addSubview($0) | ||
$0.backgroundColor = .yellow | ||
$0.setTitle("전자기기", for: .normal) | ||
$0.setTitleColor(.black, for: .normal) | ||
} | ||
jobButton.do{ | ||
self.view.addSubview($0) | ||
$0.backgroundColor = .yellow | ||
$0.setTitle("직업", for: .normal) | ||
$0.setTitleColor(.black, for: .normal) | ||
2jae6 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
|
||
} | ||
|
||
|
||
} | ||
extension LiarGameSubjectViewController{ | ||
|
||
func bind(reactor: LiarGameSubjectReactor) { | ||
animalButton.rx.tap | ||
.subscribe(onNext:{ | ||
reactor.action.onNext(.selectSubject(.animal)) | ||
}).disposed(by: disposeBag) | ||
|
||
exerciseButton.rx.tap | ||
.subscribe(onNext:{ | ||
reactor.action.onNext(.selectSubject(.exercise)) | ||
}).disposed(by: disposeBag) | ||
|
||
|
||
foodButton.rx.tap | ||
.subscribe(onNext:{ | ||
reactor.action.onNext(.selectSubject(.food)) | ||
}).disposed(by: disposeBag) | ||
|
||
electronicEquipmentButton.rx.tap | ||
.subscribe(onNext:{ | ||
reactor.action.onNext(.selectSubject(.electronicEquipment)) | ||
}).disposed(by: disposeBag) | ||
|
||
jobButton.rx.tap.asDriver() | ||
.drive(onNext:{ | ||
reactor.action.onNext(.selectSubject(.job)) | ||
}).disposed(by: disposeBag) | ||
|
||
reactor.state.map{ $0.selectedSubject } | ||
.compactMap{ $0 } | ||
.distinctUntilChanged() | ||
.withUnretained(self) | ||
.subscribe(onNext:{ `self`, subject in | ||
let liarGameVC = LiarGameViewController(subject: subject ?? .job) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 넵 제거 완료했습니다 :) |
||
liarGameVC.modalPresentationStyle = .fullScreen | ||
self.present(liarGameVC, animated: true, completion: nil) | ||
|
||
}).disposed(by: disposeBag) | ||
|
||
} | ||
|
||
|
||
} |
80 changes: 80 additions & 0 deletions
80
LiarGame/Sources/ViewController/LiarGame/LiarGameViewController.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,80 @@ | ||
// | ||
// LiarGameViewController.swift | ||
// LiarGame | ||
// | ||
// Created by Jay on 2022/04/26. | ||
// | ||
|
||
import UIKit | ||
import Then | ||
import RxSwift | ||
import RxCocoa | ||
import ReactorKit | ||
import PinLayout | ||
import FlexLayout | ||
|
||
final class LiarGameViewController: UIViewController{ | ||
|
||
init(subject: LiarGameSubject){ | ||
self.selectSubject = subject | ||
super.init(nibName: nil, bundle: nil) | ||
flexContainer.flex.define{ flex in | ||
flex.addItem(self.curtainView) | ||
|
||
} | ||
} | ||
|
||
@available(*, unavailable) | ||
required init?(coder: NSCoder) { | ||
fatalError("init(coder:) has not been implemented") | ||
} | ||
|
||
override func viewDidLayoutSubviews() { | ||
self.flexContainer.pin.all() | ||
self.flexContainer.flex.layout() | ||
} | ||
override func viewDidLoad() { | ||
self.view.backgroundColor = .yellow | ||
self.setupView() | ||
} | ||
|
||
private let flexContainer: UIView = UIView() | ||
|
||
private var selectSubject: LiarGameSubject | ||
// 가림막 만들기 가림막은 클릭 시 확인창이 뜸 | ||
private let curtainView: UIView = UIView() | ||
private let curtainLabel: UILabel = UILabel() | ||
private let curtainButton: UIButton = UIButton() | ||
|
||
// 단어 나타나기 화면 만들기 | ||
private let liarView: UIView = UIView() | ||
private let liarLabel: UILabel = UILabel() | ||
private let liarButton: UIButton = UIButton() | ||
|
||
// 게임 시작!!! | ||
private let endView: UIView = UIView() | ||
private let endLabel: UILabel = UILabel() | ||
private let endButton: UIButton = UIButton() | ||
|
||
|
||
} | ||
extension LiarGameViewController{ | ||
|
||
private func setupView(){ | ||
// self.view.addSubview(flexContainer) | ||
|
||
curtainView.do{ | ||
self.view.addSubview($0) | ||
$0.backgroundColor = .yellow | ||
} | ||
|
||
curtainLabel.do{ | ||
self.curtainView.addSubview($0) | ||
$0.backgroundColor = .green | ||
$0.text = "터치해서 가림막을 제거해주세요" | ||
} | ||
curtainButton.do{ | ||
self.curtainView.addSubview($0) | ||
} | ||
} | ||
} |
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 |
---|---|---|
|
@@ -181,4 +181,4 @@ SWIFT_VERSION = 5.0 | |
|
||
TARGETED_DEVICE_FAMILY = 1,2 | ||
|
||
#include "Secret.xcconfig" | ||
#include "Secret.xcconfig" |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
view.addSubview
가 아직 존재합니다 (˃̣̣̣̣︿˂̣̣̣̣ )view hierarchy 를 보면
flexLayoutContainer
에서addItem
이 호출될때추가된걸 확인할 수 있습니다 :]
신기하게 충돌은 안나네요 🦀
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
네 확인했습니다.
![스크린샷 2022-04-26 오후 6 33 42](https://user-images.githubusercontent.com/47078140/165270248-120b4ecf-3c81-4395-928a-8379aac70e42.png)
self.view.addSubview($0)
self.view.addSubview($0)
self.view.addSubview($0)
같은 요소 여러개 추가하는걸로 제가 테스트 해봤는데 동일 인스턴스는 아무리 추가해도 하나밖에 안되도록 애플에서 그렇게 만들었나보네요
수정 완료했습니다!