Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ import androidx.compose.foundation.layout.widthIn
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.items
import androidx.compose.foundation.lazy.rememberLazyListState
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.foundation.verticalScroll
import androidx.compose.material.CircularProgressIndicator
import androidx.compose.material.Divider
import androidx.compose.material.ExperimentalMaterialApi
Expand All @@ -35,6 +37,7 @@ import androidx.compose.material.Surface
import androidx.compose.material.Text
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.automirrored.filled.ArrowForward
import androidx.compose.material.icons.filled.AccessTime
import androidx.compose.material.pullrefresh.PullRefreshIndicator
import androidx.compose.material.pullrefresh.pullRefresh
import androidx.compose.material.pullrefresh.rememberPullRefreshState
Expand Down Expand Up @@ -305,7 +308,7 @@ internal fun DashboardListView(
is DashboardUIState.Empty -> {
Box(
modifier = Modifier.fillMaxSize(),
contentAlignment = Alignment.Center
contentAlignment = Alignment.Center,
) {
Column(
Modifier
Expand Down Expand Up @@ -475,13 +478,18 @@ private fun CourseItem(

@Composable
private fun EmptyState() {
Box(
modifier = Modifier.fillMaxSize(),
contentAlignment = Alignment.Center
Column(
modifier = Modifier
.fillMaxSize()
.verticalScroll(rememberScrollState()),
horizontalAlignment = Alignment.CenterHorizontally,
) {
Column(
Modifier.width(185.dp),
horizontalAlignment = Alignment.CenterHorizontally
Modifier
.fillMaxSize()
.weight(1f),
horizontalAlignment = Alignment.CenterHorizontally,
verticalArrangement = Arrangement.Center,
) {
Icon(
painter = painterResource(id = R.drawable.dashboard_ic_empty),
Expand All @@ -499,6 +507,13 @@ private fun EmptyState() {
textAlign = TextAlign.Center
)
}
Text(
modifier = Modifier.fillMaxWidth(),
text = stringResource(id = R.string.dashboard_pull_to_refresh),
color = MaterialTheme.appColors.textSecondary,
style = MaterialTheme.appTypography.labelSmall,
textAlign = TextAlign.Center
)
}
}

Expand Down Expand Up @@ -577,6 +592,29 @@ private fun DashboardListViewTabletPreview() {
}
}


@Preview(uiMode = UI_MODE_NIGHT_NO)
@Preview(uiMode = UI_MODE_NIGHT_YES)
@Composable
private fun EmptyStatePreview() {
OpenEdXTheme {
DashboardListView(
windowSize = WindowSize(WindowType.Compact, WindowType.Compact),
apiHostUrl = "http://localhost:8000",
state = DashboardUIState.Empty,
uiMessage = null,
onSwipeRefresh = {},
onItemClick = {},
onReloadClick = {},
hasInternetConnection = true,
refreshing = false,
canLoadMore = false,
paginationCallback = {},
appUpgradeParameters = AppUpdateState.AppUpgradeParameters()
)
}
}

private val mockCourseAssignments = CourseAssignments(null, emptyList())
private val mockCourseEnrolled = EnrolledCourse(
auditAccessExpires = Date(),
Expand Down
1 change: 1 addition & 0 deletions dashboard/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
<string name="dashboard_all_courses_empty_description">You are not currently enrolled in any courses, would you like to explore the course catalog?</string>
<string name="dashboard_find_a_course">Find a Course</string>
<string name="dashboard_no_status_courses">No %1$s Courses</string>
<string name="dashboard_pull_to_refresh">Swipe down to refresh</string>

<plurals name="dashboard_past_due_assignment">
<item quantity="one">%1$d Past Due Assignment</item>
Expand Down