-
Notifications
You must be signed in to change notification settings - Fork 163
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: State management for runtime drawers
- Loading branch information
1 parent
3a8b4bc
commit 2d4628e
Showing
8 changed files
with
132 additions
and
74 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
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
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
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
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
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
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
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,34 @@ | ||
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
/** | ||
* This class is used to manage the visibility state of the runtime drawers. | ||
*/ | ||
export default class VisibilityStateManager { | ||
isVisible = false; | ||
visibilityCallback: ((isPaused: boolean) => void) | null = null; | ||
|
||
private onVisibleStateChange = () => { | ||
if (this.visibilityCallback) { | ||
this.visibilityCallback(this.isVisible); | ||
} | ||
}; | ||
|
||
registerVisibilityCallback = (callback: (isVisible: boolean) => void) => { | ||
this.visibilityCallback = callback; | ||
|
||
return () => { | ||
this.visibilityCallback = null; | ||
}; | ||
}; | ||
|
||
show = () => { | ||
this.isVisible = true; | ||
this.onVisibleStateChange(); | ||
}; | ||
|
||
hide = () => { | ||
this.isVisible = false; | ||
this.onVisibleStateChange(); | ||
}; | ||
} |