Explorar o código

Fix text for empty task list

Signed-off-by: alperozturk <alper_ozturk@proton.me>
alperozturk hai 1 ano
pai
achega
f12657d420

+ 24 - 6
app/src/main/java/com/nextcloud/client/assistant/AsssistantScreen.kt

@@ -231,6 +231,15 @@ private fun AssistantContent(
 
 @Composable
 private fun EmptyTaskList(selectedTaskType: TaskType?, taskTypes: List<TaskType>?, viewModel: AssistantViewModel) {
+    val text = if (selectedTaskType?.name ==  stringResource(id = R.string.assistant_screen_all_task_type)) {
+        stringResource(id = R.string.assistant_screen_no_task_available_for_all_task_filter_text)
+    } else {
+        stringResource(
+            id = R.string.assistant_screen_no_task_available_text,
+            selectedTaskType?.name ?: ""
+        )
+    }
+
     Column(
         modifier = Modifier
             .fillMaxSize()
@@ -242,12 +251,7 @@ private fun EmptyTaskList(selectedTaskType: TaskType?, taskTypes: List<TaskType>
 
         Spacer(modifier = Modifier.height(8.dp))
 
-        CenterText(
-            text = stringResource(
-                id = R.string.assistant_screen_no_task_available_text,
-                selectedTaskType?.name ?: ""
-            )
-        )
+        CenterText(text = text)
     }
 }
 
@@ -264,3 +268,17 @@ private fun AssistantScreenPreview() {
         }
     )
 }
+
+@Composable
+@Preview
+private fun AssistantEmptyScreenPreview() {
+    val mockRepository = AssistantMockRepository(giveEmptyTasks = true)
+    MaterialTheme(
+        content = {
+            AssistantScreen(
+                viewModel = AssistantViewModel(repository = mockRepository),
+                activity = ComposeActivity()
+            )
+        }
+    )
+}

+ 9 - 3
app/src/main/java/com/nextcloud/client/assistant/repository/AssistantMockRepository.kt

@@ -27,7 +27,7 @@ import com.owncloud.android.lib.resources.assistant.model.TaskList
 import com.owncloud.android.lib.resources.assistant.model.TaskType
 import com.owncloud.android.lib.resources.assistant.model.TaskTypes
 
-class AssistantMockRepository : AssistantRepositoryType {
+class AssistantMockRepository(private val giveEmptyTasks: Boolean = false) : AssistantRepositoryType {
     override fun getTaskTypes(): RemoteOperationResult<TaskTypes> {
         return RemoteOperationResult<TaskTypes>(RemoteOperationResult.ResultCode.OK).apply {
             resultData = TaskTypes(
@@ -44,8 +44,10 @@ class AssistantMockRepository : AssistantRepositoryType {
     }
 
     override fun getTaskList(appId: String): RemoteOperationResult<TaskList> {
-        return RemoteOperationResult<TaskList>(RemoteOperationResult.ResultCode.OK).apply {
-            resultData = TaskList(
+        val taskList = if (giveEmptyTasks) {
+            TaskList(listOf())
+        } else {
+            TaskList(
                 listOf(
                     Task(
                         1,
@@ -79,6 +81,10 @@ class AssistantMockRepository : AssistantRepositoryType {
                 )
             )
         }
+
+        return RemoteOperationResult<TaskList>(RemoteOperationResult.ResultCode.OK).apply {
+            resultData = taskList
+        }
     }
 
     override fun deleteTask(id: Long): RemoteOperationResult<Void> {

+ 1 - 0
app/src/main/res/values/strings.xml

@@ -20,6 +20,7 @@
 
     <string name="assistant_screen_top_bar_title">Assistant</string>
     <string name="assistant_screen_loading">Task List are loading, please wait</string>
+    <string name="assistant_screen_no_task_available_for_all_task_filter_text">No task available. Select a task type to create a new task.</string>
     <string name="assistant_screen_no_task_available_text">No task available for %s task type, you can create a new task from bottom right.</string>
     <string name="assistant_screen_delete_task_alert_dialog_title">Delete Task</string>
     <string name="assistant_screen_delete_task_alert_dialog_description">Are you sure you want to delete this task?</string>