From f77bae4f13a45e6dd447451ecc4cb364aa40a319 Mon Sep 17 00:00:00 2001
From: kimyujin-com <80165026+kimyujin-com@users.noreply.github.com>
Date: Sat, 17 Feb 2024 23:29:30 +0900
Subject: [PATCH 1/2] =?UTF-8?q?Design:=20=EC=A1=B8=EC=97=85=EC=97=90?=
=?UTF-8?q?=EC=A0=95=EC=9D=BC=20nestedScrollView=20=EC=A0=81=EC=9A=A9?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../main/res/layout/fragment_grad_date.xml | 297 +++++++++---------
1 file changed, 151 insertions(+), 146 deletions(-)
diff --git a/app/src/main/res/layout/fragment_grad_date.xml b/app/src/main/res/layout/fragment_grad_date.xml
index 517ab29..94ca895 100644
--- a/app/src/main/res/layout/fragment_grad_date.xml
+++ b/app/src/main/res/layout/fragment_grad_date.xml
@@ -11,169 +11,174 @@
-
-
-
-
-
+ android:layout_height="match_parent"
+ android:orientation="vertical">
+
+
+
+
-
-
+
+
+
+
+
+
+
+
+
+
+ app:layout_constraintTop_toBottomOf="@+id/iv_grad_date_card1">
+
+
+
+
+
+
-
-
-
-
-
-
-
+
+
-
+ android:layout_marginBottom="6dp"
+ android:background="@drawable/bg_solid_gray_radius_25"
+ android:backgroundTint="@color/gray"
+ android:minHeight="0dp"
+ android:paddingTop="17dp"
+ android:paddingBottom="17dp"
+ android:stateListAnimator="@null"
+ android:text="저장하기"
+ android:textColor="@color/skyBlue"
+ android:visibility="@{vm.isEditMode ? 0 : 8}"
+ app:layout_constraintBottom_toBottomOf="parent"
+ app:layout_constraintEnd_toEndOf="@+id/tv_grad_date_memo"
+ app:layout_constraintStart_toStartOf="@+id/tv_grad_date_memo" />
-
-
-
-
-
-
-
+
\ No newline at end of file
From 6d48526cb6dc00d8d4292a71f8ae83bd2bbe5977 Mon Sep 17 00:00:00 2001
From: kimyujin-com <80165026+kimyujin-com@users.noreply.github.com>
Date: Sat, 17 Feb 2024 23:30:55 +0900
Subject: [PATCH 2/2] =?UTF-8?q?Fix:=20=EC=A1=B8=EC=97=85=EC=98=88=EC=A0=95?=
=?UTF-8?q?=EC=9D=BC=20=EB=B2=84=ED=8A=BC=20=ED=99=9C=EC=84=B1=ED=99=94=20?=
=?UTF-8?q?=EC=A1=B0=EA=B1=B4=20=EC=88=98=EC=A0=95?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../project/ui/board/GradDateFragment.kt | 5 +++++
.../ui/board/viewmodel/GradDateViewModel.kt | 22 ++++++++++---------
2 files changed, 17 insertions(+), 10 deletions(-)
diff --git a/app/src/main/java/umc/com/mobile/project/ui/board/GradDateFragment.kt b/app/src/main/java/umc/com/mobile/project/ui/board/GradDateFragment.kt
index 3684339..f7e6487 100644
--- a/app/src/main/java/umc/com/mobile/project/ui/board/GradDateFragment.kt
+++ b/app/src/main/java/umc/com/mobile/project/ui/board/GradDateFragment.kt
@@ -113,6 +113,11 @@ class GradDateFragment : Fragment() {
binding.tvGradDateDday.text = "D-$dday"
}
+ //api에서 메모 hint로 가져오기
+ viewModel._dateResponse2.observe(viewLifecycleOwner) { response ->
+ binding.tvGradDateMemo.hint = response!!.result.message
+ }
+
//수정하기 및 버튼 visible 조건
viewModel.isEditMode.observe(viewLifecycleOwner, Observer { isEditMode ->
if (isEditMode) {
diff --git a/app/src/main/java/umc/com/mobile/project/ui/board/viewmodel/GradDateViewModel.kt b/app/src/main/java/umc/com/mobile/project/ui/board/viewmodel/GradDateViewModel.kt
index 59b14f0..cceeef1 100644
--- a/app/src/main/java/umc/com/mobile/project/ui/board/viewmodel/GradDateViewModel.kt
+++ b/app/src/main/java/umc/com/mobile/project/ui/board/viewmodel/GradDateViewModel.kt
@@ -14,9 +14,11 @@ import umc.com.mobile.project.data.model.home.UpdateGradDateRequest
import umc.com.mobile.project.data.model.home.UpdateGradDateResponse
import umc.com.mobile.project.data.network.ApiClient
import umc.com.mobile.project.data.network.api.HomeApi
+import java.text.SimpleDateFormat
import java.time.LocalDate
import java.time.format.DateTimeFormatter
import java.time.temporal.ChronoUnit
+import java.util.Locale
class GradDateViewModel : ViewModel() {
val _selectedDate: MutableLiveData = MutableLiveData()
@@ -55,10 +57,6 @@ class GradDateViewModel : ViewModel() {
val isEditMode: LiveData
get() = _isEditMode
- init {
- cheeringMessage.value = ""
- }
-
fun init() {
_isEditMode.value = false
}
@@ -86,12 +84,9 @@ class GradDateViewModel : ViewModel() {
_isEditMode.value = !_isEditMode.value!!
}
- //전의 메모랑 같으면 저장 안됨
- private var previousMessage: String? = null
- private var previousDDay: Int? = null
-
//버튼 활성화 조건
val isButtonEnabled = MediatorLiveData().apply {
+ //이전 메모랑 내용 같으면 저장 안됨
var previousMessage: String? = null
var previousDDay: String? = null
@@ -99,14 +94,14 @@ class GradDateViewModel : ViewModel() {
val cheeringMessageObserver = Observer { currentMessage ->
val dDayValue = _dday.value
value =
- previousMessage != currentMessage && currentMessage.isNotEmpty() && dDayValue != null && dDayValue != 0
+ previousMessage != currentMessage && currentMessage.isNotEmpty()
previousMessage = currentMessage
}
//_dday 값이 변경될 때마다 실행
val dDayObserver = Observer { currentDDay ->
val messageValue = cheeringMessage.value
value =
- previousDDay != currentDDay.toString() && currentDDay != null && currentDDay != 0 && messageValue != null && messageValue.isNotEmpty()
+ previousDDay != currentDDay.toString() && currentDDay != null && currentDDay != 0
previousDDay = currentDDay.toString()
}
addSource(cheeringMessage, cheeringMessageObserver)
@@ -124,6 +119,13 @@ class GradDateViewModel : ViewModel() {
if (dateInfoResponse != null) {
dateResponse.postValue(dateInfoResponse)//home에 있어서 놔둠
_dateResponse2.postValue(dateInfoResponse)
+ val originalFormat = SimpleDateFormat("yyyy-MM-dd", Locale.KOREA)
+ val targetFormat = SimpleDateFormat("yyyy-M월-d", Locale.KOREA)
+ if (dateInfoResponse.result.dday != null) {
+ val date = originalFormat.parse(dateInfoResponse.result.gradDate)
+ val formattedDate = targetFormat.format(date)
+ _selectedDateRequest.value = formattedDate
+ }
if (_dateResponse2.value != null && _dateResponse2.value!!.result != null) {
_selectedDate.value = _dateResponse2.value!!.result.gradDate
}