-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[feat] 신규 단체 개설하기 뷰 구현 #199
Changes from 39 commits
a993e6d
351cbef
414853c
234ca5f
eccbf48
356b126
e11d66b
278e44d
d259ef7
461b4f9
ac7e697
d7c9856
f494d67
8b48fa2
0c2590a
b997abd
73890ba
4b82e40
f21c7b5
137049c
a2e0409
cdb2000
43875fc
0e151f0
b04de99
40fcd85
d5f8267
8667c7a
9139db1
29301a1
1b11ca6
70344e1
d3e6815
a0e6741
4459c5b
9c9d846
ac41292
e017d95
56b02b5
36a948a
d1c144e
ba7b829
ba06955
c335d47
99b0d07
6a8116b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 하지은 이제 나를 너무 잘 안다 무섭다 무서워 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ㄷ |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
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.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() | ||
) | ||
Comment on lines
+101
to
+105
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 쏘굿도리 ~ |
||
} | ||
} | ||
|
||
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,56 @@ | ||
package org.sopt.pingle.presentation.ui.newgroup | ||
|
||
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.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() | ||
finish() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. navigateHome에 finish가 있는ㄴ데 또 추가해야 하나용?? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 오옹 그러네요!? |
||
} | ||
} | ||
) | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package org.sopt.pingle.presentation.ui.newgroup | ||
|
||
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 | ||
|
||
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 | ||
|
||
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 | ||
|
||
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) | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package org.sopt.pingle.presentation.ui.newgroup | ||
|
||
import android.os.Bundle | ||
import android.view.View | ||
import com.google.android.material.chip.Chip | ||
import dagger.hilt.android.AndroidEntryPoint | ||
import org.sopt.pingle.R | ||
import org.sopt.pingle.databinding.FragmentNewGroupKeywordBinding | ||
import org.sopt.pingle.util.base.BindingFragment | ||
|
||
@AndroidEntryPoint | ||
class NewGroupKeywordFragment : | ||
BindingFragment<FragmentNewGroupKeywordBinding>(R.layout.fragment_new_group_keyword) { | ||
private val itemList = | ||
listOf(Item(1, "연합동아리"), Item(2, "교내동아리"), Item(3, "학생회"), Item(4, "대학교")) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 여기두 다 상수화할 수 있지 않을까용?! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 이거 나중에 서버통신으로 불러올 거라 ㄱㅊ을 듯요 !! |
||
|
||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { | ||
super.onViewCreated(view, savedInstanceState) | ||
|
||
initLayout() | ||
} | ||
|
||
private fun initLayout() { | ||
setChipKeyword() | ||
} | ||
|
||
private fun setChipKeyword() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 칩 spacing 처리 해주셨나요? 안 보여서 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. chip간의 간격은 xml 에서 |
||
binding.cgNewGroupKeyword.removeAllViews() | ||
|
||
for (item in itemList) { | ||
val chip = | ||
layoutInflater.inflate(R.layout.view_new_group_chip_keyword, null, false) as Chip | ||
chip.text = item.name | ||
chip.setOnCheckedChangeListener { _, isChecked -> | ||
when (isChecked) { | ||
true -> chip.setTextAppearance(R.style.TextAppearance_Pingle_Sub_Semi_16) | ||
false -> chip.setTextAppearance(R.style.TextAppearance_Pingle_Body_Med_16) | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 초기에 textAppearance 가 먹히지 않아서 처음에 칩 선택할 때 크기가 바뀌는 것 같아요 view_new_group_chip_keyword 여기에 있는 칩에 초기 textAppearance 값 추가해 주세요 |
||
} | ||
binding.cgNewGroupKeyword.addView(chip) | ||
} | ||
} | ||
|
||
// TODO Api연결시 response로 변경 예정 | ||
data class Item(val id: Int, val name: String) | ||
} |
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 | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
단체 정보 확인 페이지에서 버튼 텍스트 바뀌는 로직 빠져있는 것 같습니다.