This commit is contained in:
2025-07-25 17:30:11 -04:00
parent 310c120ca3
commit 3fd6887ce7
55 changed files with 1062 additions and 649 deletions

View File

@ -0,0 +1,22 @@
import Foundation
import OSLog
struct AppLogger {
private let logger: Logger
init(subsystem: String, category: String) {
self.logger = Logger(subsystem: subsystem, category: category)
}
func debug(_ message: String) {
logger.debug("\(message)")
}
func info(_ message: String) {
logger.info("\(message)")
}
func error(_ message: String) {
logger.error("\(message)")
}
}

View File

@ -0,0 +1,21 @@
import SwiftUI
extension Color {
static func color(from name: String) -> Color {
switch name {
case "red": return .red
case "orange": return .orange
case "yellow": return .yellow
case "green": return .green
case "mint": return .mint
case "teal": return .teal
case "cyan": return .cyan
case "blue": return .blue
case "indigo": return .indigo
case "purple": return .purple
case "pink": return .pink
case "brown": return .brown
default: return .indigo
}
}
}

View File

@ -0,0 +1,9 @@
import Foundation
extension Date {
func formatDate() -> String {
let formatter = DateFormatter()
formatter.dateStyle = .short
return formatter.string(from: self)
}
}

View File

@ -0,0 +1,14 @@
import Foundation
extension Date {
func formatDateET(format: String = "MMMM, d yyyy @ h:mm a z") -> String {
let formatter = DateFormatter()
formatter.timeZone = TimeZone(identifier: "America/New_York")
formatter.dateFormat = format
return formatter.string(from: self)
}
static var ISO8601: String {
"yyyy-MM-dd'T'HH:mm:ssZ"
}
}

View File

@ -0,0 +1,9 @@
import Foundation
extension Date {
func formattedDate() -> String {
let formatter = DateFormatter()
formatter.dateStyle = .short
return formatter.string(from: self)
}
}

View File

@ -0,0 +1,33 @@
import Foundation
import WatchKit
struct HapticFeedback {
static func success() {
WKInterfaceDevice.current().play(.success)
}
static func notification() {
WKInterfaceDevice.current().play(.notification)
}
static func click() {
WKInterfaceDevice.current().play(.click)
}
static func doubleTap() {
WKInterfaceDevice.current().play(.click)
DispatchQueue.main.asyncAfter(deadline: .now() + 0.3) {
WKInterfaceDevice.current().play(.click)
}
}
static func tripleTap() {
WKInterfaceDevice.current().play(.notification)
DispatchQueue.main.asyncAfter(deadline: .now() + 0.3) {
WKInterfaceDevice.current().play(.notification)
}
DispatchQueue.main.asyncAfter(deadline: .now() + 0.6) {
WKInterfaceDevice.current().play(.notification)
}
}
}

View File

@ -0,0 +1,18 @@
//
// TimeInterval+minutesSecons.swift
// Workouts
//
// Created by rzen on 7/23/25 at 4:22PM.
//
// Copyright 2025 Rouslan Zenetl. All Rights Reserved.
//
import Foundation
extension Int {
var secondsFormatted: String {
let minutes = self / 60
let seconds = self % 60
return String(format: "%02d:%02d", minutes, seconds)
}
}