general: conform reminder pages

This commit is contained in:
Michael Freno
2026-01-08 16:43:34 -05:00
parent 0e43a70a66
commit 4b3a1f99c9
4 changed files with 179 additions and 84 deletions

View File

@@ -0,0 +1,43 @@
//
// InfoBox.swift
// Gaze
//
// Created by Mike Freno on 1/8/26.
//
import SwiftUI
struct InfoBox: View {
let text: String
let url: String?
var body: some View {
HStack(spacing: 12) {
if let url = url, let urlObj = URL(string: url) {
Button(action: {
#if os(iOS)
UIApplication.shared.open(urlObj)
#elseif os(macOS)
NSWorkspace.shared.open(urlObj)
#endif
}) {
Image(systemName: "info.circle")
.foregroundColor(.white)
}.buttonStyle(.plain)
} else {
Image(systemName: "info.circle")
.foregroundColor(.white)
}
Text(text)
.font(.headline)
.foregroundColor(.white)
}
.padding()
.glassEffect(.regular.tint(.blue), in: .rect(cornerRadius: 8))
}
}
#Preview {
InfoBox(text: "This is an informational message that provides helpful context to the user.", url: "https://www.healthline.com/health/eye-health/20-20-20-rule")
.padding()
}

View File

@@ -24,6 +24,31 @@ struct BlinkSetupView: View {
.font(.title3)
.foregroundColor(.secondary)
// InfoBox with link functionality
HStack(spacing: 12) {
Button(action: {
if let url = URL(
string: "https://www.healthline.com/health/eye-health/eye-strain#symptoms")
{
#if os(iOS)
UIApplication.shared.open(url)
#elseif os(macOS)
NSWorkspace.shared.open(url)
#endif
}
}) {
Image(systemName: "info.circle")
.foregroundColor(.white)
}.buttonStyle(.plain)
Text(
"We blink much less when focusing on screens. Regular blink reminders help prevent dry eyes"
)
.font(.headline)
.foregroundColor(.white)
}
.padding()
.glassEffect(.regular.tint(.blue), in: .rect(cornerRadius: 8))
VStack(alignment: .leading, spacing: 20) {
Toggle("Enable Blink Reminders", isOn: $enabled)
.font(.headline)
@@ -35,10 +60,11 @@ struct BlinkSetupView: View {
.foregroundColor(.secondary)
HStack {
Slider(value: Binding(
get: { Double(intervalMinutes) },
set: { intervalMinutes = Int($0) }
), in: 1...15, step: 1)
Slider(
value: Binding(
get: { Double(intervalMinutes) },
set: { intervalMinutes = Int($0) }
), in: 1...15, step: 1)
Text("\(intervalMinutes) min")
.frame(width: 60, alignment: .trailing)
@@ -50,7 +76,9 @@ struct BlinkSetupView: View {
.padding()
.glassEffect(.regular, in: .rect(cornerRadius: 12))
InfoBox(text: "We blink much less when focusing on screens. Regular blink reminders help prevent dry eyes")
Text(
"You will be subtly reminded every \(intervalMinutes) minutes to blink"
)
Spacer()
}

View File

@@ -6,10 +6,11 @@
//
import SwiftUI
#if os(iOS)
import UIKit
#elseif os(macOS)
import AppKit
import UIKit
#else
import AppKit
#endif
struct LookAwaySetupView: View {
@@ -26,7 +27,28 @@ struct LookAwaySetupView: View {
Text("Look Away Reminder")
.font(.system(size: 28, weight: .bold))
InfoBox(text: "Suggested: 20-20-20 rule")
// InfoBox with link functionality
HStack(spacing: 12) {
Button(action: {
if let url = URL(
string: "https://www.healthline.com/health/eye-health/20-20-20-rule")
{
#if os(iOS)
UIApplication.shared.open(url)
#elseif os(macOS)
NSWorkspace.shared.open(url)
#endif
}
}) {
Image(systemName: "info.circle")
.foregroundColor(.white)
}.buttonStyle(.plain)
Text("Suggested: 20-20-20 rule")
.font(.headline)
.foregroundColor(.white)
}
.padding()
.glassEffect(.regular.tint(.blue), in: .rect(cornerRadius: 8))
VStack(alignment: .leading, spacing: 20) {
Toggle("Enable Look Away Reminders", isOn: $enabled)
@@ -39,25 +61,27 @@ struct LookAwaySetupView: View {
.foregroundColor(.secondary)
HStack {
Slider(value: Binding(
get: { Double(intervalMinutes) },
set: { intervalMinutes = Int($0) }
), in: 5...60, step: 5)
Slider(
value: Binding(
get: { Double(intervalMinutes) },
set: { intervalMinutes = Int($0) }
), in: 5...60, step: 5)
Text("\(intervalMinutes) min")
.frame(width: 60, alignment: .trailing)
.monospacedDigit()
}
Text("Look away for:")
Text("Look away for:")
.font(.subheadline)
.foregroundColor(.secondary)
HStack {
Slider(value: Binding(
get: { Double(countdownSeconds) },
set: { countdownSeconds = Int($0) }
), in: 10...30, step: 5)
Slider(
value: Binding(
get: { Double(countdownSeconds) },
set: { countdownSeconds = Int($0) }
), in: 10...30, step: 5)
Text("\(countdownSeconds) sec")
.frame(width: 60, alignment: .trailing)
@@ -69,7 +93,9 @@ struct LookAwaySetupView: View {
.padding()
.glassEffect(.regular, in: .rect(cornerRadius: 12))
Text("You will be reminded every \(intervalMinutes) minutes to look in the distance for \(countdownSeconds) seconds")
Text(
"You will be reminded every \(intervalMinutes) minutes to look in the distance for \(countdownSeconds) seconds"
)
Spacer()
}
@@ -79,32 +105,6 @@ struct LookAwaySetupView: View {
}
}
struct InfoBox: View {
let text: String
var body: some View {
HStack(spacing: 12) {
Button(action: {
if let url = URL(string: "https://www.healthline.com/health/eye-health/20-20-20-rule") {
#if os(iOS)
UIApplication.shared.open(url)
#elseif os(macOS)
NSWorkspace.shared.open(url)
#endif
}
}) {
Image(systemName: "info.circle")
.foregroundColor(.white)
}.buttonStyle(.plain)
Text(text)
.font(.headline)
.foregroundColor(.white)
}
.padding()
.glassEffect(.regular.tint(.blue), in: .rect(cornerRadius: 8))
}
}
#Preview("Look Away Setup View") {
LookAwaySetupView(
enabled: .constant(true),
@@ -113,7 +113,3 @@ struct InfoBox: View {
)
}
#Preview("Info Box") {
InfoBox(text: "This is an informational message that provides helpful context to the user.")
.padding()
}

View File

@@ -24,6 +24,31 @@ struct PostureSetupView: View {
.font(.title3)
.foregroundColor(.secondary)
// InfoBox with link functionality
HStack(spacing: 12) {
Button(action: {
if let url = URL(
string: "https://www.healthline.com/health/ergonomic-workspace")
{
#if os(iOS)
UIApplication.shared.open(url)
#elseif os(macOS)
NSWorkspace.shared.open(url)
#endif
}
}) {
Image(systemName: "info.circle")
.foregroundColor(.white)
}.buttonStyle(.plain)
Text(
"Regular posture checks help prevent back and neck pain from prolonged sitting"
)
.font(.headline)
.foregroundColor(.white)
}
.padding()
.glassEffect(.regular.tint(.blue), in: .rect(cornerRadius: 8))
VStack(alignment: .leading, spacing: 20) {
Toggle("Enable Posture Reminders", isOn: $enabled)
.font(.headline)
@@ -35,10 +60,11 @@ struct PostureSetupView: View {
.foregroundColor(.secondary)
HStack {
Slider(value: Binding(
get: { Double(intervalMinutes) },
set: { intervalMinutes = Int($0) }
), in: 15...60, step: 5)
Slider(
value: Binding(
get: { Double(intervalMinutes) },
set: { intervalMinutes = Int($0) }
), in: 15...60, step: 5)
Text("\(intervalMinutes) min")
.frame(width: 60, alignment: .trailing)
@@ -50,7 +76,9 @@ struct PostureSetupView: View {
.padding()
.glassEffect(.regular, in: .rect(cornerRadius: 12))
InfoBox(text: "Regular posture checks help prevent back and neck pain from prolonged sitting")
Text(
"You will be subtly reminded every \(intervalMinutes) minutes to check your posture"
)
Spacer()
}