-
Notifications
You must be signed in to change notification settings - Fork 2
✨[feat]: 폰트 변경 추가, userdefault 사용 #7
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
base: Dev
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -15,10 +15,15 @@ struct TaskManagerView: View { | |
| @Environment(\.managedObjectContext) var context | ||
| // MARK: Edit Button Context | ||
| @Environment(\.editMode) var editButton | ||
| // MARK: Font Select | ||
| @EnvironmentObject var fontSettings: FontSettings | ||
|
|
||
| var body: some View { | ||
| VStack { | ||
| calenderView() | ||
| NavigationView { | ||
| VStack { | ||
| calenderView() | ||
| } | ||
|
|
||
| } | ||
| } | ||
|
|
||
|
|
@@ -34,7 +39,7 @@ struct TaskManagerView: View { | |
|
|
||
| HStack(spacing: 10){ | ||
|
|
||
| ForEach(taskModel.currentWeek,id: \.self){day in | ||
| ForEach(taskModel.currentWeek, id: \.self){day in | ||
|
|
||
| VStack(spacing: 10){ | ||
| Text(taskModel.extractDate(date: day, format: "dd")) | ||
|
|
@@ -54,9 +59,9 @@ struct TaskManagerView: View { | |
| .foregroundStyle(taskModel.isToday(date: day) ? .primary : .secondary) | ||
| .foregroundColor(taskModel.isToday(date: day) ? .white : ColorAsset.dateColor) | ||
| // MARK: Capsule Shape | ||
| .frame(width: (gemotry.size.width / 9) , height: (gemotry.size.height / 9)) | ||
| .frame(width: (gemotry.size.width / 9), height: (gemotry.size.height / 9)) | ||
| .background( | ||
|
|
||
| ZStack{ | ||
| // MARK: Matched Geometry Effect | ||
| if taskModel.isToday(date: day){ | ||
|
|
@@ -88,14 +93,14 @@ struct TaskManagerView: View { | |
| .ignoresSafeArea(.container, edges: .top) | ||
| // MARK: Add Button | ||
| .overlay( | ||
|
|
||
| Button(action: { | ||
| taskModel.addNewTask.toggle() | ||
| }, label: { | ||
| Image(systemName: "plus") | ||
| .foregroundColor(.white) | ||
| .padding() | ||
| .background(ColorAsset.mainViewColor,in: Circle()) | ||
| .background(ColorAsset.mainViewColor, in: Circle()) | ||
| }) | ||
| .padding() | ||
|
|
||
|
|
@@ -123,9 +128,9 @@ struct TaskManagerView: View { | |
| } | ||
| // MARK: Task Card View | ||
| @ViewBuilder | ||
| func taskCardView(task: Task)->some View{ | ||
| func taskCardView(task: Task) -> some View{ | ||
| // MARK: Since CoreData Values will Give Optinal data | ||
| HStack(alignment: editButton?.wrappedValue == .active ? .center : .top,spacing: 30){ | ||
| HStack(alignment: editButton?.wrappedValue == .active ? .center : .top, spacing: 30){ | ||
| // If Edit mode enabled then showing Delete Button | ||
| if editButton?.wrappedValue == .active{ | ||
| // Edit Button for Current and Future Tasks | ||
|
|
@@ -160,9 +165,9 @@ struct TaskManagerView: View { | |
| .fill(taskModel.isCurrentHour(date: task.taskDate ?? Date()) ? (task.isCompleted ? .green : ColorAsset.dateColor) : .clear) | ||
| .frame(width: 15, height: 15) | ||
| .background( | ||
|
|
||
| Circle() | ||
| .stroke(ColorAsset.dateColor,lineWidth: 0.5) | ||
| .stroke(ColorAsset.dateColor, lineWidth: 0.5) | ||
| .padding(-3) | ||
| ) | ||
| .scaleEffect(!taskModel.isCurrentHour(date: task.taskDate ?? Date()) ? 0.8 : 1) | ||
|
|
@@ -179,13 +184,16 @@ struct TaskManagerView: View { | |
| VStack(alignment: .leading, spacing: 12) { | ||
|
|
||
| Text(task.taskTitle ?? "") | ||
| .font(.title2.bold()) | ||
| .foregroundColor(ColorAsset.dateColor) | ||
| .font(.custom(fontSettings.selectedFont.rawValue, size: 20)) | ||
| //.font(.title2.bold()) | ||
| //.foregroundColor(ColorAsset.dateColor) | ||
|
|
||
| Text(task.taskDescription ?? "") | ||
| .font(.callout) | ||
| .foregroundColor(Color(.lightGray)) | ||
| .foregroundStyle(.secondary) | ||
| //.font(.callout) | ||
| //.foregroundColor(Color(.lightGray)) | ||
| //.foregroundStyle(.secondary) | ||
| .font(.custom(fontSettings.selectedFont.rawValue, size: 20)) | ||
|
|
||
| } | ||
| .hLeading() | ||
|
|
||
|
|
@@ -208,7 +216,7 @@ struct TaskManagerView: View { | |
| Image(systemName: "checkmark") | ||
| .foregroundStyle(.black) | ||
| .padding(10) | ||
| .background(ColorAsset.titleColor,in: RoundedRectangle(cornerRadius: 10)) | ||
| .background(ColorAsset.titleColor, in: RoundedRectangle(cornerRadius: 10)) | ||
| } | ||
| } | ||
| Text(task.isCompleted ? "Marked as Completed" : "Mark Task as Completed") | ||
|
|
@@ -222,7 +230,7 @@ struct TaskManagerView: View { | |
| .foregroundColor(taskModel.isCurrentHour(date: task.taskDate ?? Date()) ? ColorAsset.dateColor : ColorAsset.dateColor) | ||
|
|
||
| .padding(taskModel.isCurrentHour(date: task.taskDate ?? Date()) ? 15 : 0) | ||
| .padding(.bottom,taskModel.isCurrentHour(date: task.taskDate ?? Date()) ? 0 : 10) | ||
| .padding(.bottom, taskModel.isCurrentHour(date: task.taskDate ?? Date()) ? 0 : 10) | ||
| .hLeading() | ||
| .background( | ||
| Color("MainColor2") | ||
|
|
@@ -234,7 +242,7 @@ struct TaskManagerView: View { | |
| } | ||
| // MARK: Header | ||
| @ViewBuilder | ||
| func headerView()->some View{ | ||
| func headerView() -> some View{ | ||
| HStack(spacing: 10){ | ||
| VStack(alignment: .leading, spacing: 10) { | ||
| Text(Date().formatted(date: .abbreviated, time: .omitted)) | ||
|
|
@@ -247,14 +255,42 @@ struct TaskManagerView: View { | |
| // MARK: Edit Button | ||
| EditButton() | ||
| .foregroundColor(ColorAsset.mainViewColor) | ||
| // MARK: Setting Button | ||
| NavigationLink { | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @cyberman0306 여기에서 settingView는 무슨 역활을 하나요 ?? |
||
| settingView() | ||
| } label: { | ||
| Text("설정") | ||
| } | ||
|
|
||
| } | ||
| .padding() | ||
| .padding(.top,getSafeArea().top) | ||
| .padding(.top, getSafeArea().top) | ||
| } | ||
|
|
||
| @ViewBuilder | ||
| func settingView() -> some View { | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @cyberman0306 여기에서 viewbuilder 사용 하는거 좋아요 !! |
||
| VStack { | ||
| List(FontType.allCases, id: \.self) { font in | ||
| Button { | ||
| fontSettings.selectedFont = font | ||
| } label: { | ||
| HStack { | ||
| Text(font.rawValue) | ||
| if font == fontSettings.selectedFont { | ||
| Spacer() | ||
| Image(systemName: "checkmark") | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
| .navigationTitle("본문 폰트 설정") | ||
|
|
||
| } | ||
| } | ||
|
|
||
| struct TaskManagerView_Previews: PreviewProvider { | ||
| static var previews: some View { | ||
| TaskManagerView() | ||
| TaskManagerView() | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,3 +11,21 @@ struct Fonts { | |
| static let mainFont: String = "나눔손글씨 둥근인연" | ||
| static let subFont: String = "나눔손글씨 맛있는체" | ||
| } | ||
|
|
||
| enum FontType: String, CaseIterable { | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @cyberman0306 안녕하세요 현준님 |
||
| case mainFont = "나눔손글씨 둥근인연" | ||
| case subFont = "나눔손글씨 맛있는체" | ||
| } | ||
|
|
||
| class FontSettings: ObservableObject { | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @cyberman0306 여기에는 왜 class 로 사용 했나용 ?? |
||
| @Published var selectedFont: FontType { | ||
| didSet { | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @cyberman0306 여기에서 왜 didSet을 사용 했나요 ?? 왜 사용한지 이유를 알수 있을까요 ???/ |
||
| UserDefaults.standard.set(selectedFont.rawValue, forKey: "SelectedFont") | ||
| } | ||
| } | ||
|
|
||
| init() { | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @cyberman0306 여기에서 init이 필요했을까요 ?? 필요했다면 이유를 알고 싶어요!! |
||
| let savedFont = UserDefaults.standard.string(forKey: "SelectedFont") ?? FontType.mainFont.rawValue | ||
| selectedFont = FontType(rawValue: savedFont) ?? .mainFont | ||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@cyberman0306 여기에서 왜 EnvironmentObject을 사용하셨나요 ?? 그러면 EnvironmentObject 역활에 대해서 설명부탁드려도 될까요 ??