Skip to content

Commit

Permalink
Implement updateAlign relevant methods for Compose
Browse files Browse the repository at this point in the history
  • Loading branch information
skydoves committed Dec 27, 2023
1 parent 4472e0a commit a1f95f0
Show file tree
Hide file tree
Showing 3 changed files with 79 additions and 0 deletions.
10 changes: 10 additions & 0 deletions balloon-compose/api/balloon-compose.api
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,11 @@ public abstract interface class com/skydoves/balloon/compose/BalloonWindow {
public abstract fun showAsDropDown (II)V
public abstract fun showAtCenter (IILcom/skydoves/balloon/BalloonCenterAlign;)V
public abstract fun update (II)V
public abstract fun updateAlign (Lcom/skydoves/balloon/BalloonAlign;II)V
public abstract fun updateAlignBottom (II)V
public abstract fun updateAlignEnd (II)V
public abstract fun updateAlignStart (II)V
public abstract fun updateAlignTop (II)V
public abstract fun updateSizeOfBalloonCard (II)V
}

Expand Down Expand Up @@ -116,6 +121,11 @@ public final class com/skydoves/balloon/compose/BalloonWindow$DefaultImpls {
public static synthetic fun showAsDropDown$default (Lcom/skydoves/balloon/compose/BalloonWindow;IIILjava/lang/Object;)V
public static synthetic fun showAtCenter$default (Lcom/skydoves/balloon/compose/BalloonWindow;IILcom/skydoves/balloon/BalloonCenterAlign;ILjava/lang/Object;)V
public static synthetic fun update$default (Lcom/skydoves/balloon/compose/BalloonWindow;IIILjava/lang/Object;)V
public static synthetic fun updateAlign$default (Lcom/skydoves/balloon/compose/BalloonWindow;Lcom/skydoves/balloon/BalloonAlign;IIILjava/lang/Object;)V
public static synthetic fun updateAlignBottom$default (Lcom/skydoves/balloon/compose/BalloonWindow;IIILjava/lang/Object;)V
public static synthetic fun updateAlignEnd$default (Lcom/skydoves/balloon/compose/BalloonWindow;IIILjava/lang/Object;)V
public static synthetic fun updateAlignStart$default (Lcom/skydoves/balloon/compose/BalloonWindow;IIILjava/lang/Object;)V
public static synthetic fun updateAlignTop$default (Lcom/skydoves/balloon/compose/BalloonWindow;IIILjava/lang/Object;)V
}

public final class com/skydoves/balloon/compose/ComposableSingletons$BalloonComposeViewKt {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,30 @@ internal class BalloonComposeView(
yOff: Int,
): Balloon = balloon.relayShowAlign(align, balloon, anchorView, xOff, yOff)

override fun updateAlignTop(xOff: Int, yOff: Int) {
balloon.updateAlignTop(anchorView, xOff, yOff)
}

override fun updateAlignBottom(xOff: Int, yOff: Int) {
balloon.updateAlignBottom(anchorView, xOff, yOff)
}

override fun updateAlignEnd(xOff: Int, yOff: Int) {
balloon.updateAlignEnd(anchorView, xOff, yOff)
}

override fun updateAlignStart(xOff: Int, yOff: Int) {
balloon.updateAlignStart(anchorView, xOff, yOff)
}

override fun updateAlign(align: BalloonAlign, xOff: Int, yOff: Int) {
balloon.updateAlign(align, anchorView, xOff, yOff)
}

@Deprecated(
"Use updateAlign instead.",
replaceWith = ReplaceWith("updateAlign(BalloonAlign.Top, xOff, yOff)"),
)
override fun update(xOff: Int, yOff: Int): Unit = balloon.update(anchorView, xOff, yOff)

override fun showAlign(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -402,13 +402,58 @@ public interface BalloonWindow {
yOff: Int = 0,
): Balloon

/**
* Update the balloon on an [anchorView] as the top alignment with x-off and y-off.
*
* @param xOff A horizontal offset from the anchor in pixels.
* @param yOff A vertical offset from the anchor in pixels.
*/
public fun updateAlignTop(xOff: Int = 0, yOff: Int = 0)

/**
* Update the balloon on an [anchorView] as the bottom alignment with x-off and y-off.
*
* @param xOff A horizontal offset from the anchor in pixels.
* @param yOff A vertical offset from the anchor in pixels.
*/
public fun updateAlignBottom(xOff: Int = 0, yOff: Int = 0)

/**
* Update the balloon on an [anchorView] as the end alignment with x-off and y-off.
*
* @param xOff A horizontal offset from the anchor in pixels.
* @param yOff A vertical offset from the anchor in pixels.
*/
public fun updateAlignEnd(xOff: Int = 0, yOff: Int = 0)

/**
* Update the balloon on an [anchorView] as the start alignment with x-off and y-off.
*
* @param xOff A horizontal offset from the anchor in pixels.
* @param yOff A vertical offset from the anchor in pixels.
*/
public fun updateAlignStart(xOff: Int = 0, yOff: Int = 0)

/**
* Update the balloon on an [anchorView] as the bottom alignment with x-off and y-off.
*
* @param align Decides where the balloon should be placed.
* @param xOff A horizontal offset from the anchor in pixels.
* @param yOff A vertical offset from the anchor in pixels.
*/
public fun updateAlign(align: BalloonAlign, xOff: Int = 0, yOff: Int = 0)

/**
* updates popup and arrow position of the popup based on
* a new target anchor view with additional x-off and y-off.
*
* @param xOff A horizontal offset from the anchor in pixels.
* @param yOff A vertical offset from the anchor in pixels.
*/
@Deprecated(
"Use updateAlign instead.",
replaceWith = ReplaceWith("updateAlign(BalloonAlign.Top, xOff, yOff)"),
)
public fun update(xOff: Int = 0, yOff: Int = 0)

/** updates the size of the balloon card. */
Expand Down

0 comments on commit a1f95f0

Please sign in to comment.