-
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.
- Loading branch information
1 parent
23cf765
commit 7dddc1a
Showing
10 changed files
with
184 additions
and
76 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
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
This file was deleted.
Oops, something went wrong.
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,62 @@ | ||
// | ||
// FirebaseService.swift | ||
// JCAlerts | ||
// | ||
// Created by John Choi on 12/10/23. | ||
// | ||
|
||
import Foundation | ||
|
||
class UserSettingService { | ||
static let instance = UserSettingService() | ||
|
||
let userDefaults = UserDefaults.standard | ||
|
||
private var currentUsername: String | ||
|
||
private var textViewFontSize: Int | ||
|
||
private init() { | ||
// check if UserDefaults has username defined | ||
if let username = userDefaults.string(forKey: "currentUsername") { | ||
currentUsername = username | ||
} else { | ||
// generate username | ||
let uuid = UUID().uuidString | ||
currentUsername = uuid | ||
userDefaults.setValue(uuid, forKey: "currentUsername") | ||
} | ||
|
||
// check if UserDefaults has textViewFontSize defined | ||
if userDefaults.integer(forKey: "textViewFontSize") != 0 { | ||
textViewFontSize = userDefaults.integer(forKey: "textViewFontSize") | ||
} else { | ||
textViewFontSize = 14 | ||
userDefaults.setValue(textViewFontSize, forKey: "textViewFontSize") | ||
} | ||
} | ||
|
||
func getTextViewFontSize() -> Int { | ||
return textViewFontSize | ||
} | ||
|
||
func decreaseTextViewFontSize() { | ||
if textViewFontSize <= 12 { | ||
return | ||
} | ||
textViewFontSize -= 1 | ||
userDefaults.setValue(textViewFontSize, forKey: "textViewFontSize") | ||
} | ||
|
||
func increaseTextViewFontSize() { | ||
if textViewFontSize >= 30 { | ||
return | ||
} | ||
textViewFontSize += 1 | ||
userDefaults.setValue(textViewFontSize, forKey: "textViewFontSize") | ||
} | ||
|
||
func getCurrentUsername() -> String { | ||
return currentUsername | ||
} | ||
} |
Oops, something went wrong.