feat(ListView): Add some missing fields

This commit is contained in:
LuanRT
2026-03-20 17:25:42 -03:00
parent 37a4808693
commit cf5412986b
2 changed files with 38 additions and 3 deletions

View File

@@ -13,9 +13,22 @@ export default class ListItemView extends YTNode {
public title?: Text;
public subtitle?: Text;
public selection_text?: Text;
public selection_style?:
| 'LIST_ITEM_SELECTION_STYLE_UNSPECIFIED'
| 'LIST_ITEM_SELECTION_STYLE_DEFAULT'
| 'LIST_ITEM_SELECTION_STYLE_CHECKBOX'
| 'LIST_ITEM_SELECTION_STYLE_RADIO'
| 'LIST_ITEM_SELECTION_STYLE_TOGGLE';
public background_color?: number;
public leading_accessory: AvatarView | null;
public renderer_context?: RendererContext;
public trailing_button: YTNode | null;
public trailing_buttons: ObservedArray<SubscribeButtonView>;
public is_disabled: boolean;
public is_selected: boolean;
public has_divider_below: boolean;
public renderer_context?: RendererContext;
constructor(data: RawNode) {
super();
@@ -27,12 +40,28 @@ export default class ListItemView extends YTNode {
this.subtitle = Text.fromAttributed(data.subtitle);
}
if ('selectionText' in data) {
this.selection_text = Text.fromAttributed(data.selectionText);
}
if ('selectionStyle' in data) {
this.selection_style = data.selectionStyle;
}
if ('backgroundColor' in data) {
this.background_color = parseInt(data.backgroundColor, 16);
}
this.leading_accessory = Parser.parseItem(data.leadingAccessory, AvatarView);
this.trailing_buttons = Parser.parseArray(data.trailingButtons?.buttons, SubscribeButtonView);
this.trailing_button = Parser.parseItem(data.trailingButton);
this.is_disabled = !!data.isDisabled;
this.is_selected = !!data.isSelected;
this.has_divider_below = !!data.hasDividerBelow;
if ('rendererContext' in data) {
this.renderer_context = new RendererContext(data.rendererContext);
}
this.trailing_buttons = Parser.parseArray(data.trailingButtons?.buttons, SubscribeButtonView);
}
}

View File

@@ -4,15 +4,21 @@ import { YTNode } from '../helpers.js';
import { Parser } from '../index.js';
import ListItemView from './ListItemView.js';
import RendererContext from './misc/RendererContext.js';
export default class ListView extends YTNode {
static type = 'ListView';
public items: ObservedArray<ListItemView>;
public renderer_context?: RendererContext;
constructor(data: RawNode) {
super();
this.items = Parser.parseArray(data.listItems, ListItemView);
if ('rendererContext' in data) {
this.renderer_context = new RendererContext(data.rendererContext);
}
}
}