-
-
Notifications
You must be signed in to change notification settings - Fork 254
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(Parser): Implement utility class to parse
rendererContext
This field is found in most of the newer view model nodes. It can contain accessibility labels, text, commands or nothing but logging info.
- Loading branch information
Showing
2 changed files
with
33 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import type { RawNode } from '../../types/index.js'; | ||
import NavigationEndpoint from '../NavigationEndpoint.js'; | ||
|
||
export type CommandContext = { | ||
on_tap?: NavigationEndpoint; | ||
}; | ||
|
||
export type AccessibilityContext = { | ||
label?: string; | ||
}; | ||
|
||
export default class RendererContext { | ||
public command_context: CommandContext; | ||
public accessibility_context: AccessibilityContext; | ||
|
||
constructor(data: RawNode) { | ||
this.command_context = {}; | ||
this.accessibility_context = {}; | ||
|
||
if (Reflect.has(data, 'commandContext')) { | ||
if (Reflect.has(data.commandContext, 'onTap')) { | ||
this.command_context.on_tap = new NavigationEndpoint(data.commandContext.onTap); | ||
} | ||
} | ||
|
||
if (Reflect.has(data, 'accessibilityContext')) { | ||
if (Reflect.has(data.accessibilityContext, 'label')) { | ||
this.accessibility_context.label = data.accessibilityContext.label; | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters