Skip to content

Commit

Permalink
feat: display no jobs message on worker home screen
Browse files Browse the repository at this point in the history
This commit introduces a "No Jobs Message" component to be displayed on the worker home screen when no jobs
 are available.

- Added a new composable function `NoJobsMessage` to display an informative message when no jobs are found.
- Updated the `WorkerHomeScreenUiState` to include an error message field.
- Modified the worker home screen to display the `NoJobsMessage` component when the list of
 jobs is empty.
  • Loading branch information
OkelloSam21 committed Aug 4, 2024
1 parent ae027a0 commit 955e382
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 12 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
package com.samuelokello.kazihub.presentation.common.components

import androidx.annotation.StringRes
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Info
import androidx.compose.material3.Icon
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.unit.dp

@Composable
fun NoJobsMessage(@StringRes message: Int) {
Column(
modifier =
Modifier
.padding(8.dp),
horizontalAlignment = Alignment.CenterHorizontally,
verticalArrangement = Arrangement.Center,
) {
Icon(
imageVector = Icons.Default.Info,
contentDescription = null,
modifier = Modifier.size(64.dp),
tint = Color.Gray,
)
Spacer(modifier = Modifier.height(16.dp))
Text(
text = "No jobs posted yet",
style = MaterialTheme.typography.bodyLarge,
color = Color.Gray,
)
Spacer(modifier = Modifier.height(8.dp))
Text(
text = stringResource(message),
style = MaterialTheme.typography.bodyLarge,
color = Color.Gray,
textAlign = TextAlign.Center,
)

Spacer(modifier = Modifier.height(32.dp))
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,8 @@ data class WorkerHomeScreenUiState(
val drawerState: DrawerValue = DrawerValue.Closed,
val isSearchBarActive: Boolean = false,
val selectedItemIndex: Int = 0,
val allJobs: List<Job?> = emptyList(),

// Recent Jobs
val recentJobs: List<Job> = emptyList(),
val nearByJobs: List<Job?> = emptyList()

val allData: List<data?> = emptyList(),
val error: String = "",
val recentJobs: List<data> = emptyList(),
val nearByJobs: List<data?> = emptyList(),
)
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
package com.samuelokello.kazihub.presentation.worker.state

import com.samuelokello.kazihub.domain.model.job.Job
import com.samuelokello.kazihub.domain.model.job.data

sealed interface WorkerHomeScreenUiEvent {
data object OpenDrawer : WorkerHomeScreenUiEvent
data object OnSearchClick : WorkerHomeScreenUiEvent
data object OnPullToRefresh : WorkerHomeScreenUiEvent
data class NavigateToJobDetails(val jobId: Int) : WorkerHomeScreenUiEvent
data class SearchQueryChanged(val query: String) : WorkerHomeScreenUiEvent
data object OnViewAllClick : WorkerHomeScreenUiEvent
data object OnSHowAllClick : WorkerHomeScreenUiEvent
data class JobSelected(val job: Job) : WorkerHomeScreenUiEvent
data class JobSelected(val data: data) : WorkerHomeScreenUiEvent
}

0 comments on commit 955e382

Please sign in to comment.