MCPcopy Create free account
hub / github.com/material-shell/material-shell / nextLayout

Method nextLayout

src/layout/msWorkspace/msWorkspace.ts:565–587  ·  view source on GitHub ↗
(direction: number)

Source from the content-addressed store, hash-verified

563 }
564
565 nextLayout(direction: number) {
566 this.layout.onDestroy();
567
568 let { key } = (this.layout.constructor as LayoutType).state;
569 if (
570 !this.state.layoutStateList.find(
571 (layoutState) => layoutState.key === key
572 )
573 ) {
574 key = this.state.layoutStateList[0].key;
575 }
576 let nextIndex =
577 this.state.layoutStateList.findIndex(
578 (layoutState) => layoutState.key === key
579 ) + direction;
580 if (nextIndex < 0) {
581 nextIndex += this.state.layoutStateList.length;
582 }
583 nextIndex = nextIndex % this.state.layoutStateList.length;
584 // Get the next layout available
585 const newLayoutState = this.state.layoutStateList[nextIndex];
586 this.setLayoutByKey(newLayoutState.key);
587 }
588
589 setLayoutByKey(layoutKey: string) {
590 logAssert(!this.destroyed, 'Workspace is destroyed');

Callers 2

constructorMethod · 0.80
constructorMethod · 0.80

Calls 3

setLayoutByKeyMethod · 0.95
findMethod · 0.65
onDestroyMethod · 0.45

Tested by

no test coverage detected