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

Hot Reload & Updating options knob does not work #387

Closed
buehler opened this issue Dec 15, 2022 · 0 comments · Fixed by #454
Closed

Hot Reload & Updating options knob does not work #387

buehler opened this issue Dec 15, 2022 · 0 comments · Fixed by #454
Assignees
Labels
t: bug Something isn't working

Comments

@buehler
Copy link

buehler commented Dec 15, 2022

Description
I tried to use widgetbook and created a small sample for myself. However, when using an options knob on a button with "button style", I need to switch panes to reflect the change in the button.

The second problem is hotreloading (in desktop environment), which does not update anything when I tell android studio to hot reload. Only a full hot restart does reflect the latest changes (even with a UniqueKey() in the whole widgetbook app).

Steps To Reproduce

  1. Start widgetbook

  2. Change some title in the code

  3. use hotreload -> nothing happens

  4. Use widgetbook

  5. Use an options knob

  6. Change it in the widget you are displaying -> widget is not rerendered

Expected Behavior
Both features should work like expected.

Screenshots
Hot Reload

Knob

Additional Context

Widgetbook build function
  @override
  Widget build(BuildContext context) {
    return Widgetbook.material(
      key: UniqueKey(),
      localizationsDelegates: [
        S.delegate,
        GlobalMaterialLocalizations.delegate,
        GlobalCupertinoLocalizations.delegate,
        GlobalWidgetsLocalizations.delegate,
      ],
      supportedLocales: S.delegate.supportedLocales,
      devices: [
        Samsung.s10,
        Apple.iPhone12ProMax,
        Apple.iPhone13Mini,
        Apple.iPhone11ProMax,
        Apple.iPhone11,
        Desktop.desktop1080p,
        Desktop.desktop1440p,
      ],
      themes: [
        WidgetbookTheme(
          name: 'Default',
          data: ThemeData(
              colorScheme: const ColorScheme.light(primary: AppColors.signal500, secondary: AppColors.text500)),
        )
      ],
      categories: [
        WidgetbookCategory(name: 'Brand', widgets: [
          WidgetbookComponent(name: 'Default', isExpanded: true, useCases: [
            ...colorUseCases,
            ...iconographyUseCases,
            ...typographyUseCases,
          ])
        ]),
        WidgetbookCategory(name: 'Components', isExpanded: true, widgets: [
          buttonsComponent,
        ]),
      ],
      appInfo: AppInfo(name: 'Widgetbook'),
    );
  }
buttons component
WidgetbookComponent buttonsComponent = WidgetbookComponent(name: 'Button', useCases: [
  WidgetbookUseCase(
    name: 'Default',
    builder: (context) => Center(
        child: Button(
            text: context.knobs.text(label: 'Text', description: 'Button label', initialValue: 'Click Me'),
            style: context.knobs.options(label: 'Style', options: [
              const Option(label: 'Primary', value: ButtonStyle.primary),
              const Option(label: 'Secondary', value: ButtonStyle.secondary),
            ]),
            onPressed: () {})),
  ),
  WidgetbookUseCase(
    name: 'Icon Button',
    builder: (context) => Center(
        child: IconButton(
            key: UniqueKey(), onPressed: () {}, icon: const Icon(AppIcons.back, color: AppColors.signal500))),
  ),
]);
@jenshor jenshor added the t: bug Something isn't working label Feb 7, 2023
@jenshor jenshor added this to the feat: widgetbook 3.0 milestone Feb 7, 2023
@jenshor jenshor self-assigned this Feb 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
t: bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants