Skip to content

Commit

Permalink
#30 [feat] 공통 바텀 시트 구현 완
Browse files Browse the repository at this point in the history
  • Loading branch information
emjayMJkim committed Jan 11, 2024
1 parent 3bbd7a1 commit bcda072
Show file tree
Hide file tree
Showing 10 changed files with 124 additions and 123 deletions.
4 changes: 4 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".ui.setting.SettingActivity"
android:exported="false"
android:screenOrientation="portrait" />

</application>

Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/com/sopetit/softie/SoftieApplication.kt
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class SoftieApplication : Application() {
if (BuildConfig.DEBUG) Timber.plant(Timber.DebugTree())

AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO)
// setStatusBarTransparent()
setStatusBarTransparent()
}

private fun setStatusBarTransparent() {
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import com.sopetit.softie.R
import com.sopetit.softie.databinding.FragmentSettingInitBinding
import com.sopetit.softie.ui.setting.SettingActivity.Companion.USER_EXIT
import com.sopetit.softie.ui.setting.SettingActivity.Companion.USER_SECURITY
import com.sopetit.softie.util.binding.BindingBottomSheet
import com.sopetit.softie.util.binding.BindingFragment

class SettingInitFragment :
Expand Down Expand Up @@ -49,27 +50,20 @@ class SettingInitFragment :

private fun clickLogOut() {
binding.btnSettingLogout.setOnClickListener {
// BindingBottomSheet.Builder().build(
// image = "https://github.com/Team-Sopetit/Sopetit-Android/assets/128988935/765fdb9d-a29a-4c07-a9f5-852b8c6b3a7f",
// title = "제목",
// content = "내용",
// isContentVisible = true,
// contentColor = R.color.gray300,
// backBtnContent = "돌아가기",
// doBtnContent = "그냥 해",
// doBtnColor = R.drawable.shape_red_fill_12_rect,
// backBtnAction = {},
// doBtnAction = {}
// ).show(parentFragmentManager, "bottom sheet")

BottomSheetFragment().show(parentFragmentManager, "bottom")

// BottomSheet가 뜰 때 다시 적용
// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
// requireActivity().window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
// }
// requireActivity().window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
// requireActivity().window.setStatusBarColor(Color.TRANSPARENT);
BindingBottomSheet.Builder().build(
isDrawable = true,
imageDrawable = R.drawable.ic_bear_face_crying,
imageUri = "",
title = "제목",
content = "내용",
isContentVisible = true,
contentColor = R.color.gray300,
backBtnContent = "돌아가기",
doBtnContent = "그냥 해",
doBtnColor = R.drawable.shape_red_fill_12_rect,
backBtnAction = {},
doBtnAction = {}
).show(parentFragmentManager, BOTTOM_SHEET_TAG)
}
}

Expand All @@ -78,4 +72,8 @@ class SettingInitFragment :
viewModel.setSettingFragment(USER_EXIT)
}
}

companion object {
const val BOTTOM_SHEET_TAG = "BOTTOM SHEET TAG"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,13 @@ class OriginalBottomSheet : BindingBottomSheet() {
}

override fun setImage() {
// binding.ivBottomSheet.setImageURI(image)
binding.ivBottomSheet.setImage(image)
// binding.ivBottomSheet.setImage(image)
// image?.let { binding.ivBottomSheet.setImageResource(it) }
if (isDrawable == true) {
imageDrawable?.let { binding.ivBottomSheet.setImageResource(it) }
} else {
binding.ivBottomSheet.setImage(imageUri)
}
}

override fun setTitle() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ import com.sopetit.softie.util.OriginalBottomSheet
abstract class BindingBottomSheet : BottomSheetDialogFragment() {

protected var _binding: ViewBinding? = null
protected var image: String? = null
protected var isDrawable: Boolean? = null
protected var imageDrawable: Int? = null
protected var imageUri: String? = null
protected var title: String? = null
protected var content: String? = null
protected var isContentVisible: Boolean? = null
Expand Down Expand Up @@ -49,7 +51,9 @@ abstract class BindingBottomSheet : BottomSheetDialogFragment() {

class Builder() {
fun build(
image: String,
isDrawable: Boolean,
imageDrawable: Int,
imageUri: String,
title: String,
content: String,
isContentVisible: Boolean,
Expand All @@ -62,7 +66,9 @@ abstract class BindingBottomSheet : BottomSheetDialogFragment() {
): BindingBottomSheet {
val bottomSheet = OriginalBottomSheet()
return bottomSheet.apply {
this.image = image
this.isDrawable = isDrawable
this.imageDrawable = imageDrawable
this.imageUri = imageUri
this.title = title
this.content = content
this.isContentVisible = isContentVisible
Expand Down
3 changes: 2 additions & 1 deletion app/src/main/res/layout/activity_setting.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/white">
android:background="@color/white"
android:fitsSystemWindows="true">

<androidx.appcompat.widget.AppCompatImageButton
android:id="@+id/btn_setting_back"
Expand Down
140 changes: 76 additions & 64 deletions app/src/main/res/layout/fragment_bottomsheet.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,82 +4,94 @@
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fitsSystemWindows="true"
app:layout_behavior="com.google.android.material.bottomsheet.BottomSheetBehavior">

<ImageView
android:id="@+id/iv_bottom_sheet"
android:layout_width="67dp"
android:layout_height="67dp"
android:layout_marginTop="31dp"
android:src="@drawable/ic_bear_face_crying"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" />

<TextView
android:id="@+id/tv_bottom_sheet_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:textAppearance="@style/head1"
android:textColor="@color/gray700"
app:layout_constraintTop_toBottomOf="@id/iv_bottom_sheet"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
tools:text="@string/bottom_sheet_title" />

<TextView
android:id="@+id/tv_bottom_sheet_content"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="6dp"
android:textAppearance="@style/body4"
android:textColor="@color/gray400"
app:layout_constraintStart_toStartOf="@id/tv_bottom_sheet_title"
app:layout_constraintEnd_toEndOf="@id/tv_bottom_sheet_title"
app:layout_constraintTop_toBottomOf="@id/tv_bottom_sheet_title"
tools:text="@string/bottom_sheet_content" />

<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/cl_bottom_sheet_btn"
android:id="@+id/cl_test"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginHorizontal="20dp"
android:layout_marginTop="35dp"
android:layout_marginBottom="33dp"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@id/tv_bottom_sheet_content"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintHorizontal_chainStyle="spread_inside">
app:layout_constraintEnd_toEndOf="parent">

<androidx.appcompat.widget.AppCompatButton
android:id="@+id/btn_bottom_sheet_back"
android:layout_width="0dp"
<ImageView
android:id="@+id/iv_bottom_sheet"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="@style/body1"
android:textColor="@color/gray300"
android:paddingVertical="20dp"
android:background="@drawable/shape_gray100_fill_12_rect"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
android:layout_marginTop="31dp"
android:src="@drawable/ic_bear_face_crying"
android:adjustViewBounds="true"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" />

<TextView
android:id="@+id/tv_bottom_sheet_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:textAppearance="@style/head1"
android:textColor="@color/gray700"
app:layout_constraintTop_toBottomOf="@id/iv_bottom_sheet"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toStartOf="@id/btn_bottom_sheet_do"
tools:text="@string/bottom_sheet_back" />
app:layout_constraintEnd_toEndOf="parent"
tools:text="@string/bottom_sheet_title" />

<androidx.appcompat.widget.AppCompatButton
android:id="@+id/btn_bottom_sheet_do"
<TextView
android:id="@+id/tv_bottom_sheet_content"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="6dp"
android:textAppearance="@style/body4"
android:textColor="@color/gray400"
app:layout_constraintStart_toStartOf="@id/tv_bottom_sheet_title"
app:layout_constraintEnd_toEndOf="@id/tv_bottom_sheet_title"
app:layout_constraintTop_toBottomOf="@id/tv_bottom_sheet_title"
tools:text="@string/bottom_sheet_content" />

<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/cl_bottom_sheet_btn"
android:layout_width="0dp"
android:layout_height="0dp"
android:textAppearance="@style/body1"
android:textColor="@color/gray000"
android:background="@drawable/shape_main1_fill_12_rect"
android:layout_marginStart="10dp"
app:layout_constraintTop_toTopOf="@id/btn_bottom_sheet_back"
app:layout_constraintBottom_toBottomOf="@id/btn_bottom_sheet_back"
android:layout_height="wrap_content"
android:layout_marginHorizontal="20dp"
android:layout_marginTop="35dp"
android:layout_marginBottom="33dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@id/btn_bottom_sheet_back"
tools:text="@string/bottom_sheet_do" />
app:layout_constraintTop_toBottomOf="@id/tv_bottom_sheet_content"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintHorizontal_chainStyle="spread_inside">

<androidx.appcompat.widget.AppCompatButton
android:id="@+id/btn_bottom_sheet_back"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:textAppearance="@style/body1"
android:textColor="@color/gray300"
android:paddingVertical="20dp"
android:background="@drawable/shape_gray100_fill_12_rect"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toStartOf="@id/btn_bottom_sheet_do"
tools:text="@string/bottom_sheet_back" />

<androidx.appcompat.widget.AppCompatButton
android:id="@+id/btn_bottom_sheet_do"
android:layout_width="0dp"
android:layout_height="0dp"
android:textAppearance="@style/body1"
android:textColor="@color/gray000"
android:background="@drawable/shape_main1_fill_12_rect"
android:layout_marginStart="10dp"
app:layout_constraintTop_toTopOf="@id/btn_bottom_sheet_back"
app:layout_constraintBottom_toBottomOf="@id/btn_bottom_sheet_back"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@id/btn_bottom_sheet_back"
tools:text="@string/bottom_sheet_do" />

</androidx.constraintlayout.widget.ConstraintLayout>

</androidx.constraintlayout.widget.ConstraintLayout>

Expand Down
3 changes: 2 additions & 1 deletion app/src/main/res/layout/fragment_setting_init.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/white">
android:background="@color/white"
android:fitsSystemWindows="true">

<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/cl_setting_user_security"
Expand Down
8 changes: 4 additions & 4 deletions app/src/main/res/values/themes.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
<style name="Base.Theme.Softie" parent="Theme.Material3.Light.NoActionBar">
<!-- Customize your light theme here. -->
<item name="android:includeFontPadding">false</item>
<!-- <item name="android:windowLightStatusBar">true</item>-->
<!-- <item name="android:windowDrawsSystemBarBackgrounds">true</item>-->
<!-- <item name="android:statusBarColor">@android:color/transparent</item>-->
<!-- <item name="android:windowTranslucentStatus">true</item>-->
<item name="android:windowLightStatusBar">true</item>
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
<item name="android:statusBarColor">@android:color/transparent</item>
<item name="android:windowTranslucentStatus">true</item>
</style>

<style name="Theme.Softie" parent="Base.Theme.Softie" />
Expand Down

0 comments on commit bcda072

Please sign in to comment.