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 @@ -4,6 +4,8 @@ import androidx.compose.ui.test.assertIsDisplayed
import androidx.compose.ui.test.junit4.createComposeRule
import androidx.compose.ui.test.onNodeWithTag
import androidx.test.ext.junit.runners.AndroidJUnit4
import com.instructure.canvasapi2.models.CanvasContext
import com.instructure.pandautils.features.dashboard.notifications.DashboardRouter
import com.instructure.student.features.dashboard.compose.DashboardScreenContent
import com.instructure.student.features.dashboard.compose.DashboardUiState
import kotlinx.coroutines.flow.MutableSharedFlow
Expand All @@ -17,6 +19,13 @@ class DashboardScreenTest {
@get:Rule
val composeTestRule = createComposeRule()

private val mockRouter = object : DashboardRouter {
override fun routeToGlobalAnnouncement(subject: String, message: String) {}
override fun routeToSubmissionDetails(canvasContext: CanvasContext, assignmentId: Long, attemptId: Long) {}
override fun routeToMyFiles(canvasContext: CanvasContext, folderId: Long) {}
override fun routeToSyncProgress() {}
}

@Test
fun testDashboardScreenShowsLoadingState() {
val mockUiState = DashboardUiState(
Expand All @@ -32,7 +41,8 @@ class DashboardScreenTest {
uiState = mockUiState,
refreshSignal = MutableSharedFlow(),
snackbarMessageFlow = MutableSharedFlow(),
onShowSnackbar = { _, _, _ -> }
onShowSnackbar = { _, _, _ -> },
router = mockRouter
)
}

Expand All @@ -55,7 +65,8 @@ class DashboardScreenTest {
uiState = mockUiState,
refreshSignal = MutableSharedFlow(),
snackbarMessageFlow = MutableSharedFlow(),
onShowSnackbar = { _, _, _ -> }
onShowSnackbar = { _, _, _ -> },
router = mockRouter
)
}

Expand All @@ -78,7 +89,8 @@ class DashboardScreenTest {
uiState = mockUiState,
refreshSignal = MutableSharedFlow(),
snackbarMessageFlow = MutableSharedFlow(),
onShowSnackbar = { _, _, _ -> }
onShowSnackbar = { _, _, _ -> },
router = mockRouter
)
}

Expand All @@ -101,7 +113,8 @@ class DashboardScreenTest {
uiState = mockUiState,
refreshSignal = MutableSharedFlow(),
snackbarMessageFlow = MutableSharedFlow(),
onShowSnackbar = { _, _, _ -> }
onShowSnackbar = { _, _, _ -> },
router = mockRouter
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,17 @@ import androidx.compose.ui.platform.ComposeView
import com.instructure.canvasapi2.models.CanvasContext
import com.instructure.interactions.router.Route
import com.instructure.pandautils.compose.CanvasTheme
import com.instructure.pandautils.features.dashboard.notifications.DashboardRouter
import com.instructure.student.fragment.ParentFragment
import dagger.hilt.android.AndroidEntryPoint
import javax.inject.Inject

@AndroidEntryPoint
class DashboardFragment : ParentFragment() {

@Inject
lateinit var router: DashboardRouter

override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
Expand All @@ -39,7 +44,7 @@ class DashboardFragment : ParentFragment() {
return ComposeView(requireContext()).apply {
setContent {
CanvasTheme {
DashboardScreen()
DashboardScreen(router = router)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,23 +56,26 @@ import com.instructure.pandautils.compose.composables.CanvasThemedAppBar
import com.instructure.pandautils.compose.composables.EmptyContent
import com.instructure.pandautils.compose.composables.ErrorContent
import com.instructure.pandautils.compose.composables.Loading
import com.instructure.pandautils.features.dashboard.notifications.DashboardRouter
import com.instructure.pandautils.features.dashboard.widget.WidgetMetadata
import com.instructure.pandautils.features.dashboard.widget.courseinvitation.CourseInvitationsWidget
import com.instructure.pandautils.features.dashboard.widget.institutionalannouncements.InstitutionalAnnouncementsWidget
import com.instructure.student.R
import com.instructure.student.activity.NavigationActivity
import com.instructure.student.features.dashboard.widget.welcome.WelcomeWidget
import kotlinx.coroutines.flow.SharedFlow

@Composable
fun DashboardScreen() {
fun DashboardScreen(router: DashboardRouter) {
val viewModel: DashboardViewModel = hiltViewModel()
val uiState by viewModel.uiState.collectAsState()

DashboardScreenContent(
uiState = uiState,
refreshSignal = viewModel.refreshSignal,
snackbarMessageFlow = viewModel.snackbarMessage,
onShowSnackbar = viewModel::showSnackbar
onShowSnackbar = viewModel::showSnackbar,
router = router
)
}

Expand All @@ -82,7 +85,8 @@ fun DashboardScreenContent(
uiState: DashboardUiState,
refreshSignal: SharedFlow<Unit>,
snackbarMessageFlow: SharedFlow<SnackbarMessage>,
onShowSnackbar: (String, String?, (() -> Unit)?) -> Unit
onShowSnackbar: (String, String?, (() -> Unit)?) -> Unit,
router: DashboardRouter
) {
val activity = LocalActivity.current
val pullRefreshState = rememberPullRefreshState(
Expand Down Expand Up @@ -158,6 +162,7 @@ fun DashboardScreenContent(
widgets = uiState.widgets,
refreshSignal = refreshSignal,
onShowSnackbar = onShowSnackbar,
router = router,
modifier = Modifier.fillMaxSize()
)
}
Expand All @@ -180,6 +185,7 @@ private fun WidgetGrid(
widgets: List<WidgetMetadata>,
refreshSignal: SharedFlow<Unit>,
onShowSnackbar: (String, String?, (() -> Unit)?) -> Unit,
router: DashboardRouter,
modifier: Modifier = Modifier
) {
val activity = LocalActivity.current ?: return
Expand Down Expand Up @@ -209,7 +215,7 @@ private fun WidgetGrid(
}
}
) { metadata ->
GetWidgetComposable(metadata.id, refreshSignal, columns, onShowSnackbar)
GetWidgetComposable(metadata.id, refreshSignal, columns, onShowSnackbar, router)
}
}
}
Expand All @@ -219,7 +225,8 @@ private fun GetWidgetComposable(
widgetId: String,
refreshSignal: SharedFlow<Unit>,
columns: Int,
onShowSnackbar: (String, String?, (() -> Unit)?) -> Unit
onShowSnackbar: (String, String?, (() -> Unit)?) -> Unit,
router: DashboardRouter
) {
return when (widgetId) {
WidgetMetadata.WIDGET_ID_WELCOME -> WelcomeWidget(refreshSignal = refreshSignal)
Expand All @@ -228,6 +235,11 @@ private fun GetWidgetComposable(
columns = columns,
onShowSnackbar = onShowSnackbar
)
WidgetMetadata.WIDGET_ID_INSTITUTIONAL_ANNOUNCEMENTS -> InstitutionalAnnouncementsWidget(
refreshSignal = refreshSignal,
columns = columns,
onAnnouncementClick = router::routeToGlobalAnnouncement
)
else -> {}
}
}
35 changes: 35 additions & 0 deletions libs/pandares/src/main/res/drawable/ic_calendar_solid.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="16dp"
android:height="16dp"
android:viewportWidth="13.333"
android:viewportHeight="13.333">
<path
android:pathData="M5.267,7.607V8.019H4.867V7.607H5.267Z"
android:fillColor="#2B7ABC"/>
<path
android:pathData="M6.867,7.607V8.019H6.467V7.607H6.867Z"
android:fillColor="#2B7ABC"/>
<path
android:pathData="M8.467,7.607V8.019H8.067V7.607H8.467Z"
android:fillColor="#2B7ABC"/>
<path
android:pathData="M5.267,5.96V6.372H4.867V5.96H5.267Z"
android:fillColor="#2B7ABC"/>
<path
android:pathData="M6.867,5.96V6.372H6.467V5.96H6.867Z"
android:fillColor="#2B7ABC"/>
<path
android:pathData="M8.467,5.96V6.372H8.067V5.96H8.467Z"
android:fillColor="#2B7ABC"/>
<path
android:pathData="M9.267,4.725V9.254H4.067V4.725H9.267ZM4.467,8.431H5.667V7.195H4.467V8.431ZM6.067,8.431H7.267V7.195H6.067V8.431ZM7.667,8.431H8.867V7.195H7.667V8.431ZM4.467,6.783H5.667V5.549H4.467V6.783ZM6.067,6.783H7.267V5.549H6.067V6.783ZM7.667,6.783H8.867V5.549H7.667V6.783Z"
android:fillColor="#2B7ABC"
android:fillType="evenOdd"/>
<path
android:pathData="M4.867,3.695C4.867,3.809 4.957,3.901 5.067,3.901C5.178,3.901 5.267,3.809 5.267,3.695V3.489H8.067V3.695C8.067,3.809 8.156,3.901 8.267,3.901C8.377,3.901 8.467,3.809 8.467,3.695V3.489H9.067C9.177,3.489 9.266,3.582 9.267,3.695V4.313H4.067V3.695C4.067,3.582 4.157,3.489 4.267,3.489H4.867V3.695Z"
android:fillColor="#2B7ABC"/>
<path
android:pathData="M6.667,0C10.344,0 13.333,2.991 13.333,6.667C13.333,10.343 10.344,13.333 6.667,13.333C2.991,13.333 0,10.343 0,6.667C0,2.991 2.991,0 6.667,0ZM8.267,2.666C8.156,2.666 8.067,2.759 8.067,2.872V3.078H5.267V2.872C5.267,2.759 5.178,2.666 5.067,2.666C4.957,2.666 4.867,2.758 4.867,2.872V3.078H4.267C3.936,3.078 3.667,3.355 3.667,3.695V9.666H9.667V3.695C9.667,3.355 9.398,3.078 9.067,3.078H8.467V2.872C8.467,2.758 8.377,2.666 8.267,2.666Z"
android:fillColor="#2B7ABC"
android:fillType="evenOdd"/>
</vector>
10 changes: 10 additions & 0 deletions libs/pandares/src/main/res/drawable/ic_question_solid.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="16dp"
android:height="16dp"
android:viewportWidth="13.333"
android:viewportHeight="13.333">
<path
android:pathData="M8.693,5.901C8.377,6.437 7.852,6.831 7.252,6.985C7.156,7.01 7.059,7.088 7.059,7.207V7.843H6.275V7.207C6.275,6.747 6.596,6.344 7.057,6.226C7.457,6.123 7.807,5.86 8.018,5.503C8.232,5.14 8.29,4.707 8.18,4.282C8.044,3.756 7.616,3.329 7.091,3.192C6.598,3.066 6.095,3.165 5.707,3.465C5.32,3.765 5.098,4.217 5.098,4.706H4.314C4.314,3.973 4.646,3.294 5.227,2.845C5.808,2.394 6.558,2.245 7.287,2.433C8.085,2.639 8.733,3.288 8.94,4.085C9.102,4.714 9.014,5.358 8.693,5.901ZM6.667,10.196C6.235,10.196 5.882,9.844 5.882,9.412C5.882,8.98 6.235,8.627 6.667,8.627C7.099,8.627 7.451,8.98 7.451,9.412C7.451,9.844 7.099,10.196 6.667,10.196ZM6.667,0C2.991,0 0,2.991 0,6.667C0,10.343 2.991,13.333 6.667,13.333C10.344,13.333 13.333,10.343 13.333,6.667C13.333,2.991 10.344,0 6.667,0Z"
android:fillColor="#2B7ABC"
android:fillType="evenOdd"/>
</vector>
10 changes: 10 additions & 0 deletions libs/pandares/src/main/res/drawable/ic_warning_solid.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="14dp"
android:height="14dp"
android:viewportWidth="14"
android:viewportHeight="14">
<path
android:pathData="M6.667,13.333C10.349,13.333 13.333,10.349 13.333,6.667C13.333,2.985 10.349,0 6.667,0C2.985,0 0,2.985 0,6.667C0,10.349 2.985,13.333 6.667,13.333ZM6.598,9.324C6.012,9.324 5.535,9.801 5.535,10.388C5.535,10.975 6.012,11.452 6.598,11.452C7.185,11.452 7.662,10.975 7.662,10.388C7.662,9.801 7.185,9.324 6.598,9.324ZM8.012,2.222H5.185L5.873,8.463H7.323L8.012,2.222Z"
android:fillColor="#CF4A00"
android:fillType="evenOdd"/>
</vector>
3 changes: 3 additions & 0 deletions libs/pandares/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2229,4 +2229,7 @@
<string name="courseInvitationDeclined">Invitation to %s declined</string>
<string name="courseInvitationDeclineConfirmTitle">Decline Invitation</string>
<string name="courseInvitationDeclineConfirmMessage">Are you sure you want to decline the invitation to %s?</string>

<!-- Institutional Announcements -->
<string name="institutionalAnnouncementsTitle">Announcements (%d)</string>
</resources>
Loading
Loading