Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/develop' into feat/change_date_t…
Browse files Browse the repository at this point in the history
…ime_format
  • Loading branch information
KxxHyoRim committed Feb 29, 2024
2 parents 5dc1e50 + 165c88f commit 770f876
Show file tree
Hide file tree
Showing 29 changed files with 848 additions and 12 deletions.
5 changes: 5 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -82,5 +82,10 @@
android:name=".mission_suggestion.ui.detail.SuggestionDetailActivity"
android:exported="false" />

<activity
android:name=".mission_suggestion.ui.create_suggestion.CreateSuggestionActivity"
android:exported="false"
android:windowSoftInputMode="adjustResize" />

</application>
</manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import com.lgtm.android.main.notification.NotificationCenterActivity
import com.lgtm.android.manage_mission.dashboard.DashboardActivity
import com.lgtm.android.manage_mission.ping_pong_junior.PingPongJuniorActivity
import com.lgtm.android.mission_detail.MissionDetailActivity
import com.lgtm.android.mission_suggestion.ui.create_suggestion.CreateSuggestionActivity
import com.lgtm.android.mission_suggestion.ui.dashboard.SuggestionDashboardActivity
import com.lgtm.android.mission_suggestion.ui.detail.SuggestionDetailActivity
import com.lgtm.android.profile.ProfileActivity
Expand Down Expand Up @@ -78,6 +79,11 @@ class LgtmNavigatorImpl @Inject constructor(
context.startActivity(intent)
}

override fun navigateToCreateSuggestion(context: Context) {
val intent = Intent(context, CreateSuggestionActivity::class.java)
context.startActivity(intent)
}

override fun openUrlInBrowser(context: Context, url: String) {
val intent = Intent(Intent.ACTION_VIEW).apply {
data = Uri.parse(url)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,12 @@ import androidx.compose.ui.res.colorResource
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.unit.dp
import com.lgtm.android.common_ui.R
import com.lgtm.android.common_ui.util.throttleClickable

@Composable
fun BackButton(
modifier: Modifier = Modifier
modifier: Modifier = Modifier,
onClick: () -> Unit
) {
Box(
modifier = modifier
Expand All @@ -29,9 +31,13 @@ fun BackButton(
color = Color.White,
shape = RoundedCornerShape(10.dp)
)
.padding(7.dp)
.throttleClickable(
enabled = true,
onClick = onClick
)
) {
Image(
modifier = Modifier.padding(7.dp),
painter = painterResource(id = R.drawable.ic_back),
contentDescription = null
)
Expand Down
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)
}
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
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ enum class InfoType(
GITHUB_URL_ONLY(R.color.red, R.string.github_url_only, true, R.drawable.ic_info_red),
DUPLICATE_NICKNAME(R.color.red, R.string.duplicate_nickname, true, R.drawable.ic_info_red),
CAN_USE(R.color.blue, R.string.can_use, true, R.drawable.ic_info_blue),
PROPER_URL(R.color.blue, R.string.proper_url, true, R.drawable.ic_info_blue)
PROPER_URL(R.color.blue, R.string.proper_url, true, R.drawable.ic_info_blue),
TITLE_REQUIRED(R.color.red, R.string.title_required, true, R.drawable.ic_info_red),
CONTENT_REQUIRED(R.color.red, R.string.content_required, true, R.drawable.ic_info_red),
}

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),
)
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,7 @@ interface LgtmNavigator {

fun navigateToSuggestionDetail(context: Context, suggestionId: Int)

fun navigateToCreateSuggestion(context: Context)

fun openUrlInBrowser(context: Context, url: String)
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,17 +42,41 @@ class LGTMEditText @JvmOverloads constructor(
binding.editText.maxLines = lines
}

fun setMinLine(lines: Int) {
binding.editText.minLines = lines
}

fun setGravity(gravity: Int) {
binding.editText.gravity = gravity
}

private fun initializeView() {
addView(binding.root)
showClearButton()
}


private fun showClearButton() {
binding.apply {
editText.addTextChangedListener {
ivClear.visibility = if (editText.text.isNotEmpty()) View.VISIBLE else View.GONE
}
}
}

fun bindStateEditTextData(editTextData: EditTextData?) {
binding.editTextData = editTextData
binding.lifecycleOwner = lifecycleOwner
}

fun onTextChangedListener(listener: (String) -> Unit) {
binding.editText.addTextChangedListener {
listener(it.toString())
}
}

fun onFocusChangedListener(listener: (Boolean) -> Unit) {
binding.editText.setOnFocusChangeListener { _, hasFocus ->
listener(hasFocus)
}
}
}
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
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import android.content.ContentValues.TAG
import android.util.Log
import android.view.View


class OnThrottleClickListener(
private val onClickListener: View.OnClickListener,
private val interval: Long = 300L,
Expand All @@ -31,4 +30,4 @@ fun View.setOnThrottleClickListener(action: (v: View) -> Unit) {

fun View.setOnThrottleClickListener(action: (v: View) -> Unit, interval: Long) {
setOnClickListener(OnThrottleClickListener(action, interval))
}
}
1 change: 1 addition & 0 deletions common-ui/src/main/res/values/colors.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,5 @@
<color name="gray_2">#e7ecf2</color>
<color name="gray_1">#f4f5f9</color>
<color name="white">#fcfcfc</color>
<color name="transparent_black">#9E030C1B</color>
</resources>
11 changes: 11 additions & 0 deletions common-ui/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,17 @@
<!-- 미션 제안 디테일 -->
<string name="want_this_mission">저도 이 미션 원해요!</string>

<!-- 미션 제안 생성 -->
<string name="mission_suggestion_title">제목</string>
<string name="mission_suggestion_title_description">어떤 주제로 코드 리뷰를 받고 싶나요?</string>
<string name="mission_suggestion_content">본문</string>
<string name="mission_suggestion_content_description">리뷰어에게 자세히 설명해 주세요.</string>
<string name="suggestion_next">다음</string>
<string name="title_required">제목은 필수 입력 항목 입니다.</string>
<string name="content_required">본문은 필수 입력 항목 입니다.</string>
<string name="want_to_stop_creating_suggestion">작성을 중단할까요?</string>
<string name="content_will_not_be_saved">작성한 내용은 저장되지 않아요.</string>

<!-- dialog -->
<string name="want_to_logout">로그아웃 하시겠어요?</string>
<string name="cannot_cancle_after_participate_mission">참여한 미션은 취소가 불가능해요</string>
Expand Down
Loading

0 comments on commit 770f876

Please sign in to comment.