-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[fix]: mission unlocked alert and description(#540)
- Loading branch information
Showing
7 changed files
with
148 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
14th-team5-iOS/Data/Sources/UserDefaults/MissionUserDefaultsRepository.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
// | ||
// MissionUserDefaultsRepository.swift | ||
// Data | ||
// | ||
// Created by 마경미 on 03.06.24. | ||
// | ||
|
||
import Foundation | ||
|
||
import Domain | ||
|
||
import RxSwift | ||
|
||
public final class MissionUserDefaultsRepository: MissionUserdefaultsRepositoryProtocol { | ||
|
||
private let lastMissionUploadDateId = "lastMissionUploadDateId" | ||
|
||
public init() { } | ||
|
||
public func isAlreadyShowMissionAlert() -> Observable<Bool> { | ||
guard let lastDate = UserDefaults.standard.string(forKey: lastMissionUploadDateId) else { | ||
saveMissionUploadDate() | ||
return .just(false) | ||
} | ||
|
||
if lastDate == Date().toFormatString(with: "yyyy-MM-dd") { | ||
return .just(true) | ||
} else { | ||
saveMissionUploadDate() | ||
return .just(false) | ||
} | ||
} | ||
|
||
private func saveMissionUploadDate() { | ||
let isoDateFormatter = ISO8601DateFormatter() | ||
isoDateFormatter.formatOptions = [.withInternetDateTime, .withFractionalSeconds] | ||
|
||
let dateFormatter = DateFormatter() | ||
dateFormatter.dateFormat = "yyyy-MM-dd" | ||
let extractedDate = dateFormatter.string(from: Date()) | ||
UserDefaults.standard.set(extractedDate, forKey: lastMissionUploadDateId) | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
14th-team5-iOS/Domain/Sources/Mission/Interfaces/CheckMissionAlertShowUseCaseProtocol.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// | ||
// MissionAlertUseCaseProtocol.swift | ||
// Domain | ||
// | ||
// Created by 마경미 on 03.06.24. | ||
// | ||
|
||
import Foundation | ||
|
||
import RxSwift | ||
|
||
public protocol CheckMissionAlertShowUseCaseProtocol { | ||
func execute() -> Observable<Bool> | ||
} |
14 changes: 14 additions & 0 deletions
14
14th-team5-iOS/Domain/Sources/Mission/Interfaces/MissionUserdefaultsRepositoryProtocol.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// | ||
// MissionUserdefaultsRepositoryProtocol.swift | ||
// Domain | ||
// | ||
// Created by 마경미 on 03.06.24. | ||
// | ||
|
||
import Foundation | ||
|
||
import RxSwift | ||
|
||
public protocol MissionUserdefaultsRepositoryProtocol { | ||
func isAlreadyShowMissionAlert() -> Observable<Bool> | ||
} |
22 changes: 22 additions & 0 deletions
22
14th-team5-iOS/Domain/Sources/Mission/UseCases/CheckMissionAlertShowUseCase.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// | ||
// CheckMissionUseCase.swift | ||
// Domain | ||
// | ||
// Created by 마경미 on 03.06.24. | ||
// | ||
|
||
import Foundation | ||
|
||
import RxSwift | ||
|
||
public class CheckMissionAlertShowUseCase: CheckMissionAlertShowUseCaseProtocol { | ||
private let missionUserDefaultsRepository: MissionUserdefaultsRepositoryProtocol | ||
|
||
public init(missionUserDefaultsRepository: MissionUserdefaultsRepositoryProtocol) { | ||
self.missionUserDefaultsRepository = missionUserDefaultsRepository | ||
} | ||
|
||
public func execute() -> Observable<Bool> { | ||
return missionUserDefaultsRepository.isAlreadyShowMissionAlert().asObservable() | ||
} | ||
} |