Skip to content

Commit

Permalink
[#49] 온보딩 편지 UI
Browse files Browse the repository at this point in the history
[#49] 온보딩 편지 UI
  • Loading branch information
cchanmi authored Jul 16, 2022
2 parents 51684e8 + 5bf458a commit 0f17137
Show file tree
Hide file tree
Showing 6 changed files with 426 additions and 97 deletions.
4 changes: 4 additions & 0 deletions Deartoday/Deartoday.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
objects = {

/* Begin PBXBuildFile section */
4A44EEFB28807DC00062420E /* PlayTapeOnboardingViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4A44EEFA28807DC00062420E /* PlayTapeOnboardingViewController.swift */; };
4A45D37E287F0B2F00592749 /* OpenBoxOnboardingViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4A45D37D287F0B2F00592749 /* OpenBoxOnboardingViewController.swift */; };
4A45D380287F2BF800592749 /* LetterOnboardingViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4A45D37F287F2BF800592749 /* LetterOnboardingViewController.swift */; };
4A706264287C079F00140315 /* Onboarding.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 4A706263287C079F00140315 /* Onboarding.storyboard */; };
Expand Down Expand Up @@ -87,6 +88,7 @@
/* End PBXBuildFile section */

/* Begin PBXFileReference section */
4A44EEFA28807DC00062420E /* PlayTapeOnboardingViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PlayTapeOnboardingViewController.swift; sourceTree = "<group>"; };
4A45D37D287F0B2F00592749 /* OpenBoxOnboardingViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OpenBoxOnboardingViewController.swift; sourceTree = "<group>"; };
4A45D37F287F2BF800592749 /* LetterOnboardingViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LetterOnboardingViewController.swift; sourceTree = "<group>"; };
4A706263287C079F00140315 /* Onboarding.storyboard */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; path = Onboarding.storyboard; sourceTree = "<group>"; };
Expand Down Expand Up @@ -472,6 +474,7 @@
92DB35652875652F001E2006 /* OnboardingViewController.swift */,
4A45D37D287F0B2F00592749 /* OpenBoxOnboardingViewController.swift */,
4A45D37F287F2BF800592749 /* LetterOnboardingViewController.swift */,
4A44EEFA28807DC00062420E /* PlayTapeOnboardingViewController.swift */,
);
path = Controller;
sourceTree = "<group>";
Expand Down Expand Up @@ -879,6 +882,7 @@
92DB356E287565AC001E2006 /* UIScreen+.swift in Sources */,
98B4B5AA287EB54600F4AD7A /* ViewController.swift in Sources */,
98D912D2287DC3590088A7F9 /* CheckMessageDataModel.swift in Sources */,
4A44EEFB28807DC00062420E /* PlayTapeOnboardingViewController.swift in Sources */,
92DB358A28756B8E001E2006 /* TempAPI.swift in Sources */,
98D912A5287D3B0D0088A7F9 /* DeartodayAlertViewController.swift in Sources */,
92DB356A28756577001E2006 /* DDSTextField.swift in Sources */,
Expand Down
1 change: 1 addition & 0 deletions Deartoday/Deartoday/Global/Constant/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ extension Constant {
static let Onboarding = "OnboardingViewController"
static let OpenBoxOnboarding = "OpenBoxOnboardingViewController"
static let LetterOnboarding = "LetterOnboardingViewController"
static let PlayTapeOnboarding = "PlayTapeOnboardingViewController"

///메인
static let Main = "MainViewController"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,26 @@ import UIKit

final class LetterOnboardingViewController: UIViewController {

// MARK: - Property

var letterNumber: Int?
var nextButtonNumber: Int = 0

// MARK: - UI Property

@IBOutlet weak var dearLabel: UILabel!
@IBOutlet weak var checkPlayerButton: UIButton!
@IBOutlet var letterLabelCollection: [UILabel]!
@IBOutlet var nextButtonCollection: [UIButton]!
@IBOutlet weak var letterTopConstraint: NSLayoutConstraint!
@IBOutlet weak var dearLabelTopConstraint: NSLayoutConstraint!

// MARK: - Life Cycle

override func viewDidLoad() {
super.viewDidLoad()
setInitAnimation()
setLabelUI()
setLayout()
setAnimation()
}

// MARK: - Custom Method
Expand All @@ -33,24 +38,77 @@ final class LetterOnboardingViewController: UIViewController {
$0.font = .p4
$0.textColor = .darkGray01
}
nextButtonCollection.forEach {
$0.titleLabel?.font = .btn0
$0.setTitleColor(.blue02, for: .normal)
}
dearLabel.font = .p5En
dearLabel.textColor = .blue02
checkPlayerButton.titleLabel?.font = .btn0
checkPlayerButton.setTitleColor(.blue02, for: .normal)
}

private func setInitAnimation() {
private func setLayout() {
letterTopConstraint.constant = (getDeviceHeight() == 667) ? 100 : 160
dearLabelTopConstraint.constant = (getDeviceHeight() == 667) ? -58 : -64
}

private func setAnimation() {
if letterNumber == 1 {
setFirstInitAnimation()
} else if letterNumber == 2 {
setSecondInitAnimation()
} else if letterNumber == 4 {
print("네번째 온보딩 편지")
}
}

private func setFirstInitAnimation() {
DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) {
self.setComponentsAnimation()
self.setFirstComponentsAnimation()
}
}

private func setLayout() {
letterTopConstraint.constant = (getDeviceHeight() == 667) ? 100 : 160
dearLabelTopConstraint.constant = (getDeviceHeight() == 667) ? -58 : -64
private func setSecondInitAnimation() {
DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) {
self.setSecondComponentsAnimation()
}
}

private func setThirdInitAnimation() {
DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) {
self.setThirdComponentsAnimation()
}
}

