Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: 인게임 쪽지에 등록자와 등록 시간 보여주기 #571

Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,13 @@ import android.view.View
import android.view.ViewGroup
import androidx.fragment.app.DialogFragment
import com.now.naaga.databinding.DialogReadLetterBinding
import com.now.naaga.presentation.uimodel.model.LetterUiModel
import com.now.naaga.util.dpToPx
import com.now.naaga.util.getWidthProportionalToDevice
import java.time.LocalDateTime
import java.time.format.DateTimeFormatter

class LetterReadDialog(private val content: String) : DialogFragment() {
class LetterReadDialog(private val content: LetterUiModel) : DialogFragment() {
private lateinit var binding: DialogReadLetterBinding

override fun onCreateView(
Expand Down Expand Up @@ -39,10 +42,18 @@ class LetterReadDialog(private val content: String) : DialogFragment() {

private fun setContent() {
binding.letter = content
binding.tvDialogLetterDate.text = formatDate()
}

private fun formatDate(): String {
hyunji1203 marked this conversation as resolved.
Show resolved Hide resolved
val serverLocalDateTime = LocalDateTime.parse(content.registerDate, DateTimeFormatter.ISO_DATE_TIME)
val outputFormatter = DateTimeFormatter.ofPattern(DATE_FORMAT_PATTERN)
return serverLocalDateTime.format(outputFormatter)
}

companion object {
private const val WIDTH_RATE = 0.78f
private const val HEIGHT = 430
private const val DATE_FORMAT_PATTERN = "yyyy-MM-dd"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import com.now.naaga.presentation.common.dialog.PolaroidDialog
import com.now.naaga.presentation.uimodel.mapper.toDomain
import com.now.naaga.presentation.uimodel.mapper.toUi
import com.now.naaga.presentation.uimodel.model.AdventureUiModel
import com.now.naaga.presentation.uimodel.model.LetterUiModel
import com.now.naaga.util.extension.getParcelableCompat
import com.now.naaga.util.extension.showSnackbar
import com.now.naaga.util.extension.showToast
Expand Down Expand Up @@ -134,7 +135,7 @@ class OnAdventureActivity :
drawLetters(it)
}
viewModel.letter.observe(this) {
showLetterReadDialog(it.message)
showLetterReadDialog(it)
}
viewModel.throwable.observe(this) { throwable: DataThrowable ->
logServerError(ON_ADVENTURE_GAME, throwable.code, throwable.message.toString())
Expand Down Expand Up @@ -248,7 +249,7 @@ class OnAdventureActivity :
}
}

private fun showLetterReadDialog(content: String) {
private fun showLetterReadDialog(content: LetterUiModel) {
LetterReadDialog(content).show(supportFragmentManager, LETTER)
}

Expand Down
48 changes: 41 additions & 7 deletions android/app/src/main/res/layout/dialog_read_letter.xml
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"
<layout xmlns:tools="http://schemas.android.com/tools"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">

<data>
<variable
name="letter"
type="String" />
type="com.now.naaga.presentation.uimodel.model.LetterUiModel" />
</data>

<androidx.constraintlayout.widget.ConstraintLayout
Expand All @@ -31,28 +32,61 @@
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginVertical="20dp"
android:background="@color/primary"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
android:background="@color/primary"
app:layout_constraintTop_toBottomOf="@id/iv_dialog_send_letter_icon"/>
app:layout_constraintTop_toBottomOf="@id/iv_dialog_send_letter_icon" />

<TextView
android:id="@+id/et_dialog_letter"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginHorizontal="40dp"
android:layout_marginVertical="40dp"
android:backgroundTint="@android:color/transparent"
android:fontFamily="@font/pretendard_medium"
android:gravity="center"
android:text="@{letter.message}"
android:textColor="@color/on_primary"
android:textSize="16sp"
android:text="@{letter}"
android:backgroundTint="@android:color/transparent"
android:maxLines="10"
android:ellipsize="marquee"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/iv_dialog_send_letter_icon"/>
app:layout_constraintTop_toBottomOf="@id/iv_dialog_send_letter_icon"
app:layout_constraintVertical_bias="0.475" />

<TextView
android:id="@+id/tv_dialog_letter_date"
hyunji1203 marked this conversation as resolved.
Show resolved Hide resolved
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="32dp"
android:layout_marginBottom="24dp"
android:fontFamily="@font/pretendard_semibold"
android:textColor="@color/black"
android:textSize="12sp"
app:layout_constraintBottom_toBottomOf="@+id/et_dialog_letter"
app:layout_constraintEnd_toEndOf="@+id/v_dialog_letter_background"
tools:text="2023.02.03" />

<TextView
android:id="@+id/tv_dialog_letter_nickname"
android:layout_width="200dp"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:fontFamily="@font/pretendard_semibold"
android:text="@{letter.nickname}"
android:textAlignment="textEnd"
android:textColor="@color/black"
android:ellipsize="marquee"
hyunji1203 marked this conversation as resolved.
Show resolved Hide resolved
android:maxLines="1"
android:textSize="16sp"
app:layout_constraintEnd_toEndOf="@+id/tv_dialog_letter_date"
app:layout_constraintTop_toBottomOf="@+id/tv_dialog_letter_date"
tools:text="뽀또" />

</androidx.constraintlayout.widget.ConstraintLayout>
</layout>
Loading