Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feat] #211 - 공통 알림 모달 구현 #212

Merged
merged 5 commits into from
Jan 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -50,6 +50,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 @@ -211,6 +212,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 @@ -843,6 +845,7 @@
children = (
3B9532F22A284CAD006510F8 /* Protocol */,
3B4E12F12A27B621001D1EC1 /* NottodoModalViewController.swift */,
09ED941A2B2ABAB7001864EF /* CommonNotificationViewController.swift */,
3B4E12F52A27C0BE001D1EC1 /* QuitModalView.swift */,
3B4E12F72A27C12F001D1EC1 /* WithdrawModalView.swift */,
092C09B62A48596500E9B06B /* DeleteModalView.swift */,
Expand Down Expand Up @@ -1383,6 +1386,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
1 change: 1 addition & 0 deletions iOS-NOTTODO/iOS-NOTTODO/Global/Enum/DefaultKeys.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,5 @@ struct DefaultKeys {
static let socialToken = "socialToken"
static let accessToken = "accessToken"
static let fcmToken = "fcmToken"
static let isSelected = "isSelected"
}
4 changes: 4 additions & 0 deletions iOS-NOTTODO/iOS-NOTTODO/Global/Enum/KeychainUtil.swift
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ public final class KeychainUtil {
UserDefaults.standard.string(forKey: DefaultKeys.appleEmail) ?? "연동된 이메일 정보가 없습니다"
}

static func isSelected() -> Bool {
UserDefaults.standard.bool(forKey: DefaultKeys.isSelected)
}

static func removeUserInfo() {
if UserDefaults.standard.bool(forKey: DefaultKeys.isAppleLogin) {
UserDefaults.standard.removeObject(forKey: DefaultKeys.appleName)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ extension UIImage {
static var calendarRight: UIImage { UIImage(named: "btn_calendar_right")! }
static var checkboxFill: UIImage { UIImage(named: "btn_checkbox_active")! }
static var checkbox: UIImage { UIImage(named: "btn_checkbox_inactive")! }
static var deprecatedCheckBoxFill: UIImage { UIImage(named: "btn_common_active")! }
static var deprecatedCheckBox: UIImage { UIImage(named: "btn_common_inactive")! }

// home

Expand Down Expand Up @@ -58,6 +60,7 @@ extension UIImage {
static var icToastError: UIImage { UIImage(named: "ic_toast_error")! }
static var icBell: UIImage { UIImage(named: "ic_bell")! }
static var icCircle: UIImage { UIImage(named: "acceptCircle")! }
static var icStarbucks: UIImage { UIImage(named: "ic_starbucks")! }

// image

Expand Down
4 changes: 4 additions & 0 deletions iOS-NOTTODO/iOS-NOTTODO/Global/Literals/Strings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,10 @@ struct I18N {
static let allow = "허용"
static let notiDialogButton = "네, 알겠어요 :)"

static let formButton = "이정도야 쉽지!"
static let deprecatedTitle = "더 이상 보지 않기"
static let close = "닫기"

/// home
static let subText = "*달성 가능한 계획을 위해 다가올 일주일만 선택할 수 있어요"
}
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 @@ -23,19 +23,25 @@ final class HomeViewController: UIViewController {
private var current: Date?

private lazy var safeArea = self.view.safeAreaLayoutGuide
private var isSelected: Bool {
return KeychainUtil.isSelected()
}

// MARK: - UI Components

private var missionCollectionView = UICollectionView(frame: .zero, collectionViewLayout: .init())
private lazy var missionDataSource = HomeDataSource(collectionView: missionCollectionView, missionList: missionList)

private lazy var alertViewContrilelr = CommonNotificationViewController()
private let weekCalendar = CalendarView(calendarScope: .week, scrollDirection: .horizontal)
private let addButton = UIButton()

// MARK: - Life Cycle

override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)

showPopup(isSelected: isSelected)
AmplitudeAnalyticsService.shared.send(event: AnalyticsEvent.Home.viewHome)

dailyLoadData()
Expand Down Expand Up @@ -346,3 +352,15 @@ extension HomeViewController {
return .white
}
}

extension HomeViewController {

private func showPopup(isSelected: Bool) {
if !isSelected {
let nextView = CommonNotificationViewController()
nextView.modalPresentationStyle = .overFullScreen
nextView.modalTransitionStyle = .crossDissolve
self.present(nextView, animated: true)
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"images" : [
{
"filename" : "icon_starbucks.svg",
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
},
"properties" : {
"preserves-vector-representation" : true
}
}
Loading