SnoozerView.swift 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. //
  2. // SnoozerView.swift
  3. // LoopFollow
  4. //
  5. // Created by Jonas Björkert on 2025-04-26.
  6. // Copyright © 2025 Jon Fawcett. All rights reserved.
  7. //
  8. import SwiftUI
  9. struct SnoozerView: View {
  10. @ObservedObject var minAgoText = Observable.shared.minAgoText
  11. @ObservedObject var bgText = Observable.shared.bgText
  12. @ObservedObject var bgTextColor = Observable.shared.bgTextColor
  13. @ObservedObject var directionText = Observable.shared.directionText
  14. @ObservedObject var deltaText = Observable.shared.deltaText
  15. @ObservedObject var bgStale = Observable.shared.bgStale
  16. @Binding var snoozeMinutes: Int
  17. var onSnooze: () -> Void
  18. var body: some View {
  19. ZStack {
  20. Color.black
  21. .edgesIgnoringSafeArea(.all)
  22. VStack(spacing: 0) {
  23. VStack(spacing: 0) {
  24. Text(bgText.value)
  25. .font(.system(size: 220, weight: .black))
  26. .minimumScaleFactor(0.5)
  27. .foregroundColor(bgTextColor.value)
  28. .strikethrough(
  29. bgStale.value,
  30. pattern: .solid,
  31. color: bgStale.value ? .red : .clear
  32. )
  33. .frame(maxWidth: .infinity, maxHeight: 167)
  34. Text(directionText.value)
  35. .font(.system(size: 110, weight: .black))
  36. .minimumScaleFactor(0.5)
  37. .foregroundColor(.white)
  38. .frame(maxWidth: .infinity, maxHeight: 96)
  39. Text(deltaText.value)
  40. .font(.system(size: 70))
  41. .minimumScaleFactor(0.5)
  42. .foregroundColor(.white.opacity(0.8))
  43. .frame(maxWidth: .infinity, maxHeight: 78)
  44. Text(minAgoText.value)
  45. .font(.system(size: 70))
  46. .minimumScaleFactor(0.5)
  47. .foregroundColor(.white.opacity(0.6))
  48. .frame(maxWidth: .infinity, maxHeight: 48)
  49. }
  50. // MARK: Clock + optional alert label
  51. VStack(spacing: 8) {
  52. Text("19:59"/*time.value*/)
  53. .font(.system(size: 70))
  54. .minimumScaleFactor(0.5)
  55. .foregroundColor(.white)
  56. .frame(height: 78)
  57. /*
  58. if let alarm = ""/*alarmText.value*/, !alarm.isEmpty {
  59. Text(alarm)
  60. .font(.system(size: 40, weight: .semibold))
  61. .foregroundColor(.red)
  62. .minimumScaleFactor(0.5)
  63. .lineLimit(1)
  64. .frame(height: 48)
  65. }*/
  66. }
  67. .padding(.vertical, 16)
  68. Spacer()
  69. // MARK: Snooze controls
  70. HStack(spacing: 12) {
  71. Text("Snooze for")
  72. .font(.system(size: 20))
  73. .foregroundColor(.white)
  74. Text("\(snoozeMinutes) min")
  75. .font(.system(size: 20, weight: .semibold))
  76. .foregroundColor(.white)
  77. Spacer()
  78. Stepper("", value: $snoozeMinutes, in: 1...60)
  79. .labelsHidden()
  80. }
  81. .padding(.horizontal, 32)
  82. .frame(height: 44)
  83. Button(action: onSnooze) {
  84. Text("Snooze")
  85. .font(.system(size: 24, weight: .bold))
  86. .frame(maxWidth: .infinity, minHeight: 56)
  87. }
  88. .background(Color(white: 0.15))
  89. .foregroundColor(.white)
  90. .cornerRadius(8)
  91. .padding(.horizontal, 32)
  92. .padding(.bottom, 32)
  93. }
  94. }
  95. }
  96. }