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

refactor: small fixes on remix #512

Merged
merged 4 commits into from
Nov 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/remix/demo/lib/components/accordion_use_case.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Widget buildAccordionUseCase(BuildContext context) {
child: SizedBox(
width: 300,
child: Accordion(
header: (spec) => XAccordionHeaderSpecWidget(
header: (spec) => AccordionHeaderSpecWidget(
title: context.knobs.string(
label: 'Title',
initialValue: 'Title',
Expand Down
1 change: 1 addition & 0 deletions packages/remix/demo/lib/components/checkbox_use_case.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ Widget buildCheckboxUseCase(BuildContext context) {
key: _key,
child: Center(
child: Checkbox(
label: context.knobs.string(label: 'Label', initialValue: 'Label'),
variants: [context.knobs.variant(FortalezaCheckboxStyle.variants)],
disabled:
context.knobs.boolean(label: 'Disabled', initialValue: false),
Expand Down
4 changes: 0 additions & 4 deletions packages/remix/demo/lib/components/menu_item_use_case.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import 'package:demo/helpers/knob_builder.dart';
import 'package:flutter/material.dart' hide Scaffold;
import 'package:remix/remix.dart';
import 'package:widgetbook/widgetbook.dart';
Expand All @@ -18,9 +17,6 @@ Widget buildButtonUseCase(BuildContext context) {
child: SizedBox(
width: 350,
child: MenuItem(
variants: [
context.knobs.variant(FortalezaButtonStyle.variants),
],
title: context.knobs.string(
label: 'Title',
initialValue: 'Menu Item',
Expand Down
90 changes: 41 additions & 49 deletions packages/remix/demo/lib/components/radio_use_case.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,70 +5,62 @@ import 'package:remix/remix.dart';
import 'package:widgetbook/widgetbook.dart';
import 'package:widgetbook_annotation/widgetbook_annotation.dart' as widgetbook;

final _key = GlobalKey();

enum Theme {
dark,
light,
system,
system;
}

@widgetbook.UseCase(
name: 'Radio Component',
type: Radio,
)
Widget buildRadioUseCase(BuildContext context) {
return const Scaffold(
return Scaffold(
body: Center(
child: RadioExample(),
child: ListenableBuilder(
listenable: _state,
builder: (context, child) {
return Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.min,
children: Theme.values
.map(
(theme) => Padding(
padding: const EdgeInsets.all(4.0),
child: Radio<Theme>(
value: theme,
disabled: context.knobs.boolean(
label: 'Disabled',
initialValue: false,
),
groupValue: _state.value,
onChanged: (value) {
_state.update(value!);
},
variants: [
context.knobs.variant(FortalezaRadioStyle.variants)
],
label: theme.name.capitalize(),
),
),
)
.toList(),
);
},
),
),
);
}

class RadioExample extends StatefulWidget {
const RadioExample({super.key});

@override
State<RadioExample> createState() => _RadioExampleState();
}
class _ThemeState extends ValueNotifier<Theme> {
_ThemeState(super.value);

class _RadioExampleState extends State<RadioExample> {
Theme _theme = Theme.dark;

@override
Widget build(BuildContext context) {
return SizedBox(
width: 200,
child: Column(
mainAxisSize: MainAxisSize.min,
key: _key,
children: <Widget>[
for (var theme in Theme.values) ...[
Row(
children: [
Radio<Theme>(
variants: [
context.knobs.variant(FortalezaRadioStyle.variants)
],
value: theme,
groupValue: _theme,
onChanged: (Theme? value) {
setState(() {
_theme = value!;
});
},
disabled: context.knobs.boolean(
label: 'Disabled',
initialValue: false,
),
text: theme.name.capitalize(),
),
],
),
const SizedBox(height: 8),
]
],
),
);
void update(Theme value) {
this.value = value;
notifyListeners();
}
}

_ThemeState _state = _ThemeState(Theme.dark);
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@ class _WidgetDemoState extends State<_WidgetDemo> {
return SegmentedControl(
index: index,
buttons: const [
XSegmentButton(
SegmentButton(
text: 'Apple',
),
XSegmentButton(
SegmentButton(
text: 'Pear',
),
XSegmentButton(
SegmentButton(
text: 'Banana',
),
],
Expand Down
2 changes: 1 addition & 1 deletion packages/remix/demo/lib/components/select_use_case.dart
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class _SelectDemoState extends State<SelectDemo> {
items.length,
(index) => SelectMenuItem<String>(
value: items[index],
child: XSelectMenuItemWidget(
child: SelectMenuItemWidget(
text: items[index],
),
),
Expand Down
Loading
Loading