Skip to content

Commit

Permalink
Merge pull request #27 from TeamPINGLE/feat-plan-view
Browse files Browse the repository at this point in the history
[feat] 핑글 개최 프로세스 전체 뷰 구현
  • Loading branch information
Dan2dani authored Jan 5, 2024
2 parents 7581e12 + 94aea55 commit ddc22d0
Show file tree
Hide file tree
Showing 11 changed files with 261 additions and 10 deletions.
Original file line number Diff line number Diff line change
@@ -1,13 +1,89 @@
package org.sopt.pingle.presentation.ui.main.plan

import android.os.Bundle
import androidx.activity.viewModels
import androidx.fragment.app.Fragment
import androidx.lifecycle.flowWithLifecycle
import androidx.lifecycle.lifecycleScope
import androidx.viewpager2.widget.ViewPager2
import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.onEach
import org.sopt.pingle.R
import org.sopt.pingle.databinding.ActivityPlanBinding
import org.sopt.pingle.util.base.BindingActivity

class PlanActivity : BindingActivity<ActivityPlanBinding>(R.layout.activity_plan) {
private val planViewModel: PlanViewModel by viewModels()
private lateinit var fragmentList: ArrayList<Fragment>
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_plan)

setPlanFragmentStateAdapter()
addListeners()
collectData()
}

private fun setPlanFragmentStateAdapter() {
// TODO 차후에 나머지 개최 프로세스 fragment 추가
fragmentList = ArrayList()
fragmentList.apply {
add(PlanTitleFragment())
add(PlanDateTimeFragment())
add(PlanOpenChattingFragment())
}

val adapter = PlanFragmentStateAdapter(fragmentList, this)
with(binding.vpPlan) {
this.adapter = adapter
isUserInputEnabled = false
registerOnPageChangeCallback(object :
ViewPager2.OnPageChangeCallback() {
override fun onPageSelected(position: Int) {
super.onPageSelected(position)
planViewModel.setCurrentPage(position)
}
})
}
}

private fun addListeners() {
binding.btnPlan.setOnClickListener {
when (binding.vpPlan.currentItem) {
// TODO 핑글 개최 api 연동
fragmentList.size - 1 -> {}
else -> {
binding.vpPlan.currentItem++
}
}
}
binding.toolbar.ivAllTopbarArrowWithTitleArrowLeft.setOnClickListener {
when (binding.vpPlan.currentItem) {
0 -> {
// TODO 나가기 확인 모달
}

else -> {
binding.vpPlan.currentItem--
}
}
}
binding.tvPlanClose.setOnClickListener {
// TODO 나가기 확인 모달
}
}

private fun collectData() {
planViewModel.currentPage.flowWithLifecycle(lifecycle).onEach { currentPage ->
when (currentPage) {
fragmentList.size - 1 -> {
binding.btnPlan.text = getString(R.string.plan_pingle)
}

// TODO 다른 다음으로 스트링과 합치기
else -> {
binding.btnPlan.text = getString(R.string.plan_next)
}
}
}.launchIn(lifecycleScope)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package org.sopt.pingle.presentation.ui.main.plan

import android.os.Bundle
import android.view.View
import org.sopt.pingle.R
import org.sopt.pingle.databinding.FragmentPlanDateTimeBinding
import org.sopt.pingle.util.base.BindingFragment

class PlanDateTimeFragment : BindingFragment<FragmentPlanDateTimeBinding>(R.layout.fragment_plan_date_time) {
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package org.sopt.pingle.presentation.ui.main.plan

import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentActivity
import androidx.viewpager2.adapter.FragmentStateAdapter

class PlanFragmentStateAdapter(
private val fragmentList: ArrayList<Fragment>,
fragmentActivity: FragmentActivity
) : FragmentStateAdapter(fragmentActivity) {
override fun getItemCount(): Int = fragmentList.size
override fun createFragment(position: Int): Fragment {
return fragmentList[position]
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package org.sopt.pingle.presentation.ui.main.plan

import android.os.Bundle
import android.view.View
import org.sopt.pingle.R
import org.sopt.pingle.databinding.FragmentPlanOpenChattingBinding
import org.sopt.pingle.util.base.BindingFragment

class PlanOpenChattingFragment : BindingFragment<FragmentPlanOpenChattingBinding>(R.layout.fragment_plan_open_chatting) {
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package org.sopt.pingle.presentation.ui.main.plan

import android.os.Bundle
import android.view.View
import org.sopt.pingle.R
import org.sopt.pingle.databinding.FragmentPlanTitleBinding
import org.sopt.pingle.util.base.BindingFragment

class PlanTitleFragment : BindingFragment<FragmentPlanTitleBinding>(R.layout.fragment_plan_title) {
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package org.sopt.pingle.presentation.ui.main.plan

import androidx.lifecycle.ViewModel
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.asStateFlow

class PlanViewModel : ViewModel() {
private val _currentPage = MutableStateFlow(FIRST_PAGE_POSITION)
val currentPage get() = _currentPage.asStateFlow()

fun setCurrentPage(position: Int) {
_currentPage.value = position
}

companion object {
const val FIRST_PAGE_POSITION = 0
}
}
76 changes: 67 additions & 9 deletions app/src/main/res/layout/activity_plan.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,77 @@

<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".presentation.ui.main.plan.PlanActivity">
android:layout_height="match_parent">

<TextView
<include
android:id="@+id/toolbar"
layout="@layout/view_all_topbar_arrow_with_title" />

<androidx.constraintlayout.widget.Guideline
android:id="@+id/gl_start"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
app:layout_constraintGuide_begin="@dimen/spacing16" />

<androidx.constraintlayout.widget.Guideline
android:id="@+id/gl_end"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="핑글 개최 프로세스"
android:textAppearance="@style/TextAppearance.Pingle.Title.Semi.32"
android:textColor="@color/white"
android:orientation="vertical"
app:layout_constraintGuide_end="@dimen/spacing16" />

<androidx.viewpager2.widget.ViewPager2
android:id="@+id/vp_plan"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginTop="37dp"
android:layout_marginBottom="16dp"
app:layout_constraintBottom_toTopOf="@+id/btn_plan"
app:layout_constraintEnd_toEndOf="@id/gl_end"
app:layout_constraintStart_toStartOf="@id/gl_start"
app:layout_constraintTop_toBottomOf="@id/toolbar" />

<com.google.android.material.button.MaterialButton
android:id="@+id/btn_plan"
style="@style/Theme.Pingle.Button.L"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/spacing12"
android:backgroundTint="@color/g_08"
android:textColor="@color/g_10"
app:layout_constraintBottom_toTopOf="@+id/layout_close"
app:layout_constraintEnd_toEndOf="@id/gl_end"
app:layout_constraintStart_toStartOf="@id/gl_start"
tools:text="다음으로" />

<LinearLayout
android:id="@+id/layout_close"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/spacing20"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
app:layout_constraintEnd_toEndOf="@id/gl_end"
app:layout_constraintStart_toStartOf="@id/gl_start">

<TextView
android:id="@+id/tv_plan_later_des"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:text="@string/plan_later_des"
android:textAppearance="@style/TextAppearance.Pingle.Cap.Semi.12"
android:textColor="@color/g_06" />

<TextView
android:id="@+id/tv_plan_close"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingHorizontal="4dp"
android:paddingVertical="5dp"
android:text="@string/plan_close"
android:textAppearance="@style/TextAppearance.Pingle.Cap.Semi.12"
android:textColor="@color/g_06" />
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
</layout>
13 changes: 13 additions & 0 deletions app/src/main/res/layout/fragment_plan_date_time.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android">

<data>

</data>

<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">

</androidx.constraintlayout.widget.ConstraintLayout>
</layout>
13 changes: 13 additions & 0 deletions app/src/main/res/layout/fragment_plan_open_chatting.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android">

<data>

</data>

<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">

</androidx.constraintlayout.widget.ConstraintLayout>
</layout>
13 changes: 13 additions & 0 deletions app/src/main/res/layout/fragment_plan_title.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android">

<data>

</data>

<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">

</androidx.constraintlayout.widget.ConstraintLayout>
</layout>
6 changes: 6 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@
<string name="on_boarding_original_group">기존 단체\n입장하기</string>
<string name="on_boarding_new_group">신규 단체\n개설하기</string>

<!-- plan -->
<string name="plan_later_des">나중에 만드시겠어요?</string>
<string name="plan_close"><u>나가기</u></string>
<string name="plan_next">다음으로</string>
<string name="plan_pingle">핑글 개최하기</string>

<!-- join group success -->
<string name="join_group_success_btn">입장하기</string>
<string name="join_gorup_success_title">단체 입장\n완료!</string>
Expand Down

0 comments on commit ddc22d0

Please sign in to comment.