From 460acc789f8b38d13713083cf03d2530b41684ac Mon Sep 17 00:00:00 2001 From: jeongdung-eo Date: Wed, 3 Jan 2024 16:21:41 +0900 Subject: [PATCH] =?UTF-8?q?[Feat]=20#211-=20=EA=B3=B5=ED=86=B5=20=EC=95=8C?= =?UTF-8?q?=EB=A6=BC=20=EB=AA=A8=EB=8B=AC=EB=B7=B0=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../iOS-NOTTODO.xcodeproj/project.pbxproj | 4 + .../CommonNotificationViewController.swift | 189 ++++++++++++++++++ .../ViewControllers/HomeViewController.swift | 18 ++ 3 files changed, 211 insertions(+) create mode 100644 iOS-NOTTODO/iOS-NOTTODO/Presentation/Common/Modal/CommonNotificationViewController.swift diff --git a/iOS-NOTTODO/iOS-NOTTODO.xcodeproj/project.pbxproj b/iOS-NOTTODO/iOS-NOTTODO.xcodeproj/project.pbxproj index 92673262..e2712ec4 100644 --- a/iOS-NOTTODO/iOS-NOTTODO.xcodeproj/project.pbxproj +++ b/iOS-NOTTODO/iOS-NOTTODO.xcodeproj/project.pbxproj @@ -48,6 +48,7 @@ 09DCCD1F2A18ED76003DCF8A /* DailyMissionResponseDTO.swift in Sources */ = {isa = PBXBuildFile; fileRef = 09DCCD1E2A18ED76003DCF8A /* DailyMissionResponseDTO.swift */; }; 09DCCD212A18EF43003DCF8A /* HomeSevice.swift in Sources */ = {isa = PBXBuildFile; fileRef = 09DCCD202A18EF43003DCF8A /* HomeSevice.swift */; }; 09DCCD232A18EFB0003DCF8A /* HomeAPI.swift in Sources */ = {isa = PBXBuildFile; fileRef = 09DCCD222A18EFB0003DCF8A /* HomeAPI.swift */; }; + 09ED941B2B2ABAB7001864EF /* CommonNotificationViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 09ED941A2B2ABAB7001864EF /* CommonNotificationViewController.swift */; }; 09F6718029CAD76C00708725 /* SecondOnboardingViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 09F6717F29CAD76C00708725 /* SecondOnboardingViewController.swift */; }; 09F6718229CAD86100708725 /* OnboardingCollectionViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 09F6718129CAD86100708725 /* OnboardingCollectionViewCell.swift */; }; 09F6718429CADB1100708725 /* OnboardingModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 09F6718329CADB1100708725 /* OnboardingModel.swift */; }; @@ -205,6 +206,7 @@ 09DCCD1E2A18ED76003DCF8A /* DailyMissionResponseDTO.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DailyMissionResponseDTO.swift; sourceTree = ""; }; 09DCCD202A18EF43003DCF8A /* HomeSevice.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HomeSevice.swift; sourceTree = ""; }; 09DCCD222A18EFB0003DCF8A /* HomeAPI.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HomeAPI.swift; sourceTree = ""; }; + 09ED941A2B2ABAB7001864EF /* CommonNotificationViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CommonNotificationViewController.swift; sourceTree = ""; }; 09F6717F29CAD76C00708725 /* SecondOnboardingViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SecondOnboardingViewController.swift; sourceTree = ""; }; 09F6718129CAD86100708725 /* OnboardingCollectionViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OnboardingCollectionViewCell.swift; sourceTree = ""; }; 09F6718329CADB1100708725 /* OnboardingModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OnboardingModel.swift; sourceTree = ""; }; @@ -816,6 +818,7 @@ children = ( 3B9532F22A284CAD006510F8 /* Protocol */, 3B4E12F12A27B621001D1EC1 /* NottodoModalViewController.swift */, + 09ED941A2B2ABAB7001864EF /* CommonNotificationViewController.swift */, 3B4E12F52A27C0BE001D1EC1 /* QuitModalView.swift */, 3B4E12F72A27C12F001D1EC1 /* WithdrawModalView.swift */, 092C09B62A48596500E9B06B /* DeleteModalView.swift */, @@ -1351,6 +1354,7 @@ 09F6718829CB383800708725 /* ThirdOnboardingViewController.swift in Sources */, 3B37AE2B29C8904800AB7587 /* RecommendKeywordCollectionViewCell.swift in Sources */, 099FC98929B3233D005B37E6 /* CalendarView.swift in Sources */, + 09ED941B2B2ABAB7001864EF /* CommonNotificationViewController.swift in Sources */, 6C9628A92A22209E003ADE25 /* LogoOnboardingViewController.swift in Sources */, 09F6718029CAD76C00708725 /* SecondOnboardingViewController.swift in Sources */, 098BFD5D29B79CE3008E80F9 /* InfoCollectionViewCell.swift in Sources */, diff --git a/iOS-NOTTODO/iOS-NOTTODO/Presentation/Common/Modal/CommonNotificationViewController.swift b/iOS-NOTTODO/iOS-NOTTODO/Presentation/Common/Modal/CommonNotificationViewController.swift new file mode 100644 index 00000000..6f76e237 --- /dev/null +++ b/iOS-NOTTODO/iOS-NOTTODO/Presentation/Common/Modal/CommonNotificationViewController.swift @@ -0,0 +1,189 @@ +// +// CommonNotificationViewController.swift +// iOS-NOTTODO +// +// Created by JEONGEUN KIM on 12/14/23. +// + +import UIKit + +import SnapKit +import Then +import SafariServices + +final class CommonNotificationViewController: UIViewController { + + // MARK: - UI Components + + private let backgroundView = UIView() + private let titleLabel = UILabel() + private let subTitleLabel = UILabel() + private let icon = UIImageView() + private let deprecatedTitle = UILabel() + private let bottomView = UIView() + private lazy var formButton = UIButton() + private lazy var closeButton = UIButton() + private lazy var deprecatedButton = UIButton() + + // MARK: - View Life Cycle + + override func viewDidLoad() { + super.viewDidLoad() + + setUI() + setLayout() + } +} + +// MARK: - Methods + +extension CommonNotificationViewController { + private func setUI() { + view.backgroundColor = .black.withAlphaComponent(0.6) + + backgroundView.do { + $0.backgroundColor = .white + $0.layer.cornerRadius = 15 + } + + titleLabel.do { + $0.font = .Pretendard(.bold, size: 18) + $0.textAlignment = .center + $0.text = "1분 서비스 피드백하고 \n기프티콘 받아가세요!" + $0.numberOfLines = 2 + } + + subTitleLabel.do { + $0.font = .Pretendard(.medium, size: 12) + $0.textAlignment = .center + $0.text = "매주 추첨을 통해 스타벅스 기프티콘을 드려요" + } + + deprecatedTitle.do { + $0.font = .Pretendard(.medium, size: 13) + $0.text = I18N.deprecatedTitle + $0.textColor = .gray3 + } + + icon.do { + $0.contentMode = .scaleAspectFit + $0.image = .icStarbucks + } + + bottomView.do { + $0.backgroundColor = .gray5 + $0.layer.maskedCorners = [.layerMinXMaxYCorner, .layerMaxXMaxYCorner] + $0.layer.cornerRadius = 15 + } + + formButton.do { + $0.backgroundColor = .black + $0.setTitle(I18N.formButton, for: .normal) + $0.setTitleColor(.white, for: .normal) + $0.titleLabel?.font = .Pretendard(.medium, size: 13) + $0.layer.cornerRadius = 20 + $0.addTarget(self, action: #selector(didFormButtonTap), for: .touchUpInside) + } + + deprecatedButton.do { + $0.setImage(.deprecatedCheckBox, for: .normal) + $0.setImage(.deprecatedCheckBoxFill, for: .selected) + $0.addTarget(self, action: #selector(didDeprecatedButtonTap), for: .touchUpInside) + } + + closeButton.do { + $0.setTitle(I18N.close, for: .normal) + $0.setTitleColor(.gray3, for: .normal) + $0.titleLabel?.font = .Pretendard(.medium, size: 13) + $0.addTarget(self, action: #selector(didCancelButtonTap), for: .touchUpInside) + } + } + + private func setLayout() { + + view.addSubview(backgroundView) + backgroundView.addSubviews(titleLabel, subTitleLabel, icon, formButton, bottomView) + bottomView.addSubviews(deprecatedButton, deprecatedTitle, closeButton) + + backgroundView.snp.makeConstraints { + $0.horizontalEdges.equalToSuperview().inset(46) + $0.height.equalTo(408) + $0.center.equalToSuperview() + } + titleLabel.snp.makeConstraints { + $0.top.equalToSuperview().inset(28) + $0.centerX.equalToSuperview() + } + + subTitleLabel.snp.makeConstraints { + $0.top.equalTo(titleLabel.snp.bottom).offset(6) + $0.centerX.equalToSuperview() + } + + icon.snp.makeConstraints { + $0.top.equalTo(subTitleLabel.snp.bottom).offset(7) + $0.horizontalEdges.equalToSuperview().inset(16) + $0.height.equalTo(197) + } + + formButton.snp.makeConstraints { + $0.top.equalTo(icon.snp.bottom).offset(4) + $0.horizontalEdges.equalToSuperview().inset(36) + $0.height.equalTo(40) + } + + bottomView.snp.makeConstraints { + $0.horizontalEdges.bottom.equalToSuperview() + $0.height.equalTo(50) + } + + deprecatedButton.snp.makeConstraints { + $0.centerY.equalToSuperview() + $0.leading.equalToSuperview().inset(10) + $0.size.equalTo(20) + } + + deprecatedTitle.snp.makeConstraints { + $0.leading.equalTo(deprecatedButton.snp.trailing).offset(4) + $0.centerY.equalToSuperview() + } + + closeButton.snp.makeConstraints { + $0.trailing.equalToSuperview().inset(15) + $0.centerY.equalToSuperview() + } + } +} + +// MARK: - @objc Methods + +extension CommonNotificationViewController { + + @objc + func didFormButtonTap() { + + guard let url = URL(string: MyInfoURL.googleForm.url) else { return } + let safariView: SFSafariViewController = SFSafariViewController(url: url) + safariView.delegate = self + self.present(safariView, animated: true, completion: nil) + } + + @objc + func didCancelButtonTap() { + dismissViewController() + } + + @objc + func didDeprecatedButtonTap() { + deprecatedButton.isSelected.toggle() + KeychainUtil.setBool(deprecatedButton.isSelected, + forKey: DefaultKeys.isSelected) + } +} + +extension CommonNotificationViewController: SFSafariViewControllerDelegate { + + func safariViewControllerDidFinish(_ controller: SFSafariViewController) { + dismissViewController() + } +} diff --git a/iOS-NOTTODO/iOS-NOTTODO/Presentation/Home/ViewControllers/HomeViewController.swift b/iOS-NOTTODO/iOS-NOTTODO/Presentation/Home/ViewControllers/HomeViewController.swift index 8d75533a..a6de1c61 100644 --- a/iOS-NOTTODO/iOS-NOTTODO/Presentation/Home/ViewControllers/HomeViewController.swift +++ b/iOS-NOTTODO/iOS-NOTTODO/Presentation/Home/ViewControllers/HomeViewController.swift @@ -22,6 +22,9 @@ final class HomeViewController: UIViewController { private var count: Int? private var calendarDataSource: [String: Float] = [:] private lazy var safeArea = self.view.safeAreaLayoutGuide + private var isSelected: Bool { + return KeychainUtil.isSelected() + } enum Sections: Int, Hashable { case mission, empty @@ -30,6 +33,7 @@ final class HomeViewController: UIViewController { // MARK: - UI Components + private lazy var alertViewContrilelr = CommonNotificationViewController() private lazy var missionCollectionView = UICollectionView(frame: .zero, collectionViewLayout: layout()) private let weekCalendar = CalendarView(calendarScope: .week, scrollDirection: .horizontal) private let addButton = UIButton() @@ -38,6 +42,8 @@ final class HomeViewController: UIViewController { override func viewWillAppear(_ animated: Bool) { super.viewWillAppear(animated) + + showPopup(isSelected: isSelected) AmplitudeAnalyticsService.shared.send(event: AnalyticsEvent.Home.viewHome) dailyLoadData() weeklyLoadData() @@ -424,3 +430,15 @@ extension HomeViewController { } } } + +extension HomeViewController { + + private func showPopup(isSelected: Bool) { + if !isSelected { + let nextView = CommonNotificationViewController() + nextView.modalPresentationStyle = .overFullScreen + nextView.modalTransitionStyle = .crossDissolve + self.present(nextView, animated: true) + } + } +}