diff --git a/frontend/app/src/main/java/com/example/speechbuddy/compose/symbolselection/SelectedSymbolsBox.kt b/frontend/app/src/main/java/com/example/speechbuddy/compose/symbolselection/SelectedSymbolsBox.kt index 19a0932f..07875c8c 100644 --- a/frontend/app/src/main/java/com/example/speechbuddy/compose/symbolselection/SelectedSymbolsBox.kt +++ b/frontend/app/src/main/java/com/example/speechbuddy/compose/symbolselection/SelectedSymbolsBox.kt @@ -34,6 +34,7 @@ import com.example.speechbuddy.ui.SpeechBuddyTheme @Composable fun SelectedSymbolsBox( selectedSymbols: List, + onClear: (Symbol) -> Unit, onClearAll: () -> Unit, modifier: Modifier = Modifier ) { @@ -59,7 +60,7 @@ fun SelectedSymbolsBox( horizontalArrangement = Arrangement.spacedBy(10.dp) ) { items(selectedSymbols) { symbol -> - SelectedSymbolUi(symbol = symbol, onClear = {}) + SelectedSymbolUi(symbol = symbol, onClear = { onClear(symbol) }) } } } @@ -78,7 +79,7 @@ fun SelectedSymbolsBox( shape = RoundedCornerShape(5.dp), colors = ButtonDefaults.buttonColors( containerColor = MaterialTheme.colorScheme.tertiary, - contentColor = MaterialTheme.colorScheme.onTertiary, + contentColor = MaterialTheme.colorScheme.onTertiary ), contentPadding = PaddingValues(2.dp) ) { @@ -106,6 +107,6 @@ fun SelectedSymbolsBoxPreview() { val selectedSymbols = List(size = 10, init = { previewSymbol }) SpeechBuddyTheme { - SelectedSymbolsBox(selectedSymbols = selectedSymbols, onClearAll = {}) + SelectedSymbolsBox(selectedSymbols = selectedSymbols, onClear = {}, onClearAll = {}) } } \ No newline at end of file diff --git a/frontend/app/src/main/java/com/example/speechbuddy/compose/symbolselection/SymbolSearchTextField.kt b/frontend/app/src/main/java/com/example/speechbuddy/compose/symbolselection/SymbolSearchTextField.kt index 62954fb8..288e14fb 100644 --- a/frontend/app/src/main/java/com/example/speechbuddy/compose/symbolselection/SymbolSearchTextField.kt +++ b/frontend/app/src/main/java/com/example/speechbuddy/compose/symbolselection/SymbolSearchTextField.kt @@ -57,7 +57,7 @@ fun SymbolSearchTextFieldPreview() { SpeechBuddyTheme { SymbolSearchTextField( value = "검색어", - onValueChange = {}, + onValueChange = {} ) } } \ No newline at end of file diff --git a/frontend/app/src/main/java/com/example/speechbuddy/compose/symbolselection/SymbolSelectionScreen.kt b/frontend/app/src/main/java/com/example/speechbuddy/compose/symbolselection/SymbolSelectionScreen.kt index 4e9bfdb8..a15b8603 100644 --- a/frontend/app/src/main/java/com/example/speechbuddy/compose/symbolselection/SymbolSelectionScreen.kt +++ b/frontend/app/src/main/java/com/example/speechbuddy/compose/symbolselection/SymbolSelectionScreen.kt @@ -32,18 +32,21 @@ fun SymbolSelectionScreen( Surface(modifier = modifier.fillMaxSize()) { Column( modifier = Modifier - .padding(start = 24.dp, top = 80.dp, end = 24.dp, bottom = 80.dp) + .padding(horizontal = 24.dp, vertical = 100.dp) .fillMaxSize(), verticalArrangement = Arrangement.spacedBy(20.dp) ) { /* TODO: ViewModel 연결 */ SymbolSearchTextField( value = viewModel.queryInput, - onValueChange = { viewModel.setQuery(it) }) + onValueChange = { viewModel.setQuery(it) } + ) SelectedSymbolsBox( selectedSymbols = viewModel.selectedSymbols, - onClearAll = { viewModel.clearAll() }) + onClear = { viewModel.clear(it) }, + onClearAll = { viewModel.clearAll() } + ) Box( modifier = Modifier @@ -64,11 +67,13 @@ fun SymbolSelectionScreen( is Symbol -> SymbolUi( symbol = entry, onSelect = { viewModel.selectSymbol(entry) }, - onFavoriteChange = {}) + onFavoriteChange = { viewModel.toggleFavorite(entry, it) } + ) is Category -> CategoryUi( category = entry, - onSelect = { viewModel.selectCategory(entry) }) + onSelect = { viewModel.selectCategory(entry) } + ) } } } diff --git a/frontend/app/src/main/java/com/example/speechbuddy/compose/utils/SymbolUi.kt b/frontend/app/src/main/java/com/example/speechbuddy/compose/utils/SymbolUi.kt index 5a6736dc..e6f1dbd7 100644 --- a/frontend/app/src/main/java/com/example/speechbuddy/compose/utils/SymbolUi.kt +++ b/frontend/app/src/main/java/com/example/speechbuddy/compose/utils/SymbolUi.kt @@ -49,7 +49,7 @@ fun SymbolUi( symbol: Symbol, modifier: Modifier = Modifier, onSelect: () -> Unit, - onFavoriteChange: () -> Unit + onFavoriteChange: (Boolean) -> Unit ) { Card( onClick = onSelect, @@ -62,7 +62,7 @@ fun SymbolUi( Box(contentAlignment = Alignment.TopEnd) { IconToggleButton( checked = symbol.isFavorite, - onCheckedChange = { onFavoriteChange() }, + onCheckedChange = onFavoriteChange, modifier = Modifier .size(24.dp) .padding(4.dp), diff --git a/frontend/app/src/main/java/com/example/speechbuddy/viewmodel/SymbolSelectionViewModel.kt b/frontend/app/src/main/java/com/example/speechbuddy/viewmodel/SymbolSelectionViewModel.kt index 757d2797..7554032d 100644 --- a/frontend/app/src/main/java/com/example/speechbuddy/viewmodel/SymbolSelectionViewModel.kt +++ b/frontend/app/src/main/java/com/example/speechbuddy/viewmodel/SymbolSelectionViewModel.kt @@ -70,6 +70,12 @@ class SymbolSelectionViewModel @Inject internal constructor() : ViewModel() { queryInput = input } + fun clear(symbol: Symbol) { + val mutableSelectedSymbols = selectedSymbols.toMutableList() + mutableSelectedSymbols.remove(symbol) + selectedSymbols = mutableSelectedSymbols.toList() + } + fun clearAll() { selectedSymbols = listOf() entries = initialEntries @@ -80,6 +86,10 @@ class SymbolSelectionViewModel @Inject internal constructor() : ViewModel() { entries = secondaryEntries } + fun toggleFavorite(symbol: Symbol, value: Boolean) { + /* TODO */ + } + fun selectCategory(category: Category) { /* TODO */ }