From 0b7d3fb20c790b7756223bd1a6627a5fb5ce4668 Mon Sep 17 00:00:00 2001 From: Huyen Nguyen <25715018+huyenltnguyen@users.noreply.github.com> Date: Tue, 15 Jul 2025 23:49:09 +0700 Subject: [PATCH 1/2] fix(view): add videoId null check --- .../learn/challenge/templates/python/python_view.dart | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/mobile-app/lib/ui/views/learn/challenge/templates/python/python_view.dart b/mobile-app/lib/ui/views/learn/challenge/templates/python/python_view.dart index 0a2f63839..7f7a2e4ac 100644 --- a/mobile-app/lib/ui/views/learn/challenge/templates/python/python_view.dart +++ b/mobile-app/lib/ui/views/learn/challenge/templates/python/python_view.dart @@ -68,12 +68,13 @@ class PythonView extends StatelessWidget { ), ), const SizedBox(height: 12), - ChallengeCard( - title: 'Video', - child: YoutubePlayerWidget( - videoId: challenge.videoId!, + if (challenge.videoId != null) + ChallengeCard( + title: 'Video', + child: YoutubePlayerWidget( + videoId: challenge.videoId!, + ), ), - ), const SizedBox(height: 12), if (challenge.transcript.isNotEmpty) ...[ ChallengeCard( From 1cb45ca32aec659f6d05b497f1ede5bd7a960e55 Mon Sep 17 00:00:00 2001 From: Huyen Nguyen <25715018+huyenltnguyen@users.noreply.github.com> Date: Wed, 16 Jul 2025 00:04:03 +0700 Subject: [PATCH 2/2] fix(view): display transcript as plain text if video is unvailable --- .../multiple_choice/multiple_choice_view.dart | 1 + .../templates/python/python_view.dart | 1 + .../templates/review/review_view.dart | 1 + .../learn/widgets/transcript_widget.dart | 43 ++++++++++++------- 4 files changed, 30 insertions(+), 16 deletions(-) diff --git a/mobile-app/lib/ui/views/learn/challenge/templates/multiple_choice/multiple_choice_view.dart b/mobile-app/lib/ui/views/learn/challenge/templates/multiple_choice/multiple_choice_view.dart index 285d0ff01..b58795e60 100644 --- a/mobile-app/lib/ui/views/learn/challenge/templates/multiple_choice/multiple_choice_view.dart +++ b/mobile-app/lib/ui/views/learn/challenge/templates/multiple_choice/multiple_choice_view.dart @@ -72,6 +72,7 @@ class MultipleChoiceView extends StatelessWidget { title: 'Transcript', child: Transcript( transcript: challenge.transcript, + isCollapsible: challenge.videoId != null, ), ), ], diff --git a/mobile-app/lib/ui/views/learn/challenge/templates/python/python_view.dart b/mobile-app/lib/ui/views/learn/challenge/templates/python/python_view.dart index 7f7a2e4ac..5879b3e7e 100644 --- a/mobile-app/lib/ui/views/learn/challenge/templates/python/python_view.dart +++ b/mobile-app/lib/ui/views/learn/challenge/templates/python/python_view.dart @@ -81,6 +81,7 @@ class PythonView extends StatelessWidget { title: 'Transcript', child: Transcript( transcript: challenge.transcript, + isCollapsible: challenge.videoId != null, ), ), ], diff --git a/mobile-app/lib/ui/views/learn/challenge/templates/review/review_view.dart b/mobile-app/lib/ui/views/learn/challenge/templates/review/review_view.dart index 5339e15fd..dd59206de 100644 --- a/mobile-app/lib/ui/views/learn/challenge/templates/review/review_view.dart +++ b/mobile-app/lib/ui/views/learn/challenge/templates/review/review_view.dart @@ -60,6 +60,7 @@ class ReviewView extends StatelessWidget { title: 'Transcript', child: Transcript( transcript: challenge.transcript, + isCollapsible: challenge.videoId != null, ), ), ], diff --git a/mobile-app/lib/ui/views/learn/widgets/transcript_widget.dart b/mobile-app/lib/ui/views/learn/widgets/transcript_widget.dart index 106c698f3..2fccde628 100644 --- a/mobile-app/lib/ui/views/learn/widgets/transcript_widget.dart +++ b/mobile-app/lib/ui/views/learn/widgets/transcript_widget.dart @@ -5,29 +5,40 @@ class Transcript extends StatelessWidget { const Transcript({ super.key, required this.transcript, + this.isCollapsible = true, }); final String transcript; + final bool isCollapsible; @override Widget build(BuildContext context) { HTMLParser parser = HTMLParser(context: context); - return ExpansionTile( - backgroundColor: Colors.transparent, - collapsedBackgroundColor: Colors.transparent, - title: const Text('Tap to expand'), - shape: const RoundedRectangleBorder( - side: BorderSide.none, - borderRadius: BorderRadius.zero, - ), - collapsedShape: const RoundedRectangleBorder( - side: BorderSide.none, - borderRadius: BorderRadius.zero, - ), - children: [ - ...parser.parse(transcript), - ], - ); + if (isCollapsible) { + return ExpansionTile( + backgroundColor: Colors.transparent, + collapsedBackgroundColor: Colors.transparent, + title: const Text('Tap to expand'), + shape: const RoundedRectangleBorder( + side: BorderSide.none, + borderRadius: BorderRadius.zero, + ), + collapsedShape: const RoundedRectangleBorder( + side: BorderSide.none, + borderRadius: BorderRadius.zero, + ), + children: [ + ...parser.parse(transcript), + ], + ); + } else { + return Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + ...parser.parse(transcript), + ], + ); + } } }