mirror of
https://github.com/FBukovina/Atoll.git
synced 2026-10-27 15:14:33 +00:00
Merge pull request #166 from Ebullioscopic/feature/timer
BugFixes and stuff
This commit is contained in:
commit
72504c7cc1
3 changed files with 94 additions and 37 deletions
|
|
@ -296,27 +296,41 @@ struct EventListView: View {
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
ScrollViewReader { proxy in
|
ScrollViewReader { proxy in
|
||||||
List {
|
ZStack {
|
||||||
ForEach(filteredEvents) { event in
|
List {
|
||||||
Button(action: {
|
ForEach(filteredEvents) { event in
|
||||||
if let url = event.calendarAppURL() {
|
Button(action: {
|
||||||
openURL(url)
|
if let url = event.calendarAppURL() {
|
||||||
|
openURL(url)
|
||||||
|
}
|
||||||
|
}) {
|
||||||
|
eventRow(event)
|
||||||
}
|
}
|
||||||
}) {
|
.id(event.id)
|
||||||
eventRow(event)
|
.padding(.leading, -5)
|
||||||
|
.buttonStyle(PlainButtonStyle())
|
||||||
|
.listRowSeparator(.automatic)
|
||||||
|
.listRowSeparatorTint(.gray.opacity(0.2))
|
||||||
|
.listRowBackground(Color.clear)
|
||||||
}
|
}
|
||||||
.id(event.id)
|
|
||||||
.padding(.leading, -5)
|
|
||||||
.buttonStyle(PlainButtonStyle())
|
|
||||||
.listRowSeparator(.automatic)
|
|
||||||
.listRowSeparatorTint(.gray.opacity(0.2))
|
|
||||||
.listRowBackground(Color.clear)
|
|
||||||
}
|
}
|
||||||
|
.listStyle(.plain)
|
||||||
|
.scrollIndicators(.never)
|
||||||
|
.scrollContentBackground(.hidden)
|
||||||
|
.background(Color.clear)
|
||||||
|
|
||||||
|
LinearGradient(colors: [Color.black.opacity(0.65), .clear], startPoint: .top, endPoint: .bottom)
|
||||||
|
.frame(height: 16)
|
||||||
|
.allowsHitTesting(false)
|
||||||
|
.alignmentGuide(.top) { d in d[.top] }
|
||||||
|
.frame(maxHeight: .infinity, alignment: .top)
|
||||||
|
|
||||||
|
LinearGradient(colors: [.clear, Color.black.opacity(0.65)], startPoint: .top, endPoint: .bottom)
|
||||||
|
.frame(height: 16)
|
||||||
|
.allowsHitTesting(false)
|
||||||
|
.alignmentGuide(.bottom) { d in d[.bottom] }
|
||||||
|
.frame(maxHeight: .infinity, alignment: .bottom)
|
||||||
}
|
}
|
||||||
.listStyle(.plain)
|
|
||||||
.scrollIndicators(.never)
|
|
||||||
.scrollContentBackground(.hidden)
|
|
||||||
.background(Color.clear)
|
|
||||||
.onAppear {
|
.onAppear {
|
||||||
scrollToRelevantEvent(proxy: proxy)
|
scrollToRelevantEvent(proxy: proxy)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -20,12 +20,35 @@ struct LockScreenTimerWidget: View {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private var countdownFont: Font { displayFont(size: 56) }
|
|
||||||
|
|
||||||
private func displayFont(size: CGFloat) -> Font {
|
private func displayFont(size: CGFloat) -> Font {
|
||||||
.custom("SF Pro Display", size: size)
|
.custom("SF Pro Display", size: size)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private var hasHoursComponent: Bool {
|
||||||
|
abs(timerManager.remainingTime) >= 3600
|
||||||
|
}
|
||||||
|
|
||||||
|
private var hasDoubleDigitHours: Bool {
|
||||||
|
abs(timerManager.remainingTime) >= 36_000 // 10 hours or more
|
||||||
|
}
|
||||||
|
|
||||||
|
private var titleFrameWidth: CGFloat {
|
||||||
|
if hasDoubleDigitHours { return 78 }
|
||||||
|
if hasHoursComponent { return 90 }
|
||||||
|
return 130
|
||||||
|
}
|
||||||
|
|
||||||
|
private var countdownFrameWidth: CGFloat {
|
||||||
|
if hasDoubleDigitHours { return 248 }
|
||||||
|
if hasHoursComponent { return 235 }
|
||||||
|
return 205
|
||||||
|
}
|
||||||
|
|
||||||
|
private var countdownFont: Font {
|
||||||
|
let baseSize: CGFloat = hasDoubleDigitHours ? 52 : 56
|
||||||
|
return displayFont(size: baseSize)
|
||||||
|
}
|
||||||
|
|
||||||
private var timerLabel: String {
|
private var timerLabel: String {
|
||||||
timerManager.timerName.isEmpty ? "Timer" : timerManager.timerName
|
timerManager.timerName.isEmpty ? "Timer" : timerManager.timerName
|
||||||
}
|
}
|
||||||
|
|
@ -104,7 +127,7 @@ struct LockScreenTimerWidget: View {
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
VStack(spacing: 16) {
|
VStack(spacing: 16) {
|
||||||
HStack(alignment: .center, spacing: 18) {
|
HStack(alignment: .center, spacing: 8) {
|
||||||
controlButtons
|
controlButtons
|
||||||
|
|
||||||
titleSection
|
titleSection
|
||||||
|
|
@ -113,7 +136,7 @@ struct LockScreenTimerWidget: View {
|
||||||
countdownSection
|
countdownSection
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.padding(.horizontal, 24)
|
.padding(.horizontal, 12)
|
||||||
.padding(.vertical, 18)
|
.padding(.vertical, 18)
|
||||||
.frame(width: Self.preferredSize.width, height: Self.preferredSize.height)
|
.frame(width: Self.preferredSize.width, height: Self.preferredSize.height)
|
||||||
.background(widgetBackground)
|
.background(widgetBackground)
|
||||||
|
|
@ -161,10 +184,13 @@ struct LockScreenTimerWidget: View {
|
||||||
.foregroundStyle(timerManager.isOvertime ? Color.red : accentColor)
|
.foregroundStyle(timerManager.isOvertime ? Color.red : accentColor)
|
||||||
.contentTransition(.numericText())
|
.contentTransition(.numericText())
|
||||||
.animation(.smooth(duration: 0.25), value: timerManager.remainingTime)
|
.animation(.smooth(duration: 0.25), value: timerManager.remainingTime)
|
||||||
|
.lineLimit(1)
|
||||||
|
.minimumScaleFactor(0.68)
|
||||||
.frame(maxWidth: .infinity, alignment: .trailing)
|
.frame(maxWidth: .infinity, alignment: .trailing)
|
||||||
}
|
}
|
||||||
.frame(width: 220, alignment: .center)
|
.frame(width: countdownFrameWidth, alignment: .center)
|
||||||
.padding(.trailing, 2)
|
.padding(.trailing, 2)
|
||||||
|
.layoutPriority(2)
|
||||||
}
|
}
|
||||||
|
|
||||||
private var titleSection: some View {
|
private var titleSection: some View {
|
||||||
|
|
@ -174,12 +200,13 @@ struct LockScreenTimerWidget: View {
|
||||||
font: displayFont(size: 18),
|
font: displayFont(size: 18),
|
||||||
nsFont: .title3,
|
nsFont: .title3,
|
||||||
textColor: accentColor,
|
textColor: accentColor,
|
||||||
minDuration: 0.18,
|
minDuration: 0.16,
|
||||||
frameWidth: Self.preferredSize.width * 0.35
|
frameWidth: titleFrameWidth
|
||||||
)
|
)
|
||||||
.frame(maxWidth: .infinity)
|
.frame(maxWidth: titleFrameWidth)
|
||||||
}
|
}
|
||||||
.frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .center)
|
.frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .center)
|
||||||
|
.layoutPriority(0)
|
||||||
}
|
}
|
||||||
|
|
||||||
private var accentRibbon: some View {
|
private var accentRibbon: some View {
|
||||||
|
|
|
||||||
|
|
@ -99,20 +99,34 @@ struct NotchTimerView: View {
|
||||||
} else {
|
} else {
|
||||||
let computedHeight = CGFloat(timerPresets.count) * 60 + 4
|
let computedHeight = CGFloat(timerPresets.count) * 60 + 4
|
||||||
let listHeight = min(max(0, maxTabContentHeight - 16), computedHeight)
|
let listHeight = min(max(0, maxTabContentHeight - 16), computedHeight)
|
||||||
List {
|
ZStack {
|
||||||
ForEach(timerPresets) { preset in
|
List {
|
||||||
TimerPresetCard(preset: preset, isActive: timerManager.activePresetId == preset.id) {
|
ForEach(timerPresets) { preset in
|
||||||
timerManager.startTimer(duration: preset.duration, name: preset.name, preset: preset)
|
TimerPresetCard(preset: preset, isActive: timerManager.activePresetId == preset.id) {
|
||||||
coordinator.currentView = .timer
|
timerManager.startTimer(duration: preset.duration, name: preset.name, preset: preset)
|
||||||
|
coordinator.currentView = .timer
|
||||||
|
}
|
||||||
|
.listRowInsets(EdgeInsets(top: 2, leading: 0, bottom: 2, trailing: 0))
|
||||||
|
.listRowBackground(Color.clear)
|
||||||
|
.listRowSeparator(.hidden)
|
||||||
}
|
}
|
||||||
.listRowInsets(EdgeInsets(top: 2, leading: 0, bottom: 2, trailing: 0))
|
|
||||||
.listRowBackground(Color.clear)
|
|
||||||
.listRowSeparator(.hidden)
|
|
||||||
}
|
}
|
||||||
|
.listStyle(.plain)
|
||||||
|
.scrollContentBackground(.hidden)
|
||||||
|
.scrollIndicators(.never)
|
||||||
|
|
||||||
|
LinearGradient(colors: [Color.black.opacity(0.65), .clear], startPoint: .top, endPoint: .bottom)
|
||||||
|
.frame(height: 16)
|
||||||
|
.allowsHitTesting(false)
|
||||||
|
.alignmentGuide(.top) { d in d[.top] }
|
||||||
|
.frame(maxHeight: .infinity, alignment: .top)
|
||||||
|
|
||||||
|
LinearGradient(colors: [.clear, Color.black.opacity(0.65)], startPoint: .top, endPoint: .bottom)
|
||||||
|
.frame(height: 16)
|
||||||
|
.allowsHitTesting(false)
|
||||||
|
.alignmentGuide(.bottom) { d in d[.bottom] }
|
||||||
|
.frame(maxHeight: .infinity, alignment: .bottom)
|
||||||
}
|
}
|
||||||
.listStyle(.plain)
|
|
||||||
.scrollContentBackground(.hidden)
|
|
||||||
.scrollIndicators(.never)
|
|
||||||
.frame(height: listHeight)
|
.frame(height: listHeight)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -201,6 +215,8 @@ struct NotchTimerView: View {
|
||||||
.foregroundStyle(timerManager.isOvertime ? Color.red : .white)
|
.foregroundStyle(timerManager.isOvertime ? Color.red : .white)
|
||||||
.contentTransition(.numericText())
|
.contentTransition(.numericText())
|
||||||
.animation(.smooth(duration: 0.25), value: timerManager.remainingTime)
|
.animation(.smooth(duration: 0.25), value: timerManager.remainingTime)
|
||||||
|
.lineLimit(1)
|
||||||
|
.minimumScaleFactor(0.8)
|
||||||
|
|
||||||
if timerManager.isOvertime {
|
if timerManager.isOvertime {
|
||||||
Text("Overtime")
|
Text("Overtime")
|
||||||
|
|
@ -208,7 +224,7 @@ struct NotchTimerView: View {
|
||||||
.foregroundStyle(.red)
|
.foregroundStyle(.red)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.frame(width: 150, alignment: .trailing)
|
.frame(width: 190, alignment: .trailing)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ViewBuilder
|
@ViewBuilder
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue