Skip to content

Commit

Permalink
Today: Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
Dimillian committed May 13, 2020
1 parent 0f266be commit d655a12
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 52 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,27 +16,25 @@ struct TodayBirthdaysSection: View {
var headerText: String {
villagers.count > 1 ? "Today's Birthdays" : "Today's Birthday"
}

func birthdayDay(for villager: Villager) -> String {
guard let birthday = villager.birthday else { return "" }
private func formattedDate(for villager: Villager) -> Date {
guard let birthday = villager.birthday else { return Date() }
let formatter = DateFormatter()

formatter.dateFormat = "d/M"
let birthdayDate = formatter.date(from: birthday)!
return formatter.date(from: birthday) ?? Date()
}

private func birthdayDay(for villager: Villager) -> String {
let formatter = DateFormatter()
formatter.setLocalizedDateFormatFromTemplate("dd")
return formatter.string(from: birthdayDate)
return formatter.string(from: formattedDate(for: villager))
}

func birthdayMonth(for villager: Villager) -> String {
guard let birthday = villager.birthday else { return "" }
private func birthdayMonth(for villager: Villager) -> String {
let formatter = DateFormatter()

formatter.dateFormat = "d/M"
let birthdayDate = formatter.date(from: birthday)!

formatter.setLocalizedDateFormatFromTemplate("MMM")
return formatter.string(from: birthdayDate)
return formatter.string(from: formattedDate(for: villager))
}

var body: some View {
Expand Down Expand Up @@ -82,34 +80,6 @@ struct TodayBirthdaysSection: View {

}
}

private func makeDateTitleIconCell(month: String, day: String, title: String, image: String = "") -> some View {
HStack {
VStack(alignment: .leading) {
Text("\(month) \(day)")
.font(.system(.subheadline, design: .rounded))
.fontWeight(.bold)
.foregroundColor(Color("ACSecondaryText"))
.padding(.bottom, 4)

Text(title)
.font(Font.system(.headline, design: .rounded))
.fontWeight(.semibold)
.lineLimit(2)
.foregroundColor(.acText)

}

if image != "" {
Spacer()
Image(image)
.resizable()
.aspectRatio(1, contentMode: .fit)
.frame(width: 44)
}
}
.padding(.vertical)
}
}

//struct TodayBirthdaysSection_Previews: PreviewProvider {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,6 @@ struct TodayEventsSection: View {
let todaysEvents = Date().events(for: AppUserDefaults.shared.hemisphere == .north ? .north : .south)
let nextEvent = Event.nextEvent()

// var body_old: some View {
// Section(header: SectionHeaderView(text: "Events", icon: "flag.fill")) {
// NavigationLink(destination: Text("Event 1 Detail View")) {
// makeCell(month: "May", day: "1-7", title: "May Day")
// }
//
// NavigationLink(destination: Text("Event 2 Detail View")) {
// makeCell(month: "May", day: "18-31", title: "International Museum Day")
// }
// }
// }

var body: some View {
Section(header: SectionHeaderView(text: "Events", icon: "flag.fill")) {
Expand Down

0 comments on commit d655a12

Please sign in to comment.