Skip to content

Commit

Permalink
✨ :: [#130] InputDialogFeature / InputType DotoriRoutePath를 위해 공개로 전환
Browse files Browse the repository at this point in the history
  • Loading branch information
baekteun committed Jul 30, 2023
1 parent fe4564e commit 605f5d2
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 10 deletions.
9 changes: 9 additions & 0 deletions Projects/Feature/BaseFeature/Interface/DialogInputType.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import Foundation

/**
*/
public enum DialogInputType {
case number
case text
}
7 changes: 7 additions & 0 deletions Projects/Feature/BaseFeature/Sources/DotoriRoutePath.swift
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import BaseFeatureInterface
import Moordinator
import UIKit

Expand All @@ -14,6 +15,12 @@ public enum DotoriRoutePath: RoutePath {
message: String = "",
confirmAction: () async -> Void
)
case inputDialog(
title: String,
placeholder: String,
inputType: DialogInputType,
confirmAction: (String) async -> Void
)
case dismiss
case pop

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ public protocol InputDialogFactory {
func makeViewController(
title: String,
placeholder: String,
inputType: InputType,
inputType: DialogInputType,
confirmAction: @escaping (String) async -> Void
) -> any RoutedViewControllable
}
4 changes: 0 additions & 4 deletions Projects/Feature/InputDialogFeature/Interface/InputType.swift

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,13 @@ final class InputDialogFactoryImpl: InputDialogFactory {
func makeViewController(
title: String,
placeholder: String,
inputType: InputType,
inputType: DialogInputType,
confirmAction: @escaping (String) async -> Void
) -> any RoutedViewControllable {
let store = InputDialogStore(confirmAction: confirmAction)
let store = InputDialogStore(
inputType: inputType,
confirmAction: confirmAction
)
return InputDialogViewController(title: title, placeholder: placeholder, store: store)
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import BaseFeature
import BaseFeatureInterface
import Combine
import InputDialogFeatureInterface
import Moordinator
Expand All @@ -12,7 +13,7 @@ final class InputDialogStore: BaseStore {
private let confirmAction: (String) async -> Void

init(
inputType: InputType,
inputType: DialogInputType,
confirmAction: @escaping (String) async -> Void
) {
self.initialState = .init(inputType: inputType)
Expand All @@ -21,7 +22,7 @@ final class InputDialogStore: BaseStore {
}

struct State {
var inputType: InputType
var inputType: DialogInputType
var inputText = ""
var isLoading = false
}
Expand All @@ -41,7 +42,7 @@ extension InputDialogStore {
func mutate(state: State, action: Action) -> SideEffect<Mutation, Never> {
switch action {
case let .updateInputText(inputText):
return .just(.updateInputText(inputText))
return self.updateInputText(inputText: inputText)

case .dimmedBackgroundViewDidTap, .cancelButtonDidTap:
route.send(DotoriRoutePath.dismiss)
Expand Down Expand Up @@ -78,3 +79,10 @@ extension InputDialogStore {
return newState
}
}

// MARK: - Mutate
private extension InputDialogStore {
func updateInputText(inputText: String) -> SideEffect<Mutation, Never> {
return .just(.updateInputText(inputText))
}
}

0 comments on commit 605f5d2

Please sign in to comment.