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
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,16 @@ public final class AppCoordinator: AppCoordinatorProtocol {
// MARK: - Public Methods
public func showMainTab(selectedIndex: Int = 0) {
let tabItems: [TabItem] = [
TabItem(title: "도감", icon: DesignSystemAsset.image(named: "dictionary")),
TabItem(title: "추천", icon: DesignSystemAsset.image(named: "favorite")
),
TabItem(title: "도감", icon: DesignSystemAsset.image(named: "dictionary")),
TabItem(title: "북마크", icon: DesignSystemAsset.image(named: "bookmarkList")),
TabItem(title: "MY", icon: DesignSystemAsset.image(named: "mypage"))
]
let tabBar = BottomTabBarController(
viewControllers: [
recommendationMainFactory.make(),
dictionaryMainViewFactory.make(),
recommendationMainFactory.make(),
bookmarkMainFactory.make(bottomInset: 64),
myPageMainFactory.make()
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,7 @@ public enum FactoryAssembly {
type: SocialLoginUseCase.self
),
userDefaultsRepository: DIContainer.resolve(
type: UserDefaultsRepository.self, name: "authUserDefaultsRepository"
)
type: UserDefaultsRepository.self)
)
}
DIContainer.register(type: DictionaryDetailFactory.self) {
Expand Down Expand Up @@ -184,7 +183,12 @@ public enum FactoryAssembly {
type: DictionaryNotificationFactory.self
),
loginFactory: DIContainer.resolve(type: LoginFactory.self),
fetchProfileUseCase: DIContainer.resolve(
userDefaultsRepository: DIContainer
.resolve(
type: DictionaryUserDefaultsRepository.self
),
fetchProfileUseCase: DIContainer
.resolve(
type: FetchProfileUseCase.self
)
)
Expand Down Expand Up @@ -432,7 +436,7 @@ public enum FactoryAssembly {
DIContainer.register(type: RecommendationMainFactory.self) {
RecommendationMainFactoryImpl(
repository: DIContainer.resolve(type: RecommendationRepository.self),
bookmarkRepository: DIContainer.resolve(type: BookmarkRepository.self),
bookmarkRepository: DIContainer.resolve(type: BookmarkRepository.self), recommendationUserDefaultsRepository: DIContainer.resolve(type: RecommendationUserDefaultsRepository.self),
Comment thread
pinocchio22 marked this conversation as resolved.
makeLoginVC: {
DIContainer.resolve(type: LoginFactory.self).make(exitRoute: .pop)
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@ public enum RepositoryAssembly {
DIContainer.register(type: BookmarkRepository.self) {
BookmarkRepositoryImpl()
}
DIContainer.register(type: MLSAuthFeatureInterface.UserDefaultsRepository.self, name: "authUserDefaultsRepository") {
MLSAuthFeature.UserDefaultsRepositoryImpl()
DIContainer.register(type: UserDefaultsRepository.self) {
UserDefaultsRepositoryImpl()
}
DIContainer.register(type: MLSDictionaryFeatureInterface.UserDefaultsRepository.self, name: "dictionaryUserDefaultsRepository") {
MLSDictionaryFeature.UserDefaultsRepositoryImpl()
DIContainer.register(type: DictionaryUserDefaultsRepository.self) {
UserDefaultsRepositoryImpl()
}
DIContainer.register(type: AlarmRepository.self) {
AlarmRepositoryImpl(
Expand Down Expand Up @@ -87,5 +87,8 @@ public enum RepositoryAssembly {
DIContainer.register(type: UpdateSkipRepositoryProtocol.self) {
UpdateSkipRepository()
}
}
DIContainer.register(type: RecommendationUserDefaultsRepository.self) {
RecommendationUserDefaultsRepositoryImpl()
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,14 @@ public enum UseCaseAssembly {
type: TokenRepository.self
),
userDefaultsRepository: DIContainer.resolve(
type: UserDefaultsRepository.self, name: "authUserDefaultsRepository"
)
type: UserDefaultsRepository.self)
)
}
DIContainer.register(type: SocialSignUpUseCaseImpl.self) {
SocialSignUpUseCaseImpl(
authRepository: DIContainer.resolve(type: AuthAPIRepository.self),
tokenRepository: DIContainer.resolve(type: TokenRepository.self),
userDefaultsRepository: DIContainer.resolve(type: UserDefaultsRepository.self, name: "authUserDefaultsRepository")
userDefaultsRepository: DIContainer.resolve(type: UserDefaultsRepository.self)
)
}
DIContainer.register(type: CheckNotificationPermissionUseCase.self) {
Expand Down Expand Up @@ -71,7 +70,7 @@ public enum UseCaseAssembly {
ParseItemFilterResultUseCaseImpl()
}
DIContainer.register(type: FetchVisitDictionaryDetailUseCase.self) {
FetchVisitDictionaryDetailUseCaseImpl(repository: DIContainer.resolve(type: UserDefaultsRepository.self, name: "dictionaryUserDefaultsRepository"))
FetchVisitDictionaryDetailUseCaseImpl(repository: DIContainer.resolve(type: DictionaryUserDefaultsRepository.self))
}
DIContainer.register(type: SocialSignUpUseCase.self) {
SocialSignUpUseCaseImpl(
Expand All @@ -80,7 +79,7 @@ public enum UseCaseAssembly {
tokenRepository: DIContainer
.resolve(type: TokenRepository.self),
userDefaultsRepository: DIContainer
.resolve(type: UserDefaultsRepository.self, name: "authUserDefaultsRepository")
.resolve(type: UserDefaultsRepository.self)
)
}
DIContainer.register(type: UpdateCheckerUseCaseProtocol.self) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,9 @@ private extension AppLauncher {
object: nil,
queue: .main
) { [weak self] _ in
self?.showForceUpdateAlert()
Task { @MainActor in
self?.showForceUpdateAlert()
}
Comment thread
pinocchio22 marked this conversation as resolved.
}
case .optional(let latestVersion):
GuideAlertFactory.show(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@ public final class BottomTabBarController: UITabBarController {
// MARK: - Type
private enum Constant {
static let horizontalInset: CGFloat = 24
static let commentBottomMargin: CGFloat = -8
static let commentWidth: CGFloat = 152
static let commentHeight: CGFloat = 28
static let buttonSize: CGFloat = 64
static let arrowInset: CGFloat = 16
@MainActor static let spacing: CGFloat = (UIScreen.main.bounds.width - (horizontalInset * 2) - (buttonSize * 4)) / 3
@MainActor static let commentLeadingOffset: CGFloat = horizontalInset + buttonSize + spacing + (buttonSize / 2) - arrowInset
Comment thread
pinocchio22 marked this conversation as resolved.
}

// MARK: - Components
Expand All @@ -17,6 +24,12 @@ public final class BottomTabBarController: UITabBarController {
view.backgroundColor = .systemBackground
return view
}()
private let recommendationCommentView: UIImageView = {
let view = UIImageView()
view.image = DesignSystemAsset.image(named: "recommendationComment")
view.isHidden = true
return view
}()

// MARK: - Init
public init(viewControllers: [UIViewController], tabItems: [TabItem]? = nil, initialIndex: Int = 0) {
Expand Down Expand Up @@ -50,6 +63,7 @@ private extension BottomTabBarController {
view.addSubview(tabBarBackground)
view.addSubview(customTabBar)
view.addSubview(divider)
view.addSubview(recommendationCommentView)
}

func setupConstraints() {
Expand All @@ -67,6 +81,13 @@ private extension BottomTabBarController {
make.horizontalEdges.bottom.equalToSuperview()
make.top.equalTo(divider.snp.top)
}

recommendationCommentView.snp.makeConstraints { make in
make.bottom.equalTo(customTabBar.snp.top).offset(Constant.commentBottomMargin)
make.leading.equalTo(view.snp.leading).offset(Constant.commentLeadingOffset)
make.width.equalTo(Constant.commentWidth)
make.height.equalTo(Constant.commentHeight)
}
}

func configureUI(controllers: [UIViewController]) {
Expand Down Expand Up @@ -132,4 +153,8 @@ public extension BottomTabBarController {
customTabBar.selectTab(index: index)
}
}

func checkRecommendationFirstLaunch(isFirst: Bool) {
recommendationCommentView.isHidden = isFirst
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import SnapKit

public final class Toast: UIView {
private enum Constant {
static let verticalEdgesInset: CGFloat = 16
static let horizontalEdges: CGFloat = 16
static let height: CGFloat = 44
static let cornerRadius: CGFloat = 8
}

Expand Down Expand Up @@ -37,23 +37,24 @@ public final class Toast: UIView {
private extension Toast {
func addViews() {
addSubview(self.toastContentView)
toastContentView.addSubview(self.label)
self.toastContentView.addSubview(self.label)
}

func setupConstraints() {
toastContentView.snp.makeConstraints { make in
self.toastContentView.snp.makeConstraints { make in
make.edges.equalToSuperview()
make.height.equalTo(Constant.height)
}

label.snp.makeConstraints { make in
make.verticalEdges.equalToSuperview().inset(Constant.verticalEdgesInset)
self.label.snp.makeConstraints { make in
make.horizontalEdges.equalToSuperview().inset(Constant.horizontalEdges)
make.centerY.equalToSuperview()
}
Comment thread
pinocchio22 marked this conversation as resolved.
}

func configureUI(message: String?) {
layer.cornerRadius = Constant.cornerRadius
clipsToBounds = true
label.attributedText = .makeStyledString(font: .b_s_r, text: message, color: .whiteMLS)
self.label.attributedText = .makeStyledString(font: .b_s_r, text: message, color: .whiteMLS)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@ public enum GuideAlertFactory {
ctaText: String,
cancelText: String? = nil,
ctaAction: @escaping () -> Void,
cancelAction: (() -> Void)? = nil
cancelAction: (() -> Void)? = nil,
ctaRatio: Double = 0.7
) {
let alert = GuideAlert(mainText: mainText, ctaText: ctaText, cancelText: cancelText)
let alert = GuideAlert(mainText: mainText, ctaText: ctaText, cancelText: cancelText, ctaRatio: ctaRatio)
presentAlert(alert: alert, ctaAction: ctaAction, cancelAction: cancelAction)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,18 @@ public final class ToLoginView: UIView {

// MARK: - Components
public let imageView = UIImageView()
private let mainLabel = UILabel()
private let subLabel = UILabel()

private let mainLabel: UILabel = {
let label = UILabel()
label.numberOfLines = 0
return label
}()

private let subLabel: UILabel = {
let label = UILabel()
label.numberOfLines = 0
return label
}()

public let button = CommonButton()

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"images" : [
{
"filename" : "recommendationComment.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"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.
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ import MLSDictionaryFeatureInterface

import RxSwift

public final class UserDefaultsRepositoryImpl: UserDefaultsRepository {
public final class UserDefaultsRepositoryImpl: DictionaryUserDefaultsRepository {
private let dictionaryDetailkey = "dictionaryDetailkey"
private let recommendationkey = "recommendationkey"

public init() {}

Expand All @@ -25,4 +26,9 @@ public final class UserDefaultsRepositoryImpl: UserDefaultsRepository {
return Disposables.create()
}
}

public func checkFirstLaunchRecommendation() -> Observable<Bool> {
let hasVisited = UserDefaults.standard.bool(forKey: recommendationkey)
return .just(hasVisited)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import MLSDictionaryFeatureInterface
import RxSwift

public class FetchVisitDictionaryDetailUseCaseImpl: FetchVisitDictionaryDetailUseCase {
private let repository: UserDefaultsRepository
public init(repository: UserDefaultsRepository) {
private let repository: DictionaryUserDefaultsRepository
public init(repository: DictionaryUserDefaultsRepository) {
self.repository = repository
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public final class DictionaryMainReactor: Reactor {
case navigateTo(Route)
case setLogin(Bool)
case setCurrentTab(oldIndex: Int, newIndex: Int)
case setIsFirstRecommendationLaunch(Bool)
}

public struct State {
Expand All @@ -31,30 +32,43 @@ public final class DictionaryMainReactor: Reactor {
var sections: [String] {
return type.pageTabList.map { $0.title }
}

var isLogin = false
var currentPageIndex = 0
var oldPageIndex = 0
var isFirstRecommendationLaunch = false
}

// MARK: - properties
public var initialState: State
var disposeBag = DisposeBag()

private let userDefaultsRepository: DictionaryUserDefaultsRepository
private let fetchProfileUseCase: FetchProfileUseCase

// MARK: - init
public init(fetchProfileUseCase: FetchProfileUseCase) {
public init(userDefaultsRepository: DictionaryUserDefaultsRepository, fetchProfileUseCase: FetchProfileUseCase) {
self.initialState = State()
self.userDefaultsRepository = userDefaultsRepository
self.fetchProfileUseCase = fetchProfileUseCase
}

// MARK: - Reactor Methods
public func mutate(action: Action) -> Observable<Mutation> {
switch action {
case .viewWillAppear:
return fetchProfileUseCase.execute()
.map { .setLogin($0 != nil) }
let firstRecommendation = userDefaultsRepository
.checkFirstLaunchRecommendation()
.map(Mutation.setIsFirstRecommendationLaunch)

let fetchProfile = fetchProfileUseCase.execute()
.map { Mutation.setLogin($0 != nil) }
.catchAndReturn(.setLogin(false))

return Observable.merge(
firstRecommendation,
fetchProfile
)
case .searchButtonTapped:
return .just(.navigateTo(.search))
case .notificationButtonTapped:
Expand All @@ -69,13 +83,15 @@ public final class DictionaryMainReactor: Reactor {
var newState = state

switch mutation {
case .navigateTo(let route):
case let .navigateTo(route):
newState.route = route
case let .setLogin(isLogin):
newState.isLogin = isLogin
case let .setCurrentTab(oldIndex, newIndex):
newState.oldPageIndex = oldIndex
newState.currentPageIndex = newIndex
case let .setIsFirstRecommendationLaunch(isFirst):
newState.isFirstRecommendationLaunch = isFirst
}

return newState
Expand Down
Loading
Loading