Skip to content

Commit

Permalink
♻️ :: 스플래쉬 코드 리팩토링
Browse files Browse the repository at this point in the history
  • Loading branch information
KangTaeHoon committed Oct 26, 2024
1 parent a246de7 commit 731f546
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,10 @@ private extension IntroViewController {
.subscribe(onNext: { owner, result in
switch result {
case let .success(entity):
owner.lottiePlay(isSpecialLogo: entity.isSpecialLogo)
let type: SplashLogoType = owner.fetchSplashLogoType(isSpecialLogo: entity.isSpecialLogo)
owner.changeAppIcon(type: type)
owner.changeBackgroundColor(type: type)
owner.playLottie(type: type)

var textPopupVc: UIViewController
let updateTitle: String = "왁타버스 뮤직이 업데이트 되었습니다."
Expand Down Expand Up @@ -154,7 +157,7 @@ private extension IntroViewController {
)

case let .failure(error):
owner.lottiePlay(isSpecialLogo: false)
owner.playLottie(type: .usual)
owner.showBottomSheet(
content: owner.textPopupFactory.makeView(
text: error.asWMError.errorDescription ?? "",
Expand Down Expand Up @@ -208,14 +211,6 @@ private extension IntroViewController {
}

private extension IntroViewController {
func changeAppIcon(_ type: SplashLogoType) {
guard UIApplication.shared.alternateIconName != type.icon else {
return
}

UIApplication.shared.setAlternateIconName(type.icon)
}

func configureUI() {
navigationController?.setNavigationBarHidden(true, animated: false)
view.addSubview(parableLogoImageView)
Expand All @@ -230,7 +225,7 @@ private extension IntroViewController {
self.navigationController?.pushViewController(viewController, animated: false)
}

func lottiePlay(isSpecialLogo: Bool) {
func fetchSplashLogoType(isSpecialLogo: Bool) -> SplashLogoType {
var logoType: SplashLogoType

if isSpecialLogo {
Expand All @@ -246,11 +241,31 @@ private extension IntroViewController {
logoType = .usual
}

changeAppIcon(logoType)
self.view.backgroundColor = logoType == .halloween ? colorFromRGB(0x191A1C) : .white
return logoType
}

func changeAppIcon(type: SplashLogoType) {
guard UIApplication.shared.alternateIconName != type.toAppIcon else {
return
}

UIApplication.shared.setAlternateIconName(type.toAppIcon)
}

func changeBackgroundColor(type: SplashLogoType) {
switch type {
case .usual:
self.view.backgroundColor = .white
case .halloween:
self.view.backgroundColor = colorFromRGB(0x191A1C)
case .xmas:
self.view.backgroundColor = .white
}
}

func playLottie(type: SplashLogoType) {
let animationView = LottieAnimationView(
name: logoType.rawValue,
name: type.rawValue,
bundle: DesignSystemResources.bundle
)
animationView.frame = self.logoContentView.bounds
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ enum SplashLogoType: String {
case halloween = "Splash_Logo_Halloween"
case xmas = "Splash_Logo_Xmas"

var icon: String? {
var toAppIcon: String? {
switch self {
case .usual:
return nil
Expand Down

0 comments on commit 731f546

Please sign in to comment.