-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #85 from yourssu/develop
[YDS] 2.0.0 배포
- Loading branch information
Showing
156 changed files
with
5,396 additions
and
1,105 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
31 changes: 0 additions & 31 deletions
31
DesignSystem/src/main/java/com/yourssu/design/system/GlobalRule.kt
This file was deleted.
Oops, something went wrong.
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
120 changes: 120 additions & 0 deletions
120
DesignSystem/src/main/java/com/yourssu/design/system/atom/EditText.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,120 @@ | ||
package com.yourssu.design.system.atom | ||
|
||
import android.content.Context | ||
import android.graphics.Color | ||
import android.util.AttributeSet | ||
import android.util.Log | ||
import androidx.appcompat.widget.AppCompatEditText | ||
import androidx.core.content.ContextCompat | ||
import androidx.databinding.BindingAdapter | ||
import com.yourssu.design.R | ||
import com.yourssu.design.system.foundation.Typo | ||
import com.yourssu.design.system.foundation.Typography | ||
import com.yourssu.design.undercarriage.size.getDimenFloat | ||
|
||
class EditText @JvmOverloads constructor( | ||
context: Context, | ||
attrs: AttributeSet? = null, | ||
defStyleAttr: Int = 0 | ||
) : AppCompatEditText(context, attrs, defStyleAttr) { | ||
|
||
init { | ||
setTextColor(ContextCompat.getColor(context, R.color.textPrimary)) | ||
setBackgroundColor(Color.TRANSPARENT) | ||
setHintTextColor(ContextCompat.getColor(context, R.color.textTertiary)) | ||
isFocusableInTouchMode = true | ||
} | ||
|
||
private var text: String = "" | ||
set(text) { | ||
field = text | ||
changeText() | ||
} | ||
|
||
private var hint: String = "" | ||
set(text) { | ||
field = text | ||
changeHint() | ||
} | ||
|
||
@Typography | ||
private var typo: Int = Typo.SubTitle1 | ||
set(@Typography typo) { | ||
field = typo | ||
setTextInfo() | ||
} | ||
|
||
private var editTextType: Int = TITLE | ||
set(value) { | ||
field = value | ||
changeEditTextType() | ||
} | ||
|
||
private fun changeHint() { | ||
setHint(hint) | ||
} | ||
|
||
private fun setTextInfo() { | ||
setTextAppearance(Typo.getStyle(typo)) | ||
|
||
// 폰트의 커스텀 padding 제거 | ||
includeFontPadding = false | ||
|
||
// 폰트가 가지고 있는 lineHeight 값 추출 | ||
val fontLineHeight = paint.getFontMetrics(paint.fontMetrics) | ||
|
||
// 디자이너가 요청한 lineHeight 값 | ||
val figmaLineHeight = context.getDimenFloat(Typo.getLineHeight(typo)) | ||
|
||
// 줄 간 간격인 lineSpacing 이자 (topPadding, bottomPadding) 의 합 | ||
val lineSpacing = figmaLineHeight - fontLineHeight | ||
|
||
setPadding(0, lineSpacing.toInt() / 2, 0, lineSpacing.toInt() / 2) | ||
setLineSpacing(lineSpacing, 1f) | ||
} | ||
|
||
private fun changeEditTextType() { | ||
typo = when (editTextType) { | ||
TITLE -> { | ||
Typo.SubTitle1 | ||
} | ||
CONTENT -> { | ||
Typo.Body1 | ||
} | ||
else -> { | ||
Typo.SubTitle1 | ||
} | ||
} | ||
Log.d("KWK", Typo.getName(typo)) | ||
} | ||
|
||
private fun changeText() { | ||
setText(text) | ||
requestLayout() | ||
invalidate() | ||
} | ||
|
||
companion object { | ||
const val TITLE = 0 | ||
const val CONTENT = 1 | ||
|
||
@JvmStatic | ||
@BindingAdapter("android:hint") | ||
fun setHint(editText: EditText, hint: String) { | ||
editText.hint = hint | ||
} | ||
|
||
@JvmStatic | ||
@BindingAdapter("android:text") | ||
fun setText(editText: EditText, text: String) { | ||
editText.text = text | ||
} | ||
|
||
@JvmStatic | ||
@BindingAdapter("editTextType") | ||
fun setEditTextType(editText: EditText, editTextType: Int) { | ||
editText.editTextType = editTextType | ||
} | ||
} | ||
|
||
} |
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.