Skip to content

Commit

Permalink
Merge pull request #93 from Trendyol/dialog_fragment_add_optional_pad…
Browse files Browse the repository at this point in the history
…ding

Add Optional Padding For Dialog
  • Loading branch information
dogukankeskinoglu authored Feb 18, 2022
2 parents 3397d59 + e05fc8c commit b973d29
Show file tree
Hide file tree
Showing 6 changed files with 28 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.2.9"
const val dialogsVersion = "1.3.0"
const val cardInputViewVersion = "1.1.3"
const val quantityPickerViewVersion = "1.2.5"
const val timelineViewVersion = "1.0.0"
Expand Down
6 changes: 5 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"/> <img src="https://raw.githubusercontent.com/Trendyol/android-ui-components/master/images/dialogs-6.png" width="280"/>

$dialogsVersion = dialogs-1.2.9 [![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
$dialogsVersion = dialogs-1.3.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 @@ -37,6 +37,8 @@ Simple dialog to show information, error or text.
| `showCloseButton` | Boolean | Close button visibility | false |
| `animateCornerRadiusWhenExpand` | Boolean | Corner radius will be removed with an animation when set true. | false |
| `cornerRadius` | Float | Corner radius will be applied. | 16dp |
| `horizontalPadding` | Float | Horizontal padding will be applied. | 16dp |
| `verticalPadding` | Float | Vertical padding will be applied. | 0dp |
| `closeButtonListener` | (DialogFragment) -> Unit | Listener for close button. When clicked, dialog will dismiss and listener will be invoked with dialog. | { } |
| `content` | CharSequence | Content of a dialog | "" |
| `showContentAsHtml` | Boolean | If you provided `content` as Html and set this flag as true, content will be parsed as HTML. | false |
Expand Down Expand Up @@ -174,6 +176,8 @@ CustomDialog is a dialog that has a fixed header and its content can take a cust
| Field | Type | Description | Default Value |
| ------------- |-------------|-------------| ------------- |
| `view` | View | The custom view that will create the body of the dialog. | null |
| `horizontalPadding` | Float | Horizontal padding will be applied. | 0dp |
| `verticalPadding` | Float | Vertical padding will be applied. | 0dp |

Sample usage:
```kotlin
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ open class InfoDialogBuilder internal constructor() : Builder() {
var contentTextPosition: TextPosition? = null
var webViewContent: WebViewContent? = null
var webViewBuilder: (WebView.() -> Unit)? = null
var horizontalPadding: Float? = null
var verticalPadding: Float? = null

internal fun buildInfoDialog(block: InfoDialogBuilder.() -> Unit): DialogFragment {
return InfoDialogBuilder().apply(block).let {
Expand All @@ -36,6 +38,8 @@ open class InfoDialogBuilder internal constructor() : Builder() {
showCloseButton = it.showCloseButton,
animateCornerRadiusWhenExpand = it.animateCornerRadiusWhenExpand,
cornerRadius = it.cornerRadius,
horizontalPadding = it.horizontalPadding,
verticalPadding = it.verticalPadding,
content = SpannableString(it.content),
contentImage = it.contentImage,
showContentAsHtml = it.showContentAsHtml,
Expand Down Expand Up @@ -67,6 +71,8 @@ open class AgreementDialogBuilder internal constructor() : InfoDialogBuilder() {
showCloseButton = it.showCloseButton,
content = SpannableString(it.content),
cornerRadius = it.cornerRadius,
horizontalPadding = it.horizontalPadding,
verticalPadding = it.verticalPadding,
showContentAsHtml = it.showContentAsHtml,
contentImage = it.contentImage,
rightButtonText = it.rightButtonText,
Expand Down Expand Up @@ -103,6 +109,8 @@ class SelectionDialogBuilder internal constructor() : InfoDialogBuilder() {
showContentAsHtml = it.showContentAsHtml,
contentImage = it.contentImage,
cornerRadius = it.cornerRadius,
horizontalPadding = it.horizontalPadding,
verticalPadding = it.verticalPadding,
animateCornerRadiusWhenExpand = it.animateCornerRadiusWhenExpand,
titleTextColor = it.titleTextColor,
items = it.items,
Expand Down Expand Up @@ -137,6 +145,8 @@ class InfoListDialogBuilder internal constructor() : InfoDialogBuilder() {
content = SpannableString(it.content),
animateCornerRadiusWhenExpand = it.animateCornerRadiusWhenExpand,
cornerRadius = it.cornerRadius,
horizontalPadding = it.horizontalPadding,
verticalPadding = it.verticalPadding,
showContentAsHtml = it.showContentAsHtml,
contentImage = it.contentImage,
webViewContent = it.webViewContent,
Expand All @@ -161,6 +171,8 @@ class CustomDialogBuilder internal constructor() : Builder() {
showCloseButton = it.showCloseButton,
animateCornerRadiusWhenExpand = animateCornerRadiusWhenExpand,
cornerRadius = it.cornerRadius,
horizontalPadding = 0.0F,
verticalPadding = 0.0F,
titleBackgroundColor = it.titleBackgroundColor,
titleTextColor = it.titleTextColor,
titleTextPosition = it.titleTextPosition,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,13 @@ class DialogFragment internal constructor() : BaseBottomSheetDialog() {
dialogArguments.infoListItems?.let { items ->
initializeInfoListDialog(items, dialogArguments.itemDividers)
}
if (dialogArguments.horizontalPadding != null || dialogArguments.verticalPadding != null) {
val topPadding = dialogArguments.verticalPadding?.toInt() ?: nestedScrollView.paddingTop
val bottomPadding = dialogArguments.verticalPadding?.toInt() ?: nestedScrollView.paddingBottom
val startPadding = dialogArguments.horizontalPadding?.toInt() ?: nestedScrollView.paddingStart
val endPadding = dialogArguments.horizontalPadding?.toInt() ?: nestedScrollView.paddingEnd
nestedScrollView.setPadding(startPadding, topPadding, endPadding, bottomPadding)
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ class DialogFragmentArguments(
val showCloseButton: Boolean? = null,
val animateCornerRadiusWhenExpand: Boolean = true,
val cornerRadius: Float? = null,
val horizontalPadding: Float? = null,
val verticalPadding: Float? = null,
val content: CharSequence? = null,
val showContentAsHtml: Boolean = false,
@DrawableRes val contentImage: Int? = null,
Expand Down
1 change: 1 addition & 0 deletions libraries/dialogs/src/main/res/layout/fragment_dialog.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
layout="@layout/layout_dialog_header"/>

<androidx.core.widget.NestedScrollView
android:id="@+id/nestedScrollView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingStart="@dimen/ui_components_dialogs_margin_outer"
Expand Down

0 comments on commit b973d29

Please sign in to comment.