Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Batter indicator fix #461

Merged
merged 2 commits into from
Jul 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/renderer/component/Battery/BatteryStatusSide.js
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ const BatteryStatusSide = ({ side, batteryLevel, isSavingMode, batteryStatus, si
if (batteryLevel < 10 && !isSavingMode && batteryStatus === 0) {
setSideStatus("status--critical");
}
if (batteryStatus === 1 || batteryStatus === 2) {
if (batteryStatus === 1) {
setIsCharging(true);
}
}, [size, batteryLevel, batteryStatus, isSavingMode]);
Expand Down
17 changes: 5 additions & 12 deletions src/renderer/component/Battery/DefyBatteryIndicator.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,17 +78,10 @@ const DefyBatteryIndicator = ({ side, batteryLevel, isCharging, batteryStatus })
<Style>
<div className="batterySideWrapper">
<div className="batterySide">
{side === "left" ? (
<DefyBatteryIndicatorLeft isCharging={isCharging} batteryStatus={batteryStatus} batteryHeight={batteryHeight} />
) : (
""
)}
{side === "right" ? (
<DefyBatteryIndicatorRight isCharging={isCharging} batteryStatus={batteryStatus} batteryHeight={batteryHeight} />
) : (
""
)}
{!isCharging && batteryStatus === 0 ? <div className="batterySide--percentage">{batteryLevel}%</div> : ""}
{side === "left" ? <DefyBatteryIndicatorLeft batteryStatus={batteryStatus} batteryHeight={batteryHeight} /> : ""}
{side === "right" ? <DefyBatteryIndicatorRight batteryStatus={batteryStatus} batteryHeight={batteryHeight} /> : ""}
{batteryStatus === 0 ? <div className="batterySide--percentage">{batteryLevel}%</div> : ""}
{batteryStatus === 2 ? <div className="batterySide--percentage">100%</div> : ""}
</div>
{batteryStatus === 3 ? (
<div className="alertMessage alert-warning">{i18n.wireless.batteryPreferences.batteryErrorReading}</div>
Expand All @@ -100,7 +93,7 @@ const DefyBatteryIndicator = ({ side, batteryLevel, isCharging, batteryStatus })
) : (
""
)}
{batteryStatus === 0xff ? (
{batteryStatus === 255 ? (
<div className="alertMessage alert-fatal-error">{i18n.wireless.batteryPreferences.batteryFatalError}</div>
) : (
""
Expand Down
6 changes: 3 additions & 3 deletions src/renderer/component/Battery/DefyBatteryIndicatorLeft.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from "react";

const DefyBatteryIndicatorLeft = ({ isCharging, batteryStatus, batteryHeight }) => {
const DefyBatteryIndicatorLeft = ({ batteryStatus, batteryHeight }) => {
const maskHash = `${(Math.random() + 1).toString(36).substring(7)}-left`;
return (
<svg
Expand Down Expand Up @@ -82,7 +82,7 @@ const DefyBatteryIndicatorLeft = ({ isCharging, batteryStatus, batteryHeight })
) : (
""
)}
{isCharging ? (
{batteryStatus === 1 ? (
<path
className="lightningbattery"
d="M40.9893 63.989L51.6559 48.1001V60.3223H56.9893L46.3226 77.4334V63.989H40.9893Z"
Expand Down Expand Up @@ -112,7 +112,7 @@ const DefyBatteryIndicatorLeft = ({ isCharging, batteryStatus, batteryHeight })
) : (
""
)}
{batteryStatus == 0xff ? (
{batteryStatus === 255 ? (
<path
d="M50.1789 67.6962C50.1789 68.0322 49.9869 68.2002 49.6029 68.2002H47.1549C46.8509 68.2002 46.6989 68.0562 46.6989 67.7682V65.1042C46.6989 64.8482 46.8029 64.7202 47.0109 64.7202H49.8669C50.0749 64.7202 50.1789 64.8322 50.1789 65.0562V67.6962ZM49.4829 62.5842C49.4829 62.7602 49.4349 62.8882 49.3389 62.9682C49.2589 63.0322 49.1229 63.0642 48.9309 63.0642H47.8749C47.6989 63.0642 47.5869 63.0322 47.5389 62.9682C47.4909 62.9042 47.4509 62.7922 47.4189 62.6322L46.6509 50.7762C46.6349 50.6482 46.6589 50.5522 46.7229 50.4882C46.7869 50.4242 46.8669 50.3922 46.9629 50.3922H49.9389C50.1629 50.3922 50.2669 50.5042 50.2509 50.7282L49.4829 62.5842Z"
fill="#FF6B6B"
Expand Down
6 changes: 3 additions & 3 deletions src/renderer/component/Battery/DefyBatteryIndicatorRight.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from "react";

const DefyBatteryIndicatorRight = ({ isCharging, batteryStatus, batteryHeight }) => {
const DefyBatteryIndicatorRight = ({ batteryStatus, batteryHeight }) => {
const maskHash = `${(Math.random() + 1).toString(36).substring(7)}-right`;
return (
<svg
Expand Down Expand Up @@ -83,7 +83,7 @@ const DefyBatteryIndicatorRight = ({ isCharging, batteryStatus, batteryHeight })
) : (
""
)}
{isCharging ? (
{batteryStatus == 1 ? (
<path
className="lightningbattery"
d="M40.9893 63.989L51.6559 48.1001V60.3223H56.9893L46.3226 77.4334V63.989H40.9893Z"
Expand All @@ -103,7 +103,7 @@ const DefyBatteryIndicatorRight = ({ isCharging, batteryStatus, batteryHeight })
""
)}
{batteryStatus == 4 ? <path d="M106 130L2 1" stroke="currentColor" className="lineDisconnected" strokeWidth="3" /> : ""}
{batteryStatus == 0xff ? (
{batteryStatus === 255 ? (
<path
d="M50.1789 67.6962C50.1789 68.0322 49.9869 68.2002 49.6029 68.2002H47.1549C46.8509 68.2002 46.6989 68.0562 46.6989 67.7682V65.1042C46.6989 64.8482 46.8029 64.7202 47.0109 64.7202H49.8669C50.0749 64.7202 50.1789 64.8322 50.1789 65.0562V67.6962ZM49.4829 62.5842C49.4829 62.7602 49.4349 62.8882 49.3389 62.9682C49.2589 63.0322 49.1229 63.0642 48.9309 63.0642H47.8749C47.6989 63.0642 47.5869 63.0322 47.5389 62.9682C47.4909 62.9042 47.4509 62.7922 47.4189 62.6322L46.6509 50.7762C46.6349 50.6482 46.6589 50.5522 46.7229 50.4882C46.7869 50.4242 46.8669 50.3922 46.9629 50.3922H49.9389C50.1629 50.3922 50.2669 50.5042 50.2509 50.7282L49.4829 62.5842Z"
fill="#FF6B6B"
Expand Down
11 changes: 3 additions & 8 deletions src/renderer/component/Battery/PileIndicator.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,13 +98,8 @@ const PileIndicator = ({ batteryLevel, isCharging, batteryStatus }) => {
)}
{batteryStatus == 2 ? (
<>
<mask id="mask2_2054_10394" style={{ maskType: "alpha" }} maskUnits="userSpaceOnUse" x="2" y="6" width="16" height="4">
<rect x="2" y="6" width="16" height="4" fill="#7879F1" />
</mask>
<g mask="url(#mask2_2054_10394)">
<path d="M16.75 6H13.75V3.5H23.75V14H11.75L16.75 6Z" fill="currentColor" />
<path d="M2.75 10.5L7.75 3H-2.25V14H5.75V10.5H2.75Z" fill="currentColor" />
</g>
<rect x="0.5" y="4.5" width="19" height="7" stroke="currentColor" />
<rect x="2" y="6" width={16} height="4" fill="currentColor" />
</>
) : (
""
Expand Down Expand Up @@ -162,7 +157,7 @@ const PileIndicator = ({ batteryLevel, isCharging, batteryStatus }) => {
) : (
""
)}
{batteryStatus == 0xff ? (
{batteryStatus === 255 ? (
<>
<mask id="mask0_2054_10114" style={{ maskType: "alpha" }} maskUnits="userSpaceOnUse" x="0" y="4" width="20" height="8">
<rect x="0.5" y="4.5" width="19" height="7" stroke="black" />
Expand Down
6 changes: 3 additions & 3 deletions src/renderer/theme/GlobalStyles.js
Original file line number Diff line number Diff line change
Expand Up @@ -1750,7 +1750,7 @@ div.card.card-preferences .card-body {
}
}
@media screen and (min-width: 1000px) {
#app {
#root {
--sidebarWidth: ${({ theme }) => theme.sidebarWidthLarge}px;
}
.bs-tooltip-right.tooltipMenu {
Expand All @@ -1770,7 +1770,7 @@ div.card.card-preferences .card-body {
}

@media screen and (max-height: 870px) {
#app {
#root {
--sidebarWidth: ${({ theme }) => theme.sidebarWidthMedium}px;
}
div.main-container {
Expand All @@ -1783,7 +1783,7 @@ div.card.card-preferences .card-body {
}

@media screen and (max-height: 670px) {
#app {
#root {
--sidebarWidth: ${({ theme }) => theme.sidebarWidthSmall}px;
}
}
Expand Down