| 
					
				 | 
			
			
				@@ -1,22 +1,38 @@ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 package eu.kanade.presentation.category.components 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import androidx.compose.foundation.clickable 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import androidx.compose.foundation.layout.Column 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import androidx.compose.foundation.layout.Row 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import androidx.compose.foundation.layout.Spacer 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import androidx.compose.foundation.layout.fillMaxWidth 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import androidx.compose.foundation.layout.padding 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import androidx.compose.foundation.rememberScrollState 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import androidx.compose.foundation.verticalScroll 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import androidx.compose.material3.AlertDialog 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import androidx.compose.material3.Checkbox 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import androidx.compose.material3.MaterialTheme 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import androidx.compose.material3.OutlinedTextField 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import androidx.compose.material3.Text 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import androidx.compose.material3.TextButton 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import androidx.compose.material3.TriStateCheckbox 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import androidx.compose.runtime.Composable 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import androidx.compose.runtime.LaunchedEffect 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import androidx.compose.runtime.getValue 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import androidx.compose.runtime.mutableStateOf 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import androidx.compose.runtime.remember 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import androidx.compose.runtime.setValue 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import androidx.compose.ui.Alignment 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import androidx.compose.ui.Modifier 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import androidx.compose.ui.focus.FocusRequester 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import androidx.compose.ui.focus.focusRequester 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import androidx.compose.ui.res.stringResource 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import eu.kanade.core.preference.asToggleableState 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import eu.kanade.presentation.category.visualName 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import eu.kanade.tachiyomi.R 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import kotlinx.coroutines.delay 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import tachiyomi.core.preference.CheckboxState 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import tachiyomi.domain.category.model.Category 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import tachiyomi.presentation.core.components.material.padding 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import kotlin.time.Duration.Companion.seconds 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 @Composable 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -164,6 +180,111 @@ fun CategoryDeleteDialog( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     ) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-internal fun List<Category>.anyWithName(name: String): Boolean { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+@Composable 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+fun ChangeCategoryDialog( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    initialSelection: List<CheckboxState<Category>>, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    onDismissRequest: () -> Unit, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    onEditCategories: () -> Unit, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    onConfirm: (List<Long>, List<Long>) -> Unit, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    if (initialSelection.isEmpty()) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        AlertDialog( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            onDismissRequest = onDismissRequest, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            confirmButton = { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                tachiyomi.presentation.core.components.material.TextButton( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    onClick = { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        onDismissRequest() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        onEditCategories() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    }, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                ) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    Text(text = stringResource(R.string.action_edit_categories)) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            }, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            title = { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                Text(text = stringResource(R.string.action_move_category)) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            }, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            text = { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                Text(text = stringResource(R.string.information_empty_category_dialog)) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            }, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        ) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        return 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    var selection by remember { mutableStateOf(initialSelection) } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    AlertDialog( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        onDismissRequest = onDismissRequest, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        confirmButton = { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            Row { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                tachiyomi.presentation.core.components.material.TextButton(onClick = { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    onDismissRequest() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    onEditCategories() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                },) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    Text(text = stringResource(R.string.action_edit)) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                Spacer(modifier = Modifier.weight(1f)) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                tachiyomi.presentation.core.components.material.TextButton(onClick = onDismissRequest) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    Text(text = stringResource(R.string.action_cancel)) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                tachiyomi.presentation.core.components.material.TextButton( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    onClick = { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        onDismissRequest() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        onConfirm( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            selection.filter { it is CheckboxState.State.Checked || it is CheckboxState.TriState.Include }.map { it.value.id }, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            selection.filter { it is CheckboxState.State.None || it is CheckboxState.TriState.None }.map { it.value.id }, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        ) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    }, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                ) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    Text(text = stringResource(android.R.string.ok)) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        }, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        title = { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            Text(text = stringResource(R.string.action_move_category)) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        }, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        text = { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            Column( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                modifier = Modifier.verticalScroll(rememberScrollState()), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            ) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                selection.forEach { checkbox -> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    val onChange: (CheckboxState<Category>) -> Unit = { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        val index = selection.indexOf(it) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        if (index != -1) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            val mutableList = selection.toMutableList() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            mutableList[index] = it.next() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            selection = mutableList.toList() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    Row( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        modifier = Modifier 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            .fillMaxWidth() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            .clickable { onChange(checkbox) }, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        verticalAlignment = Alignment.CenterVertically, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    ) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        when (checkbox) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            is CheckboxState.TriState -> { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                TriStateCheckbox( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                    state = checkbox.asToggleableState(), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                    onClick = { onChange(checkbox) }, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                ) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            is CheckboxState.State -> { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                Checkbox( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                    checked = checkbox.isChecked, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                    onCheckedChange = { onChange(checkbox) }, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                ) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        Text( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            text = checkbox.value.visualName, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            modifier = Modifier.padding(horizontal = MaterialTheme.padding.medium), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        ) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        }, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    ) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+private fun List<Category>.anyWithName(name: String): Boolean { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     return any { name == it.name } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 } 
			 |