Skip to content

Commit

Permalink
[Fix] #226 - 공통 알림모달 로직 수정
Browse files Browse the repository at this point in the history
[Fix] #226 - 공통 알림모달 로직 수정
  • Loading branch information
jeongdung-eo authored Jan 28, 2024
2 parents f0222e9 + 37e1f6a commit abe8491
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 22 deletions.
7 changes: 6 additions & 1 deletion iOS-NOTTODO/iOS-NOTTODO/Global/Enum/AnalyticsEvent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -55,20 +55,25 @@ enum AnalyticsEvent {
case viewSignIn
case clickSignIn(provider: String)
case completeSignIn(provider: String)
case clickAdModalCta
case clickAdModalClose(again: String)

var name: String {
switch self {
case .viewSignIn: return "view_signin"
case .clickSignIn: return "click_signin"
case .completeSignIn: return "complete_signin"
case .clickAdModalCta: return "click_ad_modal_cta"
case .clickAdModalClose: return "click_ad_modal_close"
}
}

var parameters: [String: Any]? {
switch self {
case .viewSignIn: return nil
case .viewSignIn, .clickAdModalCta: return nil
case .clickSignIn(provider: let provider ): return ["provider": provider]
case .completeSignIn(provider: let provider): return ["provider": provider]
case .clickAdModalClose(again: let again): return ["again": again]
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion iOS-NOTTODO/iOS-NOTTODO/Global/Enum/DefaultKeys.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,5 @@ struct DefaultKeys {
static let socialToken = "socialToken"
static let accessToken = "accessToken"
static let fcmToken = "fcmToken"
static let isSelected = "isSelected"
static let isDeprecatedBtnClicked = "isDeprecatedBtnClicked"
}
6 changes: 3 additions & 3 deletions iOS-NOTTODO/iOS-NOTTODO/Global/Enum/KeychainUtil.swift
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@ public final class KeychainUtil {
UserDefaults.standard.string(forKey: DefaultKeys.appleEmail) ?? "연동된 이메일 정보가 없습니다"
}

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

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 @@ -13,6 +13,10 @@ import SafariServices

final class CommonNotificationViewController: UIViewController {

// MARK: - Property

var tapCloseButton: (() -> Void)?

// MARK: - UI Components

private let backgroundView = UIView()
Expand All @@ -24,7 +28,7 @@ final class CommonNotificationViewController: UIViewController {
private lazy var formButton = UIButton()
private lazy var closeButton = UIButton()
private lazy var deprecatedButton = UIButton()

// MARK: - View Life Cycle

override func viewDidLoad() {
Expand Down Expand Up @@ -161,23 +165,26 @@ 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)

AmplitudeAnalyticsService.shared.send(event: AnalyticsEvent.Login.clickAdModalCta)
}

@objc
func didCancelButtonTap() {
self.tapCloseButton?()
dismissViewController()
}

@objc
func didDeprecatedButtonTap() {
deprecatedButton.isSelected.toggle()
KeychainUtil.setBool(deprecatedButton.isSelected,
forKey: DefaultKeys.isSelected)
forKey: DefaultKeys.isDeprecatedBtnClicked)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,25 +23,23 @@ final class HomeViewController: UIViewController {
private var current: Date?

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

// 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)
showPopup(isSelected: didCloseButtonTap)
AmplitudeAnalyticsService.shared.send(event: AnalyticsEvent.Home.viewHome)

dailyLoadData()
Expand All @@ -53,7 +51,6 @@ final class HomeViewController: UIViewController {

setUI()
setLayout()

}
}

Expand Down Expand Up @@ -88,7 +85,7 @@ extension HomeViewController {
}

private func setLayout() {

view.addSubviews(weekCalendar, missionCollectionView, addButton)
weekCalendar.calendar.select(today)

Expand Down Expand Up @@ -220,7 +217,7 @@ extension HomeViewController: FSCalendarDelegate, FSCalendarDataSource, FSCalend

AmplitudeAnalyticsService.shared.send(event: AnalyticsEvent.Home.clickWeeklyDate(date: Utils.dateFormatterString(format: nil, date: date)))
}

func calendar(_ calendar: FSCalendar, titleFor date: Date) -> String? {
Utils.dateFormatterString(format: "EEEEEE", date: date)
}
Expand All @@ -238,12 +235,12 @@ extension HomeViewController: FSCalendarDelegate, FSCalendarDataSource, FSCalend
}

func calendar(_ calendar: FSCalendar, cellFor date: Date, at position: FSCalendarMonthPosition) -> FSCalendarCell {

let cell = calendar.dequeueReusableCell(withIdentifier: MissionCalendarCell.identifier, for: date, at: position) as! MissionCalendarCell

guard let percentage = getPercentage(for: date) else { return cell }
cell.configure(percent: percentage)

return cell
}
}
Expand Down Expand Up @@ -288,9 +285,9 @@ extension HomeViewController {
}

private func requestDeleteMission(index: Int, id: Int) {
HomeAPI.shared.deleteMission(id: id) { [weak self] _ in
HomeAPI.shared.deleteMission(id: id) { [weak self] _ in
guard let self else { return }

self.dailyLoadData()
self.weeklyLoadData()
self.missionDataSource.updateSnapShot(missionList: self.missionList)
Expand Down Expand Up @@ -356,11 +353,17 @@ extension HomeViewController {
extension HomeViewController {

private func showPopup(isSelected: Bool) {
if !isSelected {

if !(isSelected || didDeprecatedButtonTap) {
let nextView = CommonNotificationViewController()
nextView.modalPresentationStyle = .overFullScreen
nextView.modalTransitionStyle = .crossDissolve
self.present(nextView, animated: true)

nextView.tapCloseButton = {
self.didCloseButtonTap = true
AmplitudeAnalyticsService.shared.send(event: AnalyticsEvent.Login.clickAdModalClose(again: self.didDeprecatedButtonTap ? "yes": "no" ))
}
}
}
}

0 comments on commit abe8491

Please sign in to comment.