Skip to content

Commit

Permalink
Merge pull request #96 from Trendyol/dialogs/dismissListener
Browse files Browse the repository at this point in the history
Dialogs/dismiss listener
  • Loading branch information
erolaksoy authored Jun 28, 2022
2 parents 3733463 + 8ac70ed commit 2230a88
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 2 deletions.
2 changes: 1 addition & 1 deletion buildSrc/src/main/kotlin/ComponentVersions.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ object ComponentVersions {
const val ratingBarVersion = "1.0.2"
const val imageSliderVersion = "1.0.8"
const val phoneNumberVersion = "1.0.2"
const val dialogsVersion = "1.3.1"
const val dialogsVersion = "1.4.0"
const val cardInputViewVersion = "1.2.1"
const val quantityPickerViewVersion = "1.2.5"
const val timelineViewVersion = "1.0.0"
Expand Down
3 changes: 2 additions & 1 deletion libraries/dialogs/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

<img src="https://raw.githubusercontent.com/Trendyol/android-ui-components/master/images/dialogs-1.png" width="280"/> <img src="https://raw.githubusercontent.com/Trendyol/android-ui-components/master/images/dialogs-2.png" width="280"/> <img src="https://raw.githubusercontent.com/Trendyol/android-ui-components/master/images/dialogs-3.png" width="280"/> <img src="https://raw.githubusercontent.com/Trendyol/android-ui-components/master/images/dialogs-4.png" width="280"/> <img src="https://raw.githubusercontent.com/Trendyol/android-ui-components/master/images/dialogs-5.png" width="280"/>

$dialogsVersion = dialogs-1.3.1 [![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
$dialogsVersion = dialogs-1.4.0 [![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)

## Dialogs
Dialogs is a bunch of BottomSheetDialogs to use in app to show user an information, agreement or list.
Expand Down Expand Up @@ -97,6 +97,7 @@ All **Info Dialog** arguments plus these arguments will be applicable to show se
| `items` | List<Pair<Boolean, String>> | Item list that will be listed on dialog. | null |
| `showItemsAsHtml` | Boolean | Item texts will be parsed as Html if this flag setted as true. | false |
| `onItemSelectedListener` | (DialogFragment, Int) -> Unit | Listener to notify selected index. | null |
| `onDismissListener` | (DialogFragment) -> Unit | Listener to notify when dialog is dismiss. | null |
| `enableSearch` | Boolean | Enables search function in given `items` | false |
| `showClearSearchButton` | Boolean | Shows clean button on the right of the search input line. | false |
| `searchHint` | String | Hint to show on search input line. | "" |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ open class Builder internal constructor() {
var showCloseButton: Boolean = false
var closeButtonListener: ((DialogFragment) -> Unit)? = null
var animateCornerRadiusWhenExpand: Boolean = false
var onDialogDismissListener: ((DialogFragment) -> Unit)? = null
var cornerRadius: Float? = null
}

Expand Down Expand Up @@ -50,6 +51,7 @@ open class InfoDialogBuilder internal constructor() : Builder() {
webViewBuilder = it.webViewBuilder,
).toBundle()
this.closeButtonListener = it.closeButtonListener ?: { }
this.onDismissListener = it.onDialogDismissListener ?: {}
}
}
}
Expand Down Expand Up @@ -81,6 +83,7 @@ open class AgreementDialogBuilder internal constructor() : InfoDialogBuilder() {
closeButtonListener = it.closeButtonListener
rightButtonClickListener = it.rightButtonClickListener
leftButtonClickListener = it.leftButtonClickListener
this.onDismissListener = it.onDialogDismissListener ?: {}
}
}
}
Expand Down Expand Up @@ -125,6 +128,7 @@ class SelectionDialogBuilder internal constructor() : InfoDialogBuilder() {
closeButtonListener = it.closeButtonListener
onItemSelectedListener = it.onItemSelectedListener
onItemReselectedListener = it.onItemReselectedListener
this.onDismissListener = it.onDialogDismissListener ?: {}
}

}
Expand Down Expand Up @@ -153,6 +157,7 @@ class InfoListDialogBuilder internal constructor() : InfoDialogBuilder() {
itemDividers = it.itemDividers
).toBundle()
closeButtonListener = it.closeButtonListener
this.onDismissListener = it.onDialogDismissListener ?: {}
}

}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.trendyol.uicomponents.dialogs

import android.content.DialogInterface
import android.graphics.Outline
import android.os.Bundle
import android.text.SpannableString
Expand Down Expand Up @@ -29,6 +30,7 @@ class DialogFragment internal constructor() : BaseBottomSheetDialog() {
var rightButtonClickListener: ((DialogFragment) -> Unit)? = null
var onItemSelectedListener: ((DialogFragment, Int) -> Unit)? = null
var onItemReselectedListener: ((DialogFragment, Int) -> Unit)? = null
var onDismissListener: ((DialogFragment) -> Unit)? = null

internal lateinit var binding: FragmentDialogBinding
private val dialogArguments by lazy(LazyThreadSafetyMode.NONE) {
Expand Down Expand Up @@ -232,6 +234,11 @@ class DialogFragment internal constructor() : BaseBottomSheetDialog() {
}
}

override fun onDismiss(dialog: DialogInterface) {
onDismissListener?.invoke(this@DialogFragment)
super.onDismiss(dialog)
}

companion object {

const val TAG: String = "TRENDYOL_BOTTOM_SHEET_DIALOG"
Expand Down

0 comments on commit 2230a88

Please sign in to comment.