Skip to content

Commit

Permalink
[#30] 로그인 기능 추가
Browse files Browse the repository at this point in the history
- 이미지 선택 다이얼로그 추가
  • Loading branch information
ethan-223 committed Sep 4, 2022
1 parent c11241d commit 71d3f4a
Show file tree
Hide file tree
Showing 6 changed files with 111 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import android.view.Window
import androidx.fragment.app.DialogFragment
import com.moyerun.moyeorun_android.common.extension.isActivityDestroyed

open class RoundDialogFragment : DialogFragment() {
abstract class RoundDialogFragment : DialogFragment() {

private var dismissOnPause = false

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@ import android.widget.EditText
import androidx.activity.viewModels
import androidx.core.widget.doAfterTextChanged
import com.moyerun.moyeorun_android.R
import com.moyerun.moyeorun_android.common.extension.repeatOnStart
import com.moyerun.moyeorun_android.common.extension.setDrawableEnd
import com.moyerun.moyeorun_android.common.extension.setTextIfNew
import com.moyerun.moyeorun_android.common.extension.*
import com.moyerun.moyeorun_android.databinding.ActivityProfileBinding
import dagger.hilt.android.AndroidEntryPoint
import kotlinx.coroutines.flow.collect
Expand Down Expand Up @@ -49,6 +47,19 @@ class ProfileEditActivity : AppCompatActivity() {
viewModel.onNicknameChanged(it?.toString().orEmpty())
}

binding.badgeimageviewProfileImage.setOnDebounceClickListener {
showAllowingStateLoss("selectImage") {
ProfileImageSelectDialogFragment.getInstance(
onGalleryClick = {
// Todo : 갤러리 선택 화면
},
onDefaultImagesClick = {
// Todo : 기본 이미지 선택 화면
}
)
}
}

repeatOnStart {
launch {
viewModel.profileUiModel
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package com.moyerun.moyeorun_android.profile

import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import com.moyerun.moyeorun_android.common.dialog.RoundDialogFragment
import com.moyerun.moyeorun_android.common.extension.setOnDebounceClickListener
import com.moyerun.moyeorun_android.databinding.DialogProfileImageSelectBinding

class ProfileImageSelectDialogFragment : RoundDialogFragment() {

private var onGalleryClick: () -> Unit = {}
private var onDefaultImagesClick: () -> Unit = {}

override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
): View {
return DialogProfileImageSelectBinding.inflate(inflater, container, false).root
}

override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
val binding = DialogProfileImageSelectBinding.bind(view)

binding.buttonImageSelectGallery.setOnDebounceClickListener {
onGalleryClick.invoke()
dismissAllowingStateLoss()
}

binding.buttonImageSelectDefault.setOnDebounceClickListener {
onDefaultImagesClick.invoke()
dismissAllowingStateLoss()
}
}

companion object {
fun getInstance(
onGalleryClick: () -> Unit,
onDefaultImagesClick: () -> Unit
): ProfileImageSelectDialogFragment {
return ProfileImageSelectDialogFragment().apply {
this.onGalleryClick = onGalleryClick
this.onDefaultImagesClick = onDefaultImagesClick
}
}
}
}
38 changes: 38 additions & 0 deletions app/src/main/res/layout/dialog_profile_image_select.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?xml version="1.0" encoding="utf-8"?>

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">

<LinearLayout
style="@style/Dialog.Background"
android:orientation="vertical">

<TextView
style="@style/Dialog.Title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginVertical="22dp"
android:text="프로필 사진" />

<View style="@style/Dialog.Divider" />

<androidx.appcompat.widget.AppCompatButton
android:id="@+id/button_image_select_gallery"
style="@style/Dialog.Button.VerticalLinear"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/profile_button_image_select_gallery" />

<View style="@style/Dialog.Divider" />

<androidx.appcompat.widget.AppCompatButton
android:id="@+id/button_image_select_default"
style="@style/Dialog.Button.VerticalLinear"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/profile_button_image_select_default" />

</LinearLayout>

</FrameLayout>
2 changes: 2 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,7 @@
<!-- Profile -->
<string name="profile_name">이름</string>
<string name="profile_nickname">닉네임</string>
<string name="profile_button_image_select_gallery">갤러리에서 선택</string>
<string name="profile_button_image_select_default">기본 이미지에서 선택</string>

</resources>
6 changes: 6 additions & 0 deletions app/src/main/res/values/styles_dialog.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@
<item name="android:minHeight">0dp</item>
<item name="android:paddingVertical">21dp</item>
<item name="android:textSize">16dp</item>
<item name="android:background">@android:color/transparent</item>
</style>

<style name="Dialog.Button.VerticalLinear">
<item name="android:foreground">?android:selectableItemBackgroundBorderless</item>
<item name="android:paddingVertical">18dp</item>
</style>

<style name="Dialog.Button.Negative">
Expand Down

0 comments on commit 71d3f4a

Please sign in to comment.