@rakeyshgidwani/roger-ui-bank-theme-stan-design 0.2.9 → 0.2.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +1 -1
- package/dist/components/ui/accessibility-demo.esm.js +30 -24
- package/dist/components/ui/accessibility-demo.js +30 -24
- package/dist/components/ui/advanced-component-architecture-demo.esm.js +235 -179
- package/dist/components/ui/advanced-component-architecture-demo.js +235 -179
- package/dist/components/ui/advanced-transition-system-demo.esm.js +110 -64
- package/dist/components/ui/advanced-transition-system-demo.js +110 -64
- package/dist/components/ui/advanced-transition-system.esm.js +166 -122
- package/dist/components/ui/advanced-transition-system.js +166 -122
- package/dist/components/ui/animation/animated-container.esm.js +52 -29
- package/dist/components/ui/animation/animated-container.js +52 -29
- package/dist/components/ui/animation/staggered-container.esm.js +18 -9
- package/dist/components/ui/animation/staggered-container.js +18 -9
- package/dist/components/ui/animation-demo.esm.js +67 -35
- package/dist/components/ui/animation-demo.js +67 -35
- package/dist/components/ui/badge.esm.js +9 -6
- package/dist/components/ui/badge.js +9 -6
- package/dist/components/ui/battery-conscious-animation-demo.esm.js +122 -87
- package/dist/components/ui/battery-conscious-animation-demo.js +122 -87
- package/dist/components/ui/border-radius-shadow-demo.esm.js +23 -12
- package/dist/components/ui/border-radius-shadow-demo.js +23 -12
- package/dist/components/ui/button.esm.js +8 -2
- package/dist/components/ui/button.js +8 -2
- package/dist/components/ui/card.esm.js +33 -8
- package/dist/components/ui/card.js +33 -8
- package/dist/components/ui/checkbox.esm.js +3 -3
- package/dist/components/ui/checkbox.js +3 -3
- package/dist/components/ui/color-preview.esm.js +68 -45
- package/dist/components/ui/color-preview.js +68 -45
- package/dist/components/ui/data-display/chart.esm.js +112 -84
- package/dist/components/ui/data-display/chart.js +112 -84
- package/dist/components/ui/data-display/data-grid-simple.esm.js +1 -1
- package/dist/components/ui/data-display/data-grid-simple.js +1 -1
- package/dist/components/ui/data-display/data-grid.esm.js +80 -67
- package/dist/components/ui/data-display/data-grid.js +80 -67
- package/dist/components/ui/data-display/list.esm.js +53 -45
- package/dist/components/ui/data-display/list.js +53 -45
- package/dist/components/ui/data-display/table.esm.js +62 -54
- package/dist/components/ui/data-display/table.js +62 -54
- package/dist/components/ui/data-display/timeline.esm.js +39 -34
- package/dist/components/ui/data-display/timeline.js +39 -34
- package/dist/components/ui/data-display/tree.esm.js +116 -84
- package/dist/components/ui/data-display/tree.js +116 -84
- package/dist/components/ui/data-display/types.esm.js +389 -364
- package/dist/components/ui/data-display/types.js +389 -364
- package/dist/components/ui/enterprise-mobile-experience-demo.esm.js +120 -70
- package/dist/components/ui/enterprise-mobile-experience-demo.js +120 -70
- package/dist/components/ui/enterprise-mobile-experience.esm.js +124 -73
- package/dist/components/ui/enterprise-mobile-experience.js +124 -73
- package/dist/components/ui/feedback/alert.esm.js +22 -15
- package/dist/components/ui/feedback/alert.js +22 -15
- package/dist/components/ui/feedback/progress.esm.js +47 -24
- package/dist/components/ui/feedback/progress.js +47 -24
- package/dist/components/ui/feedback/skeleton.esm.js +39 -29
- package/dist/components/ui/feedback/skeleton.js +39 -29
- package/dist/components/ui/feedback/toast.esm.js +62 -38
- package/dist/components/ui/feedback/toast.js +62 -38
- package/dist/components/ui/feedback/types.esm.js +83 -83
- package/dist/components/ui/feedback/types.js +83 -83
- package/dist/components/ui/font-preview.esm.js +41 -39
- package/dist/components/ui/font-preview.js +41 -39
- package/dist/components/ui/form-demo.esm.js +150 -113
- package/dist/components/ui/form-demo.js +150 -113
- package/dist/components/ui/hardware-acceleration-demo.esm.js +137 -87
- package/dist/components/ui/hardware-acceleration-demo.js +137 -87
- package/dist/components/ui/input.esm.js +4 -1
- package/dist/components/ui/input.js +4 -1
- package/dist/components/ui/layout-demo.esm.js +81 -56
- package/dist/components/ui/layout-demo.js +81 -56
- package/dist/components/ui/layouts/adaptive-layout.esm.js +27 -8
- package/dist/components/ui/layouts/adaptive-layout.js +27 -8
- package/dist/components/ui/layouts/desktop-layout.esm.js +39 -19
- package/dist/components/ui/layouts/desktop-layout.js +39 -19
- package/dist/components/ui/layouts/mobile-layout.esm.js +19 -9
- package/dist/components/ui/layouts/mobile-layout.js +19 -9
- package/dist/components/ui/layouts/tablet-layout.esm.js +28 -14
- package/dist/components/ui/layouts/tablet-layout.js +28 -14
- package/dist/components/ui/mobile-form-validation.esm.js +120 -87
- package/dist/components/ui/mobile-form-validation.js +120 -87
- package/dist/components/ui/mobile-input-demo.esm.js +19 -13
- package/dist/components/ui/mobile-input-demo.js +19 -13
- package/dist/components/ui/mobile-input.esm.js +185 -120
- package/dist/components/ui/mobile-input.js +185 -120
- package/dist/components/ui/mobile-skeleton-loading-demo.esm.js +128 -111
- package/dist/components/ui/mobile-skeleton-loading-demo.js +128 -111
- package/dist/components/ui/navigation/breadcrumb.esm.js +17 -14
- package/dist/components/ui/navigation/breadcrumb.js +17 -14
- package/dist/components/ui/navigation/index.esm.js +0 -1
- package/dist/components/ui/navigation/index.js +0 -1
- package/dist/components/ui/navigation/menu.esm.js +49 -35
- package/dist/components/ui/navigation/menu.js +49 -35
- package/dist/components/ui/navigation/navigation-demo.esm.js +81 -74
- package/dist/components/ui/navigation/navigation-demo.js +81 -74
- package/dist/components/ui/navigation/pagination.esm.js +62 -50
- package/dist/components/ui/navigation/pagination.js +62 -50
- package/dist/components/ui/navigation/sidebar.esm.js +56 -42
- package/dist/components/ui/navigation/sidebar.js +56 -42
- package/dist/components/ui/navigation/stepper.esm.js +34 -23
- package/dist/components/ui/navigation/stepper.js +34 -23
- package/dist/components/ui/navigation/tabs.esm.js +32 -21
- package/dist/components/ui/navigation/tabs.js +32 -21
- package/dist/components/ui/navigation/types.esm.js +196 -195
- package/dist/components/ui/navigation/types.js +196 -195
- package/dist/components/ui/overlay/backdrop.esm.js +17 -16
- package/dist/components/ui/overlay/backdrop.js +17 -16
- package/dist/components/ui/overlay/focus-manager.esm.js +21 -19
- package/dist/components/ui/overlay/focus-manager.js +21 -19
- package/dist/components/ui/overlay/index.esm.js +0 -2
- package/dist/components/ui/overlay/index.js +0 -2
- package/dist/components/ui/overlay/modal.esm.js +38 -34
- package/dist/components/ui/overlay/modal.js +38 -34
- package/dist/components/ui/overlay/overlay-manager.esm.js +25 -20
- package/dist/components/ui/overlay/overlay-manager.js +25 -20
- package/dist/components/ui/overlay/popover.esm.js +74 -58
- package/dist/components/ui/overlay/popover.js +74 -58
- package/dist/components/ui/overlay/portal.esm.js +7 -7
- package/dist/components/ui/overlay/portal.js +7 -7
- package/dist/components/ui/overlay/tooltip.esm.js +54 -39
- package/dist/components/ui/overlay/tooltip.js +54 -39
- package/dist/components/ui/overlay/types.esm.js +132 -131
- package/dist/components/ui/overlay/types.js +132 -131
- package/dist/components/ui/performance-demo.esm.js +135 -88
- package/dist/components/ui/performance-demo.js +135 -88
- package/dist/components/ui/semantic-input-system-demo.esm.js +117 -80
- package/dist/components/ui/semantic-input-system-demo.js +117 -80
- package/dist/components/ui/theme-customizer.esm.js +84 -52
- package/dist/components/ui/theme-customizer.js +84 -52
- package/dist/components/ui/theme-preview.esm.js +95 -43
- package/dist/components/ui/theme-preview.js +95 -43
- package/dist/components/ui/theme-switcher.esm.js +70 -44
- package/dist/components/ui/theme-switcher.js +70 -44
- package/dist/components/ui/theme-toggle.esm.js +3 -3
- package/dist/components/ui/theme-toggle.js +3 -3
- package/dist/components/ui/token-demo.esm.js +33 -21
- package/dist/components/ui/token-demo.js +33 -21
- package/dist/components/ui/touch-demo.esm.js +102 -73
- package/dist/components/ui/touch-demo.js +102 -73
- package/dist/components/ui/touch-friendly-interface-demo.esm.js +102 -64
- package/dist/components/ui/touch-friendly-interface-demo.js +102 -64
- package/dist/components/ui/touch-friendly-interface.esm.js +85 -61
- package/dist/components/ui/touch-friendly-interface.js +85 -61
- package/dist/hooks/use-accessibility-support.esm.js +115 -85
- package/dist/hooks/use-accessibility-support.js +115 -85
- package/dist/hooks/use-adaptive-layout.esm.js +56 -33
- package/dist/hooks/use-adaptive-layout.js +56 -33
- package/dist/hooks/use-advanced-patterns.esm.js +57 -42
- package/dist/hooks/use-advanced-patterns.js +57 -42
- package/dist/hooks/use-advanced-transition-system.esm.js +112 -71
- package/dist/hooks/use-advanced-transition-system.js +112 -71
- package/dist/hooks/use-animation-profile.esm.js +63 -34
- package/dist/hooks/use-animation-profile.js +63 -34
- package/dist/hooks/use-battery-animations.esm.js +80 -55
- package/dist/hooks/use-battery-animations.js +80 -55
- package/dist/hooks/use-battery-conscious-loading.esm.js +166 -123
- package/dist/hooks/use-battery-conscious-loading.js +166 -123
- package/dist/hooks/use-battery-optimization.esm.js +78 -55
- package/dist/hooks/use-battery-optimization.js +78 -55
- package/dist/hooks/use-battery-status.esm.js +73 -51
- package/dist/hooks/use-battery-status.js +73 -51
- package/dist/hooks/use-component-performance.esm.js +62 -47
- package/dist/hooks/use-component-performance.js +62 -47
- package/dist/hooks/use-device-loading-states.esm.js +152 -109
- package/dist/hooks/use-device-loading-states.js +152 -109
- package/dist/hooks/use-device.esm.js +25 -14
- package/dist/hooks/use-device.js +25 -14
- package/dist/hooks/use-enterprise-mobile-experience.esm.js +137 -88
- package/dist/hooks/use-enterprise-mobile-experience.js +137 -88
- package/dist/hooks/use-form-feedback.esm.js +124 -81
- package/dist/hooks/use-form-feedback.js +124 -81
- package/dist/hooks/use-form-performance.esm.js +127 -92
- package/dist/hooks/use-form-performance.js +127 -92
- package/dist/hooks/use-frame-rate.esm.js +56 -37
- package/dist/hooks/use-frame-rate.js +56 -37
- package/dist/hooks/use-gestures.esm.js +96 -72
- package/dist/hooks/use-gestures.js +96 -72
- package/dist/hooks/use-hardware-acceleration.esm.js +65 -37
- package/dist/hooks/use-hardware-acceleration.js +65 -37
- package/dist/hooks/use-input-accessibility.esm.js +157 -119
- package/dist/hooks/use-input-accessibility.js +157 -119
- package/dist/hooks/use-input-performance.esm.js +139 -104
- package/dist/hooks/use-input-performance.js +139 -104
- package/dist/hooks/use-layout-performance.esm.js +50 -29
- package/dist/hooks/use-layout-performance.js +50 -29
- package/dist/hooks/use-loading-accessibility.esm.js +209 -169
- package/dist/hooks/use-loading-accessibility.js +209 -169
- package/dist/hooks/use-loading-performance.esm.js +117 -93
- package/dist/hooks/use-loading-performance.js +117 -93
- package/dist/hooks/use-memory-usage.esm.js +57 -38
- package/dist/hooks/use-memory-usage.js +57 -38
- package/dist/hooks/use-mobile-form-layout.esm.js +111 -74
- package/dist/hooks/use-mobile-form-layout.js +111 -74
- package/dist/hooks/use-mobile-form-validation.esm.js +211 -144
- package/dist/hooks/use-mobile-form-validation.js +211 -144
- package/dist/hooks/use-mobile-keyboard-optimization.esm.js +154 -113
- package/dist/hooks/use-mobile-keyboard-optimization.js +154 -113
- package/dist/hooks/use-mobile-layout.esm.js +73 -51
- package/dist/hooks/use-mobile-layout.js +73 -51
- package/dist/hooks/use-mobile-optimization.esm.js +72 -44
- package/dist/hooks/use-mobile-optimization.js +72 -44
- package/dist/hooks/use-mobile-skeleton.esm.js +97 -64
- package/dist/hooks/use-mobile-skeleton.js +97 -64
- package/dist/hooks/use-mobile-touch.esm.js +128 -93
- package/dist/hooks/use-mobile-touch.js +128 -93
- package/dist/hooks/use-performance-throttling.esm.js +72 -48
- package/dist/hooks/use-performance-throttling.js +72 -48
- package/dist/hooks/use-performance.esm.js +90 -52
- package/dist/hooks/use-performance.js +90 -52
- package/dist/hooks/use-reusable-architecture.esm.js +94 -65
- package/dist/hooks/use-reusable-architecture.js +94 -65
- package/dist/hooks/use-semantic-input-types.esm.js +166 -124
- package/dist/hooks/use-semantic-input-types.js +166 -124
- package/dist/hooks/use-semantic-input.esm.js +178 -126
- package/dist/hooks/use-semantic-input.js +178 -126
- package/dist/hooks/use-tablet-layout.esm.js +67 -38
- package/dist/hooks/use-tablet-layout.js +67 -38
- package/dist/hooks/use-touch-friendly-input.esm.js +193 -149
- package/dist/hooks/use-touch-friendly-input.js +193 -149
- package/dist/hooks/use-touch-friendly-interface.esm.js +99 -67
- package/dist/hooks/use-touch-friendly-interface.js +99 -67
- package/dist/hooks/use-touch-optimization.esm.js +99 -72
- package/dist/hooks/use-touch-optimization.js +99 -72
- package/dist/index.esm.js +157 -281
- package/dist/index.js +157 -281
- package/dist/lib/utils.esm.js +1 -1
- package/dist/lib/utils.js +1 -1
- package/dist/plugins/theme-css-generator.esm.js +104 -55
- package/dist/plugins/theme-css-generator.js +104 -55
- package/dist/provider.esm.js +4 -4
- package/dist/provider.js +4 -4
- package/dist/styles.css +1 -1
- package/dist/theme.esm.js +633 -468
- package/dist/theme.js +633 -468
- package/dist/themes/ThemeContext.esm.js +15 -15
- package/dist/themes/ThemeContext.js +15 -15
- package/dist/themes/ThemeProvider.esm.js +25 -22
- package/dist/themes/ThemeProvider.js +25 -22
- package/dist/themes/accessibility.esm.js +147 -108
- package/dist/themes/accessibility.js +147 -108
- package/dist/themes/aria-patterns.esm.js +198 -162
- package/dist/themes/aria-patterns.js +198 -162
- package/dist/themes/base-themes.esm.js +14 -11
- package/dist/themes/base-themes.js +14 -11
- package/dist/themes/colorManager.esm.js +101 -83
- package/dist/themes/colorManager.js +101 -83
- package/dist/themes/examples/dark-theme.esm.js +133 -103
- package/dist/themes/examples/dark-theme.js +133 -103
- package/dist/themes/examples/minimal-theme.esm.js +83 -61
- package/dist/themes/examples/minimal-theme.js +83 -61
- package/dist/themes/focus-management.esm.js +202 -143
- package/dist/themes/focus-management.js +202 -143
- package/dist/themes/fontLoader.esm.js +28 -19
- package/dist/themes/fontLoader.js +28 -19
- package/dist/themes/high-contrast.esm.js +152 -104
- package/dist/themes/high-contrast.js +152 -104
- package/dist/themes/index.esm.js +1 -1
- package/dist/themes/index.js +1 -1
- package/dist/themes/inheritance.esm.js +35 -27
- package/dist/themes/inheritance.js +35 -27
- package/dist/themes/keyboard-navigation.esm.js +152 -123
- package/dist/themes/keyboard-navigation.js +152 -123
- package/dist/themes/motion-reduction.esm.js +193 -133
- package/dist/themes/motion-reduction.js +193 -133
- package/dist/themes/navigation.esm.js +146 -146
- package/dist/themes/navigation.js +146 -146
- package/dist/themes/screen-reader.esm.js +159 -94
- package/dist/themes/screen-reader.js +159 -94
- package/dist/themes/systemThemeDetector.esm.js +42 -34
- package/dist/themes/systemThemeDetector.js +42 -34
- package/dist/themes/themeCSSUpdater.esm.js +21 -9
- package/dist/themes/themeCSSUpdater.js +21 -9
- package/dist/themes/themePersistence.esm.js +68 -47
- package/dist/themes/themePersistence.js +68 -47
- package/dist/themes/themes/stan-design.esm.js +633 -468
- package/dist/themes/themes/stan-design.js +633 -468
- package/dist/themes/types.esm.js +301 -287
- package/dist/themes/types.js +301 -287
- package/dist/themes/useSystemTheme.esm.js +4 -4
- package/dist/themes/useSystemTheme.js +4 -4
- package/dist/themes/useTheme.esm.js +4 -4
- package/dist/themes/useTheme.js +4 -4
- package/dist/themes/validation.esm.js +128 -77
- package/dist/themes/validation.js +128 -77
- package/dist/tokens/index.esm.js +1 -2
- package/dist/tokens/index.js +1 -2
- package/dist/tokens/tokenExporter.esm.js +87 -61
- package/dist/tokens/tokenExporter.js +87 -61
- package/dist/tokens/tokenGenerator.esm.js +86 -77
- package/dist/tokens/tokenGenerator.js +86 -77
- package/dist/tokens/tokenManager.esm.js +64 -51
- package/dist/tokens/tokenManager.js +64 -51
- package/dist/tokens/tokenValidator.esm.js +193 -147
- package/dist/tokens/tokenValidator.js +193 -147
- package/dist/tokens/types.esm.js +49 -35
- package/dist/tokens/types.js +49 -35
- package/dist/utils/bundle-analyzer.esm.js +83 -65
- package/dist/utils/bundle-analyzer.js +83 -65
- package/dist/utils/bundle-splitting.esm.js +142 -117
- package/dist/utils/bundle-splitting.js +142 -117
- package/dist/utils/lazy-loading.esm.js +132 -106
- package/dist/utils/lazy-loading.js +132 -106
- package/dist/utils/performance-monitor.esm.js +170 -129
- package/dist/utils/performance-monitor.js +170 -129
- package/dist/utils/tree-shaking.esm.js +69 -61
- package/dist/utils/tree-shaking.js +69 -61
- package/package.json +1 -1
- package/src/index.ts +146 -146
|
@@ -1,22 +1,36 @@
|
|
|
1
1
|
import { useState, useEffect, useCallback, useRef } from 'react'
|
|
2
2
|
|
|
3
3
|
export interface BatteryStatus {
|
|
4
|
-
level
|
|
4
|
+
level: number
|
|
5
|
+
charging: boolean
|
|
6
|
+
chargingTime: number
|
|
7
|
+
dischargingTime: number
|
|
8
|
+
isLow: boolean
|
|
9
|
+
isCritical: boolean
|
|
10
|
+
}
|
|
5
11
|
|
|
6
12
|
export interface BatteryOptimizationConfig {
|
|
7
|
-
enableBatteryMonitoring
|
|
13
|
+
enableBatteryMonitoring?: boolean
|
|
14
|
+
enablePerformanceThrottling?: boolean
|
|
15
|
+
enableUserPreferences?: boolean
|
|
16
|
+
enableAdaptiveOptimization?: boolean
|
|
17
|
+
lowBatteryThreshold?: number
|
|
18
|
+
criticalBatteryThreshold?: number
|
|
19
|
+
performanceThrottleLevel?: 'none' | 'light' | 'moderate' | 'aggressive'
|
|
20
|
+
userPreferenceLevel?: 'performance' | 'balanced' | 'battery'
|
|
21
|
+
}
|
|
8
22
|
|
|
9
23
|
export interface BatteryOptimizationCallbacks {
|
|
10
|
-
onBatteryStatusChange
|
|
11
|
-
onLowBatteryWarning
|
|
12
|
-
onCriticalBatteryWarning
|
|
13
|
-
onPerformanceThrottled
|
|
14
|
-
onOptimizationApplied
|
|
24
|
+
onBatteryStatusChange?: (status: BatteryStatus) => void
|
|
25
|
+
onLowBatteryWarning?: (status: BatteryStatus) => void
|
|
26
|
+
onCriticalBatteryWarning?: (status: BatteryStatus) => void
|
|
27
|
+
onPerformanceThrottled?: (level: string, reason: string) => void
|
|
28
|
+
onOptimizationApplied?: (optimization: string) => void
|
|
15
29
|
}
|
|
16
30
|
|
|
17
31
|
export const useBatteryOptimization = (
|
|
18
|
-
config= {},
|
|
19
|
-
callbacks= {}
|
|
32
|
+
config: BatteryOptimizationConfig = {},
|
|
33
|
+
callbacks: BatteryOptimizationCallbacks = {}
|
|
20
34
|
) => {
|
|
21
35
|
const {
|
|
22
36
|
enableBatteryMonitoring = true,
|
|
@@ -29,12 +43,13 @@ export const useBatteryOptimization = (
|
|
|
29
43
|
} = config
|
|
30
44
|
|
|
31
45
|
const [batteryStatus, setBatteryStatus] = useState<BatteryStatus>({
|
|
32
|
-
level,
|
|
33
|
-
charging,
|
|
34
|
-
chargingTime,
|
|
35
|
-
dischargingTime,
|
|
36
|
-
isLow,
|
|
37
|
-
isCritical
|
|
46
|
+
level: 1,
|
|
47
|
+
charging: false,
|
|
48
|
+
chargingTime: 0,
|
|
49
|
+
dischargingTime: 0,
|
|
50
|
+
isLow: false,
|
|
51
|
+
isCritical: false
|
|
52
|
+
})
|
|
38
53
|
const [isOptimizing, setIsOptimizing] = useState(false)
|
|
39
54
|
const [optimizations, setOptimizations] = useState<string[]>([])
|
|
40
55
|
const [currentThrottleLevel, setCurrentThrottleLevel] = useState<string>('none')
|
|
@@ -45,20 +60,20 @@ export const useBatteryOptimization = (
|
|
|
45
60
|
const optimizationTimerRef = useRef<number | null>(null)
|
|
46
61
|
|
|
47
62
|
// Get battery status
|
|
48
|
-
const getBatteryStatus = useCallback(async ()=> {
|
|
63
|
+
const getBatteryStatus = useCallback(async (): Promise<BatteryStatus | null> => {
|
|
49
64
|
if (!enableBatteryMonitoring || !('getBattery' in navigator)) return null
|
|
50
65
|
|
|
51
66
|
try {
|
|
52
67
|
const battery = await (navigator as any).getBattery()
|
|
53
68
|
batteryRef.current = battery
|
|
54
69
|
|
|
55
|
-
const status= {
|
|
56
|
-
level,
|
|
57
|
-
charging,
|
|
58
|
-
chargingTime,
|
|
59
|
-
dischargingTime,
|
|
60
|
-
isLow
|
|
61
|
-
isCritical
|
|
70
|
+
const status: BatteryStatus = {
|
|
71
|
+
level: battery.level,
|
|
72
|
+
charging: battery.charging,
|
|
73
|
+
chargingTime: battery.chargingTime,
|
|
74
|
+
dischargingTime: battery.dischargingTime,
|
|
75
|
+
isLow: battery.level <= lowBatteryThreshold,
|
|
76
|
+
isCritical: battery.level <= criticalBatteryThreshold
|
|
62
77
|
}
|
|
63
78
|
|
|
64
79
|
setBatteryStatus(status)
|
|
@@ -73,36 +88,39 @@ export const useBatteryOptimization = (
|
|
|
73
88
|
|
|
74
89
|
return status
|
|
75
90
|
} catch (error) {
|
|
76
|
-
console.warn('Battery API not available, error)
|
|
91
|
+
console.warn('Battery API not available:', error)
|
|
77
92
|
return null
|
|
78
93
|
}
|
|
79
94
|
}, [enableBatteryMonitoring, lowBatteryThreshold, criticalBatteryThreshold, callbacks])
|
|
80
95
|
|
|
81
96
|
// Apply performance throttling based on battery level
|
|
82
|
-
const applyPerformanceThrottling = useCallback((level) => {
|
|
97
|
+
const applyPerformanceThrottling = useCallback((level: string) => {
|
|
83
98
|
if (!enablePerformanceThrottling) return
|
|
84
99
|
|
|
85
100
|
setIsOptimizing(true)
|
|
86
101
|
setCurrentThrottleLevel(level)
|
|
87
102
|
|
|
88
103
|
setTimeout(() => {
|
|
89
|
-
let optimizations] = []
|
|
104
|
+
let optimizations: string[] = []
|
|
90
105
|
|
|
91
106
|
switch (level) {
|
|
92
|
-
case 'light'
|
|
107
|
+
case 'light':
|
|
108
|
+
optimizations = [
|
|
93
109
|
'Light performance throttling applied',
|
|
94
110
|
'Animation complexity reduced by 20%',
|
|
95
111
|
'Hardware acceleration optimized for battery'
|
|
96
112
|
]
|
|
97
113
|
break
|
|
98
|
-
case 'moderate'
|
|
114
|
+
case 'moderate':
|
|
115
|
+
optimizations = [
|
|
99
116
|
'Moderate performance throttling applied',
|
|
100
117
|
'Animation complexity reduced by 40%',
|
|
101
118
|
'GPU utilization limited for battery efficiency',
|
|
102
119
|
'Non-essential animations disabled'
|
|
103
120
|
]
|
|
104
121
|
break
|
|
105
|
-
case 'aggressive'
|
|
122
|
+
case 'aggressive':
|
|
123
|
+
optimizations = [
|
|
106
124
|
'Aggressive performance throttling applied',
|
|
107
125
|
'Animation complexity reduced by 70%',
|
|
108
126
|
'Hardware acceleration minimized',
|
|
@@ -110,7 +128,8 @@ export const useBatteryOptimization = (
|
|
|
110
128
|
'Background processes optimized'
|
|
111
129
|
]
|
|
112
130
|
break
|
|
113
|
-
default
|
|
131
|
+
default:
|
|
132
|
+
optimizations = ['Performance throttling disabled']
|
|
114
133
|
}
|
|
115
134
|
|
|
116
135
|
setOptimizations(prev => [...prev, ...optimizations])
|
|
@@ -130,24 +149,24 @@ export const useBatteryOptimization = (
|
|
|
130
149
|
setIsOptimizing(true)
|
|
131
150
|
|
|
132
151
|
setTimeout(() => {
|
|
133
|
-
const optimizations] = []
|
|
152
|
+
const optimizations: string[] = []
|
|
134
153
|
|
|
135
154
|
if (batteryStatus.isCritical) {
|
|
136
|
-
optimizations.push('Critical battery mode)
|
|
155
|
+
optimizations.push('Critical battery mode: Maximum power saving enabled')
|
|
137
156
|
optimizations.push('All non-essential features disabled')
|
|
138
157
|
optimizations.push('Hardware acceleration completely disabled')
|
|
139
158
|
applyPerformanceThrottling('aggressive')
|
|
140
159
|
} else if (batteryStatus.isLow) {
|
|
141
|
-
optimizations.push('Low battery mode)
|
|
160
|
+
optimizations.push('Low battery mode: Enhanced power saving enabled')
|
|
142
161
|
optimizations.push('Performance throttling applied')
|
|
143
162
|
optimizations.push('Hardware acceleration optimized for battery')
|
|
144
163
|
applyPerformanceThrottling('moderate')
|
|
145
164
|
} else if (batteryStatus.level < 0.5) {
|
|
146
|
-
optimizations.push('Medium battery)
|
|
165
|
+
optimizations.push('Medium battery: Light optimization applied')
|
|
147
166
|
optimizations.push('Hardware acceleration optimized')
|
|
148
167
|
applyPerformanceThrottling('light')
|
|
149
168
|
} else {
|
|
150
|
-
optimizations.push('High battery)
|
|
169
|
+
optimizations.push('High battery: Performance mode enabled')
|
|
151
170
|
optimizations.push('Hardware acceleration at full capacity')
|
|
152
171
|
applyPerformanceThrottling('none')
|
|
153
172
|
}
|
|
@@ -162,30 +181,33 @@ export const useBatteryOptimization = (
|
|
|
162
181
|
}, [enableAdaptiveOptimization, batteryStatus, applyPerformanceThrottling, callbacks])
|
|
163
182
|
|
|
164
183
|
// Handle user preferences
|
|
165
|
-
const updateUserPreferences = useCallback((preference) => {
|
|
184
|
+
const updateUserPreferences = useCallback((preference: string) => {
|
|
166
185
|
if (!enableUserPreferences) return
|
|
167
186
|
|
|
168
187
|
setUserPreferences(preference)
|
|
169
188
|
|
|
170
|
-
let optimizations] = []
|
|
189
|
+
let optimizations: string[] = []
|
|
171
190
|
|
|
172
191
|
switch (preference) {
|
|
173
|
-
case 'performance'
|
|
174
|
-
|
|
192
|
+
case 'performance':
|
|
193
|
+
optimizations = [
|
|
194
|
+
'User preference: Performance mode enabled',
|
|
175
195
|
'Hardware acceleration at maximum',
|
|
176
196
|
'Battery optimization disabled'
|
|
177
197
|
]
|
|
178
198
|
applyPerformanceThrottling('none')
|
|
179
199
|
break
|
|
180
|
-
case 'balanced'
|
|
181
|
-
|
|
200
|
+
case 'balanced':
|
|
201
|
+
optimizations = [
|
|
202
|
+
'User preference: Balanced mode enabled',
|
|
182
203
|
'Hardware acceleration optimized',
|
|
183
204
|
'Battery and performance balanced'
|
|
184
205
|
]
|
|
185
206
|
applyPerformanceThrottling('light')
|
|
186
207
|
break
|
|
187
|
-
case 'battery'
|
|
188
|
-
|
|
208
|
+
case 'battery':
|
|
209
|
+
optimizations = [
|
|
210
|
+
'User preference: Battery saver mode enabled',
|
|
189
211
|
'Hardware acceleration optimized for battery',
|
|
190
212
|
'Performance throttling applied'
|
|
191
213
|
]
|
|
@@ -204,19 +226,19 @@ export const useBatteryOptimization = (
|
|
|
204
226
|
const recommendations = []
|
|
205
227
|
|
|
206
228
|
if (batteryStatus.isCritical) {
|
|
207
|
-
recommendations.push('Critical battery)
|
|
229
|
+
recommendations.push('Critical battery: Disable all non-essential features')
|
|
208
230
|
recommendations.push('Reduce screen brightness and disable animations')
|
|
209
231
|
recommendations.push('Close unnecessary applications and tabs')
|
|
210
232
|
} else if (batteryStatus.isLow) {
|
|
211
|
-
recommendations.push('Low battery)
|
|
233
|
+
recommendations.push('Low battery: Enable battery saver mode')
|
|
212
234
|
recommendations.push('Reduce animation complexity and GPU usage')
|
|
213
235
|
recommendations.push('Optimize background processes')
|
|
214
236
|
} else if (batteryStatus.level < 0.5) {
|
|
215
|
-
recommendations.push('Medium battery)
|
|
237
|
+
recommendations.push('Medium battery: Consider light optimizations')
|
|
216
238
|
recommendations.push('Monitor hardware acceleration usage')
|
|
217
239
|
recommendations.push('Balance performance and battery life')
|
|
218
240
|
} else {
|
|
219
|
-
recommendations.push('High battery)
|
|
241
|
+
recommendations.push('High battery: Full performance available')
|
|
220
242
|
recommendations.push('Hardware acceleration at maximum capacity')
|
|
221
243
|
recommendations.push('Monitor for optimal performance')
|
|
222
244
|
}
|
|
@@ -241,7 +263,7 @@ export const useBatteryOptimization = (
|
|
|
241
263
|
}
|
|
242
264
|
}
|
|
243
265
|
} catch (error) {
|
|
244
|
-
console.warn('Battery optimization initialization failed, error)
|
|
266
|
+
console.warn('Battery optimization initialization failed:', error)
|
|
245
267
|
}
|
|
246
268
|
}, [enableBatteryMonitoring, getBatteryStatus])
|
|
247
269
|
|
|
@@ -286,15 +308,16 @@ export const useBatteryOptimization = (
|
|
|
286
308
|
updateUserPreferences,
|
|
287
309
|
|
|
288
310
|
// Computed values
|
|
289
|
-
isLowBattery,
|
|
290
|
-
isCriticalBattery,
|
|
291
|
-
batteryPercentage),
|
|
292
|
-
optimizationRecommendations),
|
|
293
|
-
isCharging,
|
|
294
|
-
estimatedTimeRemaining
|
|
311
|
+
isLowBattery: batteryStatus.isLow,
|
|
312
|
+
isCriticalBattery: batteryStatus.isCritical,
|
|
313
|
+
batteryPercentage: Math.round(batteryStatus.level * 100),
|
|
314
|
+
optimizationRecommendations: getOptimizationRecommendations(),
|
|
315
|
+
isCharging: batteryStatus.charging,
|
|
316
|
+
estimatedTimeRemaining: batteryStatus.charging ?
|
|
317
|
+
batteryStatus.chargingTime : batteryStatus.dischargingTime,
|
|
295
318
|
|
|
296
319
|
// Utility functions
|
|
297
|
-
getBatteryHealth) => {
|
|
320
|
+
getBatteryHealth: () => {
|
|
298
321
|
if (batteryStatus.level >= 0.8) return 'excellent'
|
|
299
322
|
if (batteryStatus.level >= 0.6) return 'good'
|
|
300
323
|
if (batteryStatus.level >= 0.4) return 'fair'
|
|
@@ -1,22 +1,36 @@
|
|
|
1
1
|
import { useState, useEffect, useCallback, useRef } from 'react'
|
|
2
2
|
|
|
3
3
|
export interface BatteryStatus {
|
|
4
|
-
level
|
|
4
|
+
level: number
|
|
5
|
+
charging: boolean
|
|
6
|
+
chargingTime: number
|
|
7
|
+
dischargingTime: number
|
|
8
|
+
isLow: boolean
|
|
9
|
+
isCritical: boolean
|
|
10
|
+
}
|
|
5
11
|
|
|
6
12
|
export interface BatteryOptimizationConfig {
|
|
7
|
-
enableBatteryMonitoring
|
|
13
|
+
enableBatteryMonitoring?: boolean
|
|
14
|
+
enablePerformanceThrottling?: boolean
|
|
15
|
+
enableUserPreferences?: boolean
|
|
16
|
+
enableAdaptiveOptimization?: boolean
|
|
17
|
+
lowBatteryThreshold?: number
|
|
18
|
+
criticalBatteryThreshold?: number
|
|
19
|
+
performanceThrottleLevel?: 'none' | 'light' | 'moderate' | 'aggressive'
|
|
20
|
+
userPreferenceLevel?: 'performance' | 'balanced' | 'battery'
|
|
21
|
+
}
|
|
8
22
|
|
|
9
23
|
export interface BatteryOptimizationCallbacks {
|
|
10
|
-
onBatteryStatusChange
|
|
11
|
-
onLowBatteryWarning
|
|
12
|
-
onCriticalBatteryWarning
|
|
13
|
-
onPerformanceThrottled
|
|
14
|
-
onOptimizationApplied
|
|
24
|
+
onBatteryStatusChange?: (status: BatteryStatus) => void
|
|
25
|
+
onLowBatteryWarning?: (status: BatteryStatus) => void
|
|
26
|
+
onCriticalBatteryWarning?: (status: BatteryStatus) => void
|
|
27
|
+
onPerformanceThrottled?: (level: string, reason: string) => void
|
|
28
|
+
onOptimizationApplied?: (optimization: string) => void
|
|
15
29
|
}
|
|
16
30
|
|
|
17
31
|
export const useBatteryOptimization = (
|
|
18
|
-
config= {},
|
|
19
|
-
callbacks= {}
|
|
32
|
+
config: BatteryOptimizationConfig = {},
|
|
33
|
+
callbacks: BatteryOptimizationCallbacks = {}
|
|
20
34
|
) => {
|
|
21
35
|
const {
|
|
22
36
|
enableBatteryMonitoring = true,
|
|
@@ -29,12 +43,13 @@ export const useBatteryOptimization = (
|
|
|
29
43
|
} = config
|
|
30
44
|
|
|
31
45
|
const [batteryStatus, setBatteryStatus] = useState<BatteryStatus>({
|
|
32
|
-
level,
|
|
33
|
-
charging,
|
|
34
|
-
chargingTime,
|
|
35
|
-
dischargingTime,
|
|
36
|
-
isLow,
|
|
37
|
-
isCritical
|
|
46
|
+
level: 1,
|
|
47
|
+
charging: false,
|
|
48
|
+
chargingTime: 0,
|
|
49
|
+
dischargingTime: 0,
|
|
50
|
+
isLow: false,
|
|
51
|
+
isCritical: false
|
|
52
|
+
})
|
|
38
53
|
const [isOptimizing, setIsOptimizing] = useState(false)
|
|
39
54
|
const [optimizations, setOptimizations] = useState<string[]>([])
|
|
40
55
|
const [currentThrottleLevel, setCurrentThrottleLevel] = useState<string>('none')
|
|
@@ -45,20 +60,20 @@ export const useBatteryOptimization = (
|
|
|
45
60
|
const optimizationTimerRef = useRef<number | null>(null)
|
|
46
61
|
|
|
47
62
|
// Get battery status
|
|
48
|
-
const getBatteryStatus = useCallback(async ()=> {
|
|
63
|
+
const getBatteryStatus = useCallback(async (): Promise<BatteryStatus | null> => {
|
|
49
64
|
if (!enableBatteryMonitoring || !('getBattery' in navigator)) return null
|
|
50
65
|
|
|
51
66
|
try {
|
|
52
67
|
const battery = await (navigator as any).getBattery()
|
|
53
68
|
batteryRef.current = battery
|
|
54
69
|
|
|
55
|
-
const status= {
|
|
56
|
-
level,
|
|
57
|
-
charging,
|
|
58
|
-
chargingTime,
|
|
59
|
-
dischargingTime,
|
|
60
|
-
isLow
|
|
61
|
-
isCritical
|
|
70
|
+
const status: BatteryStatus = {
|
|
71
|
+
level: battery.level,
|
|
72
|
+
charging: battery.charging,
|
|
73
|
+
chargingTime: battery.chargingTime,
|
|
74
|
+
dischargingTime: battery.dischargingTime,
|
|
75
|
+
isLow: battery.level <= lowBatteryThreshold,
|
|
76
|
+
isCritical: battery.level <= criticalBatteryThreshold
|
|
62
77
|
}
|
|
63
78
|
|
|
64
79
|
setBatteryStatus(status)
|
|
@@ -73,36 +88,39 @@ export const useBatteryOptimization = (
|
|
|
73
88
|
|
|
74
89
|
return status
|
|
75
90
|
} catch (error) {
|
|
76
|
-
console.warn('Battery API not available, error)
|
|
91
|
+
console.warn('Battery API not available:', error)
|
|
77
92
|
return null
|
|
78
93
|
}
|
|
79
94
|
}, [enableBatteryMonitoring, lowBatteryThreshold, criticalBatteryThreshold, callbacks])
|
|
80
95
|
|
|
81
96
|
// Apply performance throttling based on battery level
|
|
82
|
-
const applyPerformanceThrottling = useCallback((level) => {
|
|
97
|
+
const applyPerformanceThrottling = useCallback((level: string) => {
|
|
83
98
|
if (!enablePerformanceThrottling) return
|
|
84
99
|
|
|
85
100
|
setIsOptimizing(true)
|
|
86
101
|
setCurrentThrottleLevel(level)
|
|
87
102
|
|
|
88
103
|
setTimeout(() => {
|
|
89
|
-
let optimizations] = []
|
|
104
|
+
let optimizations: string[] = []
|
|
90
105
|
|
|
91
106
|
switch (level) {
|
|
92
|
-
case 'light'
|
|
107
|
+
case 'light':
|
|
108
|
+
optimizations = [
|
|
93
109
|
'Light performance throttling applied',
|
|
94
110
|
'Animation complexity reduced by 20%',
|
|
95
111
|
'Hardware acceleration optimized for battery'
|
|
96
112
|
]
|
|
97
113
|
break
|
|
98
|
-
case 'moderate'
|
|
114
|
+
case 'moderate':
|
|
115
|
+
optimizations = [
|
|
99
116
|
'Moderate performance throttling applied',
|
|
100
117
|
'Animation complexity reduced by 40%',
|
|
101
118
|
'GPU utilization limited for battery efficiency',
|
|
102
119
|
'Non-essential animations disabled'
|
|
103
120
|
]
|
|
104
121
|
break
|
|
105
|
-
case 'aggressive'
|
|
122
|
+
case 'aggressive':
|
|
123
|
+
optimizations = [
|
|
106
124
|
'Aggressive performance throttling applied',
|
|
107
125
|
'Animation complexity reduced by 70%',
|
|
108
126
|
'Hardware acceleration minimized',
|
|
@@ -110,7 +128,8 @@ export const useBatteryOptimization = (
|
|
|
110
128
|
'Background processes optimized'
|
|
111
129
|
]
|
|
112
130
|
break
|
|
113
|
-
default
|
|
131
|
+
default:
|
|
132
|
+
optimizations = ['Performance throttling disabled']
|
|
114
133
|
}
|
|
115
134
|
|
|
116
135
|
setOptimizations(prev => [...prev, ...optimizations])
|
|
@@ -130,24 +149,24 @@ export const useBatteryOptimization = (
|
|
|
130
149
|
setIsOptimizing(true)
|
|
131
150
|
|
|
132
151
|
setTimeout(() => {
|
|
133
|
-
const optimizations] = []
|
|
152
|
+
const optimizations: string[] = []
|
|
134
153
|
|
|
135
154
|
if (batteryStatus.isCritical) {
|
|
136
|
-
optimizations.push('Critical battery mode)
|
|
155
|
+
optimizations.push('Critical battery mode: Maximum power saving enabled')
|
|
137
156
|
optimizations.push('All non-essential features disabled')
|
|
138
157
|
optimizations.push('Hardware acceleration completely disabled')
|
|
139
158
|
applyPerformanceThrottling('aggressive')
|
|
140
159
|
} else if (batteryStatus.isLow) {
|
|
141
|
-
optimizations.push('Low battery mode)
|
|
160
|
+
optimizations.push('Low battery mode: Enhanced power saving enabled')
|
|
142
161
|
optimizations.push('Performance throttling applied')
|
|
143
162
|
optimizations.push('Hardware acceleration optimized for battery')
|
|
144
163
|
applyPerformanceThrottling('moderate')
|
|
145
164
|
} else if (batteryStatus.level < 0.5) {
|
|
146
|
-
optimizations.push('Medium battery)
|
|
165
|
+
optimizations.push('Medium battery: Light optimization applied')
|
|
147
166
|
optimizations.push('Hardware acceleration optimized')
|
|
148
167
|
applyPerformanceThrottling('light')
|
|
149
168
|
} else {
|
|
150
|
-
optimizations.push('High battery)
|
|
169
|
+
optimizations.push('High battery: Performance mode enabled')
|
|
151
170
|
optimizations.push('Hardware acceleration at full capacity')
|
|
152
171
|
applyPerformanceThrottling('none')
|
|
153
172
|
}
|
|
@@ -162,30 +181,33 @@ export const useBatteryOptimization = (
|
|
|
162
181
|
}, [enableAdaptiveOptimization, batteryStatus, applyPerformanceThrottling, callbacks])
|
|
163
182
|
|
|
164
183
|
// Handle user preferences
|
|
165
|
-
const updateUserPreferences = useCallback((preference) => {
|
|
184
|
+
const updateUserPreferences = useCallback((preference: string) => {
|
|
166
185
|
if (!enableUserPreferences) return
|
|
167
186
|
|
|
168
187
|
setUserPreferences(preference)
|
|
169
188
|
|
|
170
|
-
let optimizations] = []
|
|
189
|
+
let optimizations: string[] = []
|
|
171
190
|
|
|
172
191
|
switch (preference) {
|
|
173
|
-
case 'performance'
|
|
174
|
-
|
|
192
|
+
case 'performance':
|
|
193
|
+
optimizations = [
|
|
194
|
+
'User preference: Performance mode enabled',
|
|
175
195
|
'Hardware acceleration at maximum',
|
|
176
196
|
'Battery optimization disabled'
|
|
177
197
|
]
|
|
178
198
|
applyPerformanceThrottling('none')
|
|
179
199
|
break
|
|
180
|
-
case 'balanced'
|
|
181
|
-
|
|
200
|
+
case 'balanced':
|
|
201
|
+
optimizations = [
|
|
202
|
+
'User preference: Balanced mode enabled',
|
|
182
203
|
'Hardware acceleration optimized',
|
|
183
204
|
'Battery and performance balanced'
|
|
184
205
|
]
|
|
185
206
|
applyPerformanceThrottling('light')
|
|
186
207
|
break
|
|
187
|
-
case 'battery'
|
|
188
|
-
|
|
208
|
+
case 'battery':
|
|
209
|
+
optimizations = [
|
|
210
|
+
'User preference: Battery saver mode enabled',
|
|
189
211
|
'Hardware acceleration optimized for battery',
|
|
190
212
|
'Performance throttling applied'
|
|
191
213
|
]
|
|
@@ -204,19 +226,19 @@ export const useBatteryOptimization = (
|
|
|
204
226
|
const recommendations = []
|
|
205
227
|
|
|
206
228
|
if (batteryStatus.isCritical) {
|
|
207
|
-
recommendations.push('Critical battery)
|
|
229
|
+
recommendations.push('Critical battery: Disable all non-essential features')
|
|
208
230
|
recommendations.push('Reduce screen brightness and disable animations')
|
|
209
231
|
recommendations.push('Close unnecessary applications and tabs')
|
|
210
232
|
} else if (batteryStatus.isLow) {
|
|
211
|
-
recommendations.push('Low battery)
|
|
233
|
+
recommendations.push('Low battery: Enable battery saver mode')
|
|
212
234
|
recommendations.push('Reduce animation complexity and GPU usage')
|
|
213
235
|
recommendations.push('Optimize background processes')
|
|
214
236
|
} else if (batteryStatus.level < 0.5) {
|
|
215
|
-
recommendations.push('Medium battery)
|
|
237
|
+
recommendations.push('Medium battery: Consider light optimizations')
|
|
216
238
|
recommendations.push('Monitor hardware acceleration usage')
|
|
217
239
|
recommendations.push('Balance performance and battery life')
|
|
218
240
|
} else {
|
|
219
|
-
recommendations.push('High battery)
|
|
241
|
+
recommendations.push('High battery: Full performance available')
|
|
220
242
|
recommendations.push('Hardware acceleration at maximum capacity')
|
|
221
243
|
recommendations.push('Monitor for optimal performance')
|
|
222
244
|
}
|
|
@@ -241,7 +263,7 @@ export const useBatteryOptimization = (
|
|
|
241
263
|
}
|
|
242
264
|
}
|
|
243
265
|
} catch (error) {
|
|
244
|
-
console.warn('Battery optimization initialization failed, error)
|
|
266
|
+
console.warn('Battery optimization initialization failed:', error)
|
|
245
267
|
}
|
|
246
268
|
}, [enableBatteryMonitoring, getBatteryStatus])
|
|
247
269
|
|
|
@@ -286,15 +308,16 @@ export const useBatteryOptimization = (
|
|
|
286
308
|
updateUserPreferences,
|
|
287
309
|
|
|
288
310
|
// Computed values
|
|
289
|
-
isLowBattery,
|
|
290
|
-
isCriticalBattery,
|
|
291
|
-
batteryPercentage),
|
|
292
|
-
optimizationRecommendations),
|
|
293
|
-
isCharging,
|
|
294
|
-
estimatedTimeRemaining
|
|
311
|
+
isLowBattery: batteryStatus.isLow,
|
|
312
|
+
isCriticalBattery: batteryStatus.isCritical,
|
|
313
|
+
batteryPercentage: Math.round(batteryStatus.level * 100),
|
|
314
|
+
optimizationRecommendations: getOptimizationRecommendations(),
|
|
315
|
+
isCharging: batteryStatus.charging,
|
|
316
|
+
estimatedTimeRemaining: batteryStatus.charging ?
|
|
317
|
+
batteryStatus.chargingTime : batteryStatus.dischargingTime,
|
|
295
318
|
|
|
296
319
|
// Utility functions
|
|
297
|
-
getBatteryHealth) => {
|
|
320
|
+
getBatteryHealth: () => {
|
|
298
321
|
if (batteryStatus.level >= 0.8) return 'excellent'
|
|
299
322
|
if (batteryStatus.level >= 0.6) return 'good'
|
|
300
323
|
if (batteryStatus.level >= 0.4) return 'fair'
|