private func setComponentsAnimation() {
// MARK: - IBAction

@IBAction func checkPlayerButtonDidTap(_ sender: UIButton) {
guard let playTapeOnboarding = UIStoryboard(name: Constant.Storyboard.Onboarding, bundle: nil).instantiateViewController(withIdentifier: Constant.ViewController.PlayTapeOnboarding) as? PlayTapeOnboardingViewController else { return }
playTapeOnboarding.modalTransitionStyle = .crossDissolve
playTapeOnboarding.modalPresentationStyle = .fullScreen
present(playTapeOnboarding, animated: true)
}

@IBAction func nextButtonDidTap(_ sender: UIButton) {
nextButtonNumber += 1

if nextButtonNumber == 1 {
letterLabelCollection[5...6].forEach {
$0.alpha = 0
}
nextButtonCollection[1].alpha = 0
setThirdInitAnimation()
} else {
guard let playTapeOnboarding = UIStoryboard(name: Constant.Storyboard.Onboarding, bundle: nil).instantiateViewController(withIdentifier: Constant.ViewController.PlayTapeOnboarding) as? PlayTapeOnboardingViewController else { return }
playTapeOnboarding.modalTransitionStyle = .crossDissolve
playTapeOnboarding.modalPresentationStyle = .fullScreen
playTapeOnboarding.playTapeNumber = 1
present(playTapeOnboarding, animated: true)
}
}

// MARK: - Animation function

private func setFirstComponentsAnimation() {
UIView.animate(withDuration: 0.6, animations: {
self.dearLabel.alpha = 1
self.letterLabelCollection[0].alpha = 1 }, completion: { _ in
Expand All @@ -67,12 +125,48 @@ final class LetterOnboardingViewController: UIViewController {
self.letterLabelCollection[4].alpha = 1
}, completion: { _ in
UIView.animate(withDuration: 0.3, delay: 1.2, animations: {
self.checkPlayerButton.alpha = 1
self.nextButtonCollection[0].alpha = 1
}, completion: nil )
} )
})
})
})
})
}

private func setSecondComponentsAnimation() {
UIView.animate(withDuration: 0.6, animations: {
self.letterLabelCollection[5].alpha = 1
}, completion: { _ in
UIView.animate(withDuration: 0.6, delay: 1.2, animations: {
self.letterLabelCollection[6].alpha = 1
}, completion: { _ in
UIView.animate(withDuration: 0.3, delay: 1.2, animations: {
self.nextButtonCollection[1].alpha = 1
}, completion: nil)
} )
})
}

