better layout of the advanced sections
This commit is contained in:
@@ -886,18 +886,6 @@ struct BatteryEditorView: View {
|
||||
.listRowSeparator(.hidden)
|
||||
.listRowBackground(Color(.systemBackground))
|
||||
}
|
||||
} footer: {
|
||||
if isAdvancedExpanded {
|
||||
VStack(alignment: .leading, spacing: 8) {
|
||||
Text(usableCapacityFooterText)
|
||||
Text(chargeVoltageHelperText)
|
||||
Text(cutOffVoltageHelperText)
|
||||
Text(temperatureRangeHelperText)
|
||||
}
|
||||
.font(.caption)
|
||||
.foregroundStyle(.secondary)
|
||||
.opacity(advancedEnabled ? 1 : 0.35)
|
||||
}
|
||||
}
|
||||
.listRowSeparator(.hidden)
|
||||
.listRowInsets(EdgeInsets(top: 12, leading: 18, bottom: 12, trailing: 18))
|
||||
@@ -906,84 +894,104 @@ struct BatteryEditorView: View {
|
||||
|
||||
private var advancedControls: some View {
|
||||
VStack(spacing: 16) {
|
||||
EditableSliderRow(
|
||||
title: usableCapacitySliderTitle,
|
||||
unit: "%",
|
||||
range: usableCapacitySliderRange,
|
||||
value: Binding(
|
||||
get: { configuration.usableCapacityFraction * 100 },
|
||||
set: { newValue in
|
||||
updateUsableCapacityPercent(newValue)
|
||||
}
|
||||
),
|
||||
buttonText: resetButtonTitle,
|
||||
buttonAction: resetUsableCapacityToDefault,
|
||||
isButtonVisible: hasUsableCapacityOverride,
|
||||
snapValues: usableCapacitySnapValues,
|
||||
sliderTransform: roundToTenth,
|
||||
alertTransform: roundToTenth,
|
||||
formatValue: formattedEditValue,
|
||||
parseInput: parseInput,
|
||||
alertCopy: EditableSliderRow.AlertCopy(
|
||||
title: usableCapacityAlertTitle,
|
||||
placeholder: usableCapacityAlertPlaceholder,
|
||||
message: usableCapacityAlertMessage,
|
||||
cancelTitle: alertCancelTitle,
|
||||
saveTitle: alertSaveTitle
|
||||
VStack(alignment: .leading, spacing: 8) {
|
||||
EditableSliderRow(
|
||||
title: usableCapacitySliderTitle,
|
||||
unit: "%",
|
||||
range: usableCapacitySliderRange,
|
||||
value: Binding(
|
||||
get: { configuration.usableCapacityFraction * 100 },
|
||||
set: { newValue in
|
||||
updateUsableCapacityPercent(newValue)
|
||||
}
|
||||
),
|
||||
buttonText: resetButtonTitle,
|
||||
buttonAction: resetUsableCapacityToDefault,
|
||||
isButtonVisible: hasUsableCapacityOverride,
|
||||
snapValues: usableCapacitySnapValues,
|
||||
sliderTransform: roundToTenth,
|
||||
alertTransform: roundToTenth,
|
||||
formatValue: formattedEditValue,
|
||||
parseInput: parseInput,
|
||||
alertCopy: EditableSliderRow.AlertCopy(
|
||||
title: usableCapacityAlertTitle,
|
||||
placeholder: usableCapacityAlertPlaceholder,
|
||||
message: usableCapacityAlertMessage,
|
||||
cancelTitle: alertCancelTitle,
|
||||
saveTitle: alertSaveTitle
|
||||
)
|
||||
)
|
||||
)
|
||||
Text(usableCapacityFooterText)
|
||||
.font(.caption)
|
||||
.foregroundStyle(.secondary)
|
||||
}
|
||||
|
||||
EditableSliderRow(
|
||||
title: chargeVoltageTitle,
|
||||
unit: "V",
|
||||
range: chargeVoltageSliderRange,
|
||||
value: Binding(
|
||||
get: { configuration.chargeVoltage },
|
||||
set: { newValue in
|
||||
let clamped = max(newValue, configuration.cutOffVoltage)
|
||||
configuration.chargeVoltage = clamped
|
||||
}
|
||||
),
|
||||
snapValues: chargeVoltageSnapValues,
|
||||
sliderTransform: normalizedChargeVoltage,
|
||||
alertTransform: roundToTenth,
|
||||
formatValue: formattedEditValue,
|
||||
parseInput: parseInput,
|
||||
alertCopy: EditableSliderRow.AlertCopy(
|
||||
title: chargeVoltageAlertTitle,
|
||||
placeholder: chargeVoltageAlertPlaceholder,
|
||||
message: chargeVoltageAlertMessage,
|
||||
cancelTitle: alertCancelTitle,
|
||||
saveTitle: alertSaveTitle
|
||||
VStack(alignment: .leading, spacing: 8) {
|
||||
EditableSliderRow(
|
||||
title: chargeVoltageTitle,
|
||||
unit: "V",
|
||||
range: chargeVoltageSliderRange,
|
||||
value: Binding(
|
||||
get: { configuration.chargeVoltage },
|
||||
set: { newValue in
|
||||
let clamped = max(newValue, configuration.cutOffVoltage)
|
||||
configuration.chargeVoltage = clamped
|
||||
}
|
||||
),
|
||||
snapValues: chargeVoltageSnapValues,
|
||||
sliderTransform: normalizedChargeVoltage,
|
||||
alertTransform: roundToTenth,
|
||||
formatValue: formattedEditValue,
|
||||
parseInput: parseInput,
|
||||
alertCopy: EditableSliderRow.AlertCopy(
|
||||
title: chargeVoltageAlertTitle,
|
||||
placeholder: chargeVoltageAlertPlaceholder,
|
||||
message: chargeVoltageAlertMessage,
|
||||
cancelTitle: alertCancelTitle,
|
||||
saveTitle: alertSaveTitle
|
||||
)
|
||||
)
|
||||
)
|
||||
Text(chargeVoltageHelperText)
|
||||
.font(.caption)
|
||||
.foregroundStyle(.secondary)
|
||||
}
|
||||
|
||||
EditableSliderRow(
|
||||
title: cutOffVoltageTitle,
|
||||
unit: "V",
|
||||
range: cutOffVoltageSliderRange,
|
||||
value: Binding(
|
||||
get: { configuration.cutOffVoltage },
|
||||
set: { newValue in
|
||||
let clamped = min(newValue, configuration.chargeVoltage)
|
||||
configuration.cutOffVoltage = clamped
|
||||
}
|
||||
),
|
||||
snapValues: cutOffVoltageSnapValues,
|
||||
sliderTransform: normalizedCutOffVoltage,
|
||||
alertTransform: roundToTenth,
|
||||
formatValue: formattedEditValue,
|
||||
parseInput: parseInput,
|
||||
alertCopy: EditableSliderRow.AlertCopy(
|
||||
title: cutOffVoltageAlertTitle,
|
||||
placeholder: cutOffVoltageAlertPlaceholder,
|
||||
message: cutOffVoltageAlertMessage,
|
||||
cancelTitle: alertCancelTitle,
|
||||
saveTitle: alertSaveTitle
|
||||
VStack(alignment: .leading, spacing: 8) {
|
||||
EditableSliderRow(
|
||||
title: cutOffVoltageTitle,
|
||||
unit: "V",
|
||||
range: cutOffVoltageSliderRange,
|
||||
value: Binding(
|
||||
get: { configuration.cutOffVoltage },
|
||||
set: { newValue in
|
||||
let clamped = min(newValue, configuration.chargeVoltage)
|
||||
configuration.cutOffVoltage = clamped
|
||||
}
|
||||
),
|
||||
snapValues: cutOffVoltageSnapValues,
|
||||
sliderTransform: normalizedCutOffVoltage,
|
||||
alertTransform: roundToTenth,
|
||||
formatValue: formattedEditValue,
|
||||
parseInput: parseInput,
|
||||
alertCopy: EditableSliderRow.AlertCopy(
|
||||
title: cutOffVoltageAlertTitle,
|
||||
placeholder: cutOffVoltageAlertPlaceholder,
|
||||
message: cutOffVoltageAlertMessage,
|
||||
cancelTitle: alertCancelTitle,
|
||||
saveTitle: alertSaveTitle
|
||||
)
|
||||
)
|
||||
)
|
||||
Text(cutOffVoltageHelperText)
|
||||
.font(.caption)
|
||||
.foregroundStyle(.secondary)
|
||||
}
|
||||
|
||||
temperatureRangeRow
|
||||
VStack(alignment: .leading, spacing: 8) {
|
||||
temperatureRangeRow
|
||||
Text(temperatureRangeHelperText)
|
||||
.font(.caption)
|
||||
.foregroundStyle(.secondary)
|
||||
}
|
||||
}
|
||||
.padding(.top, 6)
|
||||
}
|
||||
|
||||
@@ -1040,26 +1040,29 @@ struct CalculatorView: View {
|
||||
.listRowSeparator(.hidden)
|
||||
.listRowBackground(Color(.systemBackground))
|
||||
}
|
||||
dutyCycleSlider
|
||||
.listRowSeparator(.hidden)
|
||||
.listRowBackground(Color(.systemBackground))
|
||||
.opacity(advancedEnabled ? 1 : 0.35)
|
||||
.allowsHitTesting(advancedEnabled)
|
||||
usageHoursSlider
|
||||
.listRowSeparator(.hidden)
|
||||
.listRowBackground(Color(.systemBackground))
|
||||
.opacity(advancedEnabled ? 1 : 0.35)
|
||||
.allowsHitTesting(advancedEnabled)
|
||||
}
|
||||
} footer: {
|
||||
if isAdvancedExpanded {
|
||||
VStack(alignment: .leading, spacing: 8) {
|
||||
dutyCycleSlider
|
||||
.listRowSeparator(.hidden)
|
||||
.listRowBackground(Color(.systemBackground))
|
||||
.opacity(advancedEnabled ? 1 : 0.35)
|
||||
.allowsHitTesting(advancedEnabled)
|
||||
Text(dutyCycleHelperText)
|
||||
Text(usageHoursHelperText)
|
||||
.font(.caption)
|
||||
.foregroundStyle(.secondary)
|
||||
.opacity(advancedEnabled ? 1 : 0.35)
|
||||
}
|
||||
|
||||
VStack(alignment: .leading, spacing: 8) {
|
||||
usageHoursSlider
|
||||
.listRowSeparator(.hidden)
|
||||
.listRowBackground(Color(.systemBackground))
|
||||
.opacity(advancedEnabled ? 1 : 0.35)
|
||||
.allowsHitTesting(advancedEnabled)
|
||||
Text(usageHoursHelperText)
|
||||
.font(.caption)
|
||||
.foregroundStyle(.secondary)
|
||||
.opacity(advancedEnabled ? 1 : 0.35)
|
||||
}
|
||||
.font(.caption)
|
||||
.foregroundStyle(.secondary)
|
||||
.opacity(advancedEnabled ? 1 : 0.35)
|
||||
}
|
||||
}
|
||||
.listRowSeparator(.hidden)
|
||||
|
||||
Reference in New Issue
Block a user