Skip to content
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] 번개 개최뷰 - 제목, 오픈채팅뷰 구현 #49

Merged
merged 10 commits into from
Jan 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
<activity
android:name=".presentation.ui.main.plan.PlanActivity"
android:exported="false"
android:windowSoftInputMode="adjustNothing"
android:screenOrientation="portrait"
tools:ignore="LockedOrientationActivity" />

Expand Down
13 changes: 13 additions & 0 deletions app/src/main/java/org/sopt/pingle/presentation/type/PlanType.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package org.sopt.pingle.presentation.type

enum class PlanType(
val position: Int
) {
CATEGORY(0),
TITLE(1),
DATETIME(2),
LOCATION(3),
RECRUITMENT(4),
OPENCHATTING(5),
SUMMARY(6)
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class PlanActivity : BindingActivity<ActivityPlanBinding>(R.layout.activity_plan
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)

binding.viewModel = planViewModel
setPlanFragmentStateAdapter()
addListeners()
collectData()
Expand Down Expand Up @@ -78,7 +79,6 @@ class PlanActivity : BindingActivity<ActivityPlanBinding>(R.layout.activity_plan
fragmentList.size - 1 -> {
binding.btnPlan.text = getString(R.string.plan_pingle)
}

// TODO 다른 다음으로 스트링과 합치기
else -> {
binding.btnPlan.text = getString(R.string.plan_next)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,26 @@ package org.sopt.pingle.presentation.ui.main.plan

import android.os.Bundle
import android.view.View
import androidx.fragment.app.activityViewModels
import org.sopt.pingle.R
import org.sopt.pingle.databinding.FragmentPlanOpenChattingBinding
import org.sopt.pingle.util.base.BindingFragment
import org.sopt.pingle.util.context.hideKeyboard

class PlanOpenChattingFragment : BindingFragment<FragmentPlanOpenChattingBinding>(R.layout.fragment_plan_open_chatting) {
class PlanOpenChattingFragment :
BindingFragment<FragmentPlanOpenChattingBinding>(R.layout.fragment_plan_open_chatting) {
private val planViewModel: PlanViewModel by activityViewModels()
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)

binding.viewModel = planViewModel

addListeners()
}

private fun addListeners() {
binding.root.setOnClickListener {
requireActivity().hideKeyboard(it)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,25 @@ package org.sopt.pingle.presentation.ui.main.plan

import android.os.Bundle
import android.view.View
import androidx.fragment.app.activityViewModels
import org.sopt.pingle.R
import org.sopt.pingle.databinding.FragmentPlanTitleBinding
import org.sopt.pingle.util.base.BindingFragment
import org.sopt.pingle.util.context.hideKeyboard

class PlanTitleFragment : BindingFragment<FragmentPlanTitleBinding>(R.layout.fragment_plan_title) {
private val planViewModel: PlanViewModel by activityViewModels()
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)

binding.viewModel = planViewModel

addListeners()
}

private fun addListeners() {
binding.root.setOnClickListener {
requireActivity().hideKeyboard(it)
}
}
}
Original file line number Diff line number Diff line change
@@ -1,16 +1,36 @@
package org.sopt.pingle.presentation.ui.main.plan

import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.SharingStarted
import kotlinx.coroutines.flow.StateFlow
import kotlinx.coroutines.flow.asStateFlow
import kotlinx.coroutines.flow.combine
import kotlinx.coroutines.flow.stateIn
import org.sopt.pingle.presentation.type.PlanType

class PlanViewModel : ViewModel() {
private val _currentPage = MutableStateFlow(FIRST_PAGE_POSITION)
val currentPage get() = _currentPage.asStateFlow()
val planTitle = MutableStateFlow("")
private val _planDate = MutableStateFlow<String?>(null)
val planDate get() = _planDate.asStateFlow()
private val _selectedTimeType = MutableStateFlow<String?>(null)
val selectedTimeType get() = _selectedTimeType.asStateFlow()
val planOpenChattingLink = MutableStateFlow("")

// TODO Type에 맞게 수정(현재는 내가 맡은 부분 테스트를 위해 postion 값을 조정 및 임의 지정 해놓음
val isPlanBtnEnabled: StateFlow<Boolean> =
combine(
currentPage,
planTitle,
planOpenChattingLink
) { currentPage, planTitle, planOpenChattingLink ->
(currentPage == PlanType.TITLE.position - 1 && planTitle.isNotBlank()) ||
currentPage == 1 ||
(currentPage == 2 && planOpenChattingLink.isNotBlank())
}.stateIn(viewModelScope, SharingStarted.WhileSubscribed(), false)

fun setCurrentPage(position: Int) {
_currentPage.value = position
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import android.content.res.TypedArray
import android.util.AttributeSet
import android.view.LayoutInflater
import androidx.constraintlayout.widget.ConstraintLayout
import androidx.databinding.DataBindingComponent
import androidx.databinding.DataBindingUtil
import org.sopt.pingle.R
import org.sopt.pingle.databinding.EditTextPingleBinding
Expand All @@ -25,7 +24,7 @@ class PingleEditText @JvmOverloads constructor(
LayoutInflater.from(context),
R.layout.edit_text_pingle,
this,
true,
true
)
binding.view = this
val typedArray = context.obtainStyledAttributes(attrs, R.styleable.pingleEditText)
Expand All @@ -45,4 +44,4 @@ class PingleEditText @JvmOverloads constructor(
binding.etEditText.hint = hint
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,4 @@ object PingleEditTextReverseBinding {
fun getEtText(view: PingleEditText): String {
return view.editText.text.toString()
}
}
}
8 changes: 6 additions & 2 deletions app/src/main/res/layout/activity_plan.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@

<data>

<variable
name="viewModel"
type="org.sopt.pingle.presentation.ui.main.plan.PlanViewModel" />
</data>

<androidx.constraintlayout.widget.ConstraintLayout
Expand Down Expand Up @@ -46,8 +49,9 @@
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/spacing12"
android:backgroundTint="@color/g_08"
android:textColor="@color/g_10"
android:backgroundTint="@color/selector_all_btn_background"
android:enabled="@{viewModel.isPlanBtnEnabled}"
android:textColor="@color/selector_all_btn_text_color"
app:layout_constraintBottom_toTopOf="@+id/layout_close"
app:layout_constraintEnd_toEndOf="@id/gl_end"
app:layout_constraintStart_toStartOf="@id/gl_start"
Expand Down
28 changes: 27 additions & 1 deletion app/src/main/res/layout/fragment_plan_open_chatting.xml
Original file line number Diff line number Diff line change
@@ -1,13 +1,39 @@
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android">
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">

<data>

<variable
name="viewModel"
type="org.sopt.pingle.presentation.ui.main.plan.PlanViewModel" />
</data>

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

<TextView
android:id="@+id/tv_plan_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/spacing8"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

7인 듯요,,? 전체적으로 다 7인데 나중에 한 번 확인 부탁티비

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

머양 수정 전 뷰 보고 있었나봐용 ㅜ 8 맞네욤 쏘리 ㅜ

android:text="@string/plan_title"
android:textAppearance="@style/TextAppearance.Pingle.Title.Semi.24"
android:textColor="@color/white"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />

<org.sopt.pingle.util.component.PingleEditText
android:id="@+id/et_plan_title"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/spacing25"
app:etText="@={viewModel.planOpenChattingLink}"
app:hint="@string/plan_open_chatting_hint"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/tv_plan_title"
app:title="@string/plan_open_chatting_title" />
</androidx.constraintlayout.widget.ConstraintLayout>
</layout>
28 changes: 27 additions & 1 deletion app/src/main/res/layout/fragment_plan_title.xml
Original file line number Diff line number Diff line change
@@ -1,13 +1,39 @@
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android">
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">

<data>

<variable
name="viewModel"
type="org.sopt.pingle.presentation.ui.main.plan.PlanViewModel" />
</data>

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

<TextView
android:id="@+id/tv_plan_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/spacing8"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

얘둥

android:text="@string/plan_title"
android:textAppearance="@style/TextAppearance.Pingle.Title.Semi.24"
android:textColor="@color/white"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />

<org.sopt.pingle.util.component.PingleEditText
android:id="@+id/et_plan_title"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/spacing25"
app:etText="@={viewModel.planTitle}"
app:hint="@string/plan_et_hint"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/tv_plan_title"
app:title="@string/plan_et_title" />
</androidx.constraintlayout.widget.ConstraintLayout>
</layout>
5 changes: 5 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,15 @@
<string name="plan_start_time_title">시작 시각</string>
<string name="plan_time_hint">00:00</string>
<string name="plan_end_time_title">종료 시각</string>
<string name="plan_et_title">한줄 소개</string>
<string name="plan_title">개최할 핑글을\n소개해주세요!</string>
<string name="plan_et_hint">ex. 강남역에서 각잡고 공부할 사람?</string>

<!-- map -->
<string name="map_participate">참여하기</string>

<!-- map modal -->
<string name="map_modal_description">이 핑글에 참여할까요?</string>
<string name="plan_open_chatting_hint">링크를 입력해주세요</string>
<string name="plan_open_chatting_title">채팅방 링크</string>
</resources>
Loading