Class BottomSheet

All Implemented Interfaces:
Swipeable, Accessible, Buildable, ConstraintTarget, Proxy

@Generated("org.javagi.JavaGI") public final class BottomSheet extends Widget implements Swipeable, Accessible, Buildable, ConstraintTarget

A bottom sheet with an optional bottom bar.

bottom-sheet

AdwBottomSheet has three child widgets. BottomSheet:content is shown persistently. BottomSheet:sheet is displayed above it when it's open, and BottomSheet:bottom-bar is displayed when it's not.

Bottom sheet and bottom bar are attached to the bottom edge of the widget. They take the full width by default, but can only take a portion of it if BottomSheet:full-width is set to FALSE. In this case, BottomSheet:align determines where along the bottom edge they are placed.

Bottom bar can be hidden using the BottomSheet:reveal-bottom-bar property.

AdwBottomSheet can be useful for applications such as music players, that want to have a persistent bottom bar that expands into a bottom sheet when clicked. It's meant for cases where a bottom sheet is tightly integrated into the UI. For more transient bottom sheets, see Dialog.

To open or close the bottom sheet, use the BottomSheet:open property.

By default, the bottom sheet has an overlaid drag handle. It can be disabled by setting BottomSheet:show-drag-handle to FALSE. Note that the handle also controls whether the sheet can be dragged using a pointer.

Bottom sheets are modal by default, meaning that the content is dimmed and cannot be accessed while the sheet is open. Set BottomSheet:modal to FALSE if this behavior is unwanted.

To disable user interactions for opening or closing the bottom sheet (such as swipes or clicking the bottom bar or close button), set BottomSheet:can-open or BottomSheet:can-close to FALSE.

In some cases, particularly when using a full-width bottom bar, it may be necessary to shift BottomSheet:content upwards. Use the BottomSheet:bottom-bar-height and BottomSheet:sheet-height for that.

AdwBottomSheet is not adaptive, and for larger window sizes applications may want to replace it with another UI, such as a sidebar. This can be done using MultiLayoutView.

Sizing

Unlike Dialog presented as a bottom sheet, AdwBottomSheet just follows the content's natural size, and it's up to the applications to make sure their content provides one. For example, when using ScrolledWindow, make sure to set Gtk.ScrolledWindow:propagate-natural-height to TRUE.

Header Bar Integration

When placed inside an AdwBottomSheet, HeaderBar will not show the title when BottomSheet:show-drag-handle is TRUE, regardless of HeaderBar:show-title. This only applies to the default title, titles set with HeaderBar:title-widget will still be shown.

AdwBottomSheet as GtkBuildable:

The AdwBottomSheet implementation of the Buildable interface supports setting the sheet widget by specifying “sheet” as the “type” attribute of a <child> element, and the bottom bar by specifying “bottom-bar”. Specifying “content” or omitting the child type results in setting the content child.

