Skip to content

Commit d8b4b63

Browse files
committed
refactor: split into smaller classes
1 parent 6f909f0 commit d8b4b63

File tree

6 files changed

+621
-311
lines changed

6 files changed

+621
-311
lines changed

Pricey/Constants.swift

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import Foundation
2+
3+
struct AppConstants {
4+
static let updateInterval: TimeInterval = 5.0
5+
static let animationDuration: TimeInterval = 1.0
6+
static let animationFrameRate: Double = 60.0
7+
static let workDaysPerYear: Double = 260.0
8+
9+
struct Defaults {
10+
static let linesPerDay = 100
11+
static let yearlySalary = 100_000
12+
}
13+
14+
struct Colors {
15+
static let linesAdded = (red: 0x3F, green: 0xBA, blue: 0x50)
16+
static let linesRemoved = (red: 0xD1, green: 0x24, blue: 0x2F)
17+
}
18+
19+
struct Paths {
20+
static func claudeProjectsPath() -> String {
21+
let homeDirectory = FileManager.default.homeDirectoryForCurrentUser.path
22+
return "\(homeDirectory)/.claude/projects"
23+
}
24+
}
25+
}

Pricey/FormatterService.swift

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
import Foundation
2+
3+
class FormatterService {
4+
static let shared = FormatterService()
5+
6+
let currencyFormatter: NumberFormatter = {
7+
let formatter = NumberFormatter()
8+
formatter.numberStyle = .currency
9+
formatter.currencyCode = "USD"
10+
formatter.maximumFractionDigits = 3
11+
formatter.minimumFractionDigits = 3
12+
return formatter
13+
}()
14+
15+
let numberFormatter: NumberFormatter = {
16+
let formatter = NumberFormatter()
17+
formatter.numberStyle = .decimal
18+
formatter.maximumFractionDigits = 0
19+
return formatter
20+
}()
21+
22+
let salaryFormatter: NumberFormatter = {
23+
let formatter = NumberFormatter()
24+
formatter.numberStyle = .currency
25+
formatter.currencyCode = "USD"
26+
formatter.maximumFractionDigits = 0
27+
return formatter
28+
}()
29+
30+
func formatCurrency(_ value: Double) -> String {
31+
return currencyFormatter.string(from: NSNumber(value: value)) ?? "$0.000"
32+
}
33+
34+
func formatNumber(_ value: Int64) -> String {
35+
return numberFormatter.string(from: NSNumber(value: value)) ?? "0"
36+
}
37+
38+
func formatSalary(_ value: Int) -> String {
39+
return salaryFormatter.string(from: NSNumber(value: value)) ?? "$0"
40+
}
41+
42+
func formatVibeTime(seconds: Int64) -> String {
43+
let totalMinutes = Int(seconds / 60)
44+
let minutes = totalMinutes % 60
45+
let hours = totalMinutes / 60
46+
return String(format: "%02d:%02d", hours, minutes)
47+
}
48+
}

0 commit comments

Comments
 (0)