Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Toast and Modal: Custom location #22

Merged
merged 2 commits into from
Dec 21, 2024
Merged

Toast and Modal: Custom location #22

merged 2 commits into from
Dec 21, 2024

Conversation

DJ-Raven
Copy link
Owner

This PR update add custom location toast and modal

Custom toast

// create toast option
ToastOption toastOption = Toast.createOption();

// set toast location and toast direction
toastOption.getLayoutOption()
        .setLocation(100, 100)
        .setDirection(ToastDirection.LEFT_TO_RIGHT_BOTTOM);

// show toast with option
Toast.show(this, Toast.Type.SUCCESS, "Success message", toastOption);

Set toast location center of the windows frame

// create toast option
ToastOption toastOption = Toast.createOption();

// set both horizontal and vertical center
toastOption.getLayoutOption()
        .setLocation(0.5f, 0.5f);

// set only horizontal center
toastOption.getLayoutOption()
        .setLocation(0.5f, 100);

we can use value as percentage of the windows frame as float type. for fixed value use int and double type

  • 0.5f = 50%
  • 1f = 100%
  • 100 = 100px

Toast Location

These are 6 types of default toast location that we can use.
Use enum ToastLocation from package raven.modal.toast.option.ToastLocation

  • TOP_LEADING
  • TOP_CENTER
  • TOP_TRAILING
  • BOTTOM_LEADING
  • BOTTOM_CENTER
  • BOTTOM_TRAILING

Toast Direction

These are 6 types of toast direction that we can use.
Use enum ToastDirection from package raven.modal.toast.option.ToastDirection

  • TOP_TO_BOTTOM
  • BOTTOM_TO_TOP
  • LEFT_TO_RIGHT_TOP
  • LEFT_TO_RIGHT_BOTTOM
  • RIGHT_TO_LEFT_TOP
  • RIGHT_TO_LEFT_BOTTOM

Custom modal

// create modal option
Option option = ModalDialog.createOption();

// set modal location
option.getLayoutOption()
        .setLocation(100, 100);

// set modal to center of the frame
option.getLayoutOption()
        .setLocation(Location.CENTER, Location.CENTER);

// set location leading and top fixed 100px
option.getLayoutOption()
        .setLocation(Location.LEADING, 100);

// show modal
ModalDialog.showModal(this, new SimpleModalBorder(comDisplay, "Title"), option);

@DJ-Raven DJ-Raven added the enhancement New feature or request label Dec 21, 2024
@DJ-Raven DJ-Raven added this to the 2.2.0 milestone Dec 21, 2024
@DJ-Raven DJ-Raven merged commit 707ddd3 into main Dec 21, 2024
@DJ-Raven DJ-Raven deleted the custom-location branch December 21, 2024 06:51
@DJ-Raven DJ-Raven mentioned this pull request Dec 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant