mirror of
https://github.com/rio-labs/rio.git
synced 2026-01-06 05:09:43 -06:00
ruined SwitcherBar
This commit is contained in:
committed by
Jakob Pinterits
parent
79d4cc0ae5
commit
9e367bb339
@@ -42,37 +42,11 @@ export function getDisplayableChildren(comp: ComponentBase): ComponentBase[] {
|
||||
return result;
|
||||
}
|
||||
|
||||
/// Given an injected layout component, return its direct child (Which may
|
||||
/// also be injected!).
|
||||
export function getDirectChildOfInjectedComponent(
|
||||
comp: ComponentBase
|
||||
): ComponentBase {
|
||||
console.assert(comp.isInjectedLayoutComponent());
|
||||
|
||||
// Both Margins and Aligns have a single child, accessible as `content`
|
||||
console.assert(
|
||||
comp.state._type_ === 'Margin-builtin' ||
|
||||
comp.state._type_ === 'Align-builtin'
|
||||
);
|
||||
|
||||
let resultId: number = (comp.state as any).content;
|
||||
console.assert(resultId !== undefined);
|
||||
|
||||
// Return the component, not ID
|
||||
return componentsById[resultId];
|
||||
}
|
||||
|
||||
/// Return the root component, but take care to discard any rio internal
|
||||
/// components.
|
||||
export function getDisplayedRootComponent(): ComponentBase {
|
||||
let rootScroller = getRootScroller();
|
||||
let result = componentsById[rootScroller.state.content]!;
|
||||
|
||||
// This might be the user's root, but could also be injected. Keep
|
||||
// digging.
|
||||
while (result.isInjectedLayoutComponent()) {
|
||||
result = getDirectChildOfInjectedComponent(result);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user