-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
bca7e60
commit d2d53e0
Showing
31 changed files
with
1,255 additions
and
92 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
93 changes: 93 additions & 0 deletions
93
app/src/main/java/com/azamovhudstc/soplay/ui/screens/bottomsheet/CustomBottomDialog.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
package com.azamovhudstc.soplay.ui.screens.bottomsheet | ||
|
||
import android.os.Bundle | ||
import android.view.LayoutInflater | ||
import android.view.View | ||
import android.view.ViewGroup | ||
import com.azamovhudstc.soplay.databinding.BottomSheetCustomBinding | ||
import com.google.android.material.bottomsheet.BottomSheetDialogFragment | ||
|
||
class CustomBottomDialog : BottomSheetDialogFragment() { | ||
private var _binding: BottomSheetCustomBinding? = null | ||
private val binding get() = _binding!! | ||
|
||
private val viewList = mutableListOf<View>() | ||
fun addView(view: View) { | ||
viewList.add(view) | ||
} | ||
var title: String?=null | ||
fun setTitleText(string: String){ | ||
title = string | ||
} | ||
|
||
private var checkText: String? = null | ||
private var checkChecked: Boolean = false | ||
private var checkCallback: ((Boolean) -> Unit)? = null | ||
|
||
fun setCheck(text: String, checked: Boolean, callback: ((Boolean) -> Unit)) { | ||
checkText = text | ||
checkChecked = checked | ||
checkCallback = callback | ||
} | ||
|
||
private var negativeText: String? = null | ||
private var negativeCallback: (() -> Unit)? = null | ||
fun setNegativeButton(text: String, callback: (() -> Unit)) { | ||
negativeText = text | ||
negativeCallback = callback | ||
} | ||
|
||
private var positiveText: String? = null | ||
private var positiveCallback: (() -> Unit)? = null | ||
fun setPositiveButton(text: String, callback: (() -> Unit)) { | ||
positiveText = text | ||
positiveCallback = callback | ||
} | ||
|
||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View { | ||
_binding = BottomSheetCustomBinding.inflate(inflater, container, false) | ||
return binding.root | ||
} | ||
|
||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { | ||
binding.bottomSheerCustomTitle.text = title | ||
viewList.forEach { | ||
binding.bottomDialogCustomContainer.addView(it) | ||
} | ||
if (checkText != null) binding.bottomDialogCustomCheckBox.apply { | ||
visibility = View.VISIBLE | ||
text = checkText | ||
isChecked = checkChecked | ||
setOnCheckedChangeListener { _, checked -> | ||
checkCallback?.invoke(checked) | ||
} | ||
} | ||
|
||
if(negativeText!=null) binding.bottomDialogCustomNegative.apply { | ||
visibility = View.VISIBLE | ||
text = negativeText | ||
setOnClickListener { | ||
negativeCallback?.invoke() | ||
} | ||
} | ||
|
||
if(positiveText!=null) binding.bottomDialogCustomPositive.apply { | ||
visibility = View.VISIBLE | ||
text = positiveText | ||
setOnClickListener { | ||
positiveCallback?.invoke() | ||
} | ||
} | ||
|
||
} | ||
|
||
override fun onDestroy() { | ||
_binding = null | ||
super.onDestroy() | ||
} | ||
|
||
companion object { | ||
fun newInstance() = CustomBottomDialog() | ||
} | ||
|
||
} |
Oops, something went wrong.