Skip to content

Commit

Permalink
[#142] Background ScrollView UI ๊ตฌํ˜„
Browse files Browse the repository at this point in the history
  • Loading branch information
meenyweeny committed Aug 15, 2022
1 parent 06b9db2 commit ddea0d3
Show file tree
Hide file tree
Showing 2 changed files with 230 additions and 0 deletions.
4 changes: 4 additions & 0 deletions Deartoday/Deartoday.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@
986F5C3D2888345E001109F1 /* PastDialogCollectionViewCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 986F5C3B2888345E001109F1 /* PastDialogCollectionViewCell.xib */; };
986F5C4028883469001109F1 /* PresentDialogCollectionViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 986F5C3E28883469001109F1 /* PresentDialogCollectionViewCell.swift */; };
986F5C4128883469001109F1 /* PresentDialogCollectionViewCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 986F5C3F28883469001109F1 /* PresentDialogCollectionViewCell.xib */; };
988B471F28AAB38900D015D5 /* MainsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 988B471E28AAB38900D015D5 /* MainsViewController.swift */; };
98A4750A287DECCF008891F5 /* CheckTimeTravel.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 98A47509287DECCF008891F5 /* CheckTimeTravel.storyboard */; };
98A4750F287DECF7008891F5 /* CheckTImeTravelDataModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 98A4750E287DECF7008891F5 /* CheckTImeTravelDataModel.swift */; };
98A47513287DED14008891F5 /* CheckTimeTravelViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 98A47512287DED14008891F5 /* CheckTimeTravelViewController.swift */; };
Expand Down Expand Up @@ -217,6 +218,7 @@
986F5C3B2888345E001109F1 /* PastDialogCollectionViewCell.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = PastDialogCollectionViewCell.xib; sourceTree = "<group>"; };
986F5C3E28883469001109F1 /* PresentDialogCollectionViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PresentDialogCollectionViewCell.swift; sourceTree = "<group>"; };
986F5C3F28883469001109F1 /* PresentDialogCollectionViewCell.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = PresentDialogCollectionViewCell.xib; sourceTree = "<group>"; };
988B471E28AAB38900D015D5 /* MainsViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MainsViewController.swift; sourceTree = "<group>"; };
98A47509287DECCF008891F5 /* CheckTimeTravel.storyboard */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; path = CheckTimeTravel.storyboard; sourceTree = "<group>"; };
98A4750E287DECF7008891F5 /* CheckTImeTravelDataModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CheckTImeTravelDataModel.swift; sourceTree = "<group>"; };
98A47512287DED14008891F5 /* CheckTimeTravelViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CheckTimeTravelViewController.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -742,6 +744,7 @@
children = (
92DB35342875633D001E2006 /* MainViewController.swift */,
9803F39F288465C600A5A239 /* MainNavigationController.swift */,
988B471E28AAB38900D015D5 /* MainsViewController.swift */,
);
path = Controller;
sourceTree = "<group>";
Expand Down Expand Up @@ -1192,6 +1195,7 @@
92C27EAB2884459F00077FA3 /* TimeTravelAPI.swift in Sources */,
9803F3BD2884814C00A5A239 /* MainAPI.swift in Sources */,
98D912C5287DB0130088A7F9 /* Lottie.swift in Sources */,
988B471F28AAB38900D015D5 /* MainsViewController.swift in Sources */,
4ADAB7E9288507A10049C465 /* LoginResponse.swift in Sources */,
986E000328A62A04008EB3F2 /* MessageCollectionViewCell.swift in Sources */,
98A47519287E0129008891F5 /* CheckMessageDetailViewController.swift in Sources */,
Expand Down
226 changes: 226 additions & 0 deletions Deartoday/Deartoday/Screen/Main/Controller/MainsViewController.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,226 @@
//
// MainsViewController.swift
// Deartoday
//
// Created by ์ด๊ฒฝ๋ฏผ on 2022/08/16.
//

import UIKit

