From ddea0d3f93bae6d8a2fbacfad540446497cb73e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9D=B4=EA=B2=BD=EB=AF=BC?= <74659491+meenyweeny@users.noreply.github.com> Date: Tue, 16 Aug 2022 03:01:51 +0900 Subject: [PATCH] =?UTF-8?q?[#142]=20Background=20ScrollView=20UI=20?= =?UTF-8?q?=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Deartoday/Deartoday.xcodeproj/project.pbxproj | 4 + .../Main/Controller/MainsViewController.swift | 226 ++++++++++++++++++ 2 files changed, 230 insertions(+) create mode 100644 Deartoday/Deartoday/Screen/Main/Controller/MainsViewController.swift diff --git a/Deartoday/Deartoday.xcodeproj/project.pbxproj b/Deartoday/Deartoday.xcodeproj/project.pbxproj index eb31d62..8f268aa 100644 --- a/Deartoday/Deartoday.xcodeproj/project.pbxproj +++ b/Deartoday/Deartoday.xcodeproj/project.pbxproj @@ -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 */; }; @@ -217,6 +218,7 @@ 986F5C3B2888345E001109F1 /* PastDialogCollectionViewCell.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = PastDialogCollectionViewCell.xib; sourceTree = ""; }; 986F5C3E28883469001109F1 /* PresentDialogCollectionViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PresentDialogCollectionViewCell.swift; sourceTree = ""; }; 986F5C3F28883469001109F1 /* PresentDialogCollectionViewCell.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = PresentDialogCollectionViewCell.xib; sourceTree = ""; }; + 988B471E28AAB38900D015D5 /* MainsViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MainsViewController.swift; sourceTree = ""; }; 98A47509287DECCF008891F5 /* CheckTimeTravel.storyboard */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; path = CheckTimeTravel.storyboard; sourceTree = ""; }; 98A4750E287DECF7008891F5 /* CheckTImeTravelDataModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CheckTImeTravelDataModel.swift; sourceTree = ""; }; 98A47512287DED14008891F5 /* CheckTimeTravelViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CheckTimeTravelViewController.swift; sourceTree = ""; }; @@ -742,6 +744,7 @@ children = ( 92DB35342875633D001E2006 /* MainViewController.swift */, 9803F39F288465C600A5A239 /* MainNavigationController.swift */, + 988B471E28AAB38900D015D5 /* MainsViewController.swift */, ); path = Controller; sourceTree = ""; @@ -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 */, diff --git a/Deartoday/Deartoday/Screen/Main/Controller/MainsViewController.swift b/Deartoday/Deartoday/Screen/Main/Controller/MainsViewController.swift new file mode 100644 index 0000000..97d6bc1 --- /dev/null +++ b/Deartoday/Deartoday/Screen/Main/Controller/MainsViewController.swift @@ -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() { + + } +}