Skip to content

Commit

Permalink
[Feat] sopt-makers#151 - 비회원일 때 메인뷰의 버튼 액션 처리
Browse files Browse the repository at this point in the history
  • Loading branch information
lsj8706 committed Apr 15, 2023
1 parent 87a5901 commit 6a55075
Show file tree
Hide file tree
Showing 10 changed files with 75 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import Combine
import SnapKit
import Then

import AuthFeatureInterface
import MainFeatureInterface
import StampFeatureInterface
import SettingFeatureInterface
Expand All @@ -24,7 +25,7 @@ public class MainVC: UIViewController, MainViewControllable {
// MARK: - Properties

public var viewModel: MainViewModel!
public var factory: (StampFeatureViewBuildable & SettingFeatureViewBuildable)!
public var factory: (AuthFeatureViewBuildable & StampFeatureViewBuildable & SettingFeatureViewBuildable)!
private var cancelBag = CancelBag()

// MARK: - UI Components
Expand Down Expand Up @@ -60,6 +61,10 @@ extension MainVC {
private func setUI() {
self.navigationController?.isNavigationBarHidden = true
view.backgroundColor = DSKitAsset.Colors.black100.color

if viewModel.userType == .visitor {
self.naviBar.setRightButtonImage(image: DSKitAsset.Assets.btnLogout.image)
}
}

private func setLayout() {
Expand All @@ -86,9 +91,13 @@ extension MainVC {

private func bindViews() {
// FIXME: - 디버깅을 위한 임시 바인딩
naviBar.myPageButton.publisher(for: .touchUpInside)
naviBar.rightButton.publisher(for: .touchUpInside)
.withUnretained(self)
.sink { owner, _ in
if owner.viewModel.userType == .visitor {
owner.setRootViewToSignIn()
return
}
owner.pushSettingFeature()
}.store(in: self.cancelBag)
}
Expand Down Expand Up @@ -120,6 +129,11 @@ extension MainVC {
let vc = factory.makeSettingVC().viewController
navigationController?.pushViewController(vc, animated: true)
}

private func setRootViewToSignIn() {
let navigation = UINavigationController(rootViewController: factory.makeSignInVC().viewController)
ViewControllerUtils.setRootViewController(window: self.view.window!, viewController: navigation, withAnimation: true)
}
}

// MARK: - UICollectionViewDelegate
Expand All @@ -128,6 +142,7 @@ extension MainVC: UICollectionViewDelegate {
public func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
// TODO: - 디버깅을 위한 임시 솝탬프 피쳐 연결
if indexPath.section == 3 {
guard viewModel.userType != .visitor else { return }
pushSoptampFeature()
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ final class MainNavigationBar: UIView {
$0.setImage(DSKitAsset.Assets.btnNotice.image, for: .normal)
}

public let myPageButton = UIButton(type: .custom).then {
public let rightButton = UIButton(type: .custom).then {
$0.setImage(DSKitAsset.Assets.btnMypage.image, for: .normal)
$0.layer.cornerRadius = 22
$0.backgroundColor = DSKitAsset.Colors.black60.color
}

private lazy var rightItemsStackView = UIStackView(arrangedSubviews: [noticeButton, myPageButton]).then {
private lazy var rightItemsStackView = UIStackView(arrangedSubviews: [noticeButton, rightButton]).then {
$0.axis = .horizontal
$0.spacing = 4
$0.distribution = .fillEqually
Expand All @@ -49,6 +49,16 @@ final class MainNavigationBar: UIView {
}
}

// MARK: - Methods

extension MainNavigationBar {
@discardableResult
public func setRightButtonImage(image: UIImage) -> Self {
self.rightButton.setImage(image, for: .normal)
return self
}
}

// MARK: - UI & Layout

extension MainNavigationBar {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"images" : [
{
"filename" : "btn_arrow_left.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "btn_arrow_left@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "btn_arrow_left@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"images" : [
{
"filename" : "btn_logout.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "btn_logout@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "btn_logout@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 6a55075

Please sign in to comment.