Skip to content

Commit

Permalink
[Feat] #252 - 텍스트 속성 변경
Browse files Browse the repository at this point in the history
- 요일 구하는 메소드 추가
- 요일과 달성 여부에 따라 위젯 텍스트 색상 변경
  • Loading branch information
yungu0010 committed Apr 22, 2024
1 parent 5485a5b commit 9ecc260
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
7 changes: 4 additions & 3 deletions iOS-NOTTODO/Widget-NOTTODO/View/MediumFamily.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,15 @@ import WidgetKit

struct MediumFamily: View {
var entry: Provider.Entry
@AppStorage("dayOfWeek", store: UserDefaults.shared) var dayOfWeek: String = ""

var body: some View {
let progressPercent = Double(entry.lastThreeTask.filter { $0.completionStatus == .CHECKED }.count) / Double(entry.lastThreeTask.count)
HStack {
VStack {
ZStack {
Text("")
.foregroundStyle(Color.black)
Text(dayOfWeek)
.foregroundStyle(dayOfWeek == "" ? .wdgRed : .ntdBlack)
.font(.custom("Pretendard", size: 18))
.fontWeight(.semibold)
CircularProgressBarView(percent: progressPercent, size: 42, lineWidth: 4.34)}
Expand Down Expand Up @@ -58,7 +59,7 @@ struct MediumFamily: View {
.frame(width: 19, height: 19)

Text(task.title)
.foregroundStyle(.gray1)
.foregroundStyle(task.completionStatus == .CHECKED ? .gray4 : .ntdBlack)
.font(.custom("Pretendard-Regular", size: 11))
.fontWeight(.regular)
Spacer()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,7 @@ extension HomeViewController {

if Utils.dateFormatterString(format: nil, date: today) == date {
UserDefaults.shared?.setSharedCustomArray(data, forKey: "dailyMission")
UserDefaults.shared?.set(getDayOfWeek(date: today), forKey: "dayOfWeek")
}
}
}
Expand Down Expand Up @@ -322,6 +323,13 @@ extension HomeViewController {
return sundayInWeek
}

private func getDayOfWeek(date: Date) -> String {
let calendar = Calendar.current
let weekday = calendar.component(.weekday, from: date)

return I18N.weekDay[weekday-1]
}

private func getPercentage(for date: Date) -> Float? {

let dateString = Utils.dateFormatterString(format: nil, date: date)
Expand Down

0 comments on commit 9ecc260

Please sign in to comment.