@@ -38,5 +38,6 @@
diff --git a/ui-ngx/src/app/modules/home/components/widget/lib/indicator/battery-level-widget.component.ts b/ui-ngx/src/app/modules/home/components/widget/lib/indicator/battery-level-widget.component.ts
index 6e9f8323be..9161764223 100644
--- a/ui-ngx/src/app/modules/home/components/widget/lib/indicator/battery-level-widget.component.ts
+++ b/ui-ngx/src/app/modules/home/components/widget/lib/indicator/battery-level-widget.component.ts
@@ -117,7 +117,9 @@ export class BatteryLevelWidgetComponent implements OnInit, OnDestroy, AfterView
value: number;
- batterySections: boolean[] = [false, false, false, false];
+ batterySections: boolean[];
+ dividedBorderRadius: string;
+ dividedGap: string;
batteryLevelColor: ColorProcessor;
@@ -158,6 +160,26 @@ export class BatteryLevelWidgetComponent implements OnInit, OnDestroy, AfterView
this.vertical = [BatteryLevelLayout.vertical_solid, BatteryLevelLayout.vertical_divided].includes(this.layout);
this.layoutClass = this.vertical ? 'vertical' : 'horizontal';
this.solid = [BatteryLevelLayout.vertical_solid, BatteryLevelLayout.horizontal_solid].includes(this.layout);
+ if (!this.solid) {
+ let sectionsCount = this.settings.sectionsCount;
+ if (!sectionsCount) {
+ sectionsCount = 4;
+ }
+ sectionsCount = Math.min(Math.max(sectionsCount, 2), 20);
+ this.batterySections = Array.from(Array(sectionsCount), () => false);
+ const gap = 1 + (24 - sectionsCount) / 10;
+ this.dividedGap = `${gap}%`;
+ const containerAspect = 0.5567;
+ const sectionHeight = (100 - (gap * (sectionsCount - 1))) / sectionsCount;
+ const sectionAspect = 100 * containerAspect / sectionHeight;
+ const rad1 = 8.425 - sectionsCount * 0.32125;
+ const rad2 = rad1 * sectionAspect;
+ if (this.vertical) {
+ this.dividedBorderRadius = `${rad1}% / ${rad2}%`;
+ } else {
+ this.dividedBorderRadius = `${rad2}% / ${rad1}%`;
+ }
+ }
this.showValue = this.settings.showValue;
this.autoScaleValueSize = this.showValue && this.settings.autoScaleValueSize;
@@ -243,6 +265,8 @@ export class BatteryLevelWidgetComponent implements OnInit, OnDestroy, AfterView
const valueLineHeight = ratios.valueLineHeightRaio * boxSize;
this.setValueFontSize(valueFontSize, valueLineHeight, boxWidth);
}
+ const fontSize = parseInt(window.getComputedStyle(this.batteryLevelValue.nativeElement).fontSize, 10) || 10;
+ this.renderer.setStyle(this.batteryLevelValue.nativeElement, 'minWidth', `${Math.min(fontSize*4, boxWidth)}px`);
}
let height = this.batteryLevelContent.nativeElement.getBoundingClientRect().height;
const width = height * verticalBatteryDimensions.shapeAspectRatio;
diff --git a/ui-ngx/src/app/modules/home/components/widget/lib/indicator/battery-level-widget.models.ts b/ui-ngx/src/app/modules/home/components/widget/lib/indicator/battery-level-widget.models.ts
index 8d8724f901..34c00a4b92 100644
--- a/ui-ngx/src/app/modules/home/components/widget/lib/indicator/battery-level-widget.models.ts
+++ b/ui-ngx/src/app/modules/home/components/widget/lib/indicator/battery-level-widget.models.ts
@@ -53,6 +53,7 @@ export const batteryLevelLayoutImages = new Map
(
export interface BatteryLevelWidgetSettings {
layout: BatteryLevelLayout;
+ sectionsCount: number;
showValue: boolean;
autoScaleValueSize: boolean;
valueFont: Font;
@@ -64,6 +65,7 @@ export interface BatteryLevelWidgetSettings {
export const batteryLevelDefaultSettings: BatteryLevelWidgetSettings = {
layout: BatteryLevelLayout.vertical_solid,
+ sectionsCount: 4,
showValue: true,
autoScaleValueSize: true,
valueFont: {
diff --git a/ui-ngx/src/app/modules/home/components/widget/lib/settings/indicator/battery-level-widget-settings.component.html b/ui-ngx/src/app/modules/home/components/widget/lib/settings/indicator/battery-level-widget-settings.component.html
index 7e53d17df1..2b841ca9f8 100644
--- a/ui-ngx/src/app/modules/home/components/widget/lib/settings/indicator/battery-level-widget-settings.component.html
+++ b/ui-ngx/src/app/modules/home/components/widget/lib/settings/indicator/battery-level-widget-settings.component.html
@@ -28,6 +28,12 @@
{{ batteryLevelLayoutTranslationMap.get(layout) | translate }}
+