Skip to content

Commit

Permalink
[FEAT/#87] 액티비티 연결
Browse files Browse the repository at this point in the history
  • Loading branch information
leeeyubin committed Jan 12, 2024
1 parent caa25c1 commit 7aef672
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 18 deletions.
4 changes: 2 additions & 2 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,12 @@

<activity
android:name="com.going.presentation.preferencetag.entertrip.EnterPreferenceActivity"
android:exported="true"
android:exported="false"
android:screenOrientation="portrait" />

<activity
android:name="com.going.presentation.preferencetag.invitefinish.FinishPreferenceActivity"
android:exported="true"
android:exported="false"
android:screenOrientation="portrait" />

<activity
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,20 @@ package com.going.presentation.preferencetag.entertrip

import android.os.Bundle
import androidx.activity.viewModels
import androidx.core.content.ContextCompat
import com.going.domain.entity.PreferenceData
import com.going.presentation.R
import com.going.presentation.databinding.ActivityEnterPreferenceBinding
import com.going.presentation.preferencetag.PreferenceTagAdapter
import com.going.presentation.preferencetag.PreferenceTagDecoration
import com.going.presentation.preferencetag.PreferenceTagViewModel
import com.going.presentation.starttrip.createtrip.CreateTripActivity.Companion.END_DAY
import com.going.presentation.starttrip.createtrip.CreateTripActivity.Companion.END_MONTH
import com.going.presentation.starttrip.createtrip.CreateTripActivity.Companion.END_YEAR
import com.going.presentation.starttrip.createtrip.CreateTripActivity.Companion.NAME
import com.going.presentation.starttrip.createtrip.CreateTripActivity.Companion.START_DAY
import com.going.presentation.starttrip.createtrip.CreateTripActivity.Companion.START_MONTH
import com.going.presentation.starttrip.createtrip.CreateTripActivity.Companion.START_YEAR
import com.going.ui.base.BaseActivity
import com.going.ui.extension.setOnSingleClickListener

Expand All @@ -22,13 +30,17 @@ class EnterPreferenceActivity :

private val preferenceAnswers = MutableList(5) { Int.MAX_VALUE }

private var title: String? = ""
private var startDate: String? = ""
private var endDate: String? = ""
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)

initAdapter()
initItemDecoration()
initBackClickListener()
isButtonValid()
getCreateTripInfo()
sendStyleInfo()

}

Expand All @@ -44,21 +56,55 @@ class EnterPreferenceActivity :
}

private fun initBackClickListener() {
binding.btnPreferenceBack.setOnSingleClickListener {
finish()
binding.btnPreferenceStart.setOnSingleClickListener {
sendStyleInfo()
}
}

private fun isButtonValid(){
private fun isButtonValid() {
val isValid = preferenceAnswers.all { it != Int.MAX_VALUE }

if (isValid) {
binding.btnPreferenceStart.isEnabled = isValid
binding.btnPreferenceStart.setTextColor(
ContextCompat.getColorStateList(this, R.color.white_000)
)
}
}

private fun getCreateTripInfo() {
val serverList = getIntent()

if (serverList != null) {
title = intent.getStringExtra(NAME)
val startYear = intent.getIntExtra(START_YEAR, 0)
val startMonth = intent.getIntExtra(START_MONTH, 0)
val startDay = intent.getIntExtra(START_DAY, 0)
val endYear = intent.getIntExtra(END_YEAR, 0)
val endMonth = intent.getIntExtra(END_MONTH, 0)
val endDay = intent.getIntExtra(END_DAY, 0)

startDate = String.format(SERVER_DATE, startYear, startMonth, startDay)
endDate = String.format(SERVER_DATE, endYear, endMonth, endDay)
}

}

private fun sendStyleInfo() {
var styleA = preferenceAnswers[0]
}

override fun onPreferenceSelected(item: PreferenceData, checkList: Int) {
preferenceAnswers[item.number.toInt() - 1] = checkList
isButtonValid()
}

override fun onDestroy() {
super.onDestroy()
_adapter = null
}

companion object {
const val SERVER_DATE = "%s.%s.%s"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -177,22 +177,25 @@ class CreateTripActivity :
binding.btnCreateTripNext.setOnSingleClickListener {
Intent(this, EnterPreferenceActivity::class.java).apply {
putExtra(NAME, viewModel.name.value)
putExtra(START, viewModel.startYear.value)

putExtra(START, viewModel.startMonth.value)
putExtra(START, viewModel.startDay.value)
putExtra(END, viewModel.endYear.value)
putExtra(END, viewModel.endMonth.value)
putExtra(END, viewModel.endDay.value)
putExtra(START_YEAR, viewModel.startYear.value)
putExtra(START_MONTH, viewModel.startMonth.value)
putExtra(START_DAY, viewModel.startDay.value)
putExtra(END_YEAR, viewModel.endYear.value)
putExtra(END_MONTH, viewModel.endMonth.value)
putExtra(END_DAY, viewModel.endDay.value)
startActivity(this)
}
}
}

companion object {
const val NAME = "name"
const val START = "start"
const val END = "end"
const val START_YEAR = "startYear"
const val START_MONTH = "startMonth"
const val START_DAY = "startDay"
const val END_YEAR = "endYear"
const val END_MONTH = "endMonth"
const val END_DAY = "endDay"
}
}

Expand Down
13 changes: 10 additions & 3 deletions presentation/src/main/res/layout/activity_enter_preference.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@

<data>

<variable
name="vm"
type="com.going.presentation.preferencetag.PreferenceTagViewModel">

</variable>

</data>

<androidx.constraintlayout.widget.ConstraintLayout
Expand Down Expand Up @@ -76,10 +82,11 @@
android:layout_height="wrap_content"
android:layout_marginHorizontal="24dp"
android:layout_marginBottom="22dp"
android:background="@drawable/sel_rounded_corner_button_preference"
android:text="@string/preference_btn_enter"
android:background="@drawable/sel_rounded_corner_button"
android:enabled="false"
android:outlineProvider="none"
android:textColor="@drawable/sel_button_text_color_preference"
android:text="@string/preference_btn_enter"
android:textColor="@color/gray_200"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" />
Expand Down

0 comments on commit 7aef672

Please sign in to comment.