private func setThirdComponentsAnimation() {
UIView.animate(withDuration: 0.6, animations: {
self.letterLabelCollection[7].alpha = 1
}, completion: { _ in
UIView.animate(withDuration: 0.6, delay: 1.2, animations: {
self.letterLabelCollection[8].alpha = 1
}, completion: { _ in
UIView.animate(withDuration: 0.6, delay: 1.2, animations: {
self.letterLabelCollection[9].alpha = 1
}, completion: { _ in
UIView.animate(withDuration: 0.6, delay: 1.2, animations: {
self.letterLabelCollection[10].alpha = 1
}, completion: { _ in
UIView.animate(withDuration: 0.3, delay: 1.2, animations: {
self.nextButtonCollection[1].alpha = 1
}, completion: nil)
})
})
})
})
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ final class OpenBoxOnboardingViewController: UIViewController {
guard let letterOnboarding = UIStoryboard(name: Constant.Storyboard.Onboarding, bundle: nil).instantiateViewController(withIdentifier: Constant.ViewController.LetterOnboarding) as? LetterOnboardingViewController else { return }
letterOnboarding.modalPresentationStyle = .overFullScreen
letterOnboarding.modalTransitionStyle = .crossDissolve
letterOnboarding.letterNumber = 1
present(letterOnboarding, animated: true)
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
//
// PlayTapeOnboardingViewController.swift
// Deartoday
//
// Created by 황찬미 on 2022/07/15.
//

import UIKit

final class PlayTapeOnboardingViewController: UIViewController {

// MARK: - Property

var playTapeNumber: Int?

// MARK: - UI Property

@IBOutlet weak var explanationLabel: UILabel!
@IBOutlet weak var circleButton: UIImageView!
@IBOutlet weak var tapeButton: UIButton!
@IBOutlet weak var startPlayerButton: UIButton!
@IBOutlet var circleCollection: [UIView]!

// MARK: - Life Cycle

override func viewDidLoad() {
super.viewDidLoad()
setComponentsUI()
setPlayerButtonUI()
}

// MARK: - Custom Method

private func setComponentsUI() {
circleCollection.forEach {
$0.layer.cornerRadius = $0.frame.width / 2
}
explanationLabel.font = .onboard0
explanationLabel.textColor = .white
startPlayerButton.titleLabel?.font = .btn0
startPlayerButton.setTitleColor(.blue02, for: .normal)
}

private func showComponentsUI() {
startPlayerButton.alpha = 1
}

private func hideComponentsUI() {
circleCollection.forEach {
$0.isHidden = true
}
tapeButton.isHidden = true
explanationLabel.isHidden = true
circleButton.isHidden = true
}

private func setPlayerButtonUI() {
if playTapeNumber == 1 {
hideComponentsUI()
showComponentsUI()
}
}

// MARK: IBAction

@IBAction func tapeButtonDidTap(_ sender: UIButton) {
hideComponentsUI()

guard let letterOnboarding = UIStoryboard(name: Constant.Storyboard.Onboarding, bundle: nil).instantiateViewController(withIdentifier: Constant.ViewController.LetterOnboarding) as? LetterOnboardingViewController else { return }
letterOnboarding.modalTransitionStyle = .crossDissolve
letterOnboarding.modalPresentationStyle = .overFullScreen
letterOnboarding.letterNumber = 2
present(letterOnboarding, animated: true)
}

@IBAction func playLottieButtonDidTap(_ sender: UIButton) {
print("로티 재생 후")

guard let letterOnboarding = UIStoryboard(name: Constant.Storyboard.Onboarding, bundle: nil).instantiateViewController(withIdentifier: Constant.ViewController.LetterOnboarding) as? LetterOnboardingViewController else { return }
letterOnboarding.modalTransitionStyle = .crossDissolve
letterOnboarding.modalPresentationStyle = .overFullScreen
letterOnboarding.letterNumber = 4
present(letterOnboarding, animated: true)
}
}
Loading

0 comments on commit 0f17137

Please sign in to comment.