Skip to content

Commit

Permalink
ui: 타임라인 타이틀 사용자 닉네임 표시
Browse files Browse the repository at this point in the history
  • Loading branch information
s6m1n committed Jan 18, 2025
1 parent a048a7d commit feae3c7
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,15 @@ fun TextView.setIsMemoryCandidatesEmptyVisibility(memoryCandidates: MemoryCandid
isGone = !memoryCandidates?.memoryCandidate.isNullOrEmpty()
}

@BindingAdapter("timelineNickname")
fun TextView.formatTimelineNickname(nickname: String?) {
text = nickname?.let {
resources.getString(R.string.timeline_nickname_memories).format(formatNickname(it))
} ?: EMPTY_TEXT
}

fun formatNickname(nickname: String) = nickname.takeIf { it.length <= 10 } ?: ("${nickname.take(10)}...")

@BindingAdapter("visitedAtHistory")
fun TextView.formatVisitedAtHistory(visitedAt: LocalDateTime?) {
text = visitedAt?.let {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,10 @@ class TimelineFragment :
timelineViewModel.loadTimeline()
}
}

sharedViewModel.memberProfile.observe(viewLifecycleOwner) { memberProfile ->
binding.nickname = memberProfile.nickname
}
}

private fun View.inflateCreationMenu(): PopupMenu {
Expand Down
14 changes: 10 additions & 4 deletions android/Staccato_AN/app/src/main/res/layout/fragment_timeline.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@

<import type="android.view.View" />

<variable
name="nickname"
type="java.lang.String" />

<variable
name="viewModel"
type="com.on.staccato.presentation.timeline.viewmodel.TimelineViewModel" />
Expand All @@ -25,14 +29,16 @@

<TextView
android:id="@+id/tv_timeline_my_timeline"
android:layout_width="wrap_content"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="20dp"
android:layout_marginHorizontal="20dp"
android:layout_marginTop="12dp"
android:text="@string/timeline_my_timeline"
android:textAppearance="@style/Typography.Title1"
app:layout_constraintEnd_toStartOf="@id/frame_timeline_add_memory"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
app:layout_constraintTop_toTopOf="parent"
bind:timelineNickname="@{nickname}"
tools:text="WWWWWWWWWWW...의 추억"/>

<FrameLayout
android:id="@+id/frame_timeline_add_memory"
Expand Down
2 changes: 1 addition & 1 deletion android/Staccato_AN/app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
<string name="main_staccato_creation_btn_description">스타카토 기록하기로 이동</string>

// fragment_timeline
<string name="timeline_my_timeline">나의 추억들</string>
<string name="timeline_nickname_memories">%s의 추억들</string>
<string name="timeline_order">최근 생성 순</string>
<string name="timeline_empty">아직 카테고리가 없네요!\n스타카토를 담을 카테고리를 만들어보세요.</string>
<string name="timeline_add_memory">추가</string>
Expand Down

0 comments on commit feae3c7

Please sign in to comment.