-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Play queue notification * Lint fix * change binding * Add notification preference * Lint fix * changelog --------- Co-authored-by: github-action linter <[email protected]>
- Loading branch information
Showing
14 changed files
with
281 additions
and
61 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
65 changes: 65 additions & 0 deletions
65
playlet-lib/src/components/PlayQueue/Notifications/PlayQueueNotification.bs
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,65 @@ | ||
import "pkg:/source/utils/StringUtils.bs" | ||
import "pkg:/source/utils/Types.bs" | ||
|
||
' TODO:P2 a lot of shared logic with the SponsorBlock notification, should be refactored into a common notification | ||
function Init() | ||
m.translationAnimation = m.top.findNode("translationAnimation") | ||
m.translationAnimationInterpolator = m.top.findNode("translationAnimationInterpolator") | ||
m.animationTimer = m.top.findNode("animationTimer") | ||
|
||
m.top.translation = [1280, 20] | ||
m.translationAnimation.observeField("state", FuncName(OnAnimationState)) | ||
m.animationTimer.observeField("fire", FuncName(OnAnimationTimer)) | ||
end function | ||
|
||
function OnContentSet() as void | ||
content = m.top.content | ||
if content = invalid | ||
return | ||
end if | ||
|
||
if not StringUtils.IsNullOrEmpty(content.thumbnail) | ||
m.top.thumbnail = content.thumbnail | ||
else | ||
m.top.thumbnail = "pkg:/images/thumbnail-missing.jpg" | ||
end if | ||
|
||
m.top.line1 = content.title | ||
end function | ||
|
||
function OnShow() | ||
AnimateIn() | ||
end function | ||
|
||
function OnAnimationTimer() | ||
AnimateOut() | ||
end function | ||
|
||
function AnimateIn() | ||
m.translationAnimation.unobserveField("state") | ||
m.animationTimer.control = "stop" | ||
m.animationTimer.control = "start" | ||
m.translationAnimation.observeField("state", FuncName(OnAnimationState)) | ||
|
||
Animate(false) | ||
end function | ||
|
||
function AnimateOut() | ||
Animate(true) | ||
end function | ||
|
||
function Animate(reverse as boolean) as void | ||
' We are already animating in the requested direction | ||
if m.translationAnimationInterpolator.reverse = reverse and m.translationAnimation.control <> "none" | ||
return | ||
end if | ||
|
||
m.translationAnimationInterpolator.reverse = reverse | ||
m.translationAnimation.control = "start" | ||
end function | ||
|
||
function OnAnimationState() | ||
if m.translationAnimation.state = "stopped" and m.translationAnimationInterpolator.reverse = true | ||
m.top.getParent().removeChild(m.top) | ||
end if | ||
end function |
58 changes: 58 additions & 0 deletions
58
playlet-lib/src/components/PlayQueue/Notifications/PlayQueueNotification.xml
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,58 @@ | ||
<component name="PlayQueueNotification" extends="Group"> | ||
<interface> | ||
<field id="content" type="node" onChange="OnContentSet" /> | ||
<field id="thumbnail" type="uri" alias="thumbnailPoster.uri" /> | ||
<field id="line1" type="string" alias="line1Label.text" /> | ||
<field id="show" type="boolean" alwaysNotify="true" onChange="OnShow" /> | ||
</interface> | ||
<children> | ||
<Poster | ||
width="500" | ||
height="126" | ||
opacity="0.9" | ||
uri="pkg:/images/white.9.png"> | ||
|
||
<Poster | ||
id="thumbnailPoster" | ||
loadDisplayMode="scaleToZoom" | ||
width="170" | ||
height="106" | ||
failedBitmapUri="pkg:/images/thumbnail-missing.jpg" | ||
translation="[10,10]"> | ||
</Poster> | ||
|
||
<LayoutGroup | ||
itemSpacings="[10]" | ||
translation="[190,10]"> | ||
<Label | ||
width="300" | ||
font="font:SmallestBoldSystemFont" | ||
horizAlign="center" | ||
color="0x262626ff" | ||
text="Added to queue"> | ||
<Font role="font" uri="font:BoldSystemFontFile" size="22" /> | ||
</Label> | ||
<Label | ||
id="line1Label" | ||
width="300" | ||
font="font:SmallestSystemFont" | ||
maxLines="3" | ||
color="0x262626ff" | ||
wrap="true" /> | ||
</LayoutGroup> | ||
</Poster> | ||
<Animation | ||
id="translationAnimation" | ||
duration="0.3" | ||
optional="true"> | ||
<Vector2DFieldInterpolator | ||
id="translationAnimationInterpolator" | ||
key="[0.0, 0.5, 1.0]" | ||
keyValue="[ [1280.0, 20.0], [1020.0, 20.0], [760.0, 20.0] ]" | ||
fieldToInterp="PlayQueueNotification.translation" /> | ||
</Animation> | ||
<Timer | ||
id="animationTimer" | ||
duration="3" /> | ||
</children> | ||
</component> |
28 changes: 28 additions & 0 deletions
28
playlet-lib/src/components/PlayQueue/Notifications/PlayQueueNotificationUtils.bs
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,28 @@ | ||
namespace PlayQueue | ||
const NOTIFICATION_NODE_ID = "PlayQueueNotification" | ||
|
||
function ShowNotifcation(notifications as object, contentNode as object) as void | ||
notification = notifications.findNode(NOTIFICATION_NODE_ID) | ||
if notification = invalid | ||
notification = notifications.createChild("PlayQueueNotification") | ||
notification.id = NOTIFICATION_NODE_ID | ||
end if | ||
notification.content = contentNode | ||
notification.show = true | ||
end function | ||
|
||
function RemoveNotifcation(notifications as object) as void | ||
notification = notifications.findNode(NOTIFICATION_NODE_ID) | ||
if notification <> invalid | ||
notifications.RemoveChild(notification) | ||
end if | ||
end function | ||
|
||
function SetVisible(notifications as object, visible as boolean) | ||
notification = notifications.findNode(NOTIFICATION_NODE_ID) | ||
if notification <> invalid | ||
notification.visible = visible | ||
end if | ||
end function | ||
|
||
end namespace |
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
Oops, something went wrong.