Skip to content

Commit

Permalink
Merge pull request #209 from GSM-MSG/refactor/#208_add_toast_funtion
Browse files Browse the repository at this point in the history
🔀 :: (#208) Toast 생성 함수 만들기
  • Loading branch information
diejdkll authored Jun 3, 2024
2 parents 37cc22e + 5c01cf2 commit 6c26ba7
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 11 deletions.
8 changes: 8 additions & 0 deletions core/ui/src/main/java/com/msg/ui/makeToast.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package com.msg.ui

import android.content.Context
import android.widget.Toast

fun makeToast(context: Context, message: String, duration: Int = Toast.LENGTH_SHORT) {
Toast.makeText(context, message, duration).show()
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.msg.certification

import android.widget.Toast
import androidx.activity.ComponentActivity
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Arrangement
Expand All @@ -23,6 +22,7 @@ import com.msg.design_system.component.button.BitgoeulButton
import com.msg.design_system.component.topbar.DetailSettingTopBar
import com.msg.design_system.theme.color.BitgoeulColor
import com.msg.ui.DevicePreviews
import com.msg.ui.makeToast
import com.msg.ui.util.toKoreanFormat
import java.time.LocalDate

Expand Down Expand Up @@ -99,9 +99,9 @@ internal fun AddCertificationScreen(
text = "자격증 등록",
onClicked = {
if (name.value.isBlank()) {
Toast.makeText(context, "자격증 이름을 입력해주세요", Toast.LENGTH_SHORT).show()
makeToast(context, "자격증 이름을 입력해주세요")
} else if (date.value == null) {
Toast.makeText(context, "취득일을 입력해주세요", Toast.LENGTH_SHORT).show()
makeToast(context, "취득일을 입력해주세요")
} else {
onAddClicked(name.value, date.value!!)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.bitgoeul.email

import android.util.Log
import android.widget.Toast
import androidx.activity.ComponentActivity
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Column
Expand Down Expand Up @@ -29,6 +28,7 @@ import com.msg.design_system.component.icon.GoBackIcon
import com.msg.design_system.component.topbar.GoBackTopBar
import com.msg.design_system.theme.BitgoeulAndroidTheme
import com.msg.model.remote.response.email.GetEmailAuthenticateStatusResponse
import com.msg.ui.makeToast
import kotlinx.coroutines.launch

@Composable
Expand All @@ -51,10 +51,10 @@ internal fun EmailSendInformRoute(
onSuccess = { response ->
if (response.isAuthentication) {
onMoveNewPasswordClicked()
Toast.makeText(context, "이메일 인증에 성공했습니다.", Toast.LENGTH_SHORT).show()
makeToast(context, "이메일 인증에 성공했습니다.")
}
if (!response.isAuthentication) {
Toast.makeText(context, "이메일 인증에 실패했습니다.", Toast.LENGTH_SHORT).show()
makeToast(context, "이메일 인증에 실패했습니다.")
}
}
)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.bitgoeul.email

import android.widget.Toast
import androidx.activity.ComponentActivity
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Column
Expand All @@ -27,6 +26,7 @@ import com.msg.design_system.component.icon.GoBackIcon
import com.msg.design_system.component.textfield.DefaultTextField
import com.msg.design_system.component.topbar.GoBackTopBar
import com.msg.design_system.theme.BitgoeulAndroidTheme
import com.msg.ui.makeToast

@Composable
internal fun InputNewPasswordRoute(
Expand Down Expand Up @@ -134,7 +134,7 @@ internal fun InputNewPasswordScreen(
if (passwordPattern.matches(firstInputPassword.value)) {
onNextClicked(secondInputPassword.value)
} else {
Toast.makeText(context, "비밀번호는 8~24자 영문, 숫자, 특수문자 1개 이상이어야 합니다.", Toast.LENGTH_SHORT).show()
makeToast(context, "비밀번호는 8~24자 영문, 숫자, 특수문자 1개 이상이어야 합니다.")
}
}
)
Expand Down
6 changes: 3 additions & 3 deletions feature/login/src/main/java/com/bitgoeul/login/LoginScreen.kt
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.bitgoeul.login

import android.content.pm.ActivityInfo
import android.widget.Toast
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
Expand Down Expand Up @@ -35,6 +34,7 @@ import com.msg.design_system.theme.BitgoeulAndroidTheme
import com.msg.design_system.util.LockScreenOrientation
import com.msg.design_system.util.checkEmailRegex
import com.msg.design_system.util.checkPasswordRegex
import com.msg.ui.makeToast
import kotlinx.coroutines.launch

@Composable
Expand All @@ -56,11 +56,11 @@ internal fun LoginRoute(
getLoginData(
viewModel = viewModel,
onSuccess = {
Toast.makeText(context, "로그인에 성공하였습니다.", Toast.LENGTH_SHORT).show()
makeToast(context, "로그인에 성공하였습니다.")
onLoginClicked()
},
onFailure = {
Toast.makeText(context, "로그인에 실패하였습니다. 다시 시도해주세요", Toast.LENGTH_SHORT).show()
makeToast(context, "로그인에 실패하였습니다. 다시 시도해주세요")
}
)
}
Expand Down

0 comments on commit 6c26ba7

Please sign in to comment.