Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion TodoList/TodoList/Sources/Application/TodoListApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,14 @@ import CoreData
struct TodoListApp: App {
let persistenceController = PersistenceController.shared
@State private var showLanchView: Bool = true
@StateObject var fontSettings = FontSettings()

var body: some Scene {
WindowGroup {
ZStack{
TodoLIstMainHomeView()
.environment(\.managedObjectContext, persistenceController.container.viewContext)

.environmentObject(fontSettings)
ZStack{
if showLanchView {
LanchView(showLanchView: $showLanchView)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ struct DynamicFilteredView<Content: View, T>: View where T: NSManagedObject{
Text("할일 추가 하러 가기 🥳")
.font(.custom("나눔손글씨 둥근인연", size: 20))
.foregroundColor(.white)
.frame(width: geometry.size.width / 2 , height: geometry.size.width / 8)
.frame(width: geometry.size.width / 2, height: geometry.size.width / 8)
.frame(maxWidth: .infinity)
.background(animate ? ColorAsset.mainViewColor : ColorAsset.mainColor)
.cornerRadius(12)
Expand Down
78 changes: 57 additions & 21 deletions TodoList/TodoList/Sources/UI/View/MainList/TaskManagerView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cyberman0306 여기에서 왜 EnvironmentObject을 사용하셨나요 ?? 그러면 EnvironmentObject 역활에 대해서 설명부탁드려도 될까요 ??


var body: some View {
VStack {
calenderView()
NavigationView {
VStack {
calenderView()
}

}
}

Expand All @@ -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"))
Expand All @@ -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){
Expand Down Expand Up @@ -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()

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand All @@ -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()

Expand All @@ -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")
Expand All @@ -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")
Expand All @@ -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))
Expand All @@ -247,14 +255,42 @@ struct TaskManagerView: View {
// MARK: Edit Button
EditButton()
.foregroundColor(ColorAsset.mainViewColor)
// MARK: Setting Button
NavigationLink {
Copy link
Owner

Choose a reason for hiding this comment

The 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 {
Copy link
Owner

Choose a reason for hiding this comment

The 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()
}
}
18 changes: 18 additions & 0 deletions TodoList/TodoList/Sources/Utills/Font/Font.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,21 @@ struct Fonts {
static let mainFont: String = "나눔손글씨 둥근인연"
static let subFont: String = "나눔손글씨 맛있는체"
}

enum FontType: String, CaseIterable {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cyberman0306 안녕하세요 현준님
현준님이 하신 방법도 있는데 CustomStringConvertible을 사용하는 방법은 어떤가요 ??

case mainFont = "나눔손글씨 둥근인연"
case subFont = "나눔손글씨 맛있는체"
}

class FontSettings: ObservableObject {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cyberman0306 여기에는 왜 class 로 사용 했나용 ??
커스텀 폰트할때 viewModifier 를 사용하는 건 어떨가요

@Published var selectedFont: FontType {
didSet {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cyberman0306 여기에서 왜 didSet을 사용 했나요 ?? 왜 사용한지 이유를 알수 있을까요 ???/

UserDefaults.standard.set(selectedFont.rawValue, forKey: "SelectedFont")
}
}

init() {
Copy link
Owner

Choose a reason for hiding this comment

The 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
}
}