mirror of
https://github.com/Theaninova/TheaninovOS.git
synced 2026-02-15 13:02:41 +00:00
feat: update system
This commit is contained in:
@@ -7,43 +7,35 @@ import PanelButton from "../PanelButton.js";
|
||||
|
||||
const Indicator = () =>
|
||||
Widget.Stack({
|
||||
items: [
|
||||
["false", Widget.Icon({ binds: [["icon", Battery, "icon-name"]] })],
|
||||
["true", FontIcon(icons.battery.charging)],
|
||||
],
|
||||
binds: [["visible", options.battery.bar.show_icon]],
|
||||
connections: [
|
||||
[
|
||||
Battery,
|
||||
(stack) => {
|
||||
stack.shown = `${Battery.charging || Battery.charged}`;
|
||||
},
|
||||
],
|
||||
],
|
||||
children: {
|
||||
false: Widget.Icon({ icon: Battery.bind("icon_name") }),
|
||||
true: FontIcon(icons.battery.charging),
|
||||
},
|
||||
visible: options.battery.bar.show_icon.bind("value"),
|
||||
setup: (self) =>
|
||||
self.hook(Battery, () => {
|
||||
self.shown = `${Battery.charging || Battery.charged}`;
|
||||
}),
|
||||
});
|
||||
|
||||
const PercentLabel = () =>
|
||||
Widget.Revealer({
|
||||
transition: "slide_right",
|
||||
binds: [["reveal-child", options.battery.show_percentage]],
|
||||
reveal_child: options.battery.show_percentage.bind("value"),
|
||||
child: Widget.Label({
|
||||
binds: [["label", Battery, "percent", (p) => `${p}%`]],
|
||||
label: Battery.bind("percent").transform((p) => `${p}%`),
|
||||
}),
|
||||
});
|
||||
|
||||
const LevelBar = () =>
|
||||
Widget.LevelBar({
|
||||
connections: [
|
||||
[
|
||||
options.battery.bar.full,
|
||||
(self) => {
|
||||
const full = options.battery.bar.full.value;
|
||||
self.vpack = full ? "fill" : "center";
|
||||
self.hpack = full ? "fill" : "center";
|
||||
},
|
||||
],
|
||||
],
|
||||
binds: [["value", Battery, "percent", (p) => p / 100]],
|
||||
value: Battery.bind("percent").transform((p) => p / 100),
|
||||
setup: (self) =>
|
||||
self.hook(options.battery.bar.full, () => {
|
||||
const full = options.battery.bar.full.value;
|
||||
self.vpack = full ? "fill" : "center";
|
||||
self.hpack = full ? "fill" : "center";
|
||||
}),
|
||||
});
|
||||
|
||||
const WholeButton = () =>
|
||||
@@ -57,7 +49,7 @@ const WholeButton = () =>
|
||||
children: [
|
||||
FontIcon({
|
||||
icon: icons.battery.charging,
|
||||
binds: [["visible", Battery, "charging"]],
|
||||
visible: Battery.bind("charging"),
|
||||
}),
|
||||
Widget.Box({
|
||||
hpack: "center",
|
||||
@@ -77,32 +69,21 @@ export default () =>
|
||||
options.battery.show_percentage.value = !v;
|
||||
},
|
||||
content: Widget.Box({
|
||||
connections: [
|
||||
[
|
||||
Battery,
|
||||
(w) => {
|
||||
w.toggleClassName("charging", Battery.charging || Battery.charged);
|
||||
w.toggleClassName(
|
||||
"medium",
|
||||
Battery.percent < options.battery.medium.value,
|
||||
);
|
||||
w.toggleClassName(
|
||||
"low",
|
||||
Battery.percent < options.battery.low.value,
|
||||
);
|
||||
w.toggleClassName("half", Battery.percent < 48);
|
||||
},
|
||||
],
|
||||
],
|
||||
binds: [
|
||||
["visible", Battery, "available"],
|
||||
[
|
||||
"children",
|
||||
options.battery.bar.full,
|
||||
"value",
|
||||
(full) =>
|
||||
full ? [WholeButton()] : [Indicator(), PercentLabel(), LevelBar()],
|
||||
],
|
||||
],
|
||||
visible: Battery.bind("available"),
|
||||
children: options.battery.bar.full
|
||||
.bind("value")
|
||||
.transform((full) =>
|
||||
full ? [WholeButton()] : [Indicator(), PercentLabel(), LevelBar()],
|
||||
),
|
||||
setup: (self) =>
|
||||
self.hook(Battery, (w) => {
|
||||
w.toggleClassName("charging", Battery.charging || Battery.charged);
|
||||
w.toggleClassName(
|
||||
"medium",
|
||||
Battery.percent < options.battery.medium.value,
|
||||
);
|
||||
w.toggleClassName("low", Battery.percent < options.battery.low.value);
|
||||
w.toggleClassName("half", Battery.percent < 48);
|
||||
}),
|
||||
}),
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user