Showing 1 changed files with 42 additions and 32 deletions
+42 -32
USB Meter/Views/Meter/Components/MeasurementChartView.swift
@@ -174,6 +174,10 @@ struct MeasurementChartView: View {
174 174
         return isLargeDisplay ? .callout : .footnote
175 175
     }
176 176
 
177
+    private var usesCompactLandscapeOriginControls: Bool {
178
+        isIPhone && !isPortraitLayout && availableSize.width > 0 && availableSize.width <= 740
179
+    }
180
+
177 181
     var body: some View {
178 182
         let powerSeries = series(for: measurements.power, kind: .power, minimumYSpan: minimumPowerSpan)
179 183
         let voltageSeries = series(for: measurements.voltage, kind: .voltage, minimumYSpan: minimumVoltageSpan)
@@ -252,7 +256,7 @@ struct MeasurementChartView: View {
252 256
                                             voltageSeries: voltageSeries,
253 257
                                             currentSeries: currentSeries
254 258
                                         )
255
-                                        .offset(y: compactLayout ? 8 : 10)
259
+                                        .offset(y: usesCompactLandscapeOriginControls ? 2 : (compactLayout ? 8 : 10))
256 260
                                     }
257 261
                             case .belowXAxisLegend:
258 262
                                 xAxisLabelsView(context: primarySeries.context)
@@ -343,6 +347,8 @@ struct MeasurementChartView: View {
343 347
     ) -> some View {
344 348
         let condensedLayout = compactLayout || verticalSizeClass == .compact
345 349
         let showsCardBackground = !(isIPhone && isPortraitLayout) && !shouldFloatScaleControlsOverChart
350
+        let horizontalPadding: CGFloat = usesCompactLandscapeOriginControls ? 6 : (condensedLayout ? 10 : (isLargeDisplay ? 12 : 10))
351
+        let verticalPadding: CGFloat = usesCompactLandscapeOriginControls ? 5 : (condensedLayout ? 8 : (isLargeDisplay ? 10 : 8))
346 352
 
347 353
         return originControlsRow(
348 354
             voltageSeries: voltageSeries,
@@ -350,8 +356,8 @@ struct MeasurementChartView: View {
350 356
             condensedLayout: condensedLayout,
351 357
             showsLabel: !shouldFloatScaleControlsOverChart && showsLabeledOriginControls
352 358
         )
353
-        .padding(.horizontal, condensedLayout ? 10 : (isLargeDisplay ? 12 : 10))
354
-        .padding(.vertical, condensedLayout ? 8 : (isLargeDisplay ? 10 : 8))
359
+        .padding(.horizontal, horizontalPadding)
360
+        .padding(.vertical, verticalPadding)
355 361
         .background(
356 362
             Capsule(style: .continuous)
357 363
                 .fill(showsCardBackground ? Color.primary.opacity(0.08) : Color.clear)
@@ -397,20 +403,22 @@ struct MeasurementChartView: View {
397 403
         condensedLayout: Bool,
398 404
         showsLabel: Bool
399 405
     ) -> some View {
400
-        HStack(spacing: condensedLayout ? 8 : 10) {
401
-            symbolControlChip(
402
-                systemImage: "equal.circle",
403
-                enabled: supportsSharedOrigin,
404
-                active: useSharedOrigin && supportsSharedOrigin,
405
-                condensedLayout: condensedLayout,
406
-                showsLabel: showsLabel,
407
-                label: "Match Y Scale",
408
-                accessibilityLabel: "Match Y scale"
409
-            ) {
410
-                toggleSharedOrigin(
411
-                    voltageSeries: voltageSeries,
412
-                    currentSeries: currentSeries
413
-                )
406
+        HStack(spacing: usesCompactLandscapeOriginControls ? 6 : (condensedLayout ? 8 : 10)) {
407
+            if supportsSharedOrigin {
408
+                symbolControlChip(
409
+                    systemImage: "equal.circle",
410
+                    enabled: true,
411
+                    active: useSharedOrigin,
412
+                    condensedLayout: condensedLayout,
413
+                    showsLabel: showsLabel,
414
+                    label: "Match Y Scale",
415
+                    accessibilityLabel: "Match Y scale"
416
+                ) {
417
+                    toggleSharedOrigin(
418
+                        voltageSeries: voltageSeries,
419
+                        currentSeries: currentSeries
420
+                    )
421
+                }
414 422
             }
415 423
 
416 424
             symbolControlChip(
@@ -428,16 +436,18 @@ struct MeasurementChartView: View {
428 436
                 )
429 437
             }
430 438
 
431
-            symbolControlChip(
432
-                systemImage: "0.circle",
433
-                enabled: true,
434
-                active: pinnedOriginIsZero,
435
-                condensedLayout: condensedLayout,
436
-                showsLabel: showsLabel,
437
-                label: "Origin 0",
438
-                accessibilityLabel: "Set origin to zero"
439
-            ) {
440
-                setVisibleOriginsToZero()
439
+            if !pinnedOriginIsZero {
440
+                symbolControlChip(
441
+                    systemImage: "0.circle",
442
+                    enabled: true,
443
+                    active: false,
444
+                    condensedLayout: condensedLayout,
445
+                    showsLabel: showsLabel,
446
+                    label: "Origin 0",
447
+                    accessibilityLabel: "Set origin to zero"
448
+                ) {
449
+                    setVisibleOriginsToZero()
450
+                }
441 451
             }
442 452
 
443 453
         }
@@ -488,14 +498,14 @@ struct MeasurementChartView: View {
488 498
                 if showsLabel {
489 499
                     Label(label, systemImage: systemImage)
490 500
                         .font(controlChipFont(condensedLayout: condensedLayout))
491
-                        .padding(.horizontal, condensedLayout ? 10 : 12)
492
-                        .padding(.vertical, condensedLayout ? 7 : (isLargeDisplay ? 9 : 8))
501
+                        .padding(.horizontal, usesCompactLandscapeOriginControls ? 8 : (condensedLayout ? 10 : 12))
502
+                        .padding(.vertical, usesCompactLandscapeOriginControls ? 6 : (condensedLayout ? 7 : (isLargeDisplay ? 9 : 8)))
493 503
                 } else {
494 504
                     Image(systemName: systemImage)
495
-                        .font(.system(size: condensedLayout ? 15 : (isLargeDisplay ? 18 : 16), weight: .semibold))
505
+                        .font(.system(size: usesCompactLandscapeOriginControls ? 13 : (condensedLayout ? 15 : (isLargeDisplay ? 18 : 16)), weight: .semibold))
496 506
                         .frame(
497
-                            width: condensedLayout ? 34 : (isLargeDisplay ? 42 : 38),
498
-                            height: condensedLayout ? 34 : (isLargeDisplay ? 42 : 38)
507
+                            width: usesCompactLandscapeOriginControls ? 30 : (condensedLayout ? 34 : (isLargeDisplay ? 42 : 38)),
508
+                            height: usesCompactLandscapeOriginControls ? 30 : (condensedLayout ? 34 : (isLargeDisplay ? 42 : 38))
499 509
                         )
500 510
                 }
501 511
             }