mirror of
https://github.com/NinjaCheetah/RIT-Dining.git
synced 2026-03-05 05:25:29 -05:00
Mostly fixed multi opening period widgets!
- The opening status label on widgets should update properly on time now. - Improved some of the logic related to determining opening statuses. Guards exist! - Reduced the text sizes so that more of the location names fits in the widgets. Also ensures that the full opening times will be displayed (this always worked for 24-hour time but wasn't guaranteed to fit for 12-hour time).
This commit is contained in:
@@ -9,13 +9,13 @@ import SwiftUI
|
||||
|
||||
struct OpeningHoursGauge: View {
|
||||
let diningTimes: [DiningTimes]?
|
||||
let now: Date
|
||||
let referenceTime: Date
|
||||
|
||||
private let dayDuration: TimeInterval = 86_400
|
||||
|
||||
private var barFillColor: Color {
|
||||
if let diningTimes = diningTimes {
|
||||
let openStatus = parseMultiOpenStatus(diningTimes: diningTimes)
|
||||
let openStatus = parseMultiOpenStatus(diningTimes: diningTimes, referenceTime: referenceTime)
|
||||
switch openStatus {
|
||||
case .open:
|
||||
return Color.green
|
||||
@@ -34,10 +34,10 @@ struct OpeningHoursGauge: View {
|
||||
let width = geometry.size.width
|
||||
let barHeight: CGFloat = 16
|
||||
|
||||
let startOfToday = Calendar.current.startOfDay(for: now)
|
||||
let startOfToday = Calendar.current.startOfDay(for: referenceTime)
|
||||
let startOfTomorrow = Calendar.current.date(byAdding: .day, value: 1, to: startOfToday)!
|
||||
|
||||
let nowX = position(for: now, start: startOfToday, width: width)
|
||||
let nowX = position(for: referenceTime, start: startOfToday, width: width)
|
||||
|
||||
ZStack(alignment: .leading) {
|
||||
Capsule()
|
||||
|
||||
Reference in New Issue
Block a user