Skip to content

Commit f8c29fb

Browse files
fix: changes according demo feedback
1 parent 9601f28 commit f8c29fb

File tree

6 files changed

+79
-43
lines changed

6 files changed

+79
-43
lines changed

core/src/main/res/values/strings.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@
156156
<!-- endregion -->
157157

158158
<string name="core_no_course_content">No course content is currently available.</string>
159-
<string name="core_no_videos">There are no videos currently available for this course.</string>
159+
<string name="core_no_videos">No videos available for this course.</string>
160160
<string name="core_no_dates">Course dates are currently not available.</string>
161161
<string name="core_no_progress">This course does not contain exams or graded assignments.</string>
162162
<string name="core_no_discussion">Unable to load discussions.\n Please try again later.</string>

course/src/main/java/org/openedx/course/presentation/contenttab/ContentTabScreen.kt

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,22 @@ import androidx.compose.foundation.layout.fillMaxWidth
1313
import androidx.compose.foundation.layout.height
1414
import androidx.compose.foundation.layout.padding
1515
import androidx.compose.foundation.layout.width
16+
import androidx.compose.foundation.layout.widthIn
1617
import androidx.compose.material.Divider
1718
import androidx.compose.material.MaterialTheme
1819
import androidx.compose.material.Scaffold
1920
import androidx.compose.material.Text
2021
import androidx.compose.runtime.Composable
2122
import androidx.compose.runtime.getValue
2223
import androidx.compose.runtime.mutableStateOf
24+
import androidx.compose.runtime.remember
2325
import androidx.compose.runtime.saveable.rememberSaveable
2426
import androidx.compose.runtime.setValue
2527
import androidx.compose.ui.Alignment
2628
import androidx.compose.ui.Modifier
2729
import androidx.compose.ui.draw.clip
2830
import androidx.compose.ui.res.stringResource
31+
import androidx.compose.ui.unit.Dp
2932
import androidx.compose.ui.unit.dp
3033
import androidx.fragment.app.FragmentManager
3134
import org.koin.androidx.compose.koinViewModel
@@ -36,6 +39,7 @@ import org.openedx.course.presentation.container.CourseContentTab
3639
import org.openedx.course.presentation.outline.CourseContentAllScreen
3740
import org.openedx.course.presentation.videos.CourseContentVideoScreen
3841
import org.openedx.foundation.presentation.WindowSize
42+
import org.openedx.foundation.presentation.windowSizeValue
3943

