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

Add a knob to show layout explorer view #78

Open
prolificcoder opened this issue May 27, 2022 · 5 comments
Open

Add a knob to show layout explorer view #78

prolificcoder opened this issue May 27, 2022 · 5 comments

Comments

@prolificcoder
Copy link

Not sure how complicated this is but would it be possible to add a know for something that we see in a layout explorer?

I am more interested in seeing margins and paddings.

image

Some context: We are hoping to give access to our Desingers pre-merge for custom widgets, so that they can play with them and make sure they are good before developers merge them.

@ookami-kb
Copy link
Owner

I've done some investigation, and I don't think that's (easily) doable.

Some helpers can be done (e.g. switching debugPaintSizeEnabled – but the question is how to make it have an effect on the story content only, not on the whole app), but they will only work in debug mode.

Using Flutter layout inspector will require a huge amount of work, as it's not available as a library that can be integrated.

But the idea is interesting, I'll leave the issue open, maybe there are other solutions.

@kekland
Copy link

kekland commented Sep 26, 2022

@ookami-kb @prolificcoder just saw this issue, and I think I have some sort of a solution for this. I've published a package called inspector quite a while ago (https://github.com/kekland/inspector), which aims to bring the functionality of the layout inspector to the app itself.

I've tried incorporating it with storybook_flutter, and it seems to be working just fine!

Example code:

class StorybookApp extends StatelessWidget {
  StorybookApp({super.key});

  final storybookKey = GlobalKey();

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        body: Inspector(
          child: Storybook(
            key: storybookKey,
            stories: stories,
          ),
        ),
      ),
    );
  }
}

Screen Shot 2022-09-26 at 23 35 41

Let me know if this works.

P.S. The package still needs some improvements, but alas I don't have enough time to maintain it. However, the core functionality still works :)

@ookami-kb
Copy link
Owner

@kekland it looks pretty interesting, I'll check it, thanks!

@kekland
Copy link

kekland commented Sep 26, 2022

@ookami-kb I've just updated Inspector to 1.1.4, which should bring some improvements. Another thing is that I've fixed an issue with the package that previously made using it in wrapperBuilder impossible - now it should work just fine.

    return Storybook(
      key: storybookKey,
      stories: stories,
      wrapperBuilder: (context, child) => materialWrapper(
        context,
        Inspector(child: child!),
      ),
    );

Perhaps I can make a package which exports Inspector as a plugin for storybook_flutter?

@ookami-kb
Copy link
Owner

@kekland yes, a separate plug-in package makes total sense 👍

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

No branches or pull requests

3 participants