Skip to content

Commit

Permalink
[Feat] #211- 공통 알림 모달뷰 구현
Browse files Browse the repository at this point in the history
  • Loading branch information
jeongdung-eo committed Jan 3, 2024
1 parent ad9d93a commit 460acc7
Show file tree
Hide file tree
Showing 3 changed files with 211 additions and 0 deletions.
4 changes: 4 additions & 0 deletions iOS-NOTTODO/iOS-NOTTODO.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -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 */; };
Expand Down Expand Up @@ -205,6 +206,7 @@
09DCCD1E2A18ED76003DCF8A /* DailyMissionResponseDTO.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DailyMissionResponseDTO.swift; sourceTree = "<group>"; };
09DCCD202A18EF43003DCF8A /* HomeSevice.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HomeSevice.swift; sourceTree = "<group>"; };
09DCCD222A18EFB0003DCF8A /* HomeAPI.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HomeAPI.swift; sourceTree = "<group>"; };
09ED941A2B2ABAB7001864EF /* CommonNotificationViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CommonNotificationViewController.swift; sourceTree = "<group>"; };
09F6717F29CAD76C00708725 /* SecondOnboardingViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SecondOnboardingViewController.swift; sourceTree = "<group>"; };
09F6718129CAD86100708725 /* OnboardingCollectionViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OnboardingCollectionViewCell.swift; sourceTree = "<group>"; };
09F6718329CADB1100708725 /* OnboardingModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OnboardingModel.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -816,6 +818,7 @@
children = (
3B9532F22A284CAD006510F8 /* Protocol */,
3B4E12F12A27B621001D1EC1 /* NottodoModalViewController.swift */,
09ED941A2B2ABAB7001864EF /* CommonNotificationViewController.swift */,
3B4E12F52A27C0BE001D1EC1 /* QuitModalView.swift */,
3B4E12F72A27C12F001D1EC1 /* WithdrawModalView.swift */,
092C09B62A48596500E9B06B /* DeleteModalView.swift */,
Expand Down Expand Up @@ -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 */,
Expand Down
Original file line number Diff line number Diff line change
@@ -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()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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()
Expand All @@ -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()
Expand Down Expand Up @@ -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)
}
}
}

0 comments on commit 460acc7

Please sign in to comment.