4044
@Composable
4145
fun ContentScreen(
@@ -44,6 +48,15 @@ fun ContentScreen(
4448
courseId: String,
4549
courseName: String
4650
) {
51+
val tabsWidth by remember(key1 = windowSize) {
52+
mutableStateOf(
53+
windowSize.windowSizeValue(
54+
expanded = Modifier.widthIn(Dp.Unspecified, 560.dp),
55+
compact = Modifier.fillMaxWidth()
56+
)
57+
)
58+
}
59+
4760
var selectedTab by rememberSaveable { mutableStateOf(CourseContentTab.ALL) }
4861
Scaffold(
4962
modifier = Modifier.fillMaxSize(),
@@ -52,11 +65,12 @@ fun ContentScreen(
5265
modifier = Modifier
5366
.fillMaxSize()
5467
.padding(it),
68+
horizontalAlignment = Alignment.CenterHorizontally
5569
) {
5670
Row(
5771
modifier = Modifier
5872
.padding(16.dp)
59-
.fillMaxWidth()
73+
.then(tabsWidth)
6074
.height(40.dp)
6175
.clip(MaterialTheme.appShapes.buttonShape)
6276
.border(
@@ -75,7 +89,7 @@ fun ContentScreen(
7589
if (isSelected) {
7690
MaterialTheme.appColors.primary
7791
} else {
78-
MaterialTheme.appColors.primaryButtonText
92+
MaterialTheme.appColors.background
7993
}
8094
)
8195
.weight(1f)

course/src/main/java/org/openedx/course/presentation/outline/CourseContentAllScreen.kt

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ import org.openedx.core.domain.model.CourseStructure
4949
import org.openedx.core.domain.model.CoursewareAccess
5050
import org.openedx.core.domain.model.OfflineDownload
5151
import org.openedx.core.domain.model.Progress
52+
import org.openedx.core.extension.getChapterBlocks
5253
import org.openedx.core.presentation.course.CourseViewMode
5354
import org.openedx.core.ui.CircularProgress
5455
import org.openedx.core.ui.HandleUIMessage
@@ -270,25 +271,28 @@ private fun CourseContentAllUI(
270271
}
271272
}
272273

273-
val progress = uiState.courseStructure.progress
274-
if (progress != null && progress.total > 0) {
275-
item {
276-
CourseProgress(
277-
modifier = Modifier
278-
.fillMaxWidth()
279-
.padding(
280-
start = 24.dp,
281-
end = 24.dp
282-
),
283-
progress = progress,
284-
description = pluralStringResource(
285-
R.plurals.course_assignments_complete,
286-
progress.completed,
287-
progress.completed,
288-
progress.total
289-
)
274+
val sections =
275+
uiState.courseStructure.blockData.getChapterBlocks()
276+
val progress = Progress(
277+
total = sections.size,
278+
completed = sections.filter { it.isCompleted() }.size
279+
)
280+
item {
281+
CourseProgress(
282+
modifier = Modifier
283+
.fillMaxWidth()
284+
.padding(
285+
start = 24.dp,
286+
end = 24.dp
287+
),
288+
progress = progress,
289+
description = pluralStringResource(
290+
R.plurals.course_sections_complete,
291+
progress.completed,
292+
progress.completed,
293+
progress.total
290294
)
291-
}
295+
)
292296
}
293297

294298
if (uiState.resumeComponent != null) {

course/src/main/java/org/openedx/course/presentation/ui/CourseUI.kt

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ import androidx.compose.foundation.lazy.LazyListState
3333
import androidx.compose.foundation.lazy.LazyRow
3434
import androidx.compose.foundation.lazy.items
3535
import androidx.compose.foundation.lazy.itemsIndexed
36+
import androidx.compose.foundation.lazy.rememberLazyListState
3637
import androidx.compose.foundation.shape.CircleShape
3738
import androidx.compose.material.Button
3839
import androidx.compose.material.ButtonDefaults
@@ -617,6 +618,7 @@ fun CourseVideoSection(
617618
onVideoClick: (Block) -> Unit,
618619
onDownloadClick: (blocksIds: List<String>) -> Unit,
619620
) {
621+
val state = rememberLazyListState()
620622
val subSectionIds = videoBlocks.map { it.id }
621623
val filteredStatuses = downloadedStateMap.filterKeys { it in subSectionIds }.values
622624
val downloadedState = when {
@@ -626,6 +628,15 @@ fun CourseVideoSection(
626628
else -> DownloadedState.NOT_DOWNLOADED
627629
}
628630

631+
LaunchedEffect(Unit) {
632+
try {
633+
val uncompletedBlockIndex = videoBlocks.indexOf(videoBlocks.find { !it.isCompleted() })
634+
state.scrollToItem(uncompletedBlockIndex)
635+
} catch (e: Exception) {
636+
e.printStackTrace()
637+
}
638+
}
639+
629640
Column(
630641
modifier = Modifier.padding(vertical = 8.dp)
631642
) {
@@ -638,6 +649,7 @@ fun CourseVideoSection(
638649
}
639650
)
640651
LazyRow(
652+
state = state,
641653
horizontalArrangement = Arrangement.spacedBy(8.dp),
642654
contentPadding = PaddingValues(
643655
top = 8.dp,
@@ -694,7 +706,7 @@ fun CourseVideoItem(
694706
.error(coreR.drawable.core_no_image_course)
695707
.placeholder(coreR.drawable.core_no_image_course)
696708
.build(),
697-
contentDescription = null,
709+
contentDescription = stringResource(R.string.course_accessibility_video_player),
698710
contentScale = ContentScale.Crop
699711
)
700712

@@ -724,7 +736,7 @@ fun CourseVideoItem(
724736
// Title (top-left)
725737
Text(
726738
text = videoBlock.displayName,
727-
color = MaterialTheme.appColors.onPrimary,
739+
color = Color.White,
728740
style = MaterialTheme.appTypography.bodySmall,
729741
modifier = Modifier
730742
.align(Alignment.TopStart)
@@ -1470,7 +1482,7 @@ fun CourseProgress(
14701482
val buttonText = if (isCompletedShown) {
14711483
stringResource(R.string.course_hide_completed)
14721484
} else {
1473-
stringResource(R.string.course_show_completed)
1485+
stringResource(R.string.course_view_completed)
14741486
}
14751487
Column(
14761488
modifier = modifier,

course/src/main/java/org/openedx/course/presentation/videos/CourseContentVideoScreen.kt

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -174,24 +174,32 @@ private fun CourseVideosUI(
174174
)
175175
}
176176

177-
uiState.courseStructure.blockData.forEach { section ->
178-
val sectionVideos =
179-
uiState.courseVideos[section.id] ?: emptyList()
177+
uiState.courseStructure.blockData
178+
.let { list ->
179+
if (uiState.isCompletedSectionsShown) {
180+
list.sortedBy { uiState.courseVideos[it.id]?.any { !it.isCompleted() } }
181+
} else {
182+
list
183+
}
184+
}
185+
.forEach { section ->
186+
val sectionVideos =
187+
uiState.courseVideos[section.id] ?: emptyList()
180188

181-
if (sectionVideos.any { !it.isCompleted() } || uiState.isCompletedSectionsShown) {
182-
item {
183-
CourseVideoSection(
184-
block = section,
185-
videoBlocks = sectionVideos,
186-
downloadedStateMap = uiState.downloadedState,
187-
onVideoClick = onVideoClick,
188-
onDownloadClick = onDownloadClick,
189-
preview = uiState.videoPreview,
190-
progress = uiState.videoProgress,
191-
)
189+
if (sectionVideos.any { !it.isCompleted() } || uiState.isCompletedSectionsShown) {
190+
item {
191+
CourseVideoSection(
192+
block = section,
193+
videoBlocks = sectionVideos,
194+
downloadedStateMap = uiState.downloadedState,
195+
onVideoClick = onVideoClick,
196+
onDownloadClick = onDownloadClick,
197+
preview = uiState.videoPreview,
198+
progress = uiState.videoProgress,
199+
)
200+
}
192201
}
193202
}
194-
}
195203
}
196204
}
197205

course/src/main/res/values/strings.xml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,6 @@
3333
<string name="course_progress_assignment_type">Assignment Type</string>
3434
<string name="course_progress_current_max">Current / Max %</string>
3535

36-
<!-- Error Message when course dates are not available -->
37-
3836
<string name="course_container_nav_home">Home</string>
3937
<string name="course_container_nav_content">Content</string>
4038
<string name="course_container_nav_discussions">Discussions</string>
@@ -56,7 +54,7 @@
5654
<string name="course_accessibility_section_uncompleted">Section uncompleted</string>
5755
<string name="course_accessibility_video_watched">Video watched</string>
5856

59-
<plurals name="course_assignments_complete" tools:ignore="MissingTranslation">
57+
<plurals name="course_sections_complete" tools:ignore="MissingTranslation">
6058
<item quantity="one">%1$s/%2$s Section Completed</item>
6159
<item quantity="other">%1$s/%2$s Sections Completed</item>
6260
</plurals>
@@ -66,7 +64,7 @@
6664
<string name="course_error_not_started_title">This course will begin on %s. Come back then to start learning!</string>
6765
<string name="course_an_error_occurred">An error occurred while loading your course</string>
6866
<string name="course_continue">Continue</string>
69-
<string name="course_show_completed">Show Completed</string>
67+
<string name="course_view_completed">View Completed</string>
7068
<string name="course_hide_completed">Hide Completed</string>
7169
<string name="course_completed">Completed</string>
7270
<string name="progress_earned_possible_assignment_problems">%1$s / %2$s Complete</string>

0 commit comments

Comments
 (0)