From 59b858f019006eb4b4e06ccabfd102b7d59f4795 Mon Sep 17 00:00:00 2001 From: mangbaam Date: Thu, 15 Dec 2022 02:15:50 +0900 Subject: [PATCH 01/10] =?UTF-8?q?Issues=20#240=20feat:=20=EC=84=B8?= =?UTF-8?q?=EB=A1=9C=20=EB=B0=A9=ED=96=A5=EC=9C=BC=EB=A1=9C=20=ED=9A=8C?= =?UTF-8?q?=EC=A0=84=ED=95=9C=20TextView=20=EC=BB=A4=EC=8A=A4=ED=85=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit rotate 속성 만을 사용하면 layout 이 제대로 잡히지 않아서 위치를 지정하기 어려운 문제 때문에 작성 --- .../ui/common/VerticalTextView.kt | 60 +++++++++++++++++++ presentation/src/main/res/values/attrs.xml | 3 + 2 files changed, 63 insertions(+) create mode 100644 presentation/src/main/java/com/lighthouse/presentation/ui/common/VerticalTextView.kt diff --git a/presentation/src/main/java/com/lighthouse/presentation/ui/common/VerticalTextView.kt b/presentation/src/main/java/com/lighthouse/presentation/ui/common/VerticalTextView.kt new file mode 100644 index 000000000..c0c382409 --- /dev/null +++ b/presentation/src/main/java/com/lighthouse/presentation/ui/common/VerticalTextView.kt @@ -0,0 +1,60 @@ +package com.lighthouse.presentation.ui.common + +import android.content.Context +import android.graphics.Canvas +import android.util.AttributeSet +import com.lighthouse.presentation.R + +/** + * TextView 를 세로로 회전한 뷰 + * + * @property topDown true 일 때 시계 방향 회전, false 일 때 반시계 방향 회전 + * + * 코드 참고: [stackoverflow.com/a/45414489](https://stackoverflow.com/a/45414489) + */ +class VerticalTextView @JvmOverloads constructor( + context: Context, + attrs: AttributeSet? = null, + defStyleAttr: Int = 0 +) : androidx.appcompat.widget.AppCompatTextView(context, attrs, defStyleAttr) { + + var topDown: Boolean = DEFAULT_TOP_DOWN + + init { + attrs?.let { + context.obtainStyledAttributes(it, R.styleable.VerticalTextView).run { + topDown = getBoolean(R.styleable.VerticalTextView_topDown, DEFAULT_TOP_DOWN) + recycle() + } + } + } + + override fun onMeasure( + widthMeasureSpec: Int, + heightMeasureSpec: Int + ) { + super.onMeasure(heightMeasureSpec, widthMeasureSpec) + setMeasuredDimension(measuredHeight, measuredWidth) + } + + override fun onDraw(canvas: Canvas) { + canvas.save() + if (topDown) { + canvas.translate(width.toFloat(), 0f) + canvas.rotate(90f) + } else { + canvas.translate(0f, height.toFloat()) + canvas.rotate(-90f) + } + canvas.translate( + compoundPaddingLeft.toFloat(), + extendedPaddingTop.toFloat() + ) + layout.draw(canvas) + canvas.restore() + } + + companion object { + private const val DEFAULT_TOP_DOWN = true + } +} diff --git a/presentation/src/main/res/values/attrs.xml b/presentation/src/main/res/values/attrs.xml index 3e7ad5ab4..e46afc1c9 100644 --- a/presentation/src/main/res/values/attrs.xml +++ b/presentation/src/main/res/values/attrs.xml @@ -5,4 +5,7 @@ + + + \ No newline at end of file From 4eadafc44b509600fec7b6fdee193bef3e771cfc Mon Sep 17 00:00:00 2001 From: mangbaam Date: Thu, 15 Dec 2022 02:16:22 +0900 Subject: [PATCH 02/10] =?UTF-8?q?Issues=20#240=20style:=20H4=20=EC=8A=A4?= =?UTF-8?q?=ED=83=80=EC=9D=BC=20=EA=B8=B0=EB=B3=B8=20=EC=83=89=EC=83=81=20?= =?UTF-8?q?=ED=9A=8C=EC=83=89=20->=20=EA=B2=80=EC=A0=95=EC=83=89(colorOnSu?= =?UTF-8?q?rface)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- presentation/src/main/res/values/styles.xml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/presentation/src/main/res/values/styles.xml b/presentation/src/main/res/values/styles.xml index dd7af4e57..3a6822a82 100644 --- a/presentation/src/main/res/values/styles.xml +++ b/presentation/src/main/res/values/styles.xml @@ -1,7 +1,9 @@ -