Skip to content

Commit

Permalink
๐Ÿ› Fix: ์ผ์ • ๋‹ค์ด์–ผ๋กœ๊ทธ ์ƒ๋‹จ ํœด์ง€ํ†ต ๋ฒ„ํŠผ ๋…ธ์ถœ์—ฌ๋ถ€ ์„ค์ •
Browse files Browse the repository at this point in the history
- ์นดํ…Œ๊ณ ๋ฆฌ ์„ค์ • ํ™”๋ฉด์—์„œ๋Š” ํœด์ง€ํ†ต ๋ฒ„ํŠผ ์ˆจ๊ธฐ๊ธฐ
- ์ผ์ • ํ™”๋ฉด์—์„œ๋Š” ์ƒ์„ฑ/ํŽธ์ง‘ ๋ชจ๋“œ์— ๋”ฐ๋ผ ๋…ธ์ถœ ์—ฌ๋ถ€ ๊ฒฐ์ •ํ•˜๊ธฐ

Related to: #346
  • Loading branch information
nahy-512 committed Feb 9, 2025
1 parent a6a6611 commit e6298b8
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ class PersonalScheduleViewModel @Inject constructor(
private val _isDailyScheduleEmptyPair = MutableLiveData<Pair<Boolean, Boolean>>()
var isDailyScheduleEmptyPair: LiveData<Pair<Boolean, Boolean>> = _isDailyScheduleEmptyPair

// ๋‹ค์ด์–ผ๋กœ๊ทธ ์ƒ๋‹จ ํœด์ง€ํ†ต ๋ฒ„ํŠผ ๋…ธ์ถœ ์—ฌ๋ถ€
private val _isShowTopDeleteBtn = MutableLiveData<Boolean>()
var isShowTopDeleteBtn: LiveData<Boolean> = _isShowTopDeleteBtn

init {
getCategories() // ์ตœ์ดˆ ์นดํ…Œ๊ณ ๋ฆฌ ๋ชฉ๋ก ์กฐํšŒ
}
Expand Down Expand Up @@ -301,6 +305,10 @@ class PersonalScheduleViewModel @Inject constructor(
return null
}

fun setDeleteBtnVisibility(isVisible: Boolean) {
_isShowTopDeleteBtn.value = isVisible
}

fun isInvalidDate(): Boolean {
// ์‹œ์ž‘์ผ > ์ข…๋ฃŒ์ผ
return schedule.value!!.period.startDate > schedule.value!!.period.endDate
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,13 @@ import org.joda.time.LocalDateTime
@AndroidEntryPoint
class ScheduleActivity : BaseActivity<ActivityScheduleBinding>(R.layout.activity_schedule), ConfirmDialogInterface {

private val navController: NavController by lazy {
val navHostFragment = supportFragmentManager.findFragmentById(R.id.schedule_nav_host) as NavHostFragment
navHostFragment.navController
}
private val viewModel : PersonalScheduleViewModel by viewModels()

override fun setup() {
var schedule : Schedule? = null

binding.viewModel = this@ScheduleActivity.viewModel

// intent๊ฐ€ ๋„˜์–ด์™”๋Š”์ง€ ํ™•์ธ
intent.getStringExtra("schedule")?.let { scheduleJson ->
// GsonBuilder์— ์ปค์Šคํ…€ TypeAdapter ๋“ฑ๋ก
Expand All @@ -52,10 +50,8 @@ class ScheduleActivity : BaseActivity<ActivityScheduleBinding>(R.layout.activity
val nowDay = intent.getLongExtra("nowDay", 0)

if (schedule != null) { // ์ƒ์„ฑ ๋ชจ๋“œ
binding.scheduleDeleteBtn.visibility = View.VISIBLE
viewModel.setSchedule(schedule)
} else { // ํŽธ์ง‘ ๋ชจ๋“œ
binding.scheduleDeleteBtn.visibility = View.GONE
viewModel.setSchedule(
Schedule(
period = SchedulePeriod(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ class ScheduleDialogBasicFragment : BaseFragment<FragmentScheduleDialogBasicBind
override fun onResume() {
super.onResume()
mapView.resume()
viewModel.setDeleteBtnVisibility(!viewModel.isCreateMode())
}

override fun onPause() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class ScheduleDialogCategoryFragment
override fun setup() {
binding.viewModel = viewModel

viewModel.setDeleteBtnVisibility(false)
initClickListeners()
initObserve()
}
Expand Down
16 changes: 12 additions & 4 deletions app/src/main/res/layout/activity_schedule.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<layout>
<data>
<import type="android.view.View"/>
<variable
name="viewModel"
type="com.mongmong.namo.presentation.ui.home.schedule.PersonalScheduleViewModel" />
</data>

<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/schedule_background_layout"
xmlns:android="http://schemas.android.com/apk/res/android"
Expand All @@ -14,13 +21,14 @@
android:layout_width="65dp"
android:layout_height="70dp"
android:layout_marginBottom="10dp"
app:layout_constraintBottom_toTopOf="@id/schedule_container_layout"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
android:visibility="@{(viewModel.isShowTopDeleteBtn == true) ? View.VISIBLE : View.GONE}"
app:cardBackgroundColor="@color/white"
app:cardCornerRadius="25dp"
app:cardElevation="5dp"
app:cardUseCompatPadding="true">
app:cardUseCompatPadding="true"
app:layout_constraintBottom_toTopOf="@id/schedule_container_layout"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent">

<androidx.appcompat.widget.AppCompatImageView
android:layout_width="24dp"
Expand Down

0 comments on commit e6298b8

Please sign in to comment.