This commit is contained in:
2025-07-19 16:42:47 -04:00
parent 6e46775f58
commit e3c3f2c6f0
38 changed files with 556 additions and 367 deletions

View File

@ -0,0 +1,94 @@
//
// CalendarListItem.swift
// Workouts
//
// Created by rzen on 7/18/25 at 8:44AM.
//
// Copyright 2025 Rouslan Zenetl. All Rights Reserved.
//
import SwiftUI
struct CalendarListItem: View {
var date: Date
var title: String
var subtitle: String?
var subtitle2: String?
var count: Int?
var body: some View {
HStack (alignment: .top) {
ZStack {
VStack {
Text("\(date.abbreviatedWeekday)")
.font(.caption)
.foregroundColor(.secondary)
Text("\(date.dayOfMonth)")
.font(.headline)
.foregroundColor(.accentColor)
Text("\(date.abbreviatedMonth)")
.font(.caption)
.foregroundColor(.secondary)
}
.padding([.trailing], 10)
}
HStack (alignment: .top) {
VStack (alignment: .leading) {
Text("\(title)")
.font(.headline)
if let subtitle = subtitle {
Text("\(subtitle)")
.font(.footnote)
}
if let subtitle = subtitle2 {
Text("\(subtitle)")
.font(.footnote)
}
}
if let count = count {
Spacer()
Text("\(count)")
.font(.caption)
.foregroundColor(.gray)
}
}
}
.frame(maxWidth: .infinity, alignment: .leading)
.contentShape(Rectangle())
}
}
extension Date {
private static let monthFormatter: DateFormatter = {
let formatter = DateFormatter()
formatter.locale = Locale.current
formatter.dateFormat = "MMM"
return formatter
}()
private static let dayFormatter: DateFormatter = {
let formatter = DateFormatter()
formatter.locale = Locale.current
formatter.dateFormat = "d"
return formatter
}()
private static let weekdayFormatter: DateFormatter = {
let formatter = DateFormatter()
formatter.locale = Locale.current
formatter.dateFormat = "E"
return formatter
}()
var abbreviatedMonth: String {
Date.monthFormatter.string(from: self)
}
var dayOfMonth: String {
Date.dayFormatter.string(from: self)
}
var abbreviatedWeekday: String {
Date.weekdayFormatter.string(from: self)
}
}

View File

@ -0,0 +1,71 @@
//
// ListItem.swift
// Workouts
//
// Created by rzen on 7/13/25 at 10:42AM.
//
// Copyright 2025 Rouslan Zenetl. All Rights Reserved.
//
import SwiftUI
enum CheckboxStatus {
case checked
case unchecked
case intermediate
case cancelled
var color: Color {
switch (self) {
case .checked: .green
case .unchecked: .gray
case .intermediate: .yellow
case .cancelled: .red
}
}
var systemName: String {
switch (self) {
case .checked: "checkmark.circle.fill"
case .unchecked: "circle"
case .intermediate: "ellipsis.circle"
case .cancelled: "cross.circle"
}
}
}
struct CheckboxListItem: View {
var status: CheckboxStatus
var title: String
var subtitle: String?
var count: Int?
var body: some View {
HStack (alignment: .top) {
Image(systemName: status.systemName)
.resizable()
.scaledToFit()
.frame(width: 30)
.foregroundStyle(status.color)
VStack (alignment: .leading) {
Text("\(title)")
.font(.headline)
HStack (alignment: .bottom) {
if let subtitle = subtitle {
Text("\(subtitle)")
.font(.footnote)
}
}
}
if let count = count {
Spacer()
Text("\(count)")
.font(.caption)
.foregroundColor(.gray)
}
}
.frame(maxWidth: .infinity, alignment: .leading)
.contentShape(Rectangle())
}
}

View File

@ -0,0 +1,57 @@
//
// ListItem.swift
// Workouts
//
// Created by rzen on 7/13/25 at 10:42AM.
//
// Copyright 2025 Rouslan Zenetl. All Rights Reserved.
//
import SwiftUI
struct ListItem: View {
var title: String?
var text: String?
var subtitle: String?
var count: Int?
// var badges: [Badge]? = []
var body: some View {
HStack {
VStack (alignment: .leading) {
if let title = title {
Text("\(title)")
.font(.headline)
if let text = text {
Text("\(text)")
.font(.footnote)
}
} else {
if let text = text {
Text("\(text)")
}
}
HStack (alignment: .bottom) {
// if let badges = badges {
// ForEach (badges, id: \.self) { badge in
// BadgeView(badge: badge)
// }
// }
if let subtitle = subtitle {
Text("\(subtitle)")
.font(.footnote)
}
}
}
if let count = count {
Spacer()
Text("\(count)")
.font(.caption)
.foregroundColor(.gray)
}
}
.frame(maxWidth: .infinity, alignment: .leading)
.contentShape(Rectangle())
}
}