-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPrayerTimesView.swift
93 lines (80 loc) · 2.92 KB
/
PrayerTimesView.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
//
// PrayerTimesView.swift
// Arkan
import SwiftUI
import Charts
struct PrayerTimesView: View {
var currentPrayerIndex: Int
@ObservedObject var prayerData = PrayerData.shared
private var orderedPrayerTimes: [String] {
prayerData.prayers.map { prayerData.timings[$0] ?? "--:--" }
}
var body: some View {
ZStack {
RoundedRectangle(cornerRadius: 25)
Color.appBackground
.blendMode(.overlay)
VStack(spacing: 30) {
// Prayer Intervals Chart.
VStack(alignment: .leading, spacing: 10) {
Text("Prayer Intervals")
.font(.title2)
.bold()
.foregroundColor(.white)
.padding(.horizontal)
.shadow(color: .black.opacity(0.7), radius: 2, x: 0, y: 1)
PrayerLineChartView(prayerData: prayerData, currentTime: Date())
}
.padding(.vertical)
// All Prayer Times List.
VStack(alignment: .leading, spacing: 10) {
Text("All Prayer Times")
.font(.title2)
.bold()
.foregroundColor(.white)
.padding(.horizontal)
.shadow(color: .black.opacity(0.7), radius: 2, x: 0, y: 1)
ForEach(0..<prayerData.prayers.count, id: \.self) { index in
PrayerRow(
prayerName: prayerData.prayers[index],
time: prayerData.timings[prayerData.prayers[index]] ?? "--:--",
isPast: index < currentPrayerIndex
)
.padding(.horizontal)
}
}
.padding(.vertical)
}
.padding(30)
}
.padding()
}
}
// Reusable Prayer Row.
struct PrayerRow: View {
let prayerName: String
let time: String
var isPast: Bool = false
var body: some View {
HStack {
Text(prayerName)
.fontWeight(.semibold)
.foregroundColor(.white)
.opacity(isPast ? 0.7 : 1.0)
.shadow(color: .black.opacity(0.5), radius: 1, x: 0, y: 1)
Spacer()
Text(time)
.fontWeight(.bold)
.foregroundColor(.white)
.opacity(isPast ? 0.7 : 1.0)
.shadow(color: .black.opacity(0.5), radius: 1, x: 0, y: 1)
}
.padding(.vertical, 8)
.padding(.horizontal, 15)
.background(
RoundedRectangle(cornerRadius: 15)
.fill(LinearGradient(colors: [Color.blue.opacity(isPast ? 0.1 : 0.2), Color.clear], startPoint: .leading, endPoint: .trailing))
.blendMode(.plusLighter)
)
}
}