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

Feature: Slide controller & adjustable RelativeBubbleSlideChild #11

Open
wants to merge 13 commits into
base: master
Choose a base branch
from

Conversation

ming-o-0
Copy link

@ming-o-0 ming-o-0 commented Nov 14, 2020

Features

  1. Slide controller which cab be called from bubble slide child
    There are 2 arguments added to Showcase widget.
  • slideNumberStreamTrigger this to go to targeted slide. It is invoked by Stream. If receiving input is over length of slides or less, the showcase is finished. While providing position number less than -1, the showcase will stand still.
  • slideActionStream Trigger this to control slide to go next, back to previous or close. You can use StreamController to control slide like this example:
final StreamController<SlideControllerAction> slideActionConroller = StreamController();

BubbleShowcase(
  bubbleShowcaseId: 'my_bubble_showcase',
  bubbleShowcaseVersion: 2,
  bubbleSlides: [
    AbsoluteBubbleSlide(
      positionCalculator: (size) => Position(
        top: 0,
        right: 0,
        bottom: 0,
        left: 0,
      ),
      child: AbsoluteBubbleSlideChild(
        positionCalculator: (size) => Position(
          top: 0,
          left: 0,
        ),
        widget: SpeechBubble(
          nipLocation: NipLocation.LEFT,
          color: Colors.blue,
          child: Padding(
            padding: EdgeInsets.all(10),
            child: Column(
              children: [
                Text(
                  'This is the top left corner of your app.',
                  style: TextStyle(color: Colors.white),
                ),
                Row(
                  mainAxisSize: MainAxisSize.min,
                  children: [
                    GestureDetector(
                      onTap: () => slideActionConroller
                          .add(SlideControllerAction.previous),
                      child: Text('previous'),
                    ),
                    Container(
                      margin: EdgeInsets.only(left: 16.0),
                      child: RaisedButton(
                        child: Text('Next'),
                        onPressed: () {
                          slideActionConroller
                              .add(SlideControllerAction.next);
                        },
                      ),
                    ),
                    Container(
                      margin: EdgeInsets.only(left: 16.0),
                      child: RaisedButton(
                        child: Text('Done'),
                        onPressed: () {
                          slideActionConroller
                              .add(SlideControllerAction.close);
                        },
                      ),
                    )
                  ],
                ),
              ],
            ),
          ),
        ),
      ),
    ),
  ],
  child: MyMainWidget(),
);
  1. Disable click on overlay since user can now control slide using slide controller stream.
    There is a argument added to Showcase widget
  • enabledClickOnOverlayToNextSlide Whether to enable click on overlay to go to next slide. (default to true)
  1. Adding arguments to RelativeBubbleSlideChild to adjust size since it is constraint by parent size which some times not big enough to fit the content.
    extraWidthRight Additional width to the right. Working only with direction up & down.
    extraWidthLeft Additional width to the left. Working only with direction up & down.
    extraHeightTop Additional height to the top. Working only with direction left & right.
    extraHeightBottom Additional height to the bottom. Working only with direction left & right.

Notes
On both slideNumberStream and slideActionStream, I'm trying to cancel subscription when widget is disposed but after assign stream.listen() to a variable, the subscription does not work.

@rodineijf
Copy link
Contributor

Wouldn't it be better to have the state inside slideActionConroller and instead of using stream parameters only calling slideActionController.goToIndex() or slideActionController.next()?

One good example of this behavior is the PageViewController.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants