@@ -103,6 +103,27 @@ struct MeasurementChartView: View {
|
||
| 103 | 103 |
return availableSize.height >= availableSize.width |
| 104 | 104 |
} |
| 105 | 105 |
|
| 106 |
+ private var isIPhone: Bool {
|
|
| 107 |
+ #if os(iOS) |
|
| 108 |
+ return UIDevice.current.userInterfaceIdiom == .phone |
|
| 109 |
+ #else |
|
| 110 |
+ return false |
|
| 111 |
+ #endif |
|
| 112 |
+ } |
|
| 113 |
+ |
|
| 114 |
+ private enum OriginControlsPlacement {
|
|
| 115 |
+ case aboveXAxisLegend |
|
| 116 |
+ case overXAxisLegend |
|
| 117 |
+ case belowXAxisLegend |
|
| 118 |
+ } |
|
| 119 |
+ |
|
| 120 |
+ private var originControlsPlacement: OriginControlsPlacement {
|
|
| 121 |
+ if isIPhone {
|
|
| 122 |
+ return isPortraitLayout ? .aboveXAxisLegend : .overXAxisLegend |
|
| 123 |
+ } |
|
| 124 |
+ return .belowXAxisLegend |
|
| 125 |
+ } |
|
| 126 |
+ |
|
| 106 | 127 |
private var plotSectionHeight: CGFloat {
|
| 107 | 128 |
if availableSize == .zero {
|
| 108 | 129 |
return compactLayout ? 300 : 380 |
@@ -207,15 +228,42 @@ struct MeasurementChartView: View {
|
||
| 207 | 228 |
.frame(width: axisColumnWidth, height: plotHeight) |
| 208 | 229 |
} |
| 209 | 230 |
.overlay(alignment: .bottom) {
|
| 210 |
- scaleControlsPill( |
|
| 211 |
- voltageSeries: voltageSeries, |
|
| 212 |
- currentSeries: currentSeries |
|
| 213 |
- ) |
|
| 214 |
- .padding(.bottom, compactLayout ? 6 : 10) |
|
| 231 |
+ if originControlsPlacement == .aboveXAxisLegend {
|
|
| 232 |
+ scaleControlsPill( |
|
| 233 |
+ voltageSeries: voltageSeries, |
|
| 234 |
+ currentSeries: currentSeries |
|
| 235 |
+ ) |
|
| 236 |
+ .padding(.bottom, compactLayout ? 6 : 10) |
|
| 237 |
+ } |
|
| 215 | 238 |
} |
| 216 | 239 |
|
| 217 |
- xAxisLabelsView(context: primarySeries.context) |
|
| 218 |
- .frame(height: xAxisHeight) |
|
| 240 |
+ switch originControlsPlacement {
|
|
| 241 |
+ case .aboveXAxisLegend: |
|
| 242 |
+ xAxisLabelsView(context: primarySeries.context) |
|
| 243 |
+ .frame(height: xAxisHeight) |
|
| 244 |
+ case .overXAxisLegend: |
|
| 245 |
+ xAxisLabelsView(context: primarySeries.context) |
|
| 246 |
+ .frame(height: xAxisHeight) |
|
| 247 |
+ .overlay(alignment: .center) {
|
|
| 248 |
+ scaleControlsPill( |
|
| 249 |
+ voltageSeries: voltageSeries, |
|
| 250 |
+ currentSeries: currentSeries |
|
| 251 |
+ ) |
|
| 252 |
+ .offset(y: compactLayout ? 8 : 10) |
|
| 253 |
+ } |
|
| 254 |
+ case .belowXAxisLegend: |
|
| 255 |
+ xAxisLabelsView(context: primarySeries.context) |
|
| 256 |
+ .frame(height: xAxisHeight) |
|
| 257 |
+ |
|
| 258 |
+ HStack {
|
|
| 259 |
+ Spacer(minLength: 0) |
|
| 260 |
+ scaleControlsPill( |
|
| 261 |
+ voltageSeries: voltageSeries, |
|
| 262 |
+ currentSeries: currentSeries |
|
| 263 |
+ ) |
|
| 264 |
+ Spacer(minLength: 0) |
|
| 265 |
+ } |
|
| 266 |
+ } |
|
| 219 | 267 |
} |
| 220 | 268 |
.frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .top) |
| 221 | 269 |
} |