-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/develop' into feat/change_date_t…
…ime_format
- Loading branch information
Showing
29 changed files
with
848 additions
and
12 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
56 changes: 56 additions & 0 deletions
56
...i/src/main/java/com/lgtm/android/common_ui/components/buttons/DialogConfirmationButton.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,56 @@ | ||
package com.lgtm.android.common_ui.components.buttons | ||
|
||
import androidx.compose.foundation.background | ||
import androidx.compose.foundation.border | ||
import androidx.compose.foundation.layout.Box | ||
import androidx.compose.foundation.layout.padding | ||
import androidx.compose.foundation.shape.RoundedCornerShape | ||
import androidx.compose.material.Text | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.Alignment | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.res.colorResource | ||
import androidx.compose.ui.unit.dp | ||
import com.lgtm.android.common_ui.R | ||
import com.lgtm.android.common_ui.theme.body1M | ||
import com.lgtm.android.common_ui.util.throttleClickable | ||
|
||
@Composable | ||
fun DialogConfirmationButton( | ||
modifier: Modifier = Modifier, | ||
text: String, | ||
confirmBtnBackground: ConfirmButtonBackgroundColor = ConfirmButtonBackgroundColor.GRAY, | ||
onClick: () -> Unit | ||
) { | ||
Box( | ||
modifier = modifier | ||
.background( | ||
color = colorResource(id = confirmBtnBackground.background), | ||
shape = RoundedCornerShape(10.dp) | ||
) | ||
.border( | ||
width = if (confirmBtnBackground == ConfirmButtonBackgroundColor.GREEN) 0.dp else 1.dp, | ||
color = colorResource(id = R.color.gray_3), | ||
shape = RoundedCornerShape(10.dp) | ||
) | ||
.throttleClickable( | ||
enabled = true, | ||
onClick = onClick | ||
), | ||
contentAlignment = Alignment.Center | ||
) { | ||
Text( | ||
modifier = Modifier.padding( | ||
vertical = 11.dp | ||
), | ||
text = text, | ||
style = Typography.body1M, | ||
color = colorResource(id = R.color.black) | ||
) | ||
} | ||
} | ||
|
||
enum class ConfirmButtonBackgroundColor(val background: Int) { | ||
GREEN(R.color.green), | ||
GRAY(R.color.gray_1) | ||
} |
102 changes: 102 additions & 0 deletions
102
...n-ui/src/main/java/com/lgtm/android/common_ui/components/dialog/LgtmConfirmationDialog.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,102 @@ | ||
package com.lgtm.android.common_ui.components.dialog | ||
|
||
import androidx.compose.foundation.background | ||
import androidx.compose.foundation.layout.Column | ||
import androidx.compose.foundation.layout.Row | ||
import androidx.compose.foundation.layout.Spacer | ||
import androidx.compose.foundation.layout.fillMaxWidth | ||
import androidx.compose.foundation.layout.padding | ||
import androidx.compose.foundation.layout.width | ||
import androidx.compose.material.Text | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.Alignment | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.res.colorResource | ||
import androidx.compose.ui.res.stringResource | ||
import androidx.compose.ui.tooling.preview.Preview | ||
import androidx.compose.ui.unit.dp | ||
import com.lgtm.android.common_ui.R | ||
import com.lgtm.android.common_ui.components.buttons.ConfirmButtonBackgroundColor | ||
import com.lgtm.android.common_ui.components.buttons.DialogConfirmationButton | ||
import com.lgtm.android.common_ui.theme.body1B | ||
import com.lgtm.android.common_ui.theme.description | ||
|
||
@Composable | ||
fun LgtmConfirmationDialog( | ||
dialogTitle: String, | ||
dialogDescription: String? = null, | ||
onClickCancel: () -> Unit, | ||
onClickConfirm: () -> Unit, | ||
confirmBtnBackground: ConfirmButtonBackgroundColor | ||
) { | ||
Column( | ||
modifier = Modifier | ||
.fillMaxWidth() | ||
.background(color = colorResource(id = R.color.white)), | ||
horizontalAlignment = Alignment.CenterHorizontally | ||
) { | ||
DialogDescription(dialogTitle, dialogDescription) | ||
DialogButtons(onClickCancel, onClickConfirm, confirmBtnBackground) | ||
} | ||
} | ||
|
||
@Composable | ||
fun DialogDescription( | ||
title: String, | ||
description: String? = null | ||
) { | ||
Text( | ||
modifier = Modifier.padding(top = 30.dp), | ||
text = title, | ||
style = Typography.body1B, | ||
color = colorResource(id = R.color.black) | ||
) | ||
description?.let { | ||
Text( | ||
modifier = Modifier.padding(top = 10.dp), | ||
text = description, | ||
style = Typography.description, | ||
color = colorResource(id = R.color.black) | ||
) | ||
} | ||
} | ||
|
||
@Composable | ||
fun DialogButtons( | ||
onClickCancel: () -> Unit, | ||
onClickConfirm: () -> Unit, | ||
confirmBtnBackground: ConfirmButtonBackgroundColor | ||
) { | ||
Row( | ||
modifier = Modifier.padding( | ||
vertical = 30.dp, | ||
horizontal = 24.dp | ||
), | ||
verticalAlignment = Alignment.CenterVertically, | ||
) { | ||
DialogConfirmationButton( | ||
modifier = Modifier.weight(1f), | ||
text = stringResource(id = R.string.no), | ||
onClick = onClickCancel, | ||
) | ||
Spacer(modifier = Modifier.width(20.dp)) | ||
DialogConfirmationButton( | ||
modifier = Modifier.weight(1f), | ||
text = stringResource(id = R.string.yes), | ||
onClick = onClickConfirm, | ||
confirmBtnBackground = confirmBtnBackground | ||
) | ||
} | ||
} | ||
|
||
@Composable | ||
@Preview | ||
fun LGTMBottomSheetDialogContentPreview() { | ||
LgtmConfirmationDialog( | ||
dialogTitle = "작성을 중단할까요?", | ||
dialogDescription = "작성한 내용은 저장되지 않아요.", | ||
onClickCancel = {}, | ||
onClickConfirm = {}, | ||
confirmBtnBackground = ConfirmButtonBackgroundColor.GREEN | ||
) | ||
} |
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
10 changes: 10 additions & 0 deletions
10
common-ui/src/main/java/com/lgtm/android/common_ui/model/NoLimitEditTextData.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,10 @@ | ||
package com.lgtm.android.common_ui.model | ||
|
||
import androidx.lifecycle.MutableLiveData | ||
import com.lgtm.android.common_ui.constant.InfoType | ||
|
||
data class NoLimitEditTextData( | ||
val text: MutableLiveData<String>, | ||
val hint: String, | ||
var infoStatus: MutableLiveData<InfoType> = MutableLiveData(InfoType.NONE), | ||
) |
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
44 changes: 44 additions & 0 deletions
44
common-ui/src/main/java/com/lgtm/android/common_ui/util/ComposeSingleClickListener.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,44 @@ | ||
package com.lgtm.android.common_ui.util | ||
|
||
import android.content.ContentValues.TAG | ||
import android.util.Log | ||
import androidx.compose.foundation.clickable | ||
import androidx.compose.foundation.interaction.MutableInteractionSource | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.runtime.remember | ||
import androidx.compose.ui.Modifier | ||
|
||
class OnComposeThrottleClickListener( | ||
private val interval: Long = 300L | ||
) { | ||
private val now: Long | ||
get() = System.currentTimeMillis() | ||
private var lastEventTime: Long = 0 | ||
fun onClick(event: () -> Unit) { | ||
if (now - lastEventTime >= interval) { | ||
lastEventTime = now | ||
event() | ||
} else { | ||
Log.d(TAG, "onClick : operating composeThrottleClickListener") | ||
} | ||
|
||
} | ||
} | ||
|
||
@Composable | ||
fun Modifier.throttleClickable( | ||
enabled: Boolean = false, | ||
onClick: () -> Unit | ||
): Modifier { | ||
val throttleClickListener = remember { OnComposeThrottleClickListener() } | ||
|
||
return if (enabled) { | ||
clickable( | ||
onClick = { throttleClickListener.onClick { onClick() } }, | ||
interactionSource = remember { MutableInteractionSource() }, | ||
indication = null | ||
) | ||
} else { | ||
this | ||
} | ||
} |
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
Oops, something went wrong.