wip
This commit is contained in:
22
Workouts Watch App/Utils/AppLogger.swift
Normal file
22
Workouts Watch App/Utils/AppLogger.swift
Normal 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)")
|
||||
}
|
||||
}
|
21
Workouts Watch App/Utils/Color+color.swift
Normal file
21
Workouts Watch App/Utils/Color+color.swift
Normal 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
|
||||
}
|
||||
}
|
||||
}
|
9
Workouts Watch App/Utils/Date+formatDate.swift
Normal file
9
Workouts Watch App/Utils/Date+formatDate.swift
Normal file
@ -0,0 +1,9 @@
|
||||
import Foundation
|
||||
|
||||
extension Date {
|
||||
func formatDate() -> String {
|
||||
let formatter = DateFormatter()
|
||||
formatter.dateStyle = .short
|
||||
return formatter.string(from: self)
|
||||
}
|
||||
}
|
14
Workouts Watch App/Utils/Date+formatDateET.swift
Normal file
14
Workouts Watch App/Utils/Date+formatDateET.swift
Normal 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"
|
||||
}
|
||||
}
|
9
Workouts Watch App/Utils/Date+formatedDate.swift
Normal file
9
Workouts Watch App/Utils/Date+formatedDate.swift
Normal file
@ -0,0 +1,9 @@
|
||||
import Foundation
|
||||
|
||||
extension Date {
|
||||
func formattedDate() -> String {
|
||||
let formatter = DateFormatter()
|
||||
formatter.dateStyle = .short
|
||||
return formatter.string(from: self)
|
||||
}
|
||||
}
|
33
Workouts Watch App/Utils/HapticFeedback.swift
Normal file
33
Workouts Watch App/Utils/HapticFeedback.swift
Normal 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)
|
||||
}
|
||||
}
|
||||
}
|
18
Workouts Watch App/Utils/TimeInterval+formatted.swift
Normal file
18
Workouts Watch App/Utils/TimeInterval+formatted.swift
Normal file
@ -0,0 +1,18 @@
|
||||
//
|
||||
// TimeInterval+minutesSecons.swift
|
||||
// Workouts
|
||||
//
|
||||
// Created by rzen on 7/23/25 at 4:22 PM.
|
||||
//
|
||||
// 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)
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user