Skip to content
This repository has been archived by the owner on Oct 18, 2024. It is now read-only.

Commit

Permalink
fix(uidesigner): dismiss view info sheet before it is shown (fixes #1169
Browse files Browse the repository at this point in the history
)
  • Loading branch information
itsaky committed Aug 3, 2023
1 parent 800600e commit ece8257
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,11 @@ class DesignerWorkspaceFragment : BaseFragment() {

internal fun showViewInfo(view: IView) {
viewModel.view = view
viewInfo.show(childFragmentManager, ViewInfoSheet.TAG)

val existing = childFragmentManager.findFragmentByTag(ViewInfoSheet.TAG)
if (existing == null) {
viewInfo.show(childFragmentManager, ViewInfoSheet.TAG)
}
}

private fun setupViewGroup(viewGroup: UiViewGroup) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ constructor(
defStyleRes: Int = 0
) : LinearLayout(context, attrs, defStyleAttr, defStyleRes) {

private val textToIView = mutableMapOf<HierarchyText, com.itsaky.androidide.inflater.IView>()
private var onClick: ((com.itsaky.androidide.inflater.IView) -> Unit)? = null
private val textToIView = mutableMapOf<HierarchyText, IView>()
private var onClick: ((IView) -> Unit)? = null

private val clickListener = OnClickListener { view ->
onClick?.let { click -> textToIView[view]?.let(click) }
Expand All @@ -70,15 +70,15 @@ constructor(
paint.isAntiAlias = true
}

fun setupWithView(view: com.itsaky.androidide.inflater.IView, onClick: ((com.itsaky.androidide.inflater.IView) -> Unit)? = null) {
fun setupWithView(view: IView, onClick: ((IView) -> Unit)? = null) {
removeAllViews()
textToIView.clear()

this.onClick = onClick
addViews(view, 1)
}

private fun addViews(view: com.itsaky.androidide.inflater.IView, depth: Int) {
private fun addViews(view: IView, depth: Int) {
val text =
HierarchyText(context, depth, dp16).apply {
this.text = view.tag
Expand Down

0 comments on commit ece8257

Please sign in to comment.