Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Poppool/Poppool.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -3651,7 +3651,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 1.0.1;
MARKETING_VERSION = 1.0.2;
PRODUCT_BUNDLE_IDENTIFIER = com.poppoolIOS.poppool;
PRODUCT_NAME = "$(TARGET_NAME)";
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator";
Expand Down Expand Up @@ -3686,7 +3686,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 1.0.1;
MARKETING_VERSION = 1.0.2;
PRODUCT_BUNDLE_IDENTIFIER = com.poppoolIOS.poppool;
PRODUCT_NAME = "$(TARGET_NAME)";
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator";
Expand Down
2 changes: 2 additions & 0 deletions Poppool/Poppool/Application/SceneDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate {
var window: UIWindow?

static let appDidBecomeActive = PublishSubject<Void>()
static let appDidDisconnect = PublishSubject<Void>()
private let disposeBag = DisposeBag()

func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
Expand All @@ -99,6 +100,7 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate {
}

func sceneDidDisconnect(_ scene: UIScene) {
SceneDelegate.appDidDisconnect.onNext(())
}

func sceneDidBecomeActive(_ scene: UIScene) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ final class AdminViewController: BaseViewController, View {

// Store list binding
reactor.state.map { $0.storeList }
.map { "총 \($0.count)" }
.map { "총 \($0.count)" }
.bind(to: mainView.popupCountLabel.rx.text)
.disposed(by: disposeBag)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,6 @@ extension CommentListTitleSectionCell: Inputable {
}

func injection(with input: Input) {
countLabel.setLineHeightText(text: "총 \(input.count)", font: .KorFont(style: .regular, size: 13))
countLabel.setLineHeightText(text: "총 \(input.count)", font: .KorFont(style: .regular, size: 13))
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ private extension CommentUserInfoView {
instaCommentButton.snp.makeConstraints { make in
make.top.equalTo(lineView.snp.bottom).offset(16)
make.leading.trailing.equalToSuperview().inset(20)
make.bottom.equalToSuperview()
make.bottom.equalToSuperview().inset(32)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ final class NormalCommentAddController: BaseViewController, View {
// MARK: - Properties
var disposeBag = DisposeBag()

private var keyBoardDisposeBag = DisposeBag()

private var mainView = NormalCommentAddView()

private var sections: [any Sectionable] = []
Expand Down Expand Up @@ -91,22 +93,19 @@ extension NormalCommentAddController {
.skip(1)
.drive(onNext: { [weak self] keyboardHeight in
guard let self = self else { return }

// 키보드 높이만큼 뷰를 이동
if keyboardHeight == 0 {
self.mainView.contentCollectionView.setContentOffset(.init(x: 0, y: 0), animated: true)
UIView.animate(withDuration: 0.3) {
self.view.transform = .identity
self.mainView.transform = .identity
}
self.mainView.contentCollectionView.isScrollEnabled = false

} else {
self.mainView.contentCollectionView.isScrollEnabled = true
UIView.animate(withDuration: 0.3) {
self.view.transform = CGAffineTransform(translationX: 0, y: -(keyboardHeight / 4))
self.mainView.transform = .init(translationX: 0, y: -100)
}
}

})
.disposed(by: disposeBag)
.disposed(by: keyBoardDisposeBag)

mainView.saveButton.rx.tap
.withUnretained(self)
Expand Down Expand Up @@ -179,8 +178,4 @@ extension NormalCommentAddController: UICollectionViewDelegate, UICollectionView
}
view.endEditing(true)
}

func scrollViewDidScroll(_ scrollView: UIScrollView) {
view.endEditing(true)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,10 @@ final class NormalCommentAddReactor: Reactor {
}
}()
private let photoTitleSection = AddCommentTitleSection(inputDataList: [.init(title: "사진 선택")])
private let photoDescriptionSection = AddCommentDescriptionSection(inputDataList: [.init(description: "과 관련있는 사진을 업로드해보세요.")])
private lazy var photoDescriptionSection = AddCommentDescriptionSection(inputDataList: [.init(description: "\(self.popUpName)과 관련있는 사진을 업로드해보세요.")])
private var imageSection = AddCommentImageSection(inputDataList: [.init(isFirstCell: true)])
private let commentTitleSection = AddCommentTitleSection(inputDataList: [.init(title: "코멘트 작성")])
private let commentDescriptionSection = AddCommentDescriptionSection(inputDataList: [.init(description: "방문했던 에 대한 감상평을 작성해주세요.")])
private lazy var commentDescriptionSection = AddCommentDescriptionSection(inputDataList: [.init(description: "방문했던 \(self.popUpName)에 대한 감상평을 작성해주세요.")])
private let commentSection = AddCommentSection(inputDataList: [.init()])
private let spacing25Section = SpacingSection(inputDataList: [.init(spacing: 25)])
private let spacing5Section = SpacingSection(inputDataList: [.init(spacing: 5)])
Expand Down Expand Up @@ -179,7 +179,9 @@ final class NormalCommentAddReactor: Reactor {
spacing5Section,
commentDescriptionSection,
spacing16Section,
commentSection
commentSection,
spacing32Section,
spacing32Section
]
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,12 @@ import UIKit

import SnapKit
import RxSwift
import RxCocoa

final class AddCommentSectionCell: UICollectionViewCell {

// MARK: - Components

var disposeBag = DisposeBag()

let commentTextView: UITextView = {
Expand Down Expand Up @@ -43,6 +44,10 @@ final class AddCommentSectionCell: UICollectionViewCell {
return label
}()

private var isActiveComment: Bool = false

private var commentState: BehaviorRelay<CommentState> = .init(value: .empty)

// MARK: - init

override init(frame: CGRect) {
Expand All @@ -65,38 +70,45 @@ final class AddCommentSectionCell: UICollectionViewCell {
// MARK: - SetUp
private extension AddCommentSectionCell {
func bind() {

commentTextView.rx.didBeginEditing
.withUnretained(self)
.subscribe { (owner, _) in
owner.isActiveComment = true
owner.commentState.accept(owner.checkValidation(text: owner.commentTextView.text))
}
.disposed(by: disposeBag)

commentTextView.rx.didEndEditing
.withUnretained(self)
.subscribe { (owner, _) in
owner.isActiveComment = false
owner.commentState.accept(owner.checkValidation(text: owner.commentTextView.text))
}
.disposed(by: disposeBag)

commentTextView.rx.didChange
.debounce(.milliseconds(5), scheduler: MainScheduler.instance)
.withUnretained(self)
.subscribe { (owner, _) in
owner.commentState.accept(owner.checkValidation(text: owner.commentTextView.text))
}
.disposed(by: disposeBag)

commentState
.withUnretained(self)
.subscribe { (owner, state) in
let text = owner.commentTextView.text ?? ""
switch text.count {
case 0:
owner.countLabel.text = "0 / 500자"
owner.placeHolderLabel.isHidden = false
owner.noticeLabel.isHidden = true
owner.contentView.layer.borderColor = UIColor.g100.cgColor
owner.countLabel.textColor = .g500
owner.commentTextView.textColor = .g1000
case 1...500:
owner.countLabel.text = "\(text.count) / 500자"
owner.placeHolderLabel.isHidden = true
owner.noticeLabel.isHidden = true
owner.contentView.layer.borderColor = UIColor.g100.cgColor
owner.countLabel.textColor = .g500
owner.commentTextView.textColor = .g1000
default:
owner.countLabel.text = "\(text.count) / 500자"
owner.placeHolderLabel.isHidden = true
owner.noticeLabel.isHidden = false
owner.contentView.layer.borderColor = UIColor.re500.cgColor
owner.countLabel.textColor = .re500
owner.commentTextView.textColor = .re500
}
owner.countLabel.text = "\(text.count) / 500자"
owner.placeHolderLabel.isHidden = state.isHiddenPlaceHolder
owner.noticeLabel.isHidden = state.isHiddenNoticeLabel
owner.contentView.layer.borderColor = state.borderColor?.cgColor
owner.countLabel.textColor = state.countLabelColor
owner.commentTextView.textColor = state.textColor
}
.disposed(by: disposeBag)

}

func setUpConstraints() {
contentView.layer.cornerRadius = 4
contentView.clipsToBounds = true
Expand All @@ -123,6 +135,22 @@ private extension AddCommentSectionCell {
make.bottom.equalToSuperview().inset(16)
}
}

func checkValidation(text: String?) -> CommentState {
guard let text = text else { return .empty }
if text.isEmpty {
return isActiveComment ? .emptyActive : .empty
}

switch text.count {
case 1...9:
return isActiveComment ? .shortLengthActive : .shortLength
case 10...500:
return isActiveComment ? .normalActive : .normal
default:
return isActiveComment ? .longLengthActive : .longLength
}
}
}

extension AddCommentSectionCell: Inputable {
Expand All @@ -132,3 +160,70 @@ extension AddCommentSectionCell: Inputable {
func injection(with input: Input) {
}
}

enum CommentState {
case empty
case emptyActive
case shortLength
case shortLengthActive
case longLength
case longLengthActive
case normal
case normalActive

var borderColor: UIColor? {
switch self {
case .shortLength, .longLength, .longLengthActive:
return .re500
default:
return .g100
}
}

var countLabelColor: UIColor? {
switch self {
case .shortLength, .longLength, .longLengthActive:
return .re500
default:
return .g500
}
}

var textColor: UIColor? {
switch self {
case .shortLength, .longLength, .longLengthActive:
return .re500
default:
return .g1000
}
}

var description: String? {
switch self {
case .longLength, .longLengthActive:
return "최대 500자까지 입력해주세요"
case .shortLength:
return "최소 10자 이상 입력해주세요"
default:
return nil
}
}

var isHiddenNoticeLabel: Bool {
switch self {
case .longLength, .longLengthActive, .shortLength:
return false
default:
return true
}
}

var isHiddenPlaceHolder: Bool {
switch self {
case .empty, .emptyActive:
return false
default:
return true
}
}
}
Loading