From 675a5b023a4e9c97e9364a64854401a00b846497 Mon Sep 17 00:00:00 2001 From: soopeach Date: Sat, 17 Dec 2022 23:16:54 +0900 Subject: [PATCH 1/2] =?UTF-8?q?:sparkles:=20=EA=B7=B8=EB=A3=B9=20=EC=9D=B4?= =?UTF-8?q?=EB=A6=84=20=EC=A4=91=EB=B3=B5=ED=99=95=EC=9D=B8=20=ED=9B=84=20?= =?UTF-8?q?=EB=B2=84=ED=8A=BC=EC=9D=84=20=EB=B9=84=ED=99=9C=EC=84=B1?= =?UTF-8?q?=ED=99=94=ED=95=98=EB=8F=84=EB=A1=9D=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../community/group/create/CreateGroupViewModel.kt | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/presentation/src/main/java/com/whyranoid/presentation/community/group/create/CreateGroupViewModel.kt b/presentation/src/main/java/com/whyranoid/presentation/community/group/create/CreateGroupViewModel.kt index 3ebf4a4..460fbc0 100644 --- a/presentation/src/main/java/com/whyranoid/presentation/community/group/create/CreateGroupViewModel.kt +++ b/presentation/src/main/java/com/whyranoid/presentation/community/group/create/CreateGroupViewModel.kt @@ -12,7 +12,6 @@ import kotlinx.coroutines.flow.SharingStarted import kotlinx.coroutines.flow.StateFlow import kotlinx.coroutines.flow.asStateFlow import kotlinx.coroutines.flow.combine -import kotlinx.coroutines.flow.map import kotlinx.coroutines.flow.stateIn import kotlinx.coroutines.launch import javax.inject.Inject @@ -56,8 +55,8 @@ class CreateGroupViewModel @Inject constructor( } val isDoubleCheckButtonEnable: StateFlow - get() = groupName.map { name -> - name?.trim()?.isNotEmpty() ?: false + get() = groupName.combine(isNotDuplicate) { name, isNotDuplicated -> + name?.trim()?.isNotEmpty() ?: false && isNotDuplicated.not() }.stateIn( scope = viewModelScope, initialValue = false, From 9438d26fffe35acbe6d109bd86aff5bedb1cef62 Mon Sep 17 00:00:00 2001 From: soopeach Date: Sat, 17 Dec 2022 23:24:02 +0900 Subject: [PATCH 2/2] =?UTF-8?q?:sparkles:=20=EC=9C=A0=ED=9A=A8=ED=95=98?= =?UTF-8?q?=EC=A7=80=20=EC=95=8A=EC=9D=80=20=EA=B7=9C=EC=B9=99=EC=9D=84=20?= =?UTF-8?q?=EC=83=9D=EC=84=B1=20=EC=8B=9C=20=EC=8A=A4=EB=82=B5=EB=B0=94?= =?UTF-8?q?=EB=A1=9C=20=EC=95=8C=EB=A6=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../community/group/create/CreateGroupFragment.kt | 3 +++ .../community/group/create/CreateGroupViewModel.kt | 9 +++++---- .../presentation/community/group/create/Event.kt | 1 + presentation/src/main/res/values/strings.xml | 1 + 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/presentation/src/main/java/com/whyranoid/presentation/community/group/create/CreateGroupFragment.kt b/presentation/src/main/java/com/whyranoid/presentation/community/group/create/CreateGroupFragment.kt index dd25dc2..cd6e374 100644 --- a/presentation/src/main/java/com/whyranoid/presentation/community/group/create/CreateGroupFragment.kt +++ b/presentation/src/main/java/com/whyranoid/presentation/community/group/create/CreateGroupFragment.kt @@ -110,6 +110,9 @@ internal class CreateGroupFragment : } } } + is Event.InvalidRule -> { + binding.root.makeSnackBar(getString(R.string.text_invalid_rule)).show() + } } } diff --git a/presentation/src/main/java/com/whyranoid/presentation/community/group/create/CreateGroupViewModel.kt b/presentation/src/main/java/com/whyranoid/presentation/community/group/create/CreateGroupViewModel.kt index 460fbc0..2cd2201 100644 --- a/presentation/src/main/java/com/whyranoid/presentation/community/group/create/CreateGroupViewModel.kt +++ b/presentation/src/main/java/com/whyranoid/presentation/community/group/create/CreateGroupViewModel.kt @@ -41,6 +41,8 @@ class CreateGroupViewModel @Inject constructor( fun onDialogConfirm(date: String, hour: String, minute: String) { if (date.isNotEmpty() && hour.isNotEmpty() && minute.isNotEmpty()) { rules.value = rules.value + listOf("$date-$hour-$minute") + } else { + emitEvent(Event.InvalidRule) } _showDialog.value = false @@ -110,10 +112,9 @@ class CreateGroupViewModel @Inject constructor( _eventFlow.emit(event) } } - is Event.WarningButtonClick -> { - _eventFlow.emit(event) - } - is Event.AddRuleButtonClick -> { + is Event.WarningButtonClick, + is Event.AddRuleButtonClick, + is Event.InvalidRule -> { _eventFlow.emit(event) } } diff --git a/presentation/src/main/java/com/whyranoid/presentation/community/group/create/Event.kt b/presentation/src/main/java/com/whyranoid/presentation/community/group/create/Event.kt index a5fdf43..f4ec7f1 100644 --- a/presentation/src/main/java/com/whyranoid/presentation/community/group/create/Event.kt +++ b/presentation/src/main/java/com/whyranoid/presentation/community/group/create/Event.kt @@ -4,5 +4,6 @@ sealed class Event { data class CreateGroupButtonClick(val isSuccess: Boolean = true) : Event() object WarningButtonClick : Event() object AddRuleButtonClick : Event() + object InvalidRule : Event() data class DuplicateCheckButtonClick(val isDuplicatedGroupName: Boolean = false) : Event() } diff --git a/presentation/src/main/res/values/strings.xml b/presentation/src/main/res/values/strings.xml index 049957d..63fc787 100644 --- a/presentation/src/main/res/values/strings.xml +++ b/presentation/src/main/res/values/strings.xml @@ -190,5 +190,6 @@ 확인 요일 및 시간을 골라주세요!! + 유효하지 않은 규칙입니다. \ No newline at end of file