Skip to content

Commit

Permalink
Cleaned code in custom_video_control_bar.dart and added error message…
Browse files Browse the repository at this point in the history
… as saidd
  • Loading branch information
ge59dil committed Jan 25, 2024
1 parent 50c5d95 commit 3684226
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 39 deletions.
77 changes: 39 additions & 38 deletions lib/views/video_view/utils/custom_video_control_bar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,46 +21,47 @@ class CustomVideoControlBar extends StatelessWidget {
required this.onDownload,
});

void _showDownloadOptions(BuildContext context) {
showModalBottomSheet(
context: context,
builder: (BuildContext context) {
return SafeArea(
child: Wrap(
children: <Widget>[
ListTile(
leading: const Icon(Icons.download),
title: const Text('Combined'),
onTap: () {
Navigator.pop(context);
onDownload('Combined');
},
),
ListTile(
leading: const Icon(Icons.present_to_all),
title: const Text('Presentation Only'),
onTap: () {
Navigator.pop(context);
onDownload('Presentation');
},
),
ListTile(
leading: const Icon(Icons.videocam),
title: const Text('Camera'),
onTap: () {
Navigator.pop(context);
onDownload('Camera Only');
},
),
],
),
);
},
);
}

@override
Widget build(BuildContext context) {
ThemeData themeData = Theme.of(context);
void showDownloadOptions() {
showModalBottomSheet(
context: context,
builder: (BuildContext context) {
return SafeArea(
child: Wrap(
children: <Widget>[
ListTile(
leading: const Icon(Icons.download),
title: const Text('Combined'),
onTap: () {
Navigator.pop(context);
onDownload('Combined');
},
),
ListTile(
leading: const Icon(Icons.present_to_all),
title: const Text('Presentation Only'),
onTap: () {
Navigator.pop(context);
onDownload('Presentation');
},
),
ListTile(
leading: const Icon(Icons.videocam),
title: const Text('Camera'),
onTap: () {
Navigator.pop(context);
onDownload('Camera Only');
},
),
],
),
);
},
);
}

List<Map<String, IconData>> getMenuItems(bool isPinned, bool isDownloaded) {
List<Map<String, IconData>> items = [
Expand Down Expand Up @@ -114,7 +115,7 @@ class CustomVideoControlBar extends StatelessWidget {
.read(userViewModelProvider.notifier)
.pinCourse(currentStream.courseID);
} else if (choice == 'Download') {
showDownloadOptions();
_showDownloadOptions(context);
}
},
itemBuilder: (BuildContext context) {
Expand Down
2 changes: 1 addition & 1 deletion lib/views/video_view/video_player.dart
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ class VideoPlayerPageState extends ConsumerState<VideoPlayerPage> {
// Check if the Combined URL is found
if (downloadUrl == null) {
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(content: Text('Downloads not allowed for this lecture')),
SnackBar(content: Text('Download type "$type" not available for this lecture')),
);
return;
}
Expand Down

0 comments on commit 3684226

Please sign in to comment.