Skip to content

Commit

Permalink
[Feat] 그룹 생성 화면 수정 (#38)
Browse files Browse the repository at this point in the history
  • Loading branch information
PIYUJIN authored Nov 29, 2024
2 parents 664d393 + e33c266 commit d9bbef5
Show file tree
Hide file tree
Showing 8 changed files with 41 additions and 70 deletions.
3 changes: 2 additions & 1 deletion app/src/main/java/com/project/jangburich/api/ApiService.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import com.project.jangburich.api.request.group.CreateGroupRequest
import com.project.jangburich.api.request.login.SaveSignUpInfoRequest
import com.project.jangburich.api.request.store.PrepayRequest
import com.project.jangburich.api.response.BaseResponse
import com.project.jangburich.api.response.group.CreateGroupResponse
import com.project.jangburich.api.response.group.GetGroupInfoWithCodeResponse
import com.project.jangburich.api.response.group.GetGroupResponse
import com.project.jangburich.api.response.home.GetHomeDataResponse
Expand Down Expand Up @@ -47,7 +48,7 @@ interface ApiService {
fun createGroup(
@Header("Authorization") token: String,
@Body parameters: CreateGroupRequest
): Call<BaseResponse<MessageResponse>>
): Call<BaseResponse<CreateGroupResponse>>

// 그룹 정보 가져오기
@GET("/teams")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ data class CreateGroupRequest(
val teamType: String,
val teamName: String,
val description: String,
val secretCode: String,
val teamLeaderAccountNumber: String,
val bankName: String
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package com.project.jangburich.api.response.group

data class CreateGroupResponse(
val uuid: String
)
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class CreateGroupCompleteFragment : Fragment() {
transaction.commit()
}
buttonMyGroup.setOnClickListener {

mainActivity.binding.bottomNavigation.selectedItemId = R.id.menu_group
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,20 +36,10 @@ class CreateGroupInfoFragment : Fragment() {
checkEnable()
textViewDescriptionCount.text = "${editTextDescription.length()}/100"
}
editTextCode.addTextChangedListener {
checkEnable()
textViewCodeCount.text = "${editTextCode.length()}/10"
if(isValidInput(editTextCode.text.toString())) {
textViewCodeError.visibility = View.INVISIBLE
} else {
textViewCodeError.visibility = View.VISIBLE
}
}

buttonNext.setOnClickListener {
MyApplication.groupName = editTextName.text.toString()
MyApplication.groupDescription = editTextDescription.text.toString()
MyApplication.groupSecretCode = editTextCode.text.toString()

val nextFragment = CreateGroupAccountFragment()

Expand All @@ -66,7 +56,7 @@ class CreateGroupInfoFragment : Fragment() {

fun checkEnable() {
binding.run {
if(editTextName.text.isNotEmpty() && editTextDescription.text.isNotEmpty() && editTextCode.text.isNotEmpty()) {
if(editTextName.text.isNotEmpty() && editTextDescription.text.isNotEmpty()) {
buttonNext.isEnabled = true
} else {
buttonNext.isEnabled = false
Expand All @@ -84,7 +74,6 @@ class CreateGroupInfoFragment : Fragment() {
fun initView() {
binding.run {
buttonNext.isEnabled = false
textViewCodeError.visibility = View.INVISIBLE

mainActivity.hideBottomNavigation(true)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
package com.project.jangburich.ui.group

import android.content.ClipData
import android.content.ClipboardManager
import android.content.Context
import android.os.Bundle
import androidx.fragment.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.Toast
import com.project.jangburich.MyApplication
import com.project.jangburich.R
import com.project.jangburich.databinding.FragmentCreateGroupInviteBinding
Expand All @@ -28,6 +32,10 @@ class CreateGroupInviteFragment : Fragment() {
binding.run {
textViewCode.text = MyApplication.groupSecretCode

buttonCopy.setOnClickListener {
copyTextToClipboard(mainActivity, MyApplication.groupSecretCode)
}

buttonNext.setOnClickListener {
val nextFragment = CreateGroupCompleteFragment()

Expand All @@ -41,6 +49,20 @@ class CreateGroupInviteFragment : Fragment() {
return binding.root
}

fun copyTextToClipboard(context: Context, text: String) {
// ClipboardManager 인스턴스 가져오기
val clipboard = context.getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager

// 클립 데이터 생성
val clip = ClipData.newPlainText("Copied Text", text)

// 클립보드에 데이터 복사
clipboard.setPrimaryClip(clip)

// 사용자에게 복사 알림
Toast.makeText(context, "텍스트가 복사되었습니다.", Toast.LENGTH_SHORT).show()
}

fun initView() {
binding.run {
mainActivity.hideBottomNavigation(true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import com.project.jangburich.api.TokenManager
import com.project.jangburich.api.request.group.CreateGroupRequest
import com.project.jangburich.api.request.store.PrepayRequest
import com.project.jangburich.api.response.BaseResponse
import com.project.jangburich.api.response.group.CreateGroupResponse
import com.project.jangburich.api.response.group.GetGroupInfoWithCodeResponse
import com.project.jangburich.api.response.group.GetGroupResponse
import com.project.jangburich.api.response.home.GetHomeDataResponse
Expand Down Expand Up @@ -39,20 +40,22 @@ class GroupViewModel: ViewModel() {
val apiClient = ApiClient(activity)
val tokenManager = TokenManager(activity)

var groupInfo = CreateGroupRequest(MyApplication.groupType, MyApplication.groupName, MyApplication.groupDescription, MyApplication.groupSecretCode, MyApplication.groupAccountNumber, MyApplication.groupBankName)
var groupInfo = CreateGroupRequest(MyApplication.groupType, MyApplication.groupName, MyApplication.groupDescription, MyApplication.groupAccountNumber, MyApplication.groupBankName)

apiClient.apiService.createGroup("Bearer ${tokenManager.getAccessToken()}", groupInfo).enqueue(object :
Callback<BaseResponse<MessageResponse>> {
Callback<BaseResponse<CreateGroupResponse>> {
override fun onResponse(
call: Call<BaseResponse<MessageResponse>>,
response: Response<BaseResponse<MessageResponse>>
call: Call<BaseResponse<CreateGroupResponse>>,
response: Response<BaseResponse<CreateGroupResponse>>
) {
Log.d("##", "onResponse 성공: " + response.body().toString())
if (response.isSuccessful) {
// 정상적으로 통신이 성공된 경우
val result: BaseResponse<MessageResponse>? = response.body()
val result: BaseResponse<CreateGroupResponse>? = response.body()
Log.d("##", "onResponse 성공: " + result?.toString())

MyApplication.groupSecretCode = result?.data?.uuid!!

val nextFragment = CreateGroupInviteFragment()

val transaction = activity.manager.beginTransaction()
Expand All @@ -61,7 +64,7 @@ class GroupViewModel: ViewModel() {
transaction.commit()
} else {
// 통신이 실패한 경우(응답코드 3xx, 4xx 등)
var result: BaseResponse<MessageResponse>? = response.body()
var result: BaseResponse<CreateGroupResponse>? = response.body()
Log.d("##", "onResponse 실패")
Log.d("##", "onResponse 실패: " + response.code())
Log.d("##", "onResponse 실패: " + response.body())
Expand All @@ -71,7 +74,7 @@ class GroupViewModel: ViewModel() {
}
}

override fun onFailure(call: Call<BaseResponse<MessageResponse>>, t: Throwable) {
override fun onFailure(call: Call<BaseResponse<CreateGroupResponse>>, t: Throwable) {
// 통신 실패
Log.d("##", "onFailure 에러: " + t.message.toString())
}
Expand Down
48 changes: 0 additions & 48 deletions app/src/main/res/layout/fragment_create_group_info.xml
Original file line number Diff line number Diff line change
Expand Up @@ -104,54 +104,6 @@
app:layout_constraintBottom_toBottomOf="@+id/editText_description"
app:layout_constraintEnd_toEndOf="@+id/editText_description" />

<TextView
android:id="@+id/textView_code_description"
style="@style/Detail1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="그룹 비밀 코드"
android:layout_marginTop="30dp"
android:textColor="@color/gray_40"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/editText_description" />

<EditText
android:id="@+id/editText_code"
style="@style/OneLineEditText"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:ems="10"
android:maxLength="10"
android:inputType="text"
android:hint="영문, 숫자 포함 5~10자 이내"
android:layout_marginTop="10dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/textView_code_description" />

<TextView
android:id="@+id/textView_code_count"
style="@style/Detail1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="15dp"
android:text="0/10"
android:textColor="@color/gray_60"
app:layout_constraintBottom_toBottomOf="@+id/editText_code"
app:layout_constraintEnd_toEndOf="@+id/editText_code"
app:layout_constraintTop_toTopOf="@+id/editText_code" />

<TextView
android:id="@+id/textView_code_error"
style="@style/body7"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="5dp"
android:text="영문, 숫자 포함 5~10자 이내로 입력해주세요"
android:textColor="@color/main_orange"
app:layout_constraintStart_toStartOf="@+id/editText_code"
app:layout_constraintTop_toBottomOf="@+id/editText_code" />

<Button
android:id="@+id/button_next"
style="@style/NextButtonGray"
Expand Down

0 comments on commit d9bbef5

Please sign in to comment.