Since:
1.6
  • Constructor Details

    • BottomSheet

      public BottomSheet(MemorySegment address)
      Create a BottomSheet instance for the provided memory address.
      Parameters:
      address - the memory address of the native object
    • BottomSheet

      public BottomSheet()
      Create a new BottomSheet.
  • Method Details

    • getType

      public static @Nullable Type getType()
      Get the GType of the BottomSheet class.
      Returns:
      the GType
    • getMemoryLayout

      public static MemoryLayout getMemoryLayout()
      The memory layout of the native struct.
      Returns:
      the memory layout
    • asParent

      protected BottomSheet asParent()
      Return this instance as if it were its parent type. Comparable to the Java super keyword, but ensures the parent typeclass is also used in native code.
      Overrides:
      asParent in class Widget
      Returns:
      the instance as if it were its parent type
    • getAlign

      public float getAlign()
      Gets horizontal alignment of the bottom sheet.
      Returns:
      the horizontal alignment
      Since:
      1.6
    • getBottomBar

      public @Nullable Widget getBottomBar()
      Gets the bottom bar widget for self.
      Returns:
      the bottom bar widget
      Since:
      1.6
    • getBottomBarHeight

      public int getBottomBarHeight()

      Gets the current bottom bar height.

      It can be used to shift the content upwards permanently to accommodate for the bottom bar.

      Returns:
      the bottom bar height
      Since:
      1.6
    • getCanClose

      public boolean getCanClose()
      Gets whether the bottom sheet can be closed by user.
      Returns:
      whether the sheet can be closed by user
      Since:
      1.6
    • getCanOpen

      public boolean getCanOpen()
      Gets whether the bottom sheet can be opened by user.
      Returns:
      whether the sheet can be opened by user.
      Since:
      1.6
    • getContent

      public @Nullable Widget getContent()
      Gets the content widget for self.
      Returns:
      the content widget
      Since:
      1.6
    • getFullWidth

      public boolean getFullWidth()
      Gets whether the bottom sheet takes the full width.
      Returns:
      whether the sheet takes up the full width
      Since:
      1.6
    • getModal

      public boolean getModal()
      Gets whether the bottom sheet is modal.
      Returns:
      whether the sheet is modal
      Since:
      1.6
    • getOpen

      public boolean getOpen()
      Gets whether the bottom sheet is open.
      Returns:
      whether the sheet is open
      Since:
      1.6
    • getRevealBottomBar

      public boolean getRevealBottomBar()
      Gets whether the bottom bar is revealed.
      Returns:
      whether the bottom bar is revealed
      Since:
      1.7
    • getSheet

      public @Nullable Widget getSheet()
      Gets the bottom sheet widget for self.
      Returns:
      the sheet widget
      Since:
      1.6
    • getSheetHeight

      public int getSheetHeight()

      Gets the current bottom sheet height.

      It can be used to shift the content upwards when the bottom sheet is open.

      Returns:
      the sheet height
      Since:
      1.6
    • getShowDragHandle

      public boolean getShowDragHandle()
      Gets whether to show a drag handle in the bottom sheet.
      Returns:
      whether to show the drag handle
      Since:
      1.6
    • setAlign

      public void setAlign(float align)

      Sets horizontal alignment of the bottom sheet.

      0 means the bottom sheet is flush with the start edge, 1 means it's flush with the end edge. 0.5 means it's centered.

      Only used when BottomSheet:full-width is set to FALSE.

      Parameters:
      align - the new alignment
      Since:
      1.6
    • setBottomBar

      public void setBottomBar(@Nullable Widget bottomBar)

      Sets the bottom bar widget for self.

      Shown when BottomSheet:open is FALSE. When open, morphs into the BottomSheet:sheet.

      Bottom bar can be temporarily hidden using the BottomSheet:reveal-bottom-bar property.

      Parameters:
      bottomBar - the bottom bar widget
      Since:
      1.6
    • setCanClose

      public void setCanClose(boolean canClose)

      Sets whether the bottom sheet can be closed by user.

      It can be closed via the close button, swiping down, pressing Escape or clicking the content dimming (when modal).

      Bottom sheet can still be closed using BottomSheet:open.

      Parameters:
      canClose - whether the sheet can be closed by user
      Since:
      1.6
    • setCanOpen

      public void setCanOpen(boolean canOpen)

      Sets whether the bottom sheet can be opened by user.

      It can be opened via clicking or swiping up from the bottom bar.

      Does nothing if BottomSheet:bottom-bar is not set.

      Bottom sheet can still be opened using BottomSheet:open.

      Parameters:
      canOpen - whether the sheet can be opened by user.
      Since:
      1.6
    • setContent

      public void setContent(@Nullable Widget content)

      Sets the content widget for self.

      It's always shown, and the bottom sheet is overlaid over it.

      Parameters:
      content - the content widget
      Since:
      1.6
    • setFullWidth

      public void setFullWidth(boolean fullWidth)

      Sets whether the bottom sheet takes the full width.

      When full width, BottomSheet:align is ignored.

      Parameters:
      fullWidth - whether the sheet takes up the full width
      Since:
      1.6
    • setModal

      public void setModal(boolean modal)

      Sets whether the bottom sheet is modal.

      When modal, BottomSheet:content will be dimmed when the bottom sheet is open, and clicking it will close the bottom sheet. It also cannot be focused with keyboard.

      Otherwise, the content is accessible even when the bottom sheet is open.

      Parameters:
      modal - whether the sheet is modal
      Since:
      1.6
    • setOpen

      public void setOpen(boolean open)
      Sets whether the bottom sheet is open.
      Parameters:
      open - whether to open the sheet
      Since:
      1.6
    • setRevealBottomBar

      public void setRevealBottomBar(boolean reveal)

      Sets whether to reveal the bottom bar.

      The transition will be animated.

      See BottomSheet:bottom-bar and BottomSheet:bottom-bar-height.

      Parameters:
      reveal - whether to reveal the bottom bar
      Since:
      1.7
    • setSheet

      public void setSheet(@Nullable Widget sheet)

      Sets the bottom sheet widget for self.

      Only shown when BottomSheet:open is TRUE.

      Parameters:
      sheet - the sheet widget
      Since:
      1.6
    • setShowDragHandle

      public void setShowDragHandle(boolean showDragHandle)

      Sets whether to show a drag handle in the bottom sheet.

      The handle will be overlaid over BottomSheet:sheet.

      When the handle is shown, HeaderBar will hide its default title, and ToolbarView will reserve space if there are no top bars.

      Showing drag handle also allows to swipe the bottom sheet down (and to swipe the bottom bar up) with a pointer, instead of just touchscreen.

      Parameters:
      showDragHandle - whether to show the drag handle
      Since:
      1.6
    • onCloseAttempt

      Emitted when the close button or shortcut is used while Dialog:can-close is set to FALSE.
      Parameters:
      handler - the signal handler
      Returns:
      a signal handler ID to keep track of the signal connection
      Since:
      1.6
      See Also:
    • emitCloseAttempt

      public void emitCloseAttempt()
      Emits the "close-attempt" signal. See onCloseAttempt(BottomSheet.CloseAttemptCallback).
    • builder

      public static BottomSheet.Builder<? extends BottomSheet.Builder> builder()
      A BottomSheet.Builder object constructs a BottomSheet with the specified properties. Use the various set...() methods to set properties, and finish construction with BottomSheet.Builder.build().
      Returns:
      the builder object