-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: #109 Add userDefaults Manager for user notification settings
- ์๋ฆผ ๊ด๋ จ ๋ฐ์ดํฐ ์ ์ฅ ๋ฐ ๋ก๋ ๋ก์ง์ ์บก์ํํ `UserDefaultsManager` ์ถ๊ฐ - ์๋ฆผ ์๊ฐ(`hour`, `minute`) ์ ์ฅ ๋ฐ ๋ถ๋ฌ์ค๊ธฐ ๋ฉ์๋ ์ถ๊ฐ. - ์๋ฆผ ๋นํ์ฑํ ์ํ(`isNotificationDisabled`) ์ ์ฅ ๋ฐ ๋ถ๋ฌ์ค๊ธฐ ๋ฉ์๋ ์ถ๊ฐ.
- Loading branch information
Showing
3 changed files
with
52 additions
and
16 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
40 changes: 40 additions & 0 deletions
40
FiveGuyes/FiveGuyes/Sources/Models/UserDefaults/UserDefaultsManager.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,40 @@ | ||
// | ||
// UserDefaultsManager.swift | ||
// FiveGuyes | ||
// | ||
// Created by zaehorang on 11/28/24. | ||
// | ||
|
||
import Foundation | ||
|
||
struct UserDefaultsManager { | ||
enum UserDefaultsKeys: String { | ||
case isNotificationDisabled // ์์คํ ์ค์ ์ด ์๋, ์ฑ ๋ด๋ถ์์ ๊ด๋ฆฌํ๋ ๊ฐ | ||
case reminderHour | ||
case reminderMinute | ||
} | ||
|
||
/// ๋ ธํฐ ๊ถํ ์ฌ๋ถ ์ ์ฅ | ||
static func saveNotificationDisabled(_ isNotificationDisabled: Bool) { | ||
UserDefaults.standard.set(isNotificationDisabled, forKey: UserDefaultsKeys.isNotificationDisabled.rawValue) | ||
} | ||
|
||
/// ๋ ธํฐ ๊ถํ ์ฌ๋ถ ๋ถ๋ฌ์ค๊ธฐ | ||
/// ์ ์ฅ ๊ฐ์ด ์์ ๊ฒฝ์ฐ false ๋ฆฌํด | ||
static func fetchNotificationDisabled() -> Bool { | ||
return UserDefaults.standard.bool(forKey: UserDefaultsKeys.isNotificationDisabled.rawValue) | ||
} | ||
|
||
/// ์๊ฐ๊ณผ ๋ถ ์ ์ฅ | ||
static func saveNotificationTime(hour: Int, minute: Int) { | ||
UserDefaults.standard.set(hour, forKey: UserDefaultsKeys.reminderHour.rawValue) | ||
UserDefaults.standard.set(minute, forKey: UserDefaultsKeys.reminderMinute.rawValue) | ||
} | ||
|
||
/// ์ ์ฅ ๊ฐ์ด ์์ ๊ฒฝ์ฐ (9, 0) ๋ฆฌํด (= 09:00) | ||
static func fetchNotificationReminderTime() -> (hour: Int, minute: Int) { | ||
let hour = UserDefaults.standard.integer(forKey: UserDefaultsKeys.reminderHour.rawValue) | ||
let minute = UserDefaults.standard.integer(forKey: UserDefaultsKeys.reminderMinute.rawValue) | ||
return (hour == 0 && minute == 0) ? (9, 0) : (hour, minute) | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.