Skip to content

Commit

Permalink
Merge pull request #103 from boostcampwm-2022/improve/createGroup
Browse files Browse the repository at this point in the history
๊ทธ๋ฃน ์ƒ์„ฑ ํŽ˜์ด์ง€ ๊ฐœ์„ 
  • Loading branch information
yonghanJu authored Mar 17, 2024
2 parents 551e271 + 9438d26 commit 96a10bb
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,9 @@ internal class CreateGroupFragment :
}
}
}
is Event.InvalidRule -> {
binding.root.makeSnackBar(getString(R.string.text_invalid_rule)).show()
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -42,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
Expand All @@ -56,8 +57,8 @@ class CreateGroupViewModel @Inject constructor(
}

val isDoubleCheckButtonEnable: StateFlow<Boolean>
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,
Expand Down Expand Up @@ -111,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)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
1 change: 1 addition & 0 deletions presentation/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -190,5 +190,6 @@
<string name="text_minute">๋ถ„</string>
<string name="text_confirm">ํ™•์ธ</string>
<string name="text_rule_picker_title">์š”์ผ ๋ฐ ์‹œ๊ฐ„์„ ๊ณจ๋ผ์ฃผ์„ธ์š”!!</string>
<string name="text_invalid_rule">์œ ํšจํ•˜์ง€ ์•Š์€ ๊ทœ์น™์ž…๋‹ˆ๋‹ค.</string>

</resources>

0 comments on commit 96a10bb

Please sign in to comment.