-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #199 from TeamPINGLE/feat-new-group-view
[feat] 신규 단체 개설하기 뷰 구현
- Loading branch information
Showing
39 changed files
with
1,166 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
126 changes: 126 additions & 0 deletions
126
app/src/main/java/org/sopt/pingle/presentation/ui/newgroup/NewGroupActivity.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
app/src/main/java/org/sopt/pingle/presentation/ui/newgroup/NewGroupViewModel.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} | ||
} |
56 changes: 56 additions & 0 deletions
56
...sopt/pingle/presentation/ui/newgroup/newgroupannouncement/NewGroupAnnouncementActivity.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() | ||
} | ||
} | ||
) | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
...a/org/sopt/pingle/presentation/ui/newgroup/newgroupcodeshare/NewGroupCodeShareActivity.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() | ||
} | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
...in/java/org/sopt/pingle/presentation/ui/newgroup/newgroupcreate/NewGroupCreateFragment.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
...c/main/java/org/sopt/pingle/presentation/ui/newgroup/newgroupinfo/NewGroupInfoActivity.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() | ||
} | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
...main/java/org/sopt/pingle/presentation/ui/newgroup/newgroupinput/NewGroupInputFragment.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
} | ||
} |
Oops, something went wrong.