From 6f663a14d3b4da9f7e610c8fa868e503ce9de8d7 Mon Sep 17 00:00:00 2001 From: NaZe0320 Date: Sun, 11 Jun 2023 03:19:44 +0900 Subject: [PATCH] =?UTF-8?q?[FEAT]=20write=20=ED=8C=8C=ED=8A=B8=20ui=20?= =?UTF-8?q?=EA=B5=AC=ED=98=84=20=EC=99=84=EB=A3=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/nbit/Idear/write/ProfileAdapter.kt | 42 +++++++++++ .../Idear/write/WriteSecondPrivateFragment.kt | 14 ++++ .../Idear/write/WriteSecondPublicFragment.kt | 6 +- .../nbit/Idear/write/WriteThirdFragment.kt | 22 ++++++ .../res/drawable/shape_select_profile.xml | 5 ++ .../res/drawable/shape_unselect_profile.xml | 6 ++ .../layout/fragment_write_second_private.xml | 75 +++++++++++-------- .../main/res/layout/fragment_write_third.xml | 48 ++++++++++++ .../main/res/layout/item_profile_list2.xml | 67 +++++++++++++++++ 9 files changed, 250 insertions(+), 35 deletions(-) create mode 100644 app/src/main/java/com/nbit/Idear/write/ProfileAdapter.kt create mode 100644 app/src/main/res/drawable/shape_select_profile.xml create mode 100644 app/src/main/res/drawable/shape_unselect_profile.xml create mode 100644 app/src/main/res/layout/item_profile_list2.xml diff --git a/app/src/main/java/com/nbit/Idear/write/ProfileAdapter.kt b/app/src/main/java/com/nbit/Idear/write/ProfileAdapter.kt new file mode 100644 index 0000000..cdf80a0 --- /dev/null +++ b/app/src/main/java/com/nbit/Idear/write/ProfileAdapter.kt @@ -0,0 +1,42 @@ +package com.nbit.Idear.write + +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import android.widget.Button +import android.widget.TextView +import androidx.recyclerview.widget.RecyclerView +import com.nbit.Idear.R + +class ProfileAdapter(private val profileList: List, private val buttonClickListener: () -> Unit): RecyclerView.Adapter() { + + override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder { + val view = LayoutInflater.from(parent.context).inflate(R.layout.item_profile_list2, parent, false) + return ViewHolder(view) + } + + override fun onBindViewHolder(holder: ViewHolder, position: Int) { + val text = profileList[position] + + holder.tvProfile.text = "${text.mood} ${text.mbti} (${text.formal})" + + holder.btnEditProfile.setOnClickListener { + buttonClickListener.invoke() + } + } + + override fun getItemCount(): Int { + return profileList.size + } + + class ViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) { + val btnEditProfile: Button = itemView.findViewById(R.id.btn_edit_profile) + val tvProfile: TextView = itemView.findViewById(R.id.tv_profile) + } +} + +data class ProfileData( + var mood: String, + var mbti: String, + var formal: String +) \ No newline at end of file diff --git a/app/src/main/java/com/nbit/Idear/write/WriteSecondPrivateFragment.kt b/app/src/main/java/com/nbit/Idear/write/WriteSecondPrivateFragment.kt index 00b6138..4f4314a 100644 --- a/app/src/main/java/com/nbit/Idear/write/WriteSecondPrivateFragment.kt +++ b/app/src/main/java/com/nbit/Idear/write/WriteSecondPrivateFragment.kt @@ -1,6 +1,7 @@ package com.nbit.Idear.write import android.os.Bundle +import android.util.Log import androidx.fragment.app.Fragment import android.view.LayoutInflater import android.view.View @@ -18,6 +19,8 @@ class WriteSecondPrivateFragment : Fragment() { private lateinit var flexBoxAdapter: FlexBoxAdapter + private var next: Int = 0 + private var _binding: FragmentWriteSecondPrivateBinding? = null private val binding get() = _binding!! @@ -28,6 +31,13 @@ class WriteSecondPrivateFragment : Fragment() { flexBoxAdapter = FlexBoxAdapter(buttonTextList) { buttonText, selected -> // 버튼 클릭 이벤트 처리 //데이터 처리 + if (selected) { + next -- + } else { + next ++ + } + onNextButton() + Log.d("TEST","$next") Toast.makeText(context,"클릭한 버튼: $buttonText",Toast.LENGTH_SHORT).show() } @@ -54,5 +64,9 @@ class WriteSecondPrivateFragment : Fragment() { _binding = null } + private fun onNextButton() { + binding.btnNext.isEnabled = (next > 0) + } + } \ No newline at end of file diff --git a/app/src/main/java/com/nbit/Idear/write/WriteSecondPublicFragment.kt b/app/src/main/java/com/nbit/Idear/write/WriteSecondPublicFragment.kt index 2339aa0..10c1966 100644 --- a/app/src/main/java/com/nbit/Idear/write/WriteSecondPublicFragment.kt +++ b/app/src/main/java/com/nbit/Idear/write/WriteSecondPublicFragment.kt @@ -33,9 +33,9 @@ class WriteSecondPublicFragment : Fragment() { // 버튼 클릭 이벤트 처리 //데이터 처리 if (selected) { - next ++ - } else { next -- + } else { + next ++ } onNextButton() Toast.makeText(context,"클릭한 버튼: $buttonText",Toast.LENGTH_SHORT).show() @@ -63,7 +63,7 @@ class WriteSecondPublicFragment : Fragment() { _binding = null } private fun onNextButton() { - binding.btnNext.isEnabled = (next != 0) + binding.btnNext.isEnabled = (next > 0) } diff --git a/app/src/main/java/com/nbit/Idear/write/WriteThirdFragment.kt b/app/src/main/java/com/nbit/Idear/write/WriteThirdFragment.kt index ee3c0b1..8930316 100644 --- a/app/src/main/java/com/nbit/Idear/write/WriteThirdFragment.kt +++ b/app/src/main/java/com/nbit/Idear/write/WriteThirdFragment.kt @@ -1,11 +1,14 @@ package com.nbit.Idear.write +import android.content.Context import android.os.Bundle import androidx.fragment.app.Fragment import android.view.LayoutInflater import android.view.View import android.view.ViewGroup +import android.view.inputmethod.InputMethodManager import android.widget.Toast +import androidx.recyclerview.widget.LinearLayoutManager import com.google.android.flexbox.FlexDirection import com.google.android.flexbox.FlexWrap import com.google.android.flexbox.FlexboxLayoutManager @@ -29,12 +32,26 @@ class WriteThirdFragment : Fragment() { override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { _binding = FragmentWriteThirdBinding.inflate(inflater, container, false) + hideKeyboard() + binding.btnNext.setOnClickListener { parentFragmentManager.beginTransaction() .add(R.id.fl_write, WriteFourthFragment()) .addToBackStack("Write") .commit() } + + val itemList = listOf( + ProfileData("깔끔한","ESTJ","반말"), + ProfileData("까칠한","INTJ","반말"), + ProfileData("귀여운","ENFP","존댓말"), + ) + val adapter = ProfileAdapter(itemList) { + //버튼 클릭 (수정하기) + } + binding.rvProfile.layoutManager = LinearLayoutManager(context) + binding.rvProfile.adapter = adapter + return binding.root } @@ -43,5 +60,10 @@ class WriteThirdFragment : Fragment() { _binding = null } + private fun hideKeyboard() { + val inputMethodManager = + requireContext().getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager + inputMethodManager.hideSoftInputFromWindow(view?.windowToken, 0) + } } \ No newline at end of file diff --git a/app/src/main/res/drawable/shape_select_profile.xml b/app/src/main/res/drawable/shape_select_profile.xml new file mode 100644 index 0000000..b91ed6d --- /dev/null +++ b/app/src/main/res/drawable/shape_select_profile.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/shape_unselect_profile.xml b/app/src/main/res/drawable/shape_unselect_profile.xml new file mode 100644 index 0000000..e7fcc9e --- /dev/null +++ b/app/src/main/res/drawable/shape_unselect_profile.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_write_second_private.xml b/app/src/main/res/layout/fragment_write_second_private.xml index 38caf40..eea8600 100644 --- a/app/src/main/res/layout/fragment_write_second_private.xml +++ b/app/src/main/res/layout/fragment_write_second_private.xml @@ -6,42 +6,43 @@ android:layout_height="match_parent" android:background="@color/white" tools:context=".write.WriteSecondPrivateFragment"> + + android:layout_weight="1" + android:src="@drawable/ic_indicator_after" /> + android:layout_weight="1" + android:src="@drawable/ic_indicator_selector" /> + android:layout_weight="1" + android:src="@drawable/ic_indicator_before" /> + android:layout_weight="1" + android:src="@drawable/ic_indicator_before" /> @@ -50,33 +51,36 @@ android:layout_width="20dp" android:layout_height="20dp" android:layout_margin="16dp" - android:src="@drawable/ic_back_arrow" android:background="@android:color/transparent" + android:src="@drawable/ic_back_arrow" + app:layout_constraintBottom_toTopOf="@+id/textView" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@+id/indicator" /> - + - + app:layout_constraintTop_toBottomOf="@+id/tv_info" /> + + app:layout_constraintTop_toBottomOf="@id/et_info" /> + android:text="다음" + android:textColor="@color/selector_next_btn_text" + app:layout_constraintBottom_toBottomOf="parent" /> + + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_write_third.xml b/app/src/main/res/layout/fragment_write_third.xml index a41614c..9bd0982 100644 --- a/app/src/main/res/layout/fragment_write_third.xml +++ b/app/src/main/res/layout/fragment_write_third.xml @@ -56,6 +56,54 @@ app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@+id/indicator" /> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file