-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Change
Tag
to Chip
and create chip choose func
- Loading branch information
sungbin5304
committed
Jun 30, 2021
1 parent
a13af32
commit bbb2b6e
Showing
5 changed files
with
85 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
app/src/main/kotlin/team/bravepeople/devevent/ui/chip/ChipViewModel.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/* | ||
* DevEventAndroid ยฉ 2021 ์ฉ๊ฐํ ์น๊ตฌ๋ค. all rights reserved. | ||
* DevEventAndroid license is under the MIT. | ||
* | ||
* [ChipViewModel.kt] created by Ji Sungbin on 21. 6. 30. ์คํ 8:08. | ||
* | ||
* Please see: https://github.com/brave-people/Dev-Event-Android/blob/master/LICENSE. | ||
*/ | ||
|
||
package team.bravepeople.devevent.ui.chip | ||
|
||
import androidx.compose.runtime.State | ||
import androidx.compose.runtime.mutableStateListOf | ||
import androidx.compose.runtime.mutableStateOf | ||
import androidx.lifecycle.ViewModel | ||
|
||
class ChipViewModel private constructor() : ViewModel() { | ||
|
||
private val _selectedChip = mutableStateListOf<String>() | ||
val selectedChip: List<String> get() = _selectedChip | ||
|
||
fun toggleChipSelected(name: String) { | ||
if (_selectedChip.contains(name)) { | ||
_selectedChip.remove(name) | ||
} else { | ||
_selectedChip.add(name) | ||
} | ||
} | ||
|
||
fun isChipSelected(name: String): State<Boolean> { | ||
return mutableStateOf(_selectedChip.contains(name)) | ||
} | ||
|
||
companion object { | ||
val instance by lazy { ChipViewModel() } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters