@gjsify/adwaita-nativescript 0.30.0 → 0.32.0
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/lib/esm/index.js +1 -1
- package/lib/esm/widgets/adw-action-row.js +1 -1
- package/lib/esm/widgets/adw-avatar.js +1 -1
- package/lib/esm/widgets/adw-banner.js +1 -1
- package/lib/esm/widgets/adw-bottom-sheet.js +1 -1
- package/lib/esm/widgets/adw-button-content.js +1 -1
- package/lib/esm/widgets/adw-button-row.js +1 -1
- package/lib/esm/widgets/adw-carousel.js +1 -1
- package/lib/esm/widgets/adw-clamp.js +1 -1
- package/lib/esm/widgets/adw-combo-row.js +1 -1
- package/lib/esm/widgets/adw-data-grid.js +1 -0
- package/lib/esm/widgets/adw-drop-down.js +1 -0
- package/lib/esm/widgets/adw-entry-row.js +1 -1
- package/lib/esm/widgets/adw-entry.js +1 -0
- package/lib/esm/widgets/adw-expander-row.js +1 -1
- package/lib/esm/widgets/adw-header-bar.js +1 -1
- package/lib/esm/widgets/adw-inline-view-switcher.js +1 -1
- package/lib/esm/widgets/adw-navigation-split-view.js +1 -1
- package/lib/esm/widgets/adw-navigation-view.js +1 -1
- package/lib/esm/widgets/adw-overlay-split-view.js +1 -1
- package/lib/esm/widgets/adw-password-entry-row.js +1 -1
- package/lib/esm/widgets/adw-preferences-dialog.js +1 -1
- package/lib/esm/widgets/adw-preferences-group.js +1 -1
- package/lib/esm/widgets/adw-preferences-page.js +1 -1
- package/lib/esm/widgets/adw-sidebar.js +1 -1
- package/lib/esm/widgets/adw-spin-row.js +1 -1
- package/lib/esm/widgets/adw-spinner.js +1 -1
- package/lib/esm/widgets/adw-split-button.js +1 -1
- package/lib/esm/widgets/adw-status-page.js +1 -1
- package/lib/esm/widgets/adw-switch-row.js +1 -1
- package/lib/esm/widgets/adw-tab-view.js +1 -1
- package/lib/esm/widgets/adw-toolbar-view.js +1 -1
- package/lib/esm/widgets/adw-view-stack.js +1 -1
- package/lib/esm/widgets/adw-view-switcher-bar.js +1 -1
- package/lib/esm/widgets/adw-window-title.js +1 -1
- package/lib/esm/widgets/adw-wrap-box.js +1 -1
- package/lib/esm/widgets/avatar-color.js +1 -0
- package/lib/esm/widgets/bottom-sheet-state.js +1 -0
- package/lib/esm/widgets/button-content.js +1 -0
- package/lib/esm/widgets/carousel-state.js +1 -0
- package/lib/esm/widgets/chrome.js +1 -0
- package/lib/esm/widgets/data-grid-model.js +1 -0
- package/lib/esm/widgets/entry-row-view.js +1 -0
- package/lib/esm/widgets/icon-path.js +2 -2
- package/lib/esm/widgets/icons.ios.js +1 -0
- package/lib/esm/widgets/index.js +1 -1
- package/lib/esm/widgets/navigation-stack.js +1 -0
- package/lib/esm/widgets/preferences-group-state.js +1 -0
- package/lib/esm/widgets/preferences-search.js +1 -0
- package/lib/esm/widgets/row-state.js +1 -0
- package/lib/esm/widgets/sidebar-model.js +1 -0
- package/lib/esm/widgets/split-button.js +1 -0
- package/lib/esm/widgets/split-view-base.js +1 -1
- package/lib/esm/widgets/split-view-state.js +1 -0
- package/lib/esm/widgets/split-view-width.js +1 -0
- package/lib/esm/widgets/status-page-content.js +1 -0
- package/lib/esm/widgets/svg-path.js +2 -0
- package/lib/esm/widgets/tab-view-state.js +1 -0
- package/lib/esm/widgets/view-stack-state.js +1 -0
- package/lib/esm/widgets/view-switcher-base.js +1 -1
- package/lib/esm/widgets/view-switcher-model.js +1 -0
- package/lib/esm/widgets/wrap-box-layout.js +1 -0
- package/lib/types/banner.spec.d.ts +2 -0
- package/lib/types/bottom-sheet.spec.d.ts +2 -0
- package/lib/types/button-content.spec.d.ts +2 -0
- package/lib/types/carousel.spec.d.ts +1 -0
- package/lib/types/chrome.spec.d.ts +2 -0
- package/lib/types/data-grid.spec.d.ts +2 -0
- package/lib/types/drop-down.spec.d.ts +2 -0
- package/lib/types/entry-rows.spec.d.ts +2 -0
- package/lib/types/entry.spec.d.ts +2 -0
- package/lib/types/index.d.ts +2 -2
- package/lib/types/navigation-view.spec.d.ts +2 -0
- package/lib/types/preferences.spec.d.ts +2 -0
- package/lib/types/row-state.spec.d.ts +2 -0
- package/lib/types/sidebar.spec.d.ts +1 -0
- package/lib/types/split-button.spec.d.ts +1 -0
- package/lib/types/split-view-state.spec.d.ts +2 -0
- package/lib/types/split-view-width.spec.d.ts +2 -0
- package/lib/types/status-page.spec.d.ts +2 -0
- package/lib/types/svg-path.spec.d.ts +2 -0
- package/lib/types/tab-view.spec.d.ts +2 -0
- package/lib/types/view-stack.spec.d.ts +2 -0
- package/lib/types/view-switcher.spec.d.ts +1 -0
- package/lib/types/widgets/adw-action-row.d.ts +63 -7
- package/lib/types/widgets/adw-avatar.d.ts +2 -7
- package/lib/types/widgets/adw-banner.d.ts +26 -7
- package/lib/types/widgets/adw-bottom-sheet.d.ts +29 -11
- package/lib/types/widgets/adw-button-content.d.ts +41 -6
- package/lib/types/widgets/adw-button-row.d.ts +31 -9
- package/lib/types/widgets/adw-carousel.d.ts +70 -15
- package/lib/types/widgets/adw-clamp.d.ts +21 -4
- package/lib/types/widgets/adw-data-grid.d.ts +73 -0
- package/lib/types/widgets/adw-drop-down.d.ts +45 -0
- package/lib/types/widgets/adw-entry-row.d.ts +98 -2
- package/lib/types/widgets/adw-entry.d.ts +43 -0
- package/lib/types/widgets/adw-expander-row.d.ts +3 -0
- package/lib/types/widgets/adw-header-bar.d.ts +11 -2
- package/lib/types/widgets/adw-inline-view-switcher.d.ts +26 -0
- package/lib/types/widgets/adw-navigation-split-view.d.ts +2 -1
- package/lib/types/widgets/adw-navigation-view.d.ts +71 -16
- package/lib/types/widgets/adw-overlay-split-view.d.ts +29 -2
- package/lib/types/widgets/adw-password-entry-row.d.ts +33 -3
- package/lib/types/widgets/adw-preferences-dialog.d.ts +18 -0
- package/lib/types/widgets/adw-preferences-group.d.ts +56 -8
- package/lib/types/widgets/adw-preferences-page.d.ts +32 -1
- package/lib/types/widgets/adw-sidebar.d.ts +49 -7
- package/lib/types/widgets/adw-spinner.d.ts +8 -3
- package/lib/types/widgets/adw-split-button.d.ts +48 -13
- package/lib/types/widgets/adw-status-page.d.ts +5 -10
- package/lib/types/widgets/adw-switch-row.d.ts +21 -1
- package/lib/types/widgets/adw-tab-view.d.ts +129 -15
- package/lib/types/widgets/adw-toolbar-view.d.ts +39 -0
- package/lib/types/widgets/adw-view-stack.d.ts +30 -27
- package/lib/types/widgets/adw-view-switcher-bar.d.ts +22 -10
- package/lib/types/widgets/adw-window-title.d.ts +12 -8
- package/lib/types/widgets/adw-wrap-box.d.ts +21 -4
- package/lib/types/widgets/avatar-color.d.ts +14 -0
- package/lib/types/widgets/bottom-sheet-state.d.ts +73 -0
- package/lib/types/widgets/button-content.d.ts +43 -0
- package/lib/types/widgets/carousel-state.d.ts +85 -0
- package/lib/types/widgets/chrome.d.ts +159 -0
- package/lib/types/widgets/data-grid-model.d.ts +104 -0
- package/lib/types/widgets/entry-row-view.d.ts +88 -0
- package/lib/types/widgets/icon-path.d.ts +20 -0
- package/lib/types/widgets/icons.ios.d.ts +13 -0
- package/lib/types/widgets/index.d.ts +20 -5
- package/lib/types/widgets/navigation-stack.d.ts +153 -0
- package/lib/types/widgets/preferences-group-state.d.ts +52 -0
- package/lib/types/widgets/preferences-search.d.ts +68 -0
- package/lib/types/widgets/row-state.d.ts +71 -0
- package/lib/types/widgets/sidebar-model.d.ts +18 -0
- package/lib/types/widgets/split-button.d.ts +55 -0
- package/lib/types/widgets/split-view-base.d.ts +55 -12
- package/lib/types/widgets/split-view-state.d.ts +196 -0
- package/lib/types/widgets/split-view-width.d.ts +76 -0
- package/lib/types/widgets/status-page-content.d.ts +23 -0
- package/lib/types/widgets/svg-path.d.ts +28 -0
- package/lib/types/widgets/tab-view-state.d.ts +74 -0
- package/lib/types/widgets/view-stack-state.d.ts +35 -0
- package/lib/types/widgets/view-switcher-base.d.ts +61 -32
- package/lib/types/widgets/view-switcher-model.d.ts +114 -0
- package/lib/types/widgets/wrap-box-layout.d.ts +43 -0
- package/lib/types/wrap-box.spec.d.ts +2 -0
- package/package.json +7 -7
- package/src/theme/adwaita.css +393 -8
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import type { View } from '@nativescript/core';
|
|
2
|
+
import { TabViewState } from '@gjsify/adwaita-core';
|
|
3
|
+
import type { AdwTabPageState, TabViewHandlers, TabViewSelectionChange } from '@gjsify/adwaita-core';
|
|
4
|
+
/** One page of an `AdwTabView`, as a renderer reads it. */
|
|
5
|
+
export type AdwTabPage = AdwTabPageState<View>;
|
|
6
|
+
/** The two `View.visibility` values a stacked page or a tab affordance ever takes. */
|
|
7
|
+
export type NsVisibility = 'visible' | 'collapse';
|
|
8
|
+
/** The model an `AdwTabView` delegates to, typed on the NS `View`. */
|
|
9
|
+
export declare function createTabViewState(handlers?: TabViewHandlers<View>): TabViewState<View>;
|
|
10
|
+
/**
|
|
11
|
+
* The `visibility` each page's content view must carry for the current
|
|
12
|
+
* selection, in page order. Exactly one entry is `'visible'` — none when nothing
|
|
13
|
+
* is selected, which is a real state here: closing the last tab EMPTIES the view
|
|
14
|
+
* (adw-tab-view.c:1912-1913), where the old port refused the close outright.
|
|
15
|
+
*/
|
|
16
|
+
export declare function tabPageVisibilities(state: TabViewState<View>): NsVisibility[];
|
|
17
|
+
/** Push {@link tabPageVisibilities} onto the real content views. */
|
|
18
|
+
export declare function applyTabViewVisibility(state: TabViewState<View>): void;
|
|
19
|
+
/**
|
|
20
|
+
* The `visibility` each tab's close button must carry, in page order.
|
|
21
|
+
*
|
|
22
|
+
* `tabCloseVisible` is `(hovering && fullyVisible) || selected || dragging`, and
|
|
23
|
+
* never on a pinned tab (adw-tab.c:124, :645-650). Touch has no hover and this
|
|
24
|
+
* port has no tab drag-and-drop, so `hovering` and `dragging` are constantly
|
|
25
|
+
* false and the predicate REDUCES to "selected, and not pinned" — which is the
|
|
26
|
+
* old port's rule plus the pinned gate it was missing. Calling the shared
|
|
27
|
+
* predicate rather than writing `active` keeps that a derivation instead of a
|
|
28
|
+
* coincidence, and gives the pinned gate for free.
|
|
29
|
+
*/
|
|
30
|
+
export declare function tabCloseVisibilities(state: TabViewState<View>): NsVisibility[];
|
|
31
|
+
/**
|
|
32
|
+
* The `visibility` of the whole tab bar — `tabsRevealed` (adw-tab-bar.c:142-164)
|
|
33
|
+
* projected onto NS. The old port had no autohide at all; the bar was added in
|
|
34
|
+
* the constructor and never hidden.
|
|
35
|
+
*/
|
|
36
|
+
export declare function tabBarVisibility(state: TabViewState<View>, autohide: boolean): NsVisibility;
|
|
37
|
+
/**
|
|
38
|
+
* The text a tab's label shows.
|
|
39
|
+
*
|
|
40
|
+
* A pinned tab is a single-glyph chip in libadwaita — `adw_tab_constructed`
|
|
41
|
+
* hides its title outright (adw-tab.c:645-650) — so it renders no label at all
|
|
42
|
+
* here either. Everything else shows its title, which is already `''` rather
|
|
43
|
+
* than `undefined` for a page that declared none: the old port assigned
|
|
44
|
+
* `page.title` straight to `Label.text` with no coercion, so an `AdwViewPage`
|
|
45
|
+
* literal without a title rendered the string "undefined".
|
|
46
|
+
*/
|
|
47
|
+
export declare function tabLabelText(page: AdwTabPage): string;
|
|
48
|
+
/**
|
|
49
|
+
* The tooltip text for a tab — `tabTooltip`, i.e. the page's own tooltip when it
|
|
50
|
+
* has one and its title otherwise (adw-tab.c:137-146).
|
|
51
|
+
*
|
|
52
|
+
* NS has no tooltip primitive, so this is exposed for a consumer (and for the
|
|
53
|
+
* accessibility label) rather than rendered. It is deliberately the TEXT form:
|
|
54
|
+
* a page-supplied tooltip is Pango markup in C, and NS has no markup sink to
|
|
55
|
+
* push it through.
|
|
56
|
+
*/
|
|
57
|
+
export declare function tabTooltipText(page: AdwTabPage): string;
|
|
58
|
+
/** The data half of the `notify::selected-page` event (minus NS's `eventName`/`object`). */
|
|
59
|
+
export interface TabViewNotifyPayload {
|
|
60
|
+
/** Id of the newly-selected page, `null` when the view is empty. */
|
|
61
|
+
selectedId: string | null;
|
|
62
|
+
/** Its index, `-1` when the view is empty. */
|
|
63
|
+
selectedIndex: number;
|
|
64
|
+
/** The previously-selected id, `null` when there was none. */
|
|
65
|
+
previousId: string | null;
|
|
66
|
+
/** `false` for a model-driven pick (auto-select, close successor), `true` otherwise. */
|
|
67
|
+
interactive: boolean;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Project a core change onto the event payload. Kept as a function rather than
|
|
71
|
+
* spreading the change directly so that if the core payload ever grows a live
|
|
72
|
+
* model object, it does not silently leak into an event a consumer holds on to.
|
|
73
|
+
*/
|
|
74
|
+
export declare function tabViewNotifyPayload(change: TabViewSelectionChange): TabViewNotifyPayload;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { View } from '@nativescript/core';
|
|
2
|
+
import { ViewStackState } from '@gjsify/adwaita-core';
|
|
3
|
+
import type { AdwViewStackPageInfo, ViewStackStateChange } from '@gjsify/adwaita-core';
|
|
4
|
+
/** One page registered with an `AdwViewStack`, as a bound switcher reads it. */
|
|
5
|
+
export type AdwViewStackPage = AdwViewStackPageInfo<View>;
|
|
6
|
+
/** The two `View.visibility` values a stacked page ever takes. */
|
|
7
|
+
export type NsPageVisibility = 'visible' | 'collapse';
|
|
8
|
+
/** The selection machine an `AdwViewStack` delegates to, typed on the NS `View`. */
|
|
9
|
+
export declare function createViewStackState(): ViewStackState<View>;
|
|
10
|
+
/**
|
|
11
|
+
* The `visibility` each page's content view must carry for the current
|
|
12
|
+
* selection, in page order. Exactly one entry is `'visible'` — none when nothing
|
|
13
|
+
* is selected, which is a real state here (an empty stack, every page hidden, or
|
|
14
|
+
* the visible page removed).
|
|
15
|
+
*/
|
|
16
|
+
export declare function pageVisibilities(state: ViewStackState<View>): NsPageVisibility[];
|
|
17
|
+
/** Push {@link pageVisibilities} onto the real content views. */
|
|
18
|
+
export declare function applyViewStackVisibility(state: ViewStackState<View>): void;
|
|
19
|
+
/** The data half of the `notify::visible-child` event (minus NS's `eventName`/`object`). */
|
|
20
|
+
export interface ViewStackNotifyPayload {
|
|
21
|
+
/** The newly-visible page's index, `-1` when nothing is selected. */
|
|
22
|
+
index: number;
|
|
23
|
+
/** The newly-visible page's name, `''` when nothing is selected. */
|
|
24
|
+
name: string;
|
|
25
|
+
/** The newly-visible page's title, `''` when nothing is selected. */
|
|
26
|
+
title: string;
|
|
27
|
+
/** `false` for an auto-pick (add / hide / show), `true` for an explicit select. */
|
|
28
|
+
interactive: boolean;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Project a core change onto the event payload. Kept as a function rather than
|
|
32
|
+
* spreading the change directly so the `page` descriptor — a live model object —
|
|
33
|
+
* never leaks into an event a consumer might hold on to.
|
|
34
|
+
*/
|
|
35
|
+
export declare function viewStackNotifyPayload(change: ViewStackStateChange<View>): ViewStackNotifyPayload;
|
|
@@ -1,21 +1,15 @@
|
|
|
1
|
-
import { GridLayout, StackLayout,
|
|
1
|
+
import { GridLayout, StackLayout, type EventData } from '@nativescript/core';
|
|
2
|
+
import type { AdwInlineViewSwitcherDisplayMode, AdwViewSwitcherPolicy, ViewSwitcherState } from '@gjsify/adwaita-core';
|
|
3
|
+
import { type AdwViewPage, type ViewSwitcherKind, type ViewSwitcherNotifyPayload } from './view-switcher-model.js';
|
|
4
|
+
export type { AdwViewPage };
|
|
2
5
|
/** Event name emitted when the selected view changes. Mirrors GObject `notify::selected`. */
|
|
3
6
|
export declare const NOTIFY_SELECTED = "notify::selected";
|
|
4
|
-
/**
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
}
|
|
11
|
-
/** One page registered with a {@link AdwViewSwitcherBase}. */
|
|
12
|
-
export interface AdwViewPage {
|
|
13
|
-
/** The switcher button label. */
|
|
14
|
-
title: string;
|
|
15
|
-
/** The page content view, shown when this page is selected. */
|
|
16
|
-
content: View;
|
|
17
|
-
/** Optional Adwaita symbolic SVG shown left of the label in the switcher button. */
|
|
18
|
-
icon?: string;
|
|
7
|
+
/**
|
|
8
|
+
* Payload of the `notify::selected` event. `selected` is `-1` and `name`/`title`
|
|
9
|
+
* are `''` when nothing is selected — the state an empty switcher and a
|
|
10
|
+
* fully-hidden one both land in.
|
|
11
|
+
*/
|
|
12
|
+
export interface NotifyViewSelectedEventData extends EventData, ViewSwitcherNotifyPayload {
|
|
19
13
|
}
|
|
20
14
|
/**
|
|
21
15
|
* Shared base: a switcher bar (row 0) + a content area (row 1), one page visible.
|
|
@@ -26,37 +20,72 @@ export declare abstract class AdwViewSwitcherBase extends GridLayout {
|
|
|
26
20
|
protected readonly _bar: StackLayout;
|
|
27
21
|
/** The content area where the selected page is shown. */
|
|
28
22
|
protected readonly _contentArea: GridLayout;
|
|
23
|
+
/** The registered pages, in bar order. */
|
|
29
24
|
protected readonly _pages: AdwViewPage[];
|
|
30
|
-
/** The
|
|
31
|
-
protected readonly
|
|
32
|
-
|
|
25
|
+
/** The headless selection + page model every derivation reads. */
|
|
26
|
+
protected readonly _state: ViewSwitcherState;
|
|
27
|
+
private _nodes;
|
|
33
28
|
/** CSS class applied to the switcher bar — subclass-specific. */
|
|
34
29
|
protected abstract get barClass(): string;
|
|
35
30
|
/** CSS class applied to each switcher button — subclass-specific. */
|
|
36
31
|
protected abstract get buttonClass(): string;
|
|
32
|
+
/**
|
|
33
|
+
* `AdwViewSwitcher:policy`, which decides the button orientation
|
|
34
|
+
* (adw-view-switcher.c:534-537). `'wide'` — icon beside label — because that
|
|
35
|
+
* is the layout all three NS switchers have always used; the icon-over-label
|
|
36
|
+
* narrow form lives in the separate `AdwViewSwitcherBar`. There is no policy
|
|
37
|
+
* PROPERTY on NS yet, so this is a constant a subclass can override rather
|
|
38
|
+
* than settable state.
|
|
39
|
+
*/
|
|
40
|
+
protected get policy(): AdwViewSwitcherPolicy;
|
|
41
|
+
/**
|
|
42
|
+
* What the buttons show. `'both'` for the classic switcher, whose buttons
|
|
43
|
+
* "always have an icon and a label" (adw-view-switcher.c class docs);
|
|
44
|
+
* `AdwInlineViewSwitcher` overrides it with the real
|
|
45
|
+
* `AdwInlineViewSwitcherDisplayMode`.
|
|
46
|
+
*/
|
|
47
|
+
protected get buttonDisplayMode(): AdwInlineViewSwitcherDisplayMode;
|
|
37
48
|
constructor(rootClass: string);
|
|
38
49
|
/** Initialise the bar class after the subclass fields are ready. */
|
|
39
50
|
protected _initClasses(): void;
|
|
40
|
-
/** Register the view pages. Rebuilds the switcher bar + content stack. */
|
|
41
|
-
setViews(pages: AdwViewPage[]): void;
|
|
42
|
-
/** Show only the selected page; mark its button active. */
|
|
43
|
-
protected _applySelection(): void;
|
|
44
51
|
/**
|
|
45
|
-
*
|
|
46
|
-
*
|
|
47
|
-
*
|
|
52
|
+
* Register the view pages. Rebuilds the switcher bar + content stack.
|
|
53
|
+
*
|
|
54
|
+
* The SELECTED PAGE survives the rebuild whenever a page of the same name
|
|
55
|
+
* does — libadwaita's selection is a page pointer, not an index
|
|
56
|
+
* (adw-view-stack.c:660-672) — and falls back to the first VISIBLE page
|
|
57
|
+
* otherwise (:1149-1151).
|
|
48
58
|
*/
|
|
49
|
-
|
|
59
|
+
setViews(pages: AdwViewPage[]): void;
|
|
60
|
+
/** Build one button's NS nodes. Painted by {@link _applySelection}. */
|
|
61
|
+
private _buildButton;
|
|
50
62
|
/**
|
|
51
|
-
*
|
|
52
|
-
*
|
|
53
|
-
*
|
|
63
|
+
* Which visibility rule this switcher follows — see
|
|
64
|
+
* {@link switcherButtonVisible}, which holds the rule itself so a spec can
|
|
65
|
+
* reach it.
|
|
54
66
|
*/
|
|
55
|
-
protected
|
|
67
|
+
protected get switcherKind(): ViewSwitcherKind;
|
|
68
|
+
/** Paint the derived models: show only the selected page, mark its button active. */
|
|
69
|
+
protected _applySelection(): void;
|
|
56
70
|
/** The registered view pages. */
|
|
57
71
|
get views(): AdwViewPage[];
|
|
58
72
|
set views(pages: AdwViewPage[]);
|
|
59
|
-
/**
|
|
73
|
+
/**
|
|
74
|
+
* The selected view index, `-1` when nothing is selected. Swaps the visible
|
|
75
|
+
* page + emits `notify::selected`.
|
|
76
|
+
*
|
|
77
|
+
* Out-of-range, negative, fractional and hidden-page indices are all silent
|
|
78
|
+
* NO-OPS — refused, never clamped, exactly as
|
|
79
|
+
* `adw_view_stack_pages_select_item` refuses (adw-view-stack.c:682-684).
|
|
80
|
+
*/
|
|
60
81
|
get selected(): number;
|
|
61
82
|
set selected(value: number);
|
|
83
|
+
/** Name of the selected page, `''` when nothing is selected. */
|
|
84
|
+
get selectedName(): string;
|
|
85
|
+
/**
|
|
86
|
+
* Show or hide a page by name. Returns whether the SELECTION moved: hiding
|
|
87
|
+
* the selected page falls back to the first still-visible one
|
|
88
|
+
* (`update_child_visible`, adw-view-stack.c:1061-1082).
|
|
89
|
+
*/
|
|
90
|
+
setPageVisible(name: string, visible: boolean): boolean;
|
|
62
91
|
}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import type { View } from '@nativescript/core';
|
|
2
|
+
import { ViewSwitcherBarState, ViewSwitcherState } from '@gjsify/adwaita-core';
|
|
3
|
+
import type { AdwViewSwitcherPageInit, ViewSwitcherStateChange } from '@gjsify/adwaita-core';
|
|
4
|
+
/**
|
|
5
|
+
* One page registered with a view switcher.
|
|
6
|
+
*
|
|
7
|
+
* Mirrors `AdwViewStackPage`'s properties with their C defaults. `title` and
|
|
8
|
+
* `icon` are NULLABLE on purpose: a page with neither renders no button at all
|
|
9
|
+
* (adw-view-switcher.c:178), and once an absent title has been flattened to `''`
|
|
10
|
+
* that rule is no longer expressible — which is why the old shape, with a
|
|
11
|
+
* required `title: string`, could not implement it.
|
|
12
|
+
*
|
|
13
|
+
* `icon` is an Adwaita symbolic SVG DOCUMENT here, not a GTK icon name: `AdwIcon`
|
|
14
|
+
* rasterises the path data natively. The core treats the field as an opaque
|
|
15
|
+
* handle and only ever interprets "absent or empty"; {@link nsIconSvg} resolves
|
|
16
|
+
* the fallback sentinel it hands back.
|
|
17
|
+
*/
|
|
18
|
+
export interface AdwViewPage {
|
|
19
|
+
/**
|
|
20
|
+
* The switcher button label. ABSENT means the page has none — which is C's
|
|
21
|
+
* NULL, and the state the button-visibility rule turns on. Spelled as an
|
|
22
|
+
* optional `string` rather than `string | null` so the existing consumers
|
|
23
|
+
* that pass a plain `string` keep type-checking unchanged.
|
|
24
|
+
*/
|
|
25
|
+
title?: string;
|
|
26
|
+
/** The page content view, shown when this page is selected. */
|
|
27
|
+
content: View;
|
|
28
|
+
/** Adwaita symbolic SVG shown on the switcher button; absent means none. */
|
|
29
|
+
icon?: string;
|
|
30
|
+
/** Stable id used by `visible-child-name`; defaults to the page's position. */
|
|
31
|
+
name?: string;
|
|
32
|
+
/** `AdwViewStackPage:visible` — default `true`. */
|
|
33
|
+
visible?: boolean;
|
|
34
|
+
/** `AdwViewStackPage:use-underline` — an `_` in the title marks a mnemonic. */
|
|
35
|
+
useUnderline?: boolean;
|
|
36
|
+
/** `AdwViewStackPage:badge-number` — default `0`. */
|
|
37
|
+
badgeNumber?: number;
|
|
38
|
+
/** `AdwViewStackPage:needs-attention` — default `false`. */
|
|
39
|
+
needsAttention?: boolean;
|
|
40
|
+
}
|
|
41
|
+
/** The two `View.visibility` values a stacked page ever takes. */
|
|
42
|
+
export type NsPageVisibility = 'visible' | 'collapse';
|
|
43
|
+
/** The selection + page model a switcher delegates to. */
|
|
44
|
+
export declare function createViewSwitcherState(): ViewSwitcherState;
|
|
45
|
+
/** The reveal state machine an `AdwViewSwitcherBar` delegates to. */
|
|
46
|
+
export declare function createViewSwitcherBarState(): ViewSwitcherBarState;
|
|
47
|
+
/**
|
|
48
|
+
* Project one NS page onto the core's page init.
|
|
49
|
+
*
|
|
50
|
+
* A page without an explicit `name` gets its POSITION as the name — the NS API
|
|
51
|
+
* has always been positional (`setViews` takes an array), and a stable id is
|
|
52
|
+
* what the name-preserving rebuild needs to keep the selected page selected.
|
|
53
|
+
*/
|
|
54
|
+
export declare function viewSwitcherPageSpec(page: AdwViewPage, index: number): AdwViewSwitcherPageInit;
|
|
55
|
+
/** {@link viewSwitcherPageSpec} over a whole page list. */
|
|
56
|
+
export declare function viewSwitcherPageSpecs(pages: readonly AdwViewPage[]): AdwViewSwitcherPageInit[];
|
|
57
|
+
/**
|
|
58
|
+
* Resolve the core's icon slot to something `AdwIcon` can rasterise.
|
|
59
|
+
*
|
|
60
|
+
* The core substitutes the NAME `image-missing` for an absent icon
|
|
61
|
+
* (adw-view-switcher-button.c:405). On the browser side that name becomes a CSS
|
|
62
|
+
* mask class; here it has to become the actual symbolic document, so the
|
|
63
|
+
* sentinel is swapped for the vendored `image-missing-symbolic` SVG. Anything
|
|
64
|
+
* else is already an SVG and passes through.
|
|
65
|
+
*/
|
|
66
|
+
export declare function nsIconSvg(iconName: string): string;
|
|
67
|
+
/**
|
|
68
|
+
* The `visibility` each page's content view must carry for the current
|
|
69
|
+
* selection, in page order. Exactly one entry is `'visible'` — none when nothing
|
|
70
|
+
* is selected, which is a real state here (an empty switcher, or every page
|
|
71
|
+
* hidden).
|
|
72
|
+
*/
|
|
73
|
+
export declare function pageVisibilities(pages: readonly AdwViewPage[], selected: number): NsPageVisibility[];
|
|
74
|
+
/** Push {@link pageVisibilities} onto the real content views. */
|
|
75
|
+
export declare function applyViewSwitcherVisibility(pages: readonly AdwViewPage[], selected: number): void;
|
|
76
|
+
/** Which switcher is asking — the two apply different visibility rules. */
|
|
77
|
+
export type ViewSwitcherKind = 'switcher' | 'inline';
|
|
78
|
+
/**
|
|
79
|
+
* Whether a page gets a button/toggle at all.
|
|
80
|
+
*
|
|
81
|
+
* The two switchers genuinely differ, and the difference is easy to miss because
|
|
82
|
+
* only one of them is documented where you would look:
|
|
83
|
+
*
|
|
84
|
+
* - `AdwViewSwitcher` needs a title or an icon ON TOP OF `visible` —
|
|
85
|
+
* `gtk_widget_set_visible (button, visible && (title != NULL || icon_name !=
|
|
86
|
+
* NULL))` (adw-view-switcher.c:178).
|
|
87
|
+
* - `AdwInlineViewSwitcher` does not. `populate_group` gates on `visible` alone
|
|
88
|
+
* (adw-inline-view-switcher.c:370-378), so a page with neither still gets an
|
|
89
|
+
* empty toggle.
|
|
90
|
+
*
|
|
91
|
+
* The inline widget inherited the stricter rule and silently dropped toggles
|
|
92
|
+
* libadwaita draws. `@gjsify/adwaita-core` had spelled this out in
|
|
93
|
+
* `buildInlineToggles`' doc and pinned it in `INLINE_TOGGLE_VECTORS` the whole
|
|
94
|
+
* time — the rule just lived in a class that `extends GridLayout`, which no
|
|
95
|
+
* spec can import, so nothing could reach it to check. That is why it is here
|
|
96
|
+
* and not there.
|
|
97
|
+
*/
|
|
98
|
+
export declare function switcherButtonVisible(kind: ViewSwitcherKind, modelVisible: boolean, pageVisible: boolean): boolean;
|
|
99
|
+
/** The data half of the `notify::selected` event (minus NS's `eventName`/`object`). */
|
|
100
|
+
export interface ViewSwitcherNotifyPayload {
|
|
101
|
+
/** The newly-selected page index, `-1` when nothing is selected. */
|
|
102
|
+
selected: number;
|
|
103
|
+
/** Its name, `''` when nothing is selected. */
|
|
104
|
+
name: string;
|
|
105
|
+
/** Its painted label, `''` when nothing is selected. */
|
|
106
|
+
title: string;
|
|
107
|
+
/** `false` for an auto-pick (a rebuild, a visibility flip), `true` for a tap. */
|
|
108
|
+
interactive: boolean;
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Project a core change onto the event payload. A function rather than a spread
|
|
112
|
+
* so no live model object escapes into an event a consumer might hold on to.
|
|
113
|
+
*/
|
|
114
|
+
export declare function viewSwitcherNotifyPayload(change: ViewSwitcherStateChange): ViewSwitcherNotifyPayload;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `Adw.WrapBox:child-spacing` / `:line-spacing` default, in DIPs.
|
|
3
|
+
*
|
|
4
|
+
* Both are `g_param_spec_int (…, 0, G_MAXINT, 0, …)` — adw-wrap-box.c:285-287
|
|
5
|
+
* and :393-395. The port used to default both to 6, so identical markup was
|
|
6
|
+
* looser on a phone than in the browser and an EMPTY wrap box was already 12
|
|
7
|
+
* DIPs tall.
|
|
8
|
+
*/
|
|
9
|
+
export declare const DEFAULT_WRAP_BOX_SPACING = 0;
|
|
10
|
+
/**
|
|
11
|
+
* Normalise one spacing property, the way `adw_wrap_box_set_child_spacing` does.
|
|
12
|
+
*
|
|
13
|
+
* C clamps a negative value to 0 before anything else happens
|
|
14
|
+
* (adw-wrap-box.c:587-588, :927-928); the property's declared minimum is 0, so
|
|
15
|
+
* without the clamp GObject would reject it outright. The non-numeric cases have
|
|
16
|
+
* no C counterpart — the property is an `int` — and resolve to the default, so a
|
|
17
|
+
* `NaN` can never reach a native layout pass.
|
|
18
|
+
*/
|
|
19
|
+
export declare function normalizeWrapBoxSpacing(value: unknown): number;
|
|
20
|
+
/**
|
|
21
|
+
* Whether writing `next` over `current` is a change the widget must act on.
|
|
22
|
+
*
|
|
23
|
+
* The comparison happens AFTER the clamp (adw-wrap-box.c:592-593, :930-931), so
|
|
24
|
+
* a negative value written over a spacing of 0 is an early return: it neither
|
|
25
|
+
* reaches the layout nor notifies. On this port the same predicate decides
|
|
26
|
+
* whether every child's margin is rewritten.
|
|
27
|
+
*/
|
|
28
|
+
export declare function wrapBoxSpacingChanges(current: number, next: unknown): boolean;
|
|
29
|
+
/**
|
|
30
|
+
* The uniform margin that gives an NS `WrapLayout` child its share of the gaps.
|
|
31
|
+
*
|
|
32
|
+
* `WrapLayout` has no gap property, so the inter-item spacing has to come out of
|
|
33
|
+
* the children: half of it on each facing edge adds up to the whole gap between
|
|
34
|
+
* any two neighbours. The margin string is NS's `top right bottom left`
|
|
35
|
+
* shorthand.
|
|
36
|
+
*
|
|
37
|
+
* This is the one place the port is knowingly looser than libadwaita: the halves
|
|
38
|
+
* on the OUTER edges are an inset `Adw.WrapBox` does not have. It is invisible
|
|
39
|
+
* at the default spacing of 0 and bounded by half a gap otherwise, where the
|
|
40
|
+
* alternative — negative margins on the container — is not something the NS CSS
|
|
41
|
+
* subset can be trusted with.
|
|
42
|
+
*/
|
|
43
|
+
export declare function wrapBoxChildMargin(childSpacing: number, lineSpacing: number): string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gjsify/adwaita-nativescript",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.32.0",
|
|
4
4
|
"description": "Native Adwaita widgets for the NativeScript runtime — real NativeScript components (StackLayout/GridLayout/Switch/Label) styled like Libadwaita, not a webview",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "lib/esm/index.js",
|
|
@@ -47,10 +47,10 @@
|
|
|
47
47
|
"design-system"
|
|
48
48
|
],
|
|
49
49
|
"dependencies": {
|
|
50
|
-
"@gjsify/adwaita-core": "^0.
|
|
51
|
-
"@gjsify/adwaita-fonts": "^0.
|
|
52
|
-
"@gjsify/adwaita-icons": "^0.
|
|
53
|
-
"@gjsify/native-platform": "^0.
|
|
50
|
+
"@gjsify/adwaita-core": "^0.32.0",
|
|
51
|
+
"@gjsify/adwaita-fonts": "^0.32.0",
|
|
52
|
+
"@gjsify/adwaita-icons": "^0.32.0",
|
|
53
|
+
"@gjsify/native-platform": "^0.32.0"
|
|
54
54
|
},
|
|
55
55
|
"peerDependencies": {
|
|
56
56
|
"@nativescript/core": "*"
|
|
@@ -61,8 +61,8 @@
|
|
|
61
61
|
}
|
|
62
62
|
},
|
|
63
63
|
"devDependencies": {
|
|
64
|
-
"@gjsify/cli": "^0.
|
|
65
|
-
"@gjsify/unit": "^0.
|
|
64
|
+
"@gjsify/cli": "^0.32.0",
|
|
65
|
+
"@gjsify/unit": "^0.32.0",
|
|
66
66
|
"@types/node": "^25.9.2",
|
|
67
67
|
"typescript": "^6.0.3"
|
|
68
68
|
},
|