Skip to content

Commit

Permalink
Fix for crash observed on hardware; various refactorings
Browse files Browse the repository at this point in the history
  • Loading branch information
Reed Es committed Oct 26, 2023
1 parent ef52ab4 commit cd41d15
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
11 changes: 9 additions & 2 deletions Sources/Views/Run Views/QuickLog.swift
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,9 @@ public struct QuickLog: View {
Haptics.play()
}
.font(.title2)



.buttonStyle(.plain)
.modify {
if #available(iOS 16.1, watchOS 9.1, *) {
Expand Down Expand Up @@ -220,9 +223,13 @@ public struct QuickLog: View {
// NavigationStack was NOT popping, and then the user's manual pop
// caused "Fatal error: Can't remove more items from a collection
// than it contains". (Happened on iPad Mini (6th) in landscape.)
DispatchQueue.main.asyncAfter(deadline: .now() + 0.1) {
//
// October 2023 update: this async operation was causing a "Simultaneous
// accesses to 0x..., but modification requires exclusive access" on my
// iPhone 12 Pro on iOS 17.0.3, but not on simulator. Removed async for now.
// DispatchQueue.main.asyncAfter(deadline: .now() + 0.1) {
router.path.removeAll()
}
// }

logger.debug("\(#function) DONE")
} catch {
Expand Down
10 changes: 8 additions & 2 deletions Sources/Views/Run Views/ServingRun.swift
Original file line number Diff line number Diff line change
Expand Up @@ -79,17 +79,20 @@ public struct ServingRun: View {
}

#if os(watchOS)
private var slices: CGFloat = 13
private var platformView: some View {
GeometryReader { _ in
GeometryReader { geo in
VStack(spacing: verticalSpacing) {
Text(serving.wrappedName)
.font(.title3)
.lineLimit(1)
.frame(height: geo.size.height * 1 / slices)

Text("\(netCalories, specifier: "%0.0f") cal")
.font(.title)
.lineLimit(1)
.foregroundColor(.yellow)
.frame(height: geo.size.height * 3 / slices)

// TODO: refactor this into IntensityStepper, so it works on both watch and phone
ValueStepper(value: $intensity,
Expand All @@ -99,7 +102,8 @@ public struct ServingRun: View {
multiplier: 100,
maxFontSize: stepperMaxFontSize,
forceFocus: true)
.frame(maxHeight: stepperMaxHeight)
.frame(height: geo.size.height * 3 / slices)
// .frame(maxHeight: stepperMaxHeight)

HStack(spacing: 20) {
Text("\(netWeight, specifier: "%0.0f") g")
Expand All @@ -109,6 +113,7 @@ public struct ServingRun: View {
}
.font(.title2)
.lineLimit(1)
.frame(height: geo.size.height * 3 / slices)

HStack(spacing: 15) {
Button(action: editAction) {
Expand All @@ -123,6 +128,7 @@ public struct ServingRun: View {
.foregroundStyle(servingColorDarkBg)
.font(.title3)
}
.frame(height: geo.size.height * 2 / slices)
}
.symbolRenderingMode(.hierarchical)
}
Expand Down

0 comments on commit cd41d15

Please sign in to comment.