Skip to content

Commit

Permalink
refactor: AppStorage 문자열 에서 STROAGE enum 값으로 리팩토링
Browse files Browse the repository at this point in the history
  • Loading branch information
hyeonghwan committed May 8, 2024
1 parent b09835f commit 3b1f6fa
Show file tree
Hide file tree
Showing 14 changed files with 54 additions and 28 deletions.
4 changes: 4 additions & 0 deletions Pickle/Pickle.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,7 @@
96A401122BE8D259004C30EC /* HeaderActionView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96A401112BE8D259004C30EC /* HeaderActionView.swift */; };
96A401142BE8D47B004C30EC /* TodayPizzaSummaryView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96A401132BE8D47B004C30EC /* TodayPizzaSummaryView.swift */; };
96A401162BE8D526004C30EC /* TodayPizzaSheetView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96A401152BE8D526004C30EC /* TodayPizzaSheetView.swift */; };
96A9DBE02BEB73B700B40A2A /* STORAGE.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96A9DBDF2BEB73B700B40A2A /* STORAGE.swift */; };
96AAF8302AFD3A7B00410881 /* Dictionary.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96AAF82F2AFD3A7B00410881 /* Dictionary.swift */; };
96AAF8322AFD509200410881 /* Mediator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96AAF8312AFD509200410881 /* Mediator.swift */; };
96AAF8372AFD50F900410881 /* NotiMediator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96AAF8362AFD50F900410881 /* NotiMediator.swift */; };
Expand Down Expand Up @@ -445,6 +446,7 @@
96A401112BE8D259004C30EC /* HeaderActionView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HeaderActionView.swift; sourceTree = "<group>"; };
96A401132BE8D47B004C30EC /* TodayPizzaSummaryView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TodayPizzaSummaryView.swift; sourceTree = "<group>"; };
96A401152BE8D526004C30EC /* TodayPizzaSheetView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TodayPizzaSheetView.swift; sourceTree = "<group>"; };
96A9DBDF2BEB73B700B40A2A /* STORAGE.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = STORAGE.swift; sourceTree = "<group>"; };
96AAF82F2AFD3A7B00410881 /* Dictionary.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Dictionary.swift; sourceTree = "<group>"; };
96AAF8312AFD509200410881 /* Mediator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Mediator.swift; sourceTree = "<group>"; };
96AAF8362AFD50F900410881 /* NotiMediator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NotiMediator.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -784,6 +786,7 @@
isa = PBXGroup;
children = (
9619E93B2B0594210028348C /* ScrollEnableKey.swift */,
96A9DBDF2BEB73B700B40A2A /* STORAGE.swift */,
);
path = EnvironmentValues;
sourceTree = "<group>";
Expand Down Expand Up @@ -1473,6 +1476,7 @@
9661108B2AFA84CA008A80DE /* PreferenceKey.swift in Sources */,
9661107C2AF800AD008A80DE /* Realm+Combine.swift in Sources */,
966B031E2B07B4CE009B6293 /* HomeViewModel.swift in Sources */,
96A9DBE02BEB73B700B40A2A /* STORAGE.swift in Sources */,
966CD9F12B0A6BA2003AE885 /* Register-extension.swift in Sources */,
96AAF8372AFD50F900410881 /* NotiMediator.swift in Sources */,
96EB8C1E2B029AF20011B973 /* CurrentPizza-extension.swift in Sources */,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@
}
}
],
"version" : 2
"version" : 3
}
4 changes: 2 additions & 2 deletions Pickle/Pickle/Screen/App/ContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
import SwiftUI

struct ContentView: View {
@AppStorage("onboarding") var isOnboardingViewActive: Bool = true
@AppStorage("systemTheme") private var systemTheme: Int = SchemeType.allCases.first!.rawValue
@AppStorage(STORAGE.onboarding.id) var isOnboardingViewActive: Bool = true
@AppStorage(STORAGE.systemTheme.id) private var systemTheme: Int = SchemeType.allCases.first!.rawValue

@EnvironmentObject var pizzaStore: PizzaStore
@EnvironmentObject var userStore: UserStore
Expand Down
13 changes: 6 additions & 7 deletions Pickle/Pickle/Screen/App/PickleApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,15 @@ struct PickleApp: App {
@StateObject private var notificationManager = NotificationManager(mediator: NotiMediator.shared)
@StateObject private var timerVM = TimerViewModel()

init() {
Thread.sleep(forTimeInterval: 1)
}

@Environment(\.scenePhase) var scenePhase
@State private var debugDelete: Bool = true
@AppStorage(STORAGE.backgroundNumber.id) var backgroundNumber: Int = 0
@AppStorage(STORAGE.isRunTimer.id) var isRunTimer: Bool = false
@AppStorage(STORAGE.todoId.id) var todoId: String = ""

@AppStorage("backgroundNumber") var backgroundNumber: Int = 0
@AppStorage("isRunTimer") var isRunTimer: Bool = false
@AppStorage("todoId") var todoId: String = ""
init() {
Thread.sleep(forTimeInterval: 1)
}

var body: some Scene {
WindowGroup {
Expand Down
4 changes: 2 additions & 2 deletions Pickle/Pickle/Screen/Calendar/View/TaskRowView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import SwiftUI
struct TaskRowView: View {

@State private var isShowingReportSheet: Bool = false
@AppStorage("is24HourClock") private var is24HourClock: Bool = true
@AppStorage("timeFormat") private var timeFormat: String = "HH:mm"
@AppStorage(STORAGE.is24HourClock.id) private var is24HourClock: Bool = true
@AppStorage(STORAGE.timeFormat.id) private var timeFormat: String = "HH:mm"

var task: Todo
var indicatorColor: Color {
Expand Down
4 changes: 2 additions & 2 deletions Pickle/Pickle/Screen/Home/HomeView/View/HomeView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ struct HomeView: View {
@State private var description: String = ""

@State private var ongoingTodo: Todo = Todo.onGoing
@AppStorage("isRunTimer") var isRunTimer: Bool = false
@AppStorage("todoId") var todoId: String = ""
@AppStorage(STORAGE.isRunTimer.id) var isRunTimer: Bool = false
@AppStorage(STORAGE.todoId.id) var todoId: String = ""

var body: some View {
content
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import SwiftUI

struct TodoCellView: View {

@AppStorage("is24HourClock") var is24HourClock: Bool = true
@AppStorage("timeFormat") var timeFormat: String = "HH:mm"
@AppStorage(STORAGE.is24HourClock.id) var is24HourClock: Bool = true
@AppStorage(STORAGE.timeFormat.id) var timeFormat: String = "HH:mm"

@Environment(\.colorScheme) var colorScheme
@EnvironmentObject var navigationStore: NavigationStore
Expand Down
4 changes: 2 additions & 2 deletions Pickle/Pickle/Screen/Home/MissionView/MissionStyleView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -338,8 +338,8 @@ struct MissionStyle_Previews: PreviewProvider {
// @EnvironmentObject var userStore: UserStore
// @Binding var timeMission: TimeMission
//
// @AppStorage("is24HourClock") var is24HourClock: Bool = true
// @AppStorage("timeFormat") var timeFormat: String = "HH:mm"
// @AppStorage(STORAGE.is24HourClock.id) var is24HourClock: Bool = true
// @AppStorage(STORAGE.timeFormat.id) var timeFormat: String = "HH:mm"
//
// @State private var showTimeMissionModal = false
// @Binding var showsAlert: Bool
Expand Down
4 changes: 2 additions & 2 deletions Pickle/Pickle/Screen/Home/MissionView/MissionView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ struct MissionView: View {
@EnvironmentObject var missionStore: MissionStore
@EnvironmentObject var healthKitStore: HealthKitStore

@AppStorage("is24HourClock") var is24HourClock: Bool = true
@AppStorage("timeFormat") var timeFormat: String = "HH:mm"
@AppStorage(STORAGE.is24HourClock.id) var is24HourClock: Bool = true
@AppStorage(STORAGE.timeFormat.id) var timeFormat: String = "HH:mm"

@State private var showsAlert: Bool = false
@State private var showSuccessAlert: Bool = false
Expand Down
4 changes: 2 additions & 2 deletions Pickle/Pickle/Screen/Home/TimerView/TimerReportView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ struct TimerReportView: View {
@Binding var isShowingReportSheet: Bool
@Binding var isShowingTimerView: Bool

@AppStorage("is24HourClock") var is24HourClock: Bool = true
@AppStorage("timeFormat") var timeFormat: String = "HH:mm"
@AppStorage(STORAGE.is24HourClock.id) var is24HourClock: Bool = true
@AppStorage(STORAGE.timeFormat.id) var timeFormat: String = "HH:mm"

var todo: Todo

Expand Down
6 changes: 3 additions & 3 deletions Pickle/Pickle/Screen/Home/TimerView/TimerView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ struct TimerView: View {
@State private var state: TimerState = TimerState()
@Binding var isShowingTimerView: Bool
@State private var wiseSaying: String = ""
@AppStorage("isRunTimer") var isRunTimer: Bool = false
@AppStorage("backgroundNumber") var backgroundNumber: Int = 0
@AppStorage("todoId") var todoId: String = ""
@AppStorage(STORAGE.isRunTimer.id) var isRunTimer: Bool = false
@AppStorage(STORAGE.backgroundNumber.id) var backgroundNumber: Int = 0
@AppStorage(STORAGE.todoId.id) var todoId: String = ""

var body: some View {
ZStack {
Expand Down
23 changes: 23 additions & 0 deletions Pickle/Pickle/Screen/Model/EnvironmentValues/STORAGE.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
//
// Env.swift
// Pickle
//
// Created by 박형환 on 5/8/24.
//

import Foundation


enum STORAGE: String {
case backgroundNumber
case isRunTimer
case todoId
case onboarding
case systemTheme
case is24HourClock
case timeFormat

var id: String {
self.rawValue
}
}
2 changes: 1 addition & 1 deletion Pickle/Pickle/Screen/Setting/SettingNotiicationView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import SwiftUI
struct SettingNotiicationView: View {
@EnvironmentObject var notificationManager: NotificationManager

@AppStorage("onboarding") var isOnboardingViewActive: Bool = true
@AppStorage(STORAGE.onboarding.id) var isOnboardingViewActive: Bool = true

@Binding var isShowingOnboarding: Bool

Expand Down
4 changes: 2 additions & 2 deletions Pickle/Pickle/Screen/Setting/SettingView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ struct SettingView: View {
@Environment(\.colorScheme) var colorScheme
@EnvironmentObject var notificationManager: NotificationManager

@AppStorage("systemTheme") private var systemTheme: Int = SchemeType.allCases.first!.rawValue
@AppStorage("is24HourClock") var is24HourClock: Bool = true
@AppStorage(STORAGE.systemTheme.id) private var systemTheme: Int = SchemeType.allCases.first!.rawValue
@AppStorage(STORAGE.is24HourClock.id) var is24HourClock: Bool = true

@State private var isShowingMoveToSettingAlert: Bool = false
@State private var isShowingEmailAlert: Bool = false
Expand Down

0 comments on commit 3b1f6fa

Please sign in to comment.