final class MainsViewController: UIViewController {

// MARK: - Property

private var isPushed: Bool = false

// MARK: - UI Property

private lazy var scrollView: UIScrollView = {
return UIScrollView(frame: .zero).then {
$0.showsHorizontalScrollIndicator = false
$0.isPagingEnabled = true
$0.clipsToBounds = true
$0.contentInsetAdjustmentBehavior = .never
$0.bounces = false
$0.bouncesZoom = false
}
}()

private let contentView = UIView().then {
$0.backgroundColor = .clear
}

private let leftImageView = UIImageView().then {
$0.image = Constant.Image.mainLeftWithg
$0.contentMode = .scaleAspectFill
$0.clipsToBounds = true
}

private let timeTravelImageView = UIImageView().then {
$0.image = Constant.Image.btnCircleBasic
}

private let rewindImageView = UIImageView().then {
$0.image = Constant.Image.rewind
}

private let timeTravelView = UIView().then {
$0.backgroundColor = .clear
}

private let timeTravelButton = UIButton().then {
$0.backgroundColor = .clear
$0.addTarget(self, action: #selector(timeTravelComponentDidTap), for: .touchUpInside)
}

private let rightImageView = UIImageView().then {
$0.image = Constant.Image.mainRightWithg
$0.contentMode = .scaleAspectFill
$0.clipsToBounds = true
}

private let checkMessageImageView = UIImageView().then {
$0.image = Constant.Image.btnCircleBasic
}

private let checkTimeTravelImageView = UIImageView().then {
$0.image = Constant.Image.btnCircleBasic
}

private let messageStackView = UIStackView().then {
$0.spacing = 4
}

private let memoImageView = UIImageView().then {
$0.image = Constant.Image.icnMemo
}

private let messageCountLabel = UILabel().then {
$0.text = "์–ด์ฉŒ๊ตฌ"
}

private let checkMessageButton = UIButton().then {
$0.backgroundColor = .clear
$0.addTarget(self, action: #selector(checkMessageComponentDidTap), for: .touchUpInside)
}

private let checkMessageView = UIView().then {
$0.backgroundColor = .clear
}

private let timeTravelStackView = UIStackView().then {
$0.spacing = 4
}

private let tapeImageView = UIImageView().then {
$0.image = Constant.Image.icnTape
}

private let timeTravelCountLabel = UILabel().then {
$0.text = "์–ด์ฉŒ๊ตฌ"
}

private let checkTimeTravelButton = UIButton().then {
$0.backgroundColor = .clear
$0.addTarget(self, action: #selector(checkTimeTravelCompontntDidTap), for: .touchUpInside)
}

private let checkTimeTravelView = UIView().then {
$0.backgroundColor = .clear
}

// MARK: - Life Cycle

override func viewDidLoad() {
super.viewDidLoad()
setUI()
setLayout()
setGesture()
}

// MARK: - @objc

@objc private func timeTravelComponentDidTap() {
if isPushed { return }
isPushed = true
let timeTravel = TimeTravelViewController()
timeTravel.modalTransitionStyle = .crossDissolve
timeTravel.modalPresentationStyle = .fullScreen
present(timeTravel, animated: true)
}

@objc private func checkMessageComponentDidTap() {
if isPushed { return }
isPushed = true
let checkMessage = CheckMessageViewController()
navigationController?.pushViewController(checkMessage, animated: true)
}

@objc private func checkTimeTravelCompontntDidTap() {
if isPushed { return }
isPushed = true
guard let checkTimeTravel = UIStoryboard(name: Constant.Storyboard.CheckTimeTravel, bundle: nil).instantiateViewController(withIdentifier: Constant.ViewController.CheckTimeTravel) as? CheckTimeTravelViewController else { return }
navigationController?.pushViewController(checkTimeTravel, animated: true)
}

// MARK: - Custom Method

private func setUI() {
}

private func setLayout() {
setHierarchy()
setConstraint()
}

private func setHierarchy() {
view.addSubviews([scrollView])
scrollView.addSubview(contentView)
contentView.addSubviews([leftImageView, rightImageView,
timeTravelImageView, rewindImageView, timeTravelButton, timeTravelView,
checkMessageImageView, messageStackView, checkMessageButton, checkMessageView,
checkTimeTravelImageView, timeTravelStackView, checkTimeTravelButton, checkTimeTravelView])
messageStackView.addSubviews([memoImageView, messageCountLabel])
timeTravelStackView.addSubviews([tapeImageView, timeTravelCountLabel])
}

private func setConstraint() {
setBackgroundConstraint()
setLeftScreenConstraint()
setRightScreenConstraint()
setHeaderViewConstraint()
setPageControlConstraint()
}

private func setGesture() {
let timeTravelGesture = UITapGestureRecognizer(target: self, action: #selector(timeTravelComponentDidTap))
timeTravelView.addGestureRecognizer(timeTravelGesture)
let checkMessageGesture = UITapGestureRecognizer(target: self, action: #selector(checkMessageComponentDidTap))
checkMessageView.addGestureRecognizer(checkMessageGesture)
let checkTimeTravelGesture = UITapGestureRecognizer(target: self, action: #selector(checkTimeTravelCompontntDidTap))
checkTimeTravelView.addGestureRecognizer(checkTimeTravelGesture)
}
}

// MARK: - Constraint

extension MainsViewController {
private func setBackgroundConstraint() {
scrollView.snp.makeConstraints { make in
make.top.leading.bottom.trailing.equalToSuperview()
}

contentView.snp.makeConstraints { make in
make.top.leading.bottom.trailing.equalToSuperview()
make.width.equalTo(view.snp.width).priority(.low)
make.height.equalTo(view.snp.height)
}

leftImageView.snp.makeConstraints { make in
make.top.leading.bottom.equalToSuperview()
make.width.equalTo(getDeviceWidth())
}

rightImageView.snp.makeConstraints { make in
make.top.bottom.trailing.equalToSuperview()
make.width.equalTo(getDeviceWidth())
make.leading.equalTo(leftImageView.snp.trailing)
}
}

private func setLeftScreenConstraint() {

}

private func setRightScreenConstraint() {

}

private func setHeaderViewConstraint() {

}

private func setPageControlConstraint() {

}
}

0 comments on commit ddea0d3

Please sign in to comment.