Skip to content
Open
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
42 changes: 42 additions & 0 deletions .maestro/flows/002_browse_lessons_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,47 @@ onFlowComplete:
timeout: 1000
- assertVisible: "Hello World Lesson"
- tapOn: "Close"
- tapOn: "Download"
- extendedWaitUntil:
visible: "Cancel"
timeout: 1000
- extendedWaitUntil:
visible: "Downloaded"
timeout: 1000
- tapOn: "My app"
- assertVisible: "Lessons"
- tapOn: "Lessons"
- tapOn: "Grade 2"
- tapOn: "Lesson 002"
- assertVisible: "Lesson 002"
- tapOn: "Download"
- extendedWaitUntil:
visible: "Cancel"
timeout: 1000
- extendedWaitUntil:
visible: "Downloaded"
timeout: 1000
- setAirplaneMode: enabled
- tapOn: "Apps"
- tapOn:
id: "downloaded_icon"
- assertVisible:
id: "app_title"
text: "Downloaded lessons"
- assertVisible: "Sort by"
- assertVisible: "Lesson 001"
- assertVisible: "Lesson 002"
- tapOn: "Lesson 002"
- assertVisible: "Open"
- assertVisible: "Downloaded"
- tapOn: "Open"
- assertVisible: "content visible"
- tapOn: "Close"
- back
- tapOn:
id: "delete_icon"
- assertVisible: "1 deleted"
- tapOn: "Undo"
- assertVisible: "Lesson 001"


Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,16 @@ import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.platform.testTag
import kotlin.Boolean
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.automirrored.filled.LibraryBooks
import androidx.compose.material.icons.filled.Add
import androidx.compose.material.icons.filled.Edit
import androidx.compose.material.icons.filled.GridView
import androidx.compose.material.icons.filled.ImportContacts
import androidx.compose.material.icons.filled.Person
import androidx.compose.material3.Icon
import androidx.compose.material3.ExtendedFloatingActionButton
import androidx.compose.material3.SnackbarDuration
import androidx.compose.material3.SnackbarResult
import androidx.compose.runtime.collectAsState
import androidx.compose.runtime.rememberCoroutineScope
import androidx.navigation.compose.rememberNavController
Expand Down Expand Up @@ -177,17 +187,30 @@ fun App(
val koin = getKoin()

LaunchedEffect(Unit) {
koin.get<SnackBarFlowDispatcher>().snackFlow.collectLatest {
val uiText = it.message
val message = if(uiText is StringUiText) {
uiText.text
}else if(uiText is StringResourceUiText) {
getString(uiText.resource)
}else {
""
koin.get<SnackBarFlowDispatcher>().snackFlow.collectLatest { snack ->
val uiText = snack.message
val message = when (uiText) {
is StringUiText -> uiText.text
is StringResourceUiText -> getString(uiText.resource)
else -> ""
}
val actionLabel = snack.action?.let { actionUiText ->
when (actionUiText) {
is StringUiText -> actionUiText.text
is StringResourceUiText -> getString(actionUiText.resource)
else -> null
}
}

snackbarHostState.showSnackbar(message, it.action)
val result = snackbarHostState.showSnackbar(
message = message,
actionLabel = actionLabel,
duration = SnackbarDuration.Short
)

if (result == SnackbarResult.ActionPerformed) {
snack.onAction?.invoke()
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import androidx.compose.foundation.layout.width
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.automirrored.outlined.ArrowBack
import androidx.compose.material.icons.filled.Close
import androidx.compose.material.icons.filled.Download
import androidx.compose.material.icons.filled.MoreVert
import androidx.compose.material.icons.filled.Search
import androidx.compose.material.icons.filled.Settings
Expand Down Expand Up @@ -54,6 +55,7 @@ import world.respect.shared.generated.resources.search
import world.respect.shared.generated.resources.settings
import world.respect.shared.util.ext.fullName
import world.respect.datalayer.db.school.ext.fullName
import world.respect.shared.generated.resources.downloaded_lessons
import world.respect.shared.generated.resources.more_options
import world.respect.shared.util.ext.isLoading
import world.respect.shared.viewmodel.app.appstate.AppActionButton
Expand Down Expand Up @@ -209,6 +211,17 @@ fun RespectAppBar(
)
}
}
if (appUiState.downloadIconVisible == true) {
IconButton(
onClick = appUiState.onClickDownload ?: {},
modifier = Modifier.testTag("download_icon")
) {
Icon(
Icons.Default.Download,
contentDescription = stringResource(Res.string.downloaded_lessons)
)
}
}

if (appUiState.settingsIconVisible == true) {
IconButton(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,17 +63,18 @@ fun AppLauncherScreen(

AppLauncherScreen(
uiState = uiState,
onClickApp = { viewModel.onClickApp(it) },
onClickRemove = { viewModel.onClickRemove(it) },
onClickApp = viewModel::onClickApp,
onClickRemove = viewModel::onClickRemove,
onClickDownload = viewModel::onClickDownloads
)
}


@Composable
fun AppLauncherScreen(
uiState: AppLauncherUiState,
onClickApp: (DataLoadState<RespectAppManifest>) -> Unit,
onClickRemove: (DataLoadState<RespectAppManifest>) -> Unit,
onClickDownload: () -> Unit
) {
val pager = respectRememberPager(uiState.apps)
val lazyPagingItems = pager.flow.collectAsLazyPagingItems()
Expand Down Expand Up @@ -115,7 +116,6 @@ fun AppLauncherScreen(
verticalArrangement = Arrangement.spacedBy(12.dp),
horizontalArrangement = Arrangement.spacedBy(12.dp)
) {

items(
count = lazyPagingItems.itemCount,
key = { index ->
Expand Down Expand Up @@ -233,4 +233,4 @@ fun AppGridItem(
Text(text = "-")
}
}
}
}
Loading