Skip to content

Commit

Permalink
Merge pull request #18 from ttoklip/faet/#2_마이페이지_구현
Browse files Browse the repository at this point in the history
Faet/#2 마이페이지 UI 중간 병합
  • Loading branch information
posite authored Jan 23, 2024
2 parents f33803d + 1f6cfbc commit 5dc06ca
Show file tree
Hide file tree
Showing 65 changed files with 3,695 additions and 96 deletions.
16 changes: 16 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@
android:supportsRtl="true"
android:theme="@style/Theme.Ttoklip"
tools:targetApi="31">

<activity
android:name=".presentation.mypage.ManageMyInfoActivity"
android:exported="false" />
<activity
android:name=".presentation.honeytip.read.ReadActivity"
android:exported="false" />
Expand All @@ -32,6 +36,18 @@
<activity
android:name=".presentation.news.detail.ArticleActivity"
android:exported="false" />
<activity
android:name=".presentation.mypage.SetAnnouncementActivity"
android:exported="false" />
<activity
android:name=".presentation.mypage.ManageUsageActivity"
android:exported="false" />
<activity
android:name=".presentation.mypage.MyHometownAddressActivity"
android:exported="false" />
<activity
android:name=".presentation.mypage.ManageAccountActivity"
android:exported="false" />
<activity
android:name=".presentation.MainActivity"
android:exported="true">
Expand Down
60 changes: 0 additions & 60 deletions app/src/main/java/com/umc/ttoklip/presentation/MyFragment.kt

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package com.umc.ttoklip.presentation.base

import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.annotation.LayoutRes
import androidx.databinding.DataBindingUtil
import androidx.databinding.ViewDataBinding
import com.google.android.material.bottomsheet.BottomSheetDialogFragment

abstract class BaseBottomSheetDialogFragment<V : ViewDataBinding>(@LayoutRes val layoutResource: Int) :
BottomSheetDialogFragment() {
private var _binding: V? = null
protected val binding: V get() = _binding!!
abstract fun initObserver()
abstract fun initView()

override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
): View {
_binding = DataBindingUtil.inflate(
layoutInflater,
layoutResource,
null,
false
)
binding.lifecycleOwner = this
return binding.root
}

override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
initObserver()
initView()
}

override fun onDestroyView() {
super.onDestroyView()
_binding = null
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
package com.umc.ttoklip.presentation.mypage

import android.util.Log
import com.google.android.material.chip.Chip
import com.umc.ttoklip.R
import com.umc.ttoklip.databinding.FragmentChooseMainInterestBinding
import com.umc.ttoklip.presentation.base.BaseBottomSheetDialogFragment
import dagger.hilt.android.AndroidEntryPoint

@AndroidEntryPoint
class ChooseMainInterestDialogFragment(private val btnClickListener: (List<String>) -> Unit) :
BaseBottomSheetDialogFragment<FragmentChooseMainInterestBinding>(R.layout.fragment_choose_main_interest) {
private val interest = ArrayList<String>()
override fun initObserver() = Unit

override fun initView() {
with(binding) {
noInterestChip.setOnClickListener {
removeAllInterest()
}
houseworkChip.setOnClickListener {
changeInterest(houseworkChip)
}
cookingChip.setOnClickListener {
changeInterest(cookingChip)
}
safeLifeChip.setOnClickListener {
changeInterest(safeLifeChip)
}
fraudChip.setOnClickListener {
changeInterest(fraudChip)
}
welfarePolicyChip.setOnClickListener {
changeInterest(welfarePolicyChip)
}
chooseBtn.setOnClickListener {
if (interest.isNotEmpty()) {
btnClickListener(interest.toList())
dismiss()
}
}
}
}

private fun changeInterest(chip: Chip) {
Log.d("chip", chip.text.toString())
if (binding.noInterestChip.tag == YES_INTERESTING) {
removeInterest(binding.noInterestChip)
}
if (chip.tag == NOT_INTERESTING) {
addInterest(chip)
} else {
removeInterest(chip)
}
checkInterest()
}

private fun removeAllInterest() {
with(binding) {
if (noInterestChip.tag == NOT_INTERESTING) {
removeInterest(houseworkChip)
removeInterest(cookingChip)
removeInterest(safeLifeChip)
removeInterest(fraudChip)
removeInterest(welfarePolicyChip)
addInterest(noInterestChip)
} else {
removeInterest(noInterestChip)
}
}
checkInterest()
}

private fun addInterest(chip: Chip) {
chip.tag = YES_INTERESTING
chip.setChipBackgroundColorResource(R.color.yellow)
chip.setChipStrokeColorResource(R.color.yellow)
interest.add(chip.text.toString())
}

private fun removeInterest(chip: Chip) {
chip.tag = NOT_INTERESTING
chip.setChipBackgroundColorResource(R.color.white)
chip.setChipStrokeColorResource(R.color.gray40)
interest.remove(chip.text.toString())
}

private fun checkInterest() {
with(binding.chooseBtn) {
if (interest.isNotEmpty()) {
setBackgroundResource(R.drawable.yellow_btn_background)
setTextAppearance(R.style.TextAppearance_App_16sp_700)
} else {
setBackgroundResource(R.drawable.rectangle_corner_10_strok_1_black)
setTextAppearance(R.style.TextAppearance_App_16sp_500)
}
}

}

companion object {
private const val NOT_INTERESTING = "NO"
private const val YES_INTERESTING = "YES"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package com.umc.ttoklip.presentation.mypage

import android.os.Build
import android.view.ViewGroup.LayoutParams.WRAP_CONTENT
import android.widget.NumberPicker
import androidx.annotation.RequiresApi
import com.umc.ttoklip.R
import com.umc.ttoklip.databinding.FragmentInputIndependentCareerBinding
import com.umc.ttoklip.presentation.base.BaseBottomSheetDialogFragment
import dagger.hilt.android.AndroidEntryPoint

@AndroidEntryPoint
class InputIndependentCareerDialogFragment(private val btnClickListener: (Int, Int) -> Unit) :
BaseBottomSheetDialogFragment<FragmentInputIndependentCareerBinding>(R.layout.fragment_input_independent_career) {
override fun initObserver() = Unit

@RequiresApi(Build.VERSION_CODES.Q)
override fun initView() {
this@InputIndependentCareerDialogFragment.dialog?.window?.setLayout(
WRAP_CONTENT,
WRAP_CONTENT
)
with(binding.yearSelector) {
minValue = PERIOD_START
maxValue = YEAR_END
descendantFocusability = NumberPicker.FOCUS_BLOCK_DESCENDANTS
selectionDividerHeight = DIVIDER_HEIGHT_ZERO
}
with(binding.monthSelector) {
minValue = PERIOD_START
maxValue = MONTH_END
descendantFocusability = NumberPicker.FOCUS_BLOCK_DESCENDANTS
selectionDividerHeight = DIVIDER_HEIGHT_ZERO
}
binding.chooseBtn.setOnClickListener {
btnClickListener(binding.yearSelector.value, binding.monthSelector.value)
this@InputIndependentCareerDialogFragment.dismiss()
}
}

companion object {
private const val PERIOD_START = 0
private const val YEAR_END = 99
private const val MONTH_END = 12
private const val DIVIDER_HEIGHT_ZERO = 0
}
}
Loading

0 comments on commit 5dc06ca

Please sign in to comment.