Skip to content

Commit

Permalink
fix: Minor UI changes
Browse files Browse the repository at this point in the history
  • Loading branch information
PavloNetrebchuk committed May 10, 2024
1 parent b22bb30 commit 24dbbe4
Show file tree
Hide file tree
Showing 8 changed files with 94 additions and 64 deletions.
4 changes: 2 additions & 2 deletions core/src/main/java/org/openedx/core/utils/TimeUtils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ object TimeUtils {

private fun dateToCourseDate(resourceManager: ResourceManager, date: Date?): String {
return formatDate(
format = resourceManager.getString(R.string.core_date_format_MMMM_dd_yyyy), date = date
format = resourceManager.getString(R.string.core_date_format_MMM_dd_yyyy), date = date
)
}

Expand Down Expand Up @@ -152,7 +152,7 @@ object TimeUtils {
)
} else {
resourceManager.getString(
R.string.core_label_ending, dateToCourseDate(resourceManager, end)
R.string.core_label_ends, dateToCourseDate(resourceManager, end)
)
}
}
Expand Down
4 changes: 2 additions & 2 deletions core/src/main/res/values-uk/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<string name="core_select_value">Виберіть значення</string>
<string name="core_label_starting">Починається %1$s</string>
<string name="core_label_ended">Закінчився %1$s</string>
<string name="core_label_ending">Закінчується %1$s</string>
<string name="core_label_ends">Закінчується %1$s</string>
<string name="core_label_expires">Термін дії курсу закінчується %1$s</string>
<string name="core_label_expires_on">Термін дії курсу закінчується %1$s</string>
<string name="core_label_expired">Термін дії курсу минув %1$s</string>
Expand All @@ -31,7 +31,7 @@
<string name="core_user_not_active">Обліковий запис користувача не активовано. Будь ласка, спочатку активуйте свій обліковий запис.</string>
<string name="core_email_chooser_header">Надіслати електронний лист за допомогою ...</string>
<string name="core_email_client_not_present">Не встановлено жодного поштового клієнта</string>
<string name="core_date_format_MMMM_dd_yyyy">dd MMMM, yyyy</string>
<string name="core_date_format_MMM_dd_yyyy">dd MMMM, yyyy</string>
<string name="core_full_date_with_time">dd MMM yyyy HH:mm</string>
<string name="core_app_upgrade_title">Оновлення додатку</string>
<string name="core_app_upgrade_dialog_description">Ми рекомендуємо вам оновитись до останньої версії. Оновіться зараз, щоб отримати останні функції та виправлення.</string>
Expand Down
4 changes: 2 additions & 2 deletions core/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<string name="core_select_value">Select value</string>
<string name="core_label_starting">Starting %1$s</string>
<string name="core_label_ended">Ended %1$s</string>
<string name="core_label_ending">Ending %1$s</string>
<string name="core_label_ends">Ends %1$s</string>
<string name="core_label_expires">Course access expires %1$s</string>
<string name="core_label_expires_on">Course access expires on %1$s</string>
<string name="core_label_expired">Course access expired %1$s</string>
Expand Down Expand Up @@ -46,7 +46,7 @@
<string name="core_android_os_version" translatable="false">OS version: </string>
<string name="core_android_device_model" translatable="false">Device model: </string>
<string name="core_email_subject" translatable="false">Feedback</string>
<string name="core_date_format_MMMM_dd_yyyy">MMMM dd, yyyy</string>
<string name="core_date_format_MMM_dd_yyyy">MMM dd, yyyy</string>
<string name="core_full_date_with_time">dd MMM yyyy hh:mm aaa</string>
<string name="core_app_upgrade_title">App Update</string>
<string name="core_app_upgrade_dialog_description">We recommend that you update to the latest version. Upgrade now to receive the latest features and fixes.</string>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,21 +81,6 @@ class CourseUnitContainerViewModel(
private val _descendantsBlocks = MutableStateFlow<List<Block>>(listOf())
val descendantsBlocks = _descendantsBlocks.asStateFlow()

fun loadBlocks(mode: CourseViewMode) {
currentMode = mode
try {
val courseStructure = when (mode) {
CourseViewMode.FULL -> interactor.getCourseStructureFromCache()
CourseViewMode.VIDEOS -> interactor.getCourseStructureForVideos()
}
val blocks = courseStructure.blockData
courseName = courseStructure.name
this.blocks.clearAndAddAll(blocks)
} catch (e: Exception) {
//ignore e.printStackTrace()
}
}

init {
_indexInContainer.value = 0

Expand All @@ -113,6 +98,21 @@ class CourseUnitContainerViewModel(
}
}

fun loadBlocks(mode: CourseViewMode) {
currentMode = mode
try {
val courseStructure = when (mode) {
CourseViewMode.FULL -> interactor.getCourseStructureFromCache()
CourseViewMode.VIDEOS -> interactor.getCourseStructureForVideos()
}
val blocks = courseStructure.blockData
courseName = courseStructure.name
this.blocks.clearAndAddAll(blocks)
} catch (e: Exception) {
//ignore e.printStackTrace()
}
}

fun setupCurrentIndex(componentId: String = "") {
if (currentSectionIndex != -1) {
return
Expand Down
49 changes: 49 additions & 0 deletions dashboard/src/main/java/org/openedx/DashboardUI.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package org.openedx

import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.material.Icon
import androidx.compose.material.MaterialTheme
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Lock
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import org.openedx.core.ui.theme.OpenEdXTheme
import org.openedx.core.ui.theme.appColors

@Composable
fun Lock(modifier: Modifier = Modifier) {
Box(
modifier = modifier.fillMaxSize()
) {
Icon(
modifier = Modifier
.size(32.dp)
.padding(top = 8.dp, end = 8.dp)
.background(
color = MaterialTheme.appColors.onPrimary.copy(0.5f),
shape = CircleShape
)
.padding(4.dp)
.align(Alignment.TopEnd),
imageVector = Icons.Default.Lock,
contentDescription = null,
tint = MaterialTheme.appColors.onSurface
)
}
}

@Preview
@Composable
private fun LockPreview() {
OpenEdXTheme {
Lock()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import android.os.Bundle
import android.view.LayoutInflater
import android.view.ViewGroup
import androidx.compose.foundation.ExperimentalFoundationApi
import androidx.compose.foundation.background
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
Expand All @@ -22,7 +21,6 @@ import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.navigationBarsPadding
import androidx.compose.foundation.layout.offset
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.layout.widthIn
import androidx.compose.foundation.lazy.grid.GridCells
Expand All @@ -31,7 +29,6 @@ import androidx.compose.foundation.lazy.grid.items
import androidx.compose.foundation.lazy.grid.rememberLazyGridState
import androidx.compose.foundation.lazy.rememberLazyListState
import androidx.compose.foundation.pager.rememberPagerState
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.material.Card
import androidx.compose.material.CircularProgressIndicator
import androidx.compose.material.ExperimentalMaterialApi
Expand All @@ -43,7 +40,6 @@ import androidx.compose.material.Scaffold
import androidx.compose.material.Surface
import androidx.compose.material.Text
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Lock
import androidx.compose.material.icons.filled.Search
import androidx.compose.material.pullrefresh.PullRefreshIndicator
import androidx.compose.material.pullrefresh.pullRefresh
Expand All @@ -60,7 +56,6 @@ import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.ExperimentalComposeUiApi
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.platform.ComposeView
import androidx.compose.ui.platform.LocalContext
Expand All @@ -82,6 +77,7 @@ import androidx.fragment.app.FragmentManager
import coil.compose.AsyncImage
import coil.request.ImageRequest
import org.koin.androidx.compose.koinViewModel
import org.openedx.Lock
import org.openedx.core.UIMessage
import org.openedx.core.domain.model.Certificate
import org.openedx.core.domain.model.CourseAssignments
Expand Down Expand Up @@ -511,20 +507,7 @@ private fun CourseItem(
)
}
if (!course.course.coursewareAccess?.errorCode.isNullOrEmpty()) {
Icon(
modifier = Modifier
.size(32.dp)
.padding(top = 8.dp, end = 8.dp)
.background(
color = Color.White,
shape = CircleShape
)
.padding(4.dp)
.align(Alignment.TopEnd),
imageVector = Icons.Default.Lock,
contentDescription = null,
tint = MaterialTheme.appColors.textWarning
)
Lock()
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.openedx.courses.presentation

import androidx.lifecycle.viewModelScope
import kotlinx.coroutines.Job
import kotlinx.coroutines.flow.MutableSharedFlow
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.SharedFlow
Expand Down Expand Up @@ -60,6 +61,8 @@ class AllEnrolledCoursesViewModel(

private val currentFilter: MutableStateFlow<CourseStatusFilter> = MutableStateFlow(CourseStatusFilter.ALL)

private var job: Job? = null

init {
collectDiscoveryNotifier()
getCourses(currentFilter.value)
Expand Down Expand Up @@ -109,7 +112,8 @@ class AllEnrolledCoursesViewModel(
page = 1
currentFilter.value = courseStatusFilter
}
viewModelScope.launch {
job?.cancel()
job = viewModelScope.launch {
try {
isLoading = true
val response = if (networkConnection.isOnline() || page > 1) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import androidx.compose.foundation.lazy.grid.GridCells
import androidx.compose.foundation.lazy.grid.LazyHorizontalGrid
import androidx.compose.foundation.lazy.grid.items
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.foundation.verticalScroll
import androidx.compose.material.Card
import androidx.compose.material.CircularProgressIndicator
Expand All @@ -36,7 +35,6 @@ import androidx.compose.material.Text
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.automirrored.filled.ArrowForwardIos
import androidx.compose.material.icons.filled.ChevronRight
import androidx.compose.material.icons.filled.Lock
import androidx.compose.material.icons.filled.School
import androidx.compose.material.icons.filled.Warning
import androidx.compose.material.pullrefresh.PullRefreshIndicator
Expand All @@ -51,7 +49,6 @@ import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.painter.Painter
import androidx.compose.ui.graphics.vector.rememberVectorPainter
import androidx.compose.ui.layout.ContentScale
Expand All @@ -68,6 +65,7 @@ import androidx.fragment.app.FragmentManager
import coil.compose.AsyncImage
import coil.request.ImageRequest
import org.koin.androidx.compose.koinViewModel
import org.openedx.Lock
import org.openedx.core.UIMessage
import org.openedx.core.domain.model.Certificate
import org.openedx.core.domain.model.CourseAssignments
Expand Down Expand Up @@ -292,12 +290,14 @@ private fun UserCourses(
openCourse = openCourse
)
}
SecondaryCourses(
courses = userCourses.enrollments,
apiHostUrl = apiHostUrl,
onCourseClick = openCourse,
onViewAllClick = onViewAllClick
)
if (userCourses.enrollments.isNotEmpty()) {
SecondaryCourses(
courses = userCourses.enrollments,
apiHostUrl = apiHostUrl,
onCourseClick = openCourse,
onViewAllClick = onViewAllClick
)
}
}
}

Expand Down Expand Up @@ -437,20 +437,7 @@ private fun CourseListItem(
)
}
if (!course.course.coursewareAccess?.errorCode.isNullOrEmpty()) {
Icon(
modifier = Modifier
.size(32.dp)
.padding(top = 8.dp, end = 8.dp)
.background(
color = Color.White,
shape = CircleShape
)
.padding(4.dp)
.align(Alignment.TopEnd),
imageVector = Icons.Default.Lock,
contentDescription = null,
tint = MaterialTheme.appColors.textWarning
)
Lock()
}
}
}
Expand All @@ -477,6 +464,7 @@ private fun AssignmentItem(
contentDescription = null
)
Column(
modifier = Modifier.weight(1f),
verticalArrangement = Arrangement.spacedBy(4.dp)
) {
val infoTextStyle = if (title.isNullOrEmpty()) {
Expand All @@ -497,6 +485,12 @@ private fun AssignmentItem(
)
}
}
Icon(
modifier = Modifier.size(16.dp),
imageVector = Icons.AutoMirrored.Filled.ArrowForwardIos,
tint = MaterialTheme.appColors.textDark,
contentDescription = null
)
}
}

Expand Down

0 comments on commit 24dbbe4

Please sign in to comment.