-
Notifications
You must be signed in to change notification settings - Fork 52
/
Copy pathFromTodayPopupView.swift
45 lines (35 loc) · 1.13 KB
/
FromTodayPopupView.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
// Kevin Li - 6:18 PM - 6/25/20
import SwiftUI
struct FromTodayPopupView: View {
@ObservedObject var state: FromTodayPopupState
var body: some View {
fromTodayPopupView
.scaleEffect(state.showFromTodayPopup ? 1 : 0)
.opacity(state.showFromTodayPopup ? 1 : 0)
}
private var fromTodayPopupView: some View {
let weeksToToday = state.weeksFromCurrentMonthToToday
let unitsFromToday: String
if weeksToToday < 8 {
unitsFromToday = "\(weeksToToday) \(weeksToToday != 1 ? "WEEKS" : "WEEK")"
} else {
unitsFromToday = "\(weeksToToday/4) MONTHS"
}
return VStack {
unitsFromTodayText(unitsFromToday)
unitsDescriptionText
}
.transition(.identity)
.id("FromTodayPopup\(weeksToToday)")
}
private func unitsFromTodayText(_ text: String) -> some View {
Text(text)
.font(.headline)
.fontWeight(.semibold)
.tracking(2.5)
}
private var unitsDescriptionText: some View {
Text("AGO")
.font(.system(size: 10))
}
}