Skip to content

Commit

Permalink
feat(tools):新增可见性拓展方法
Browse files Browse the repository at this point in the history
  • Loading branch information
SakurajimaMaii committed Oct 20, 2024
1 parent 5104669 commit 1ff6d2a
Showing 1 changed file with 37 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,23 +33,55 @@ import com.ave.vastgui.tools.constant.DEFAULT_LOG_TAG
// Date: 2024/3/30
// Documentation: https://ave.entropy2020.cn/documents/tools/core-topics/ui/extension/view/

// ---------- Visibility ----------
// region Visibility
/** @since 1.2.1 */
fun View.gone() {
isGone = true
}

/** @since 1.5.1 */
fun View.goneIfVisible() {
if (isVisible) gone()
}

/** @since 1.5.1 */
fun View.goneIfInvisible() {
if (isInvisible) gone()
}

/** @since 1.2.1 */
fun View.visible() {
isVisible = true
}

/** @since 1.5.1 */
fun View.visibleIfGone() {
if (isGone) visible()
}

/** @since 1.5.1 */
fun View.visibleIfInvisible() {
if (isInvisible) visible()
}

/** @since 1.2.1 */
fun View.invisible() {
isInvisible = true
}

// ---------- KeyBroad ----------
/** @since 1.5.1 */
fun View.invisibleIfVisible() {
if (isVisible) invisible()
}

/** @since 1.5.1 */
fun View.invisibleIfGone() {
if (isGone) invisible()
}

// endregion

// region KeyBroad
/**
* Show KeyBroad.
*
Expand Down Expand Up @@ -108,4 +140,6 @@ fun EditText.isShouldHideKeyBroad(event: MotionEvent): Boolean {
val top = topLeft[1]
return !(event.rawX in left.toFloat()..(left + measuredWidth).toFloat() &&
event.rawY in top.toFloat()..(top + measuredHeight).toFloat())
}
}

// endregion

0 comments on commit 1ff6d2a

Please sign in to comment.