Skip to content

Commit 87da809

Browse files
feat: course home pages grades card
1 parent d1ed4bf commit 87da809

File tree

8 files changed

+399
-170
lines changed

8 files changed

+399
-170
lines changed

course/src/main/java/org/openedx/course/presentation/container/CourseContainerFragment.kt

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -489,6 +489,13 @@ private fun DashboardPager(
489489
CourseContentTab.entries.indexOf(contentTab)
490490
)
491491
}
492+
},
493+
onNavigateToProgress = {
494+
scope.launch {
495+
pagerState.animateScrollToPage(
496+
CourseContainerTab.entries.indexOf(CourseContainerTab.PROGRESS)
497+
)
498+
}
492499
}
493500
)
494501
}
@@ -717,7 +724,9 @@ private fun scrollToProgress(scope: CoroutineScope, pagerState: PagerState) {
717724
private fun HomeNavigationRow(homePagerState: PagerState) {
718725
val homeCoroutineScope = rememberCoroutineScope()
719726
Row(
720-
modifier = Modifier.fillMaxWidth(),
727+
modifier = Modifier
728+
.fillMaxWidth()
729+
.background(MaterialTheme.appColors.background),
721730
horizontalArrangement = Arrangement.SpaceBetween,
722731
verticalAlignment = Alignment.CenterVertically
723732
) {

course/src/main/java/org/openedx/course/presentation/home/AssignmentsHomePagerCardContent.kt

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,9 @@ import androidx.compose.material.Icon
1717
import androidx.compose.material.LinearProgressIndicator
1818
import androidx.compose.material.MaterialTheme
1919
import androidx.compose.material.Text
20-
import androidx.compose.material.TextButton
2120
import androidx.compose.material.icons.Icons
2221
import androidx.compose.material.icons.automirrored.filled.Assignment
2322
import androidx.compose.material.icons.automirrored.filled.KeyboardArrowRight
24-
import androidx.compose.material.icons.automirrored.filled.List
2523
import androidx.compose.material.icons.filled.Timer
2624
import androidx.compose.runtime.Composable
2725
import androidx.compose.ui.Alignment
@@ -115,23 +113,10 @@ fun AssignmentsHomePagerCardContent(
115113
Spacer(modifier = Modifier.height(8.dp))
116114

117115
// View All Assignments button
118-
TextButton(
119-
onClick = onViewAllAssignmentsClick,
120-
modifier = Modifier.fillMaxWidth()
121-
) {
122-
Icon(
123-
imageVector = Icons.AutoMirrored.Filled.List,
124-
contentDescription = null,
125-
tint = MaterialTheme.appColors.primary,
126-
modifier = Modifier.size(20.dp)
127-
)
128-
Spacer(modifier = Modifier.width(8.dp))
129-
Text(
130-
text = stringResource(R.string.course_view_all_assignments),
131-
style = MaterialTheme.appTypography.labelLarge,
132-
color = MaterialTheme.appColors.primary
133-
)
134-
}
116+
ViewAllButton(
117+
text = stringResource(R.string.course_view_all_assignments),
118+
onClick = onViewAllAssignmentsClick
119+
)
135120
}
136121
}
137122

course/src/main/java/org/openedx/course/presentation/home/CourseCompletionHomePagerCardContent.kt

Lines changed: 3 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,8 @@ import androidx.compose.foundation.layout.Spacer
77
import androidx.compose.foundation.layout.fillMaxWidth
88
import androidx.compose.foundation.layout.height
99
import androidx.compose.foundation.layout.padding
10-
import androidx.compose.foundation.layout.size
11-
import androidx.compose.foundation.layout.width
12-
import androidx.compose.material.Icon
1310
import androidx.compose.material.MaterialTheme
1411
import androidx.compose.material.Text
15-
import androidx.compose.material.TextButton
16-
import androidx.compose.material.icons.Icons
17-
import androidx.compose.material.icons.automirrored.filled.List
1812
import androidx.compose.runtime.Composable
1913
import androidx.compose.ui.Alignment
2014
import androidx.compose.ui.Modifier
@@ -117,28 +111,11 @@ fun CourseCompletionHomePagerCardContent(
117111
Spacer(modifier = Modifier.height(8.dp))
118112

119113
// View All Content Button
120-
TextButton(
114+
ViewAllButton(
115+
text = stringResource(R.string.course_completion_view_all_content),
121116
onClick = onViewAllContentClick,
122117
modifier = Modifier.align(Alignment.CenterHorizontally)
123-
) {
124-
Row(
125-
verticalAlignment = Alignment.CenterVertically,
126-
horizontalArrangement = Arrangement.Center
127-
) {
128-
Icon(
129-
imageVector = Icons.AutoMirrored.Filled.List,
130-
contentDescription = null,
131-
modifier = Modifier.size(20.dp),
132-
tint = MaterialTheme.appColors.primary
133-
)
134-
Spacer(modifier = Modifier.width(8.dp))
135-
Text(
136-
text = stringResource(R.string.course_completion_view_all_content),
137-
style = MaterialTheme.appTypography.labelLarge,
138-
color = MaterialTheme.appColors.primary
139-
)
140-
}
141-
}
118+
)
142119
}
143120
}
144121

course/src/main/java/org/openedx/course/presentation/home/CourseHomeScreen.kt

Lines changed: 43 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,23 @@ import androidx.compose.foundation.layout.fillMaxSize
1111
import androidx.compose.foundation.layout.fillMaxWidth
1212
import androidx.compose.foundation.layout.height
1313
import androidx.compose.foundation.layout.padding
14+
import androidx.compose.foundation.layout.size
15+
import androidx.compose.foundation.layout.width
1416
import androidx.compose.foundation.layout.widthIn
1517
import androidx.compose.foundation.pager.HorizontalPager
1618
import androidx.compose.foundation.pager.PagerState
1719
import androidx.compose.foundation.pager.rememberPagerState
1820
import androidx.compose.foundation.rememberScrollState
1921
import androidx.compose.foundation.verticalScroll
2022
import androidx.compose.material.Card
23+
import androidx.compose.material.Icon
2124
import androidx.compose.material.MaterialTheme
2225
import androidx.compose.material.Scaffold
2326
import androidx.compose.material.Surface
2427
import androidx.compose.material.Text
28+
import androidx.compose.material.TextButton
29+
import androidx.compose.material.icons.Icons
30+
import androidx.compose.material.icons.automirrored.filled.List
2531
import androidx.compose.material.rememberScaffoldState
2632
import androidx.compose.runtime.Composable
2733
import androidx.compose.runtime.LaunchedEffect
@@ -52,6 +58,7 @@ import org.openedx.core.ui.displayCutoutForLandscape
5258
import org.openedx.core.ui.theme.OpenEdXTheme
5359
import org.openedx.core.ui.theme.appColors
5460
import org.openedx.core.ui.theme.appShapes
61+
import org.openedx.core.ui.theme.appTypography
5562
import org.openedx.course.R
5663
import org.openedx.course.presentation.container.CourseContentTab
5764
import org.openedx.course.presentation.ui.CourseDatesBanner
@@ -72,6 +79,7 @@ fun CourseHomeScreen(
7279
homePagerState: PagerState,
7380
onResetDatesClick: () -> Unit,
7481
onNavigateToContent: (CourseContentTab) -> Unit = {},
82+
onNavigateToProgress: () -> Unit = {},
7583
) {
7684
val uiState by viewModel.uiState.collectAsState()
7785
val uiMessage by viewModel.uiMessage.collectAsState(null)
@@ -158,7 +166,8 @@ fun CourseHomeScreen(
158166
)
159167
viewModel.logAssignmentClick(assignmentBlock.id)
160168
},
161-
onNavigateToContent = onNavigateToContent
169+
onNavigateToContent = onNavigateToContent,
170+
onNavigateToProgress = onNavigateToProgress
162171
)
163172
}
164173

@@ -176,6 +185,7 @@ private fun CourseHomeUI(
176185
onVideoClick: (Block) -> Unit,
177186
onAssignmentClick: (Block) -> Unit,
178187
onNavigateToContent: (CourseContentTab) -> Unit,
188+
onNavigateToProgress: () -> Unit,
179189
) {
180190
val scaffoldState = rememberScaffoldState()
181191

@@ -316,8 +326,11 @@ private fun CourseHomeUI(
316326
)
317327
}
318328

319-
else -> {
320-
Text(tab.name)
329+
CourseHomePagerTab.GRADES -> {
330+
GradesHomePagerCardContent(
331+
uiState = uiState,
332+
onViewProgressClick = onNavigateToProgress
333+
)
321334
}
322335
}
323336
}
@@ -401,6 +414,7 @@ private fun CourseHomeScreenPreview() {
401414
onVideoClick = {},
402415
onAssignmentClick = {},
403416
onNavigateToContent = { _ -> },
417+
onNavigateToProgress = {}
404418
)
405419
}
406420
}
@@ -448,6 +462,32 @@ private fun CourseHomeScreenTabletPreview() {
448462
onVideoClick = {},
449463
onAssignmentClick = {},
450464
onNavigateToContent = { _ -> },
465+
onNavigateToProgress = { },
466+
)
467+
}
468+
}
469+
470+
@Composable
471+
fun ViewAllButton(
472+
text: String,
473+
onClick: () -> Unit,
474+
modifier: Modifier = Modifier,
475+
) {
476+
TextButton(
477+
onClick = onClick,
478+
modifier = modifier.fillMaxWidth()
479+
) {
480+
Icon(
481+
imageVector = Icons.AutoMirrored.Filled.List,
482+
contentDescription = null,
483+
tint = MaterialTheme.appColors.primary,
484+
modifier = Modifier.size(20.dp)
485+
)
486+
Spacer(modifier = Modifier.width(8.dp))
487+
Text(
488+
text = text,
489+
style = MaterialTheme.appTypography.labelLarge,
490+
color = MaterialTheme.appColors.primary
451491
)
452492
}
453493
}

0 commit comments

Comments
 (0)