Skip to content

Commit

Permalink
feat(NewAnnouncement): Handle empty organizations
Browse files Browse the repository at this point in the history
dodo849 committed Aug 25, 2024
1 parent 2bee2e9 commit fdec9d1
Showing 4 changed files with 75 additions and 29 deletions.
Original file line number Diff line number Diff line change
@@ -15,12 +15,14 @@ import Router
import ReactorKit
import ProgressHUD

// FIXME: 여기는 증맬루 심각합니다...
class NewAnnouncementFunnelReactor: Reactor {
// MARK: Action
enum Action {
case viewDidLoad
case moveNextPage
case movePreviousPage
case toggleisOpenHasLeaderRoleOrganizationDialog
}

enum Mutation {
@@ -32,7 +34,7 @@ class NewAnnouncementFunnelReactor: Reactor {
struct State {
var currentPage: NewAnnouncementFunnelPage = .selectOrganization

// - View TODO: ㅠㅠ 어떻게하지 변수명 머선일
// - View TODO: ㅠㅠ 어떡하지 변수명 머선일
var isOpenHasLeaderRoleOrganizationDialog: Bool = false
}

@@ -86,11 +88,12 @@ class NewAnnouncementFunnelReactor: Reactor {
case .viewDidLoad:
ProgressHUD.animate(nil, .horizontalDotScaling, interaction: false)

// TODO: 리더롤인지 확인하고 넣어야함
// TODO: 리더롤인지 확인하는 절차 필요
let leaderRoleObservable = getJoinedOrganizationsUsecase
.execute(.init())
.compactMap {
$0.organizations.isEmpty ? nil : ()
ProgressHUD.dismiss()
return $0.organizations.isEmpty ? () : nil
}
.map {
return Mutation.toggleisOpenHasLeaderRoleOrganizationDialog
@@ -105,6 +108,9 @@ class NewAnnouncementFunnelReactor: Reactor {
case .movePreviousPage:
let previousPage = previousPage(before: currentState.currentPage)
return Observable.just(.setCurrentPage(previousPage))

case .toggleisOpenHasLeaderRoleOrganizationDialog:
return .just(.toggleisOpenHasLeaderRoleOrganizationDialog)
}
}

Original file line number Diff line number Diff line change
@@ -36,14 +36,33 @@ public class NewAnnouncementFunnelView: BaseView {
contentsBuilder: {
[
UILabel().then {
$0.text = "참여한 그룹이 없어요"
}
$0.text = "참여한 그룹이 없습니다!"
$0.setTypo(.body2b)
},
goHomeButton
]
}
).then {
$0.styled()
}

lazy var goHomeButton = BaseButton(
contentsBuilder: {
[
UILabel().then {
$0.text = "홈으로 돌아가기"
$0.setTypo(.body1b)
}
]
}
).then {
$0.styled(
variant: .fill,
color: .ghost,
size: .medium
)
}

// MARK: Setup
public override func setupHierarchy() {
addSubview(navigationBar)
Original file line number Diff line number Diff line change
@@ -20,8 +20,24 @@ public class NewAnnouncementFunnelViewController: BaseViewController<NewAnnounce
// MARK: Reactor
private let reactor = Container.shared.resolve(NewAnnouncementFunnelReactor.self)!

// MARK: Life cycle
public override func viewDidLoad() {
super.viewDidLoad()

reactor.action.onNext(.viewDidLoad)
}

// MARK: Setup
public override func setupViewBind() { }
public override func setupViewBind() {
baseView.goHomeButton
.onTap
.subscribe(with: self, onNext: { owner, _ in
owner.reactor.action.onNext(.toggleisOpenHasLeaderRoleOrganizationDialog)

Router.shared.dismiss()
})
.disposed(by: disposeBag)
}

public override func setupStateBind() {
reactor.state.map { $0.currentPage }
@@ -32,6 +48,7 @@ public class NewAnnouncementFunnelViewController: BaseViewController<NewAnnounce
.disposed(by: self.disposeBag)

reactor.state.map { $0.isOpenHasLeaderRoleOrganizationDialog }
.skip(1)
.withUnretained(self.baseView)
.subscribe(onNext: { owner, isOpen in
if isOpen {
Original file line number Diff line number Diff line change
@@ -14,7 +14,7 @@ import SnapKit
/// Extension for set theme
public extension BaseDialog {
func styled(
variant: BasicDialogVariant = .shadow,
variant: BasicDialogVariant = .overlay,
shape: BasicDialogShape = .round
) {
let colorTheme = BasicDialogColorTheme(variant: variant)
@@ -28,29 +28,33 @@ public extension BaseDialog {
/// Extension for open and close dialog
public extension BaseDialog {
func open() {
guard let windowScene = UIApplication.shared.connectedScenes.first as? UIWindowScene
else { return }
guard let window = windowScene.windows.first
else { return }

if window.subviews.contains(self) {
DispatchQueue.main.async { [weak self] in
guard let self = self else { return }

guard let windowScene = UIApplication.shared.connectedScenes.first as? UIWindowScene
else { return }
guard let window = windowScene.windows.first
else { return }

if window.subviews.contains(self) {
self.isHidden = false
}

// Add overlayView to UIWindow
window.addSubview(self)
self.snp.makeConstraints { make in
make.edges.equalTo(window)
}

let duration = 0.3
self.isHidden = false
}

// Add overlayView to UIWindow
window.addSubview(self)
self.snp.makeConstraints { make in
make.edges.equalTo(window)
}

let duration = 0.3
self.isHidden = false
self.overlayView.alpha = 0
self.backgroundView.alpha = 0

UIView.animate(withDuration: duration) {
self.overlayView.alpha = 1
self.backgroundView.alpha = 1
self.overlayView.alpha = 0
self.backgroundView.alpha = 0

UIView.animate(withDuration: duration) {
self.overlayView.alpha = 1
self.backgroundView.alpha = 1
}
}
}

0 comments on commit fdec9d1

Please sign in to comment.