Skip to content

Commit

Permalink
Merge pull request #94 from Trendyol/dialogs/removeCustomDialog
Browse files Browse the repository at this point in the history
Remove CustomDialog support
  • Loading branch information
turkergoksu authored Mar 2, 2022
2 parents b973d29 + 1db2c32 commit 6edf9bd
Show file tree
Hide file tree
Showing 13 changed files with 3 additions and 186 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.0"
const val dialogsVersion = "1.3.1"
const val cardInputViewVersion = "1.1.3"
const val quantityPickerViewVersion = "1.2.5"
const val timelineViewVersion = "1.0.0"
Expand Down
Binary file removed images/dialogs-6.png
Binary file not shown.
30 changes: 2 additions & 28 deletions 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"/>
<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.0 [![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
$dialogsVersion = dialogs-1.3.1 [![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 @@ -169,32 +169,6 @@ infoListDialog {
}
```

* Custom Dialog

CustomDialog is a dialog that has a fixed header and its content can take a custom view.

| 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
val customView = ExampleCustomView(context)
customDialog {
title = SpannableStringBuilder().color(Color.RED) { append("Custom Dialog Sample") }
showCloseButton = true
animateCornerRadiusWhenExpand = false
cornerRadius = 0F
closeButtonListener = infoDialogClosed
titleBackgroundColor = R.color.colorAccent
titleTextColor = R.color.colorPrimary
titleTextPosition = TextPosition.CENTER
view = customView
}
```

## TODOs
* Implement ListDialog.
* ~~Implement SelectionDialog~~
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.trendyol.uicomponents.dialogs

import android.text.SpannableString
import android.view.View
import android.webkit.WebView
import androidx.annotation.DrawableRes

Expand Down Expand Up @@ -158,28 +157,3 @@ class InfoListDialogBuilder internal constructor() : InfoDialogBuilder() {

}
}

class CustomDialogBuilder internal constructor() : Builder() {

var view: View? = null

internal fun buildCustomDialog(block: CustomDialogBuilder.() -> Unit): DialogFragment {
return CustomDialogBuilder().apply(block).let {
DialogFragment().apply {
arguments = DialogFragmentArguments(
title = it.title,
showCloseButton = it.showCloseButton,
animateCornerRadiusWhenExpand = animateCornerRadiusWhenExpand,
cornerRadius = it.cornerRadius,
horizontalPadding = 0.0F,
verticalPadding = 0.0F,
titleBackgroundColor = it.titleBackgroundColor,
titleTextColor = it.titleTextColor,
titleTextPosition = it.titleTextPosition,
view = { it.view }
).toBundle()
this.closeButtonListener = it.closeButtonListener
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,3 @@ fun agreementDialog(block: AgreementDialogBuilder.() -> Unit): DialogFragment =

fun selectionDialog(block: SelectionDialogBuilder.() -> Unit): DialogFragment =
SelectionDialogBuilder().buildSelectionDialog(block)

fun customDialog(block: CustomDialogBuilder.() -> Unit): DialogFragment =
CustomDialogBuilder().buildCustomDialog(block)
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,6 @@ class DialogFragment internal constructor() : BaseBottomSheetDialog() {
titleTextPosition = dialogArguments.titleTextPosition ?: TextPosition.START,
contentTextPosition = dialogArguments.contentTextPosition ?: TextPosition.START,
webViewContent = dialogArguments.webViewContent,
customView = dialogArguments.view?.invoke(),
)

with(binding) {
Expand Down Expand Up @@ -204,11 +203,6 @@ class DialogFragment internal constructor() : BaseBottomSheetDialog() {
text = viewState.rightButtonText
visibility = viewState.getRightButtonVisibility()
}
with(frameLayoutCustom) {
visibility = viewState.getCustomViewVisibility()
if (viewState.getCustomViewVisibility() == View.VISIBLE)
addView(viewState.customView)
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package com.trendyol.uicomponents.dialogs

import android.os.Bundle
import android.os.Parcelable
import android.view.View
import android.webkit.WebView
import androidx.annotation.ColorRes
import androidx.annotation.DrawableRes
Expand Down Expand Up @@ -38,7 +37,6 @@ class DialogFragmentArguments(
val webViewBuilder: (WebView.() -> Unit)? = null,
val infoListItems: List<Pair<CharSequence, CharSequence>>? = null,
val itemDividers: List<ItemDivider> = emptyList(),
val view: (() -> View?)? = null
) : Parcelable {

fun toBundle() = bundleOf("ARGUMENTS" to this)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ data class DialogViewState(
val titleTextPosition: TextPosition,
val contentTextPosition: TextPosition,
val webViewContent: WebViewContent?,
val customView: View?,
) {

fun getTitleVisibility(): Int = if (title.isNullOrEmpty().not()) View.VISIBLE else View.GONE
Expand Down Expand Up @@ -82,6 +81,4 @@ data class DialogViewState(
fun getLeftButtonVisibility(): Int = if (leftButtonText != null) View.VISIBLE else View.GONE

fun getRightButtonVisibility(): Int = if (rightButtonText != null) View.VISIBLE else View.GONE

fun getCustomViewVisibility(): Int = if (customView != null) View.VISIBLE else View.GONE
}
9 changes: 0 additions & 9 deletions libraries/dialogs/src/main/res/layout/fragment_dialog.xml
Original file line number Diff line number Diff line change
Expand Up @@ -148,15 +148,6 @@
app:layout_constraintWidth_percent="0.4"
tools:text="Ok"
tools:visibility="gone" />

<FrameLayout
android:id="@+id/frameLayoutCustom"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"/>
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.core.widget.NestedScrollView>
</LinearLayout>
Expand Down
15 changes: 0 additions & 15 deletions sample/src/main/java/com/trendyol/uicomponents/DialogsActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ class DialogsActivity : AppCompatActivity() {
private val buttonSelectionWithSearchDialog by lazy { findViewById<Button>(R.id.button_selection_with_search_dialog) }
private val buttonInfoDialogWithWebView by lazy { findViewById<Button>(R.id.button_info_dialog_webview) }
private val buttonInfoListDialog by lazy { findViewById<Button>(R.id.button_info_list_dialog) }
private val buttonCustomDialog by lazy { findViewById<Button>(R.id.button_custom_dialog) }

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
Expand All @@ -33,7 +32,6 @@ class DialogsActivity : AppCompatActivity() {
buttonSelectionWithSearchDialog.setOnClickListener { showSelectionWithSearchDialog() }
buttonInfoDialogWithWebView.setOnClickListener { showInfoDialogWithWebView() }
buttonInfoListDialog.setOnClickListener { showInfoListDialog() }
buttonCustomDialog.setOnClickListener { showCustomDialog() }
}

private val infoDialogClosed: (DialogFragment) -> Unit = { showToast("Info dialog closed.") }
Expand Down Expand Up @@ -154,19 +152,6 @@ class DialogsActivity : AppCompatActivity() {
}.showDialog(supportFragmentManager)
}

private fun showCustomDialog() {
val customView = ExampleCustomView(this@DialogsActivity)
val customDialog = customDialog {
title = "Custom View Dialog"
showCloseButton = true
view = customView
}

customView.setButtonCancelClickListener { customDialog.dismiss() }
customView.setButtonOkClickListener { Toast.makeText(this, "Ok", Toast.LENGTH_SHORT).show() }
customDialog.showDialog(supportFragmentManager)
}

override fun onRestoreInstanceState(savedInstanceState: Bundle) {
super.onRestoreInstanceState(savedInstanceState)
setDialogFragmentListenersIfNecessary()
Expand Down

This file was deleted.

11 changes: 0 additions & 11 deletions sample/src/main/res/layout/activity_dialogs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -81,15 +81,4 @@
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/button_info_dialog_webview" />

<com.google.android.material.button.MaterialButton
android:id="@+id/button_custom_dialog"
style="@style/Sample.ButtonStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="32dp"
android:text="Show Custom Dialog"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/button_info_list_dialog" />
</androidx.constraintlayout.widget.ConstraintLayout>
58 changes: 0 additions & 58 deletions sample/src/main/res/layout/view_custom_example.xml

This file was deleted.

0 comments on commit 6edf9bd

Please sign in to comment.