Skip to content

Commit

Permalink
reduce logged in
Browse files Browse the repository at this point in the history
  • Loading branch information
Sainaamr committed Jan 28, 2024
1 parent 6e5ab6f commit 696235b
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
2 changes: 1 addition & 1 deletion lib/views/course_view/components/live_stream_section.dart
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ class LiveStreamSection extends StatelessWidget {
tumID: course.tUMOnlineIdentifier,
roomName: stream.roomName,
roomNumber: stream.roomCode,
viewerCount: stream.vodViews.toString(),
viewerCount: stream.vodViews,
path: imagePath,
courseId: course.id,
onTap: () {
Expand Down
7 changes: 3 additions & 4 deletions lib/views/course_view/components/small_stream_card.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class SmallStreamCard extends StatelessWidget {
final String? subtitle;
final String? roomName;
final String? roomNumber;
final String? viewerCount;
final int viewerCount;
final String? path;

const SmallStreamCard({
Expand All @@ -27,7 +27,7 @@ class SmallStreamCard extends StatelessWidget {
required this.tumID,
this.roomName,
this.roomNumber,
this.viewerCount,
required this.viewerCount,
this.path,
required this.courseId,
required this.onTap,
Expand Down Expand Up @@ -212,15 +212,14 @@ class SmallStreamCard extends StatelessWidget {
}

Widget _buildCourseViewerCount(ThemeData themeData) {
if (viewerCount == null) return const SizedBox();
return Container(
decoration: BoxDecoration(
color: themeData.shadowColor.withOpacity(0.15),
borderRadius: BorderRadius.circular(4),
),
padding: const EdgeInsets.all(3),
child: Text(
"${viewerCount!} viewers",
"$viewerCount viewers",
style: themeData.textTheme.labelSmall?.copyWith(
fontSize: 12,
height: 1,
Expand Down
12 changes: 7 additions & 5 deletions lib/views/course_view/courses_overview.dart
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ class CourseOverviewState extends ConsumerState<CourseOverview> {

@override
Widget build(BuildContext context) {
final isLoggedIn = ref.watch(userViewModelProvider).user != null;
final userCourses = ref.watch(userViewModelProvider).userCourses;
final publicCourses = ref.watch(userViewModelProvider).publicCourses;
final liveStreams = ref.watch(videoViewModelProvider).liveStreams;
Expand All @@ -63,14 +62,14 @@ class CourseOverviewState extends ConsumerState<CourseOverview> {
onRefresh: _refreshData,
child: ListView(
children: [
if (isLoggedIn)
Center(
child: LiveStreamSection(
ref: ref,
sectionTitle: "Live Now",
courses: (userCourses ?? []) + (publicCourses ?? []),
streams: liveStreams ?? [],
)),
),
),
if (isTablet)
Row(
crossAxisAlignment: CrossAxisAlignment.start,
Expand Down Expand Up @@ -114,8 +113,10 @@ class CourseOverviewState extends ConsumerState<CourseOverview> {
);
}

Widget _buildSection(
String title, SectionKind sectionKind, courses, streams) {
Widget _buildSection(String title,
SectionKind sectionKind,
courses,
streams,) {
return CourseSection(
ref: ref,
sectionTitle: title,
Expand Down Expand Up @@ -156,5 +157,6 @@ class CourseOverviewState extends ConsumerState<CourseOverview> {
final userViewModelNotifier = ref.read(userViewModelProvider.notifier);
await userViewModelNotifier.fetchUserCourses();
await userViewModelNotifier.fetchPublicCourses();
await ref.read(videoViewModelProvider.notifier).fetchLiveNowStreams();
}
}

0 comments on commit 696235b

Please sign in to comment.