Skip to content
This repository was archived by the owner on Feb 17, 2025. It is now read-only.

Feature: Slide controller & adjustable RelativeBubbleSlideChild - #11

Open
ming-o-0 wants to merge 13 commits into
Skyost:masterfrom
ming-o-0:features/slide-controller
Open

Feature: Slide controller & adjustable RelativeBubbleSlideChild#11
ming-o-0 wants to merge 13 commits into
Skyost:masterfrom
ming-o-0:features/slide-controller

Conversation

@ming-o-0

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

Copy link
Copy Markdown

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
Copy Markdown
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 subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants