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

[Fix] #226 - 공통 알림모달 로직 수정 #227

Merged
merged 5 commits into from
Jan 28, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
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,24 +23,22 @@ final class HomeViewController: UIViewController {
private var current: Date?

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

어떤게 선택된건지 변수명이 좀더 명확하면 좋을 것 같아요!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

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.isSelected = true
AmplitudeAnalyticsService.shared.send(event: AnalyticsEvent.Login.clickAdModalClose(again: self.didDeprecatedButtonTap ? "yes": "no" ))
}
}
}
}