Skip to content

Commit

Permalink
Merge pull request #58 from gulerbu/diaogs/linkable_content_support
Browse files Browse the repository at this point in the history
Add link support for dialog content
  • Loading branch information
gulerbu authored Nov 24, 2020
2 parents bb4586c + 29eb5a1 commit 9b2ef00
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 9 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.5"
const val phoneNumberVersion = "1.0.2"
const val dialogsVersion = "1.0.19"
const val dialogsVersion = "1.1.0"
const val cardInputViewVersion = "1.0.5"
const val quantityPickerViewVersion = "1.2.1"
const val timelineViewVersion = "1.0.0"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
package com.trendyol.uicomponents.dialogs

import android.app.Dialog
import android.os.Bundle
import android.text.SpannableString
import android.view.View
import android.text.method.LinkMovementMethod
import android.text.util.Linkify
import android.view.ViewGroup.FOCUS_AFTER_DESCENDANTS
import androidx.core.widget.doAfterTextChanged
import androidx.fragment.app.FragmentManager
import androidx.lifecycle.Observer
import androidx.lifecycle.ViewModelProviders
import com.google.android.material.bottomsheet.BottomSheetBehavior
import com.google.android.material.bottomsheet.BottomSheetDialog
import com.trendyol.dialog.R
import com.trendyol.dialog.databinding.FragmentDialogBinding
import com.trendyol.uicomponents.dialogs.list.DialogListAdapter
Expand Down Expand Up @@ -60,6 +58,9 @@ class DialogFragment internal constructor() : BaseBottomSheetDialog<FragmentDial
rightButtonClickListener?.invoke(this@DialogFragment)
}

textContent.autoLinkMask = Linkify.ALL
textContent.movementMethod = LinkMovementMethod.getInstance()

dialogArguments.items?.let { items ->
initializeRecyclerView()
editTextSearch.setOnFocusChangeListener { _, hasFocus ->
Expand Down Expand Up @@ -112,7 +113,7 @@ class DialogFragment internal constructor() : BaseBottomSheetDialog<FragmentDial
titleBackgroundColor = dialogArguments.titleBackgroundColor ?: R.color.dialogs_gray,
titleTextColor = dialogArguments.titleTextColor ?: R.color.primary_text_color,
titleTextPosition = dialogArguments.titleTextPosition ?: TextPosition.START,
contentTextPosition = dialogArguments.contentTextPosition ?: TextPosition.START
contentTextPosition = dialogArguments.contentTextPosition ?: TextPosition.START
)

binding.viewState = viewState
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import android.content.Context
import androidx.annotation.DrawableRes
import androidx.core.content.ContextCompat
import androidx.core.text.HtmlCompat
import com.trendyol.dialog.R

data class DialogViewState(
val title: String?,
Expand All @@ -31,7 +30,7 @@ data class DialogViewState(
fun isRightButtonVisible(): Boolean = rightButtonText != null

fun getContent(): CharSequence = if (showContentAsHtml) {
HtmlCompat.fromHtml(content.toString(), HtmlCompat.FROM_HTML_MODE_COMPACT)
HtmlCompat.fromHtml(content.toString(), HtmlCompat.FROM_HTML_MODE_LEGACY)
} else {
content
}
Expand All @@ -42,7 +41,7 @@ data class DialogViewState(

fun getTitleBackground(context: Context) = ContextCompat.getColor(context, titleBackgroundColor)

fun getTitleTextColor(context: Context) = ContextCompat.getColor(context, titleTextColor)
fun getTitleTextColor(context: Context) = ContextCompat.getColor(context, titleTextColor)

fun getTitleTextPosition(): Int {
return when (titleTextPosition) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,19 +142,26 @@ class DialogsActivity : AppCompatActivity() {
.bold {
append(" Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.")
}
.append("[email protected]")
.append(" Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.")
.append(" Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.")
.append("trendyol.com")
.append(" Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.")
.append(" Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.")
.append(" Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.")
.append(" Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.")
.append("+905066979797")




private fun getHtmlString(): String =
"<h1>Enter the main heading, usually the same as the title.</h1>\n" +
"<p>Be <b>bold</b> in stating your key points. Put them in a list: </p>\n" +
"<ul>\n" +
"<li>The first item in your list</li>\n" +
"<li>The second item; <i>italicize</i> key words</li>\n" +
"<a href=\"https://www.trendyol.com/\">Visit Trendyol!</a>" +
"</ul>"

private fun getListItems(): List<Pair<Boolean, String>> =
Expand Down

0 comments on commit 9b2ef00

Please sign in to comment.