Skip to content

Commit

Permalink
Merge pull request #199 from TeamPINGLE/feat-new-group-view
Browse files Browse the repository at this point in the history
[feat] 신규 단체 개설하기 뷰 구현
  • Loading branch information
Doreminwoo authored Mar 1, 2024
2 parents 5be293b + 6a8116b commit 06ccaa4
Show file tree
Hide file tree
Showing 39 changed files with 1,166 additions and 17 deletions.
20 changes: 20 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,26 @@
android:exported="false"
android:screenOrientation="portrait"
tools:ignore="LockedOrientationActivity" />
<activity
android:name=".presentation.ui.newgroup.NewGroupActivity"
android:exported="false"
android:screenOrientation="portrait"
tools:ignore="LockedOrientationActivity" />
<activity
android:name=".presentation.ui.newgroup.newgroupinfo.NewGroupInfoActivity"
android:exported="false"
android:screenOrientation="portrait"
tools:ignore="LockedOrientationActivity" />
<activity
android:name=".presentation.ui.newgroup.newgroupannouncement.NewGroupAnnouncementActivity"
android:exported="false"
android:screenOrientation="portrait"
tools:ignore="LockedOrientationActivity" />
<activity
android:name=".presentation.ui.newgroup.newgroupcodeshare.NewGroupCodeShareActivity"
android:exported="false"
android:screenOrientation="portrait"
tools:ignore="LockedOrientationActivity" />
<activity
android:name=".presentation.ui.main.planannouncement.PlanAnnouncementActivity"
android:exported="false"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,9 @@ import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.onEach
import org.sopt.pingle.R
import org.sopt.pingle.databinding.ActivityJoinGroupSearchBinding
import org.sopt.pingle.presentation.ui.onboarding.onboarding.OnboardingActivity
import org.sopt.pingle.presentation.ui.newgroup.NewGroupActivity
import org.sopt.pingle.util.base.BindingActivity
import org.sopt.pingle.util.context.hideKeyboard
import org.sopt.pingle.util.context.navigateToWebView
import org.sopt.pingle.util.view.UiState
import timber.log.Timber

Expand Down Expand Up @@ -66,7 +65,7 @@ class JoinGroupSearchActivity :
}

tvJoinGroupSearchCreate.setOnClickListener {
startActivity(navigateToWebView(OnboardingActivity.NEW_GROUP_LINK))
navigateToNewGroup()
}

btnJoinGroupCodeNext.setOnClickListener {
Expand Down Expand Up @@ -117,6 +116,12 @@ class JoinGroupSearchActivity :
}
}

private fun navigateToNewGroup() {
Intent(this, NewGroupActivity::class.java).apply {
startActivity(this)
}
}

override fun onDestroy() {
binding.rvJoinGroupSearch.adapter = null
super.onDestroy()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
package org.sopt.pingle.presentation.ui.newgroup

import android.app.ActivityOptions
import android.content.Intent
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 dagger.hilt.android.AndroidEntryPoint
import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.onEach
import org.sopt.pingle.R
import org.sopt.pingle.databinding.ActivityNewGroupBinding
import org.sopt.pingle.presentation.ui.newgroup.newgroupannouncement.NewGroupAnnouncementActivity
import org.sopt.pingle.presentation.ui.newgroup.newgroupcreate.NewGroupCreateFragment
import org.sopt.pingle.presentation.ui.newgroup.newgroupinfo.NewGroupInfoActivity
import org.sopt.pingle.presentation.ui.newgroup.newgroupinput.NewGroupInputFragment
import org.sopt.pingle.presentation.ui.newgroup.newgroupkeyword.NewGroupKeywordFragment
import org.sopt.pingle.util.base.BindingActivity
import org.sopt.pingle.util.context.stringOf
import org.sopt.pingle.util.view.PingleFragmentStateAdapter

@AndroidEntryPoint
class NewGroupActivity : BindingActivity<ActivityNewGroupBinding>(R.layout.activity_new_group) {
private val viewModel: NewGroupViewModel by viewModels()
private lateinit var fragmentList: ArrayList<Fragment>

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)

initLayout()
addListeners()
collectData()
}

private fun initLayout() {
navigateToNewGroupInfo()
setPlanFragmentStateAdapter()
}

private fun addListeners() {
binding.btnNewGroupNext.setOnClickListener {
when (binding.vpNewGroup.currentItem) {
fragmentList.size - LAST_INDEX_OFFSET -> {
navigateToNewGroupAnnouncement()
finish()
}

else -> binding.vpNewGroup.currentItem++
}
}

binding.includeNewGroupTopbar.ivAllTopbarArrowWithTitleArrowLeft.setOnClickListener {
navigateToPreviousPage()
}

binding.ivNewGroupTopbarInfo.setOnClickListener {
navigateToNewGroupInfo()
}
}

private fun collectData() {
viewModel.currentPage.flowWithLifecycle(lifecycle).onEach { currentPage ->
when (currentPage) {
fragmentList.size - LAST_INDEX_OFFSET ->
binding.btnNewGroupNext.text =
stringOf(R.string.new_group_create)

else -> binding.btnNewGroupNext.text = stringOf(R.string.new_group_next)
}
}.launchIn(lifecycleScope)
}

private fun setPlanFragmentStateAdapter() {
fragmentList = ArrayList()
fragmentList.apply {
add(NewGroupInputFragment())
add(NewGroupKeywordFragment())
add(NewGroupCreateFragment())
}

val adapter = PingleFragmentStateAdapter(fragmentList, this)
with(binding.vpNewGroup) {
this.adapter = adapter
isUserInputEnabled = false

registerOnPageChangeCallback(object :
ViewPager2.OnPageChangeCallback() {
override fun onPageSelected(position: Int) {
super.onPageSelected(position)
viewModel.setCurrentPage(position)
}
})
}
}

private fun navigateToNewGroupInfo() {
Intent(this, NewGroupInfoActivity::class.java).apply {
startActivity(
this,
ActivityOptions.makeCustomAnimation(this@NewGroupActivity, R.anim.slide_up, 0)
.toBundle()
)
}
}

private fun navigateToNewGroupAnnouncement() {
Intent(this, NewGroupAnnouncementActivity::class.java).apply {
startActivity(this)
}
}

private fun navigateToPreviousPage() {
when (binding.vpNewGroup.currentItem) {
FIRST_PAGE -> finish()
else -> binding.vpNewGroup.currentItem--
}
}

companion object {
const val FIRST_PAGE = 0
const val LAST_INDEX_OFFSET = 1
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package org.sopt.pingle.presentation.ui.newgroup

import androidx.lifecycle.ViewModel
import dagger.hilt.android.lifecycle.HiltViewModel
import javax.inject.Inject
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.asStateFlow

@HiltViewModel
class NewGroupViewModel @Inject constructor() : 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
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
package org.sopt.pingle.presentation.ui.newgroup.newgroupannouncement

import android.content.Intent
import android.os.Bundle
import androidx.activity.OnBackPressedCallback
import dagger.hilt.android.AndroidEntryPoint
import org.sopt.pingle.R
import org.sopt.pingle.databinding.ActivityNewGroupAnnouncementBinding
import org.sopt.pingle.presentation.ui.main.MainActivity
import org.sopt.pingle.presentation.ui.newgroup.newgroupcodeshare.NewGroupCodeShareActivity
import org.sopt.pingle.util.base.BindingActivity

@AndroidEntryPoint
class NewGroupAnnouncementActivity :
BindingActivity<ActivityNewGroupAnnouncementBinding>(R.layout.activity_new_group_announcement) {

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)

addListeners()
}

private fun addListeners() {
onBackPressedCallBack()
binding.btnNewGroupAnnouncementInvitation.setOnClickListener {
navigateToNewGroupShare()
}
binding.tvNewGroupAnnouncementHome.setOnClickListener {
navigateToHome()
}
}

private fun navigateToNewGroupShare() {
Intent(this, NewGroupCodeShareActivity::class.java).apply {
startActivity(this)
}
}

private fun navigateToHome() {
Intent(this, MainActivity::class.java).apply {
startActivity(this)
finish()
}
}

private fun onBackPressedCallBack() {
onBackPressedDispatcher.addCallback(
this,
object : OnBackPressedCallback(true) {
override fun handleOnBackPressed() {
navigateToHome()
}
}
)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package org.sopt.pingle.presentation.ui.newgroup.newgroupcodeshare

import android.os.Bundle
import dagger.hilt.android.AndroidEntryPoint
import org.sopt.pingle.R
import org.sopt.pingle.databinding.ActivityNewGroupCodeShareBinding
import org.sopt.pingle.util.base.BindingActivity

@AndroidEntryPoint
class NewGroupCodeShareActivity :
BindingActivity<ActivityNewGroupCodeShareBinding>(R.layout.activity_new_group_code_share) {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)

initLayout()
addListeners()
}

private fun initLayout() {
binding.etNewGroupCodeShareCode.editText.isEnabled = false
}

private fun addListeners() {
binding.includeNewGroupCodeShareTopbar.ivAllTopbarArrowWithTitleArrowLeft.setOnClickListener {
finish()
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package org.sopt.pingle.presentation.ui.newgroup.newgroupcreate

import android.os.Bundle
import android.view.View
import dagger.hilt.android.AndroidEntryPoint
import org.sopt.pingle.R
import org.sopt.pingle.databinding.FragmentNewGroupCreateBinding
import org.sopt.pingle.util.base.BindingFragment

@AndroidEntryPoint
class NewGroupCreateFragment :
BindingFragment<FragmentNewGroupCreateBinding>(R.layout.fragment_new_group_create) {

override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package org.sopt.pingle.presentation.ui.newgroup.newgroupinfo

import android.os.Bundle
import dagger.hilt.android.AndroidEntryPoint
import org.sopt.pingle.R
import org.sopt.pingle.databinding.ActivityNewGroupInfoBinding
import org.sopt.pingle.util.base.BindingActivity

@AndroidEntryPoint
class NewGroupInfoActivity :
BindingActivity<ActivityNewGroupInfoBinding>(R.layout.activity_new_group_info) {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)

addListeners()
}

private fun addListeners() {
binding.ivNewGroupInfoX.setOnClickListener {
finish()
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package org.sopt.pingle.presentation.ui.newgroup.newgroupinput

import android.os.Bundle
import android.view.View
import dagger.hilt.android.AndroidEntryPoint
import org.sopt.pingle.R
import org.sopt.pingle.databinding.FragmentNewGroupInputBinding
import org.sopt.pingle.util.base.BindingFragment

@AndroidEntryPoint
class NewGroupInputFragment :
BindingFragment<FragmentNewGroupInputBinding>(R.layout.fragment_new_group_input) {
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
}
}
Loading

0 comments on commit 06ccaa4

Please sign in to comment.