Skip to content

Commit

Permalink
[FEAT] write 파트 ui 구현 완료
Browse files Browse the repository at this point in the history
  • Loading branch information
NaZe0320 committed Jun 10, 2023
1 parent 7cc729f commit 6f663a1
Show file tree
Hide file tree
Showing 9 changed files with 250 additions and 35 deletions.
42 changes: 42 additions & 0 deletions app/src/main/java/com/nbit/Idear/write/ProfileAdapter.kt
Original file line number Diff line number Diff line change
@@ -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<ProfileData>, private val buttonClickListener: () -> Unit): RecyclerView.Adapter<ProfileAdapter.ViewHolder>() {

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
)
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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!!

Expand All @@ -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()
}

Expand All @@ -54,5 +64,9 @@ class WriteSecondPrivateFragment : Fragment() {
_binding = null
}

private fun onNextButton() {
binding.btnNext.isEnabled = (next > 0)
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ class WriteSecondPublicFragment : Fragment() {
// 버튼 클릭 이벤트 처리
//데이터 처리
if (selected) {
next ++
} else {
next --
} else {
next ++
}
onNextButton()
Toast.makeText(context,"클릭한 버튼: $buttonText",Toast.LENGTH_SHORT).show()
Expand Down Expand Up @@ -63,7 +63,7 @@ class WriteSecondPublicFragment : Fragment() {
_binding = null
}
private fun onNextButton() {
binding.btnNext.isEnabled = (next != 0)
binding.btnNext.isEnabled = (next > 0)
}


Expand Down
22 changes: 22 additions & 0 deletions app/src/main/java/com/nbit/Idear/write/WriteThirdFragment.kt
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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>(
ProfileData("깔끔한","ESTJ","반말"),
ProfileData("까칠한","INTJ","반말"),
ProfileData("귀여운","ENFP","존댓말"),
)
val adapter = ProfileAdapter(itemList) {
//버튼 클릭 (수정하기)
}
binding.rvProfile.layoutManager = LinearLayoutManager(context)
binding.rvProfile.adapter = adapter

return binding.root
}

Expand All @@ -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)
}

}
5 changes: 5 additions & 0 deletions app/src/main/res/drawable/shape_select_profile.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<corners android:radius="8dp" />
<stroke android:color="@color/idear_green" android:width="1dp" />
</shape>
6 changes: 6 additions & 0 deletions app/src/main/res/drawable/shape_unselect_profile.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<corners android:radius="8dp" />
<solid android:color="@color/white"/>
<stroke android:color="@color/idear_gray_200" android:width="1dp" />
</shape>
75 changes: 43 additions & 32 deletions app/src/main/res/layout/fragment_write_second_private.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,42 +6,43 @@
android:layout_height="match_parent"
android:background="@color/white"
tools:context=".write.WriteSecondPrivateFragment">

<LinearLayout
android:id="@+id/indicator"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginHorizontal="10dp"
android:layout_marginTop="8dp"
android:orientation="horizontal"
app:layout_constraintTop_toTopOf="parent">

<androidx.constraintlayout.utils.widget.ImageFilterView
android:layout_width="0dp"
android:layout_height="7dp"
android:layout_weight="1"
android:layout_marginHorizontal="2dp"
android:src="@drawable/ic_indicator_after"/>
android:layout_weight="1"
android:src="@drawable/ic_indicator_after" />

<androidx.constraintlayout.utils.widget.ImageFilterView
android:layout_width="0dp"
android:layout_height="7dp"
android:layout_weight="1"
android:layout_marginHorizontal="2dp"
android:src="@drawable/ic_indicator_selector"/>
android:layout_weight="1"
android:src="@drawable/ic_indicator_selector" />

<androidx.constraintlayout.utils.widget.ImageFilterView
android:layout_width="0dp"
android:layout_height="7dp"
android:layout_weight="1"
android:layout_marginHorizontal="2dp"
android:src="@drawable/ic_indicator_before"/>
android:layout_weight="1"
android:src="@drawable/ic_indicator_before" />

<androidx.constraintlayout.utils.widget.ImageFilterView
android:layout_width="0dp"
android:layout_height="7dp"
android:layout_weight="1"
android:layout_marginHorizontal="2dp"
android:src="@drawable/ic_indicator_before"/>
android:layout_weight="1"
android:src="@drawable/ic_indicator_before" />

</LinearLayout>

Expand All @@ -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" />

<TextView
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginHorizontal="16dp"
android:layout_marginTop="40dp"
android:text="메시지에 대한 키워드를 고르고\n추가적인 정보를 입력해주세요."
android:textColor="@color/black"
android:textSize="20sp"
android:textStyle="bold"
android:layout_margin="16dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintBottom_toTopOf="@+id/tv_keyword"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintTop_toBottomOf="@+id/btn_back"
app:layout_constraintVertical_bias="0.15" />

<TextView
android:id="@+id/tv_keyword"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="16dp"
android:text="키워드 설정"
android:textColor="@color/idear_gray_900"
android:textSize="14sp"
android:textStyle="bold"
android:layout_margin="16dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
Expand All @@ -86,66 +90,73 @@
android:id="@+id/rv_keyword"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginVertical="12dp"
android:layout_marginHorizontal="16dp"
android:layout_marginVertical="12dp"
app:layout_constraintTop_toBottomOf="@id/tv_keyword" />

<TextView
android:id="@+id/tv_info"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginHorizontal="16dp"
android:layout_marginTop="60dp"
android:text="정보 입력"
android:textColor="@color/idear_gray_900"
android:textSize="14sp"
android:textStyle="bold"
android:layout_marginHorizontal="16dp"
android:layout_marginTop="60dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/rv_keyword" />

<EditText
android:id="@+id/et_info"
android:layout_width="match_parent"
android:layout_height="44dp"
android:layout_marginVertical="12dp"
android:layout_marginHorizontal="16dp"
android:layout_marginVertical="12dp"
android:background="@drawable/shape_et_back"
android:hint="부가 정보를 입력하세요."
android:paddingHorizontal="12dp"
android:textColor="@color/idear_gray_900"
android:textColorHint="@color/idear_gray_600"
android:textSize="14sp"
android:textColor="@color/idear_gray_900"
android:paddingHorizontal="12dp"
app:layout_constraintTop_toBottomOf="@+id/tv_info"/>

app:layout_constraintTop_toBottomOf="@+id/tv_info" />

<androidx.constraintlayout.utils.widget.ImageFilterView
android:id="@+id/iv_warning"
android:layout_width="16dp"
android:layout_height="16dp"
android:src="@drawable/ic_alert"
android:layout_marginHorizontal="12dp"
android:layout_marginVertical="8dp"
android:src="@drawable/ic_alert"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/et_info"/>
app:layout_constraintTop_toBottomOf="@id/et_info" />

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@color/idear_gray_500"
android:text="호칭이나 요구사항을 넣어 더 좋은 글을 작성할 수 있어요."
android:layout_marginHorizontal="12dp"
android:layout_marginVertical="8dp"
android:text="호칭이나 요구사항을 넣어 더 좋은 글을 작성할 수 있어요."
android:textColor="@color/idear_gray_500"
app:layout_constraintStart_toEndOf="@id/iv_warning"
app:layout_constraintTop_toBottomOf="@id/et_info" />

<androidx.appcompat.widget.AppCompatButton
android:id="@+id/btn_next"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="다음"
android:textColor="@color/selector_next_btn_text"
android:background="@drawable/selector_next_btn"
android:layout_height="40dp"
android:layout_margin="16dp"
android:background="@drawable/selector_next_btn"
android:enabled="false"
app:layout_constraintBottom_toBottomOf="parent"/>
android:text="다음"
android:textColor="@color/selector_next_btn_text"
app:layout_constraintBottom_toBottomOf="parent" />

<androidx.constraintlayout.widget.Guideline
android:id="@+id/guideline2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
app:layout_constraintGuide_end="48dp" />

</androidx.constraintlayout.widget.ConstraintLayout>
Loading

0 comments on commit 6f663a1

Please sign in to comment.