♻️ refactor(pages): rename onClose function/property to actionClose
This commit is contained in:
@@ -34,7 +34,7 @@ export const BluetoothPage = () => <Page
|
||||
}}
|
||||
/>
|
||||
]}
|
||||
onClose={() => AstalBluetooth.get_default().adapter.discovering &&
|
||||
actionClose={() => AstalBluetooth.get_default().adapter.discovering &&
|
||||
AstalBluetooth.get_default().adapter.stop_discovery()}
|
||||
bottomButtons={[{
|
||||
title: tr("control_center.pages.more_settings"),
|
||||
|
||||
@@ -7,8 +7,8 @@ import AstalWp from "gi://AstalWp?version=0.1";
|
||||
import { lookupIcon } from "../../../scripts/apps";
|
||||
|
||||
|
||||
export function PageMicrophone(): Page {
|
||||
return <Page id={"microphone"} title={tr("control_center.pages.microphone.title")}
|
||||
export const PageMicrophone = () =>
|
||||
<Page id={"microphone"} title={tr("control_center.pages.microphone.title")}
|
||||
description={tr("control_center.pages.microphone.description")}>
|
||||
|
||||
<Gtk.Label class={"sub-header"} label={tr("devices")} xalign={0} />
|
||||
@@ -27,4 +27,3 @@ export function PageMicrophone(): Page {
|
||||
/>}
|
||||
</For>
|
||||
</Page> as Page;
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ import AstalNetwork from "gi://AstalNetwork";
|
||||
import { createBinding, For, With } from "ags";
|
||||
|
||||
|
||||
export const PageNetwork = () =>
|
||||
export const PageNetwork = () =>
|
||||
<Page id={"network"} title={tr("control_center.pages.network.title")}
|
||||
class={"network"} headerButtons={[
|
||||
<Gtk.Button class={"reload"} iconName={"arrow-circular-top-right-symbolic"}
|
||||
|
||||
@@ -5,7 +5,7 @@ import { Astal, Gtk } from "ags/gtk4";
|
||||
import { addSliderMarksFromMinMax } from "../../../scripts/utils";
|
||||
import { createBinding } from "ags";
|
||||
|
||||
export const PageNightLight: (() => Page) = () =>
|
||||
export const PageNightLight = () =>
|
||||
<Page id={"night-light"} title={tr("control_center.pages.night_light.title")}
|
||||
description={tr("control_center.pages.night_light.description")}
|
||||
class={"night-light"}>
|
||||
|
||||
@@ -3,11 +3,13 @@ import { Gtk } from "ags/gtk4";
|
||||
import { Separator } from "../../Separator";
|
||||
import { Accessor, For } from "ags";
|
||||
import { transform, transformWidget, variableToBoolean, WidgetNodeType } from "../../../scripts/utils";
|
||||
|
||||
import Pango from "gi://Pango?version=1.0";
|
||||
|
||||
|
||||
export type PageProps = {
|
||||
$?: () => void;
|
||||
onClose?: () => void;
|
||||
actionClose?: () => void;
|
||||
id: string;
|
||||
class?: string | Accessor<string>;
|
||||
title: string | Accessor<string>;
|
||||
@@ -31,27 +33,23 @@ export { Page };
|
||||
|
||||
@register({ GTypeName: "Page" })
|
||||
class Page extends Gtk.Box {
|
||||
readonly #id: string | number;
|
||||
readonly bottomButtons?: Array<BottomButton>;
|
||||
#id: string | number = "";
|
||||
readonly bottomButtons?: Array<BottomButton> = [];
|
||||
|
||||
#subs: Array<() => void> = [];
|
||||
#title: string | Accessor<string>;
|
||||
#title: string | Accessor<string> = "";
|
||||
#description?: string | Accessor<string>;
|
||||
|
||||
public get title() { return this.#title; }
|
||||
public get description() { return this.#description; }
|
||||
public get id() { return this.#id; }
|
||||
public onClose?: () => void;
|
||||
public actionClose?: () => void = () => {};
|
||||
|
||||
constructor(props: PageProps) {
|
||||
super({
|
||||
hexpand: true,
|
||||
orientation: Gtk.Orientation.VERTICAL
|
||||
});
|
||||
super();
|
||||
|
||||
this.#id = props.id;
|
||||
this.#title = props.title;
|
||||
this.#description = props.description;
|
||||
this.set_hexpand(true);
|
||||
this.set_orientation(Gtk.Orientation.VERTICAL);
|
||||
|
||||
if(props.class instanceof Accessor) {
|
||||
this.#subs.push(props.class.subscribe(() => {
|
||||
@@ -67,6 +65,11 @@ class Page extends Gtk.Box {
|
||||
this.add_css_class("page");
|
||||
}
|
||||
|
||||
this.#id = props.id;
|
||||
this.#title = props.title;
|
||||
this.#description = props.description;
|
||||
this.actionClose = props.actionClose;
|
||||
|
||||
this.prepend(<Gtk.Box class={"header"} orientation={Gtk.Orientation.VERTICAL}
|
||||
hexpand={true}>
|
||||
|
||||
@@ -117,7 +120,6 @@ class Page extends Gtk.Box {
|
||||
)}
|
||||
</Gtk.Box> as Gtk.Box);
|
||||
|
||||
this.onClose = props.onClose;
|
||||
props.$?.();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user