From 0f000590a06b6eb0fd8a14271e24dab841f694a5 Mon Sep 17 00:00:00 2001 From: Brahim Hadriche Date: Sat, 30 Dec 2023 22:32:43 -0500 Subject: [PATCH] Fixes for RowList cells (#244) * Fixes for RowList cells * typo --- CHANGELOG.md | 4 +- .../VideoFeed/VideoRowCell/PlaylistRowCell.bs | 23 +++++---- .../VideoRowCell/PlaylistRowCell.xml | 8 +++- .../VideoFeed/VideoRowCell/VideoRowCell.bs | 48 ++++++++----------- .../VideoFeed/VideoRowCell/VideoRowCell.xml | 8 ++++ 5 files changed, 48 insertions(+), 43 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 97b40c5e..eac4c534 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,7 +7,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] -- Nothing worth mentioning yet. +### Fixed + +- A rare bug that causes the app to crash when displaying video cells ## [0.18.0] - 2023-12-28 diff --git a/playlet-lib/src/components/VideoFeed/VideoRowCell/PlaylistRowCell.bs b/playlet-lib/src/components/VideoFeed/VideoRowCell/PlaylistRowCell.bs index daa6458a..af71ca8e 100644 --- a/playlet-lib/src/components/VideoFeed/VideoRowCell/PlaylistRowCell.bs +++ b/playlet-lib/src/components/VideoFeed/VideoRowCell/PlaylistRowCell.bs @@ -1,14 +1,8 @@ import "pkg:/source/utils/Types.bs" function Init() - ' TODO:P2 use component properties with alias instead of FindNode - m.titleLabel = m.top.FindNode("titleLabel") - m.authorLabel = m.top.FindNode("authorLabel") - m.updatedLabel = m.top.FindNode("updatedLabel") m.videoCountRect = m.top.FindNode("videoCountRect") m.videoCountLabel = m.top.FindNode("videoCountLabel") - m.thumbnail = m.top.FindNode("thumbnail") - m.thumbnail.failedBitmapUri = "pkg:/images/thumbnail-missing.jpg" end function function OnContentSet() as void @@ -18,23 +12,28 @@ function OnContentSet() as void return end if - m.titleLabel.text = content.title + m.top.title = content.title ' NOTE: "_author" not "author". See PlaylistContentNode.xml for explanation. - m.authorLabel.text = content._author - m.updatedLabel.text = content.updatedText + m.top.author = content._author + m.top.updated = content.updatedText - m.thumbnail.uri = content.thumbnail + m.top.thumbnailUri = content.thumbnail SetVideoCount(content.videoCountText) end function -function SetVideoCount(videoCountText as string) +function SetVideoCount(videoCountText as string) as void + m.top.videoCount = videoCountText + label = m.videoCountLabel rect = m.videoCountRect + if label = invalid or rect = invalid + return + end if + rectParent = rect.getParent() - label.text = videoCountText size = label.localBoundingRect() rect.width = size.width + 16 diff --git a/playlet-lib/src/components/VideoFeed/VideoRowCell/PlaylistRowCell.xml b/playlet-lib/src/components/VideoFeed/VideoRowCell/PlaylistRowCell.xml index eab7fcdd..440634fb 100644 --- a/playlet-lib/src/components/VideoFeed/VideoRowCell/PlaylistRowCell.xml +++ b/playlet-lib/src/components/VideoFeed/VideoRowCell/PlaylistRowCell.xml @@ -2,6 +2,11 @@ + + + + + + height="196" + failedBitmapUri="pkg:/images/thumbnail-missing.jpg"> 0 SetDurationText(content.lengthText) - m.durationRect.visible = true + m.top.durationRectVisible = true else if content.isUpcoming = true - m.upcomingRect.visible = true + m.top.upcomingRectVisible = true else if content.liveNow - m.liveRect.visible = true + m.top.liveRectVisible = true end if end if end function -function SetDurationText(text as string) +function SetDurationText(text as string) as void + m.top.duration = text + label = m.durationLabel rect = m.durationRect + if label = invalid or rect = invalid + return + end if + rectParent = rect.getParent() - label.text = text size = label.localBoundingRect() rect.width = size.width + 16 diff --git a/playlet-lib/src/components/VideoFeed/VideoRowCell/VideoRowCell.xml b/playlet-lib/src/components/VideoFeed/VideoRowCell/VideoRowCell.xml index 323ebbac..1bd50050 100644 --- a/playlet-lib/src/components/VideoFeed/VideoRowCell/VideoRowCell.xml +++ b/playlet-lib/src/components/VideoFeed/VideoRowCell/VideoRowCell.xml @@ -2,6 +2,14 @@ + + + + + + + +