Skip to content

Commit

Permalink
refactor: adjusted code to match linter
Browse files Browse the repository at this point in the history
  • Loading branch information
jenshor committed May 25, 2022
1 parent 965c355 commit 04dd9f1
Show file tree
Hide file tree
Showing 37 changed files with 161 additions and 142 deletions.
1 change: 1 addition & 0 deletions packages/widgetbook/analysis_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ linter:
public_member_api_docs: false
avoid_equals_and_hash_code_on_mutable_classes: false
avoid_dynamic_calls: false
library_private_types_in_public_api: false
lines_longer_than_80_chars: false
2 changes: 1 addition & 1 deletion packages/widgetbook/lib/src/knobs/bool_knob.dart
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,6 @@ class _BooleanKnobWidgetState extends State<BooleanKnobWidget> {
context.read<KnobsNotifier>().update(widget.label, v);
},
),
));
),);
}
}
4 changes: 2 additions & 2 deletions packages/widgetbook/lib/src/knobs/knobs.dart
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ class KnobsNotifier extends ChangeNotifier implements KnobsBuilder {
label: label,
value: initialValue,
description: description,
));
),);

@override
String? nullableText({
Expand Down Expand Up @@ -255,7 +255,7 @@ class KnobWrapper extends StatelessWidget {
style: const TextStyle(
fontWeight: FontWeight.w600,
fontSize: 16,
color: Styles.notCompletelyWhite),
color: Styles.notCompletelyWhite,),
),
const Spacer(),
if (nullableCheckbox != null) ...[
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import 'package:widgetbook/widgetbook.dart';
/// Helper to navigate the folder tree.
class FolderHelper {
static List<WidgetbookFolder> getAllFoldersFromCategories(
List<WidgetbookCategory> categories) {
List<WidgetbookCategory> categories,) {
final folders = <WidgetbookFolder>[];
for (final category in categories) {
folders.addAll(
Expand All @@ -14,12 +14,12 @@ class FolderHelper {
}

static List<WidgetbookFolder> getAllFoldersFromCategory(
WidgetbookCategory category) {
WidgetbookCategory category,) {
return getAllFoldersFromFolders(category.folders);
}

static List<WidgetbookFolder> getAllFoldersFromFolders(
List<WidgetbookFolder> folders) {
List<WidgetbookFolder> folders,) {
final folderList = <WidgetbookFolder>[];
for (final folder in folders) {
folderList.addAll(
Expand All @@ -30,7 +30,7 @@ class FolderHelper {
}

static List<WidgetbookFolder> getAllFoldersFromFolder(
WidgetbookFolder folder) {
WidgetbookFolder folder,) {
final folderList = List<WidgetbookFolder>.from(
<WidgetbookFolder>[folder],
)..addAll(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import 'package:widgetbook/src/models/organizers/organizers.dart';
/// Helper to obtain all Stories in the navigation tree.
class StoryHelper {
static List<WidgetbookUseCase> getAllStoriesFromCategories(
List<WidgetbookCategory> categories) {
List<WidgetbookCategory> categories,) {
final widgets = WidgetHelper.getAllWidgetElementsFromCategories(
categories,
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import 'package:widgetbook/widgetbook.dart';
/// helper to obtain all WidgetElements in the navigation tree.
class WidgetHelper {
static List<WidgetbookComponent> getAllWidgetElementsFromCategories(
List<WidgetbookCategory> categories) {
List<WidgetbookCategory> categories,) {
final widgets = <WidgetbookComponent>[];
for (final category in categories) {
widgets.addAll(
Expand All @@ -14,7 +14,7 @@ class WidgetHelper {
}

static List<WidgetbookComponent> getAllWidgetElementsFromCategory(
WidgetbookCategory category) {
WidgetbookCategory category,) {
final widgetList = List<WidgetbookComponent>.from(
category.widgets,
)..addAll(
Expand All @@ -24,7 +24,7 @@ class WidgetHelper {
}

static List<WidgetbookComponent> getAllWidgetElementsFromFolders(
List<WidgetbookFolder> folders) {
List<WidgetbookFolder> folders,) {
final widgetList = <WidgetbookComponent>[];
for (final folder in folders) {
widgetList.addAll(
Expand All @@ -35,7 +35,7 @@ class WidgetHelper {
}

static List<WidgetbookComponent> getAllWidgetElementsFromFolder(
WidgetbookFolder folder) {
WidgetbookFolder folder,) {
final widgetList = List<WidgetbookComponent>.from(folder.widgets)
..addAll(
getAllWidgetElementsFromFolders(folder.folders),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,9 @@ class OrganizerProvider extends StateChangeNotifier<OrganizerState> {
/// Set isExpanded an [ExpandableOrganizer] and its nested organizer to
/// the `expanded`
void setExpandedRecursive(
List<ExpandableOrganizer> organizers, bool expanded) {
List<ExpandableOrganizer> organizers, {
required bool expanded,
}) {
// Since this is modifying the object directly instead of modifying via
// copyWith, we need to call notifyListeners and are not emmitting a new
// state object. The state will be adjusted by adjusted the object.
Expand Down
2 changes: 1 addition & 1 deletion packages/widgetbook/lib/src/services/filter_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class FilterService {
}

ExpandableOrganizer? _filterOrganizer(
RegExp regExp, ExpandableOrganizer organizer) {
RegExp regExp, ExpandableOrganizer organizer,) {
if (organizer.name.contains(regExp)) {
return organizer;
}
Expand Down
64 changes: 33 additions & 31 deletions packages/widgetbook/lib/src/settings_panel/settings_panel.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,41 +13,43 @@ class SettingsPanel<CustomTheme> extends StatelessWidget {
Widget build(BuildContext context) {
return DefaultTabController(
length: 2,
child: Column(children: [
SizedBox(
height: Constants.controlBarHeight,
child: TabBar(
indicatorColor: Theme.of(context).colorScheme.primary,
tabs: const [
Tab(
key: Key('knobsTab'),
icon: Text('Knobs'),
child: Column(
children: [
SizedBox(
height: Constants.controlBarHeight,
child: TabBar(
indicatorColor: Theme.of(context).colorScheme.primary,
tabs: const [
Tab(
key: Key('knobsTab'),
icon: Text('Knobs'),
),
Tab(
key: Key('propertiesTab'),
icon: Text('Properties'),
),
],
),
),
const SizedBox(
height: 16,
),
Expanded(
child: DecoratedBox(
decoration: BoxDecoration(
color: Theme.of(context).colorScheme.surface,
borderRadius: Radii.defaultRadius,
),
Tab(
key: Key('propertiesTab'),
icon: Text('Properties'),
child: TabBarView(
children: [
const KnobsPanel(),
PropertyPanel<CustomTheme>(),
],
),
],
),
),
const SizedBox(
height: 16,
),
Expanded(
child: Container(
decoration: BoxDecoration(
color: Theme.of(context).colorScheme.surface,
borderRadius: Radii.defaultRadius,
),
child: TabBarView(
children: [
const KnobsPanel(),
PropertyPanel<CustomTheme>(),
],
),
),
),
]),
],
),
);
}
}
2 changes: 1 addition & 1 deletion packages/widgetbook/lib/src/utils/styles.dart
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ class Styles {
switchTheme: SwitchThemeData(
thumbColor: MaterialStateProperty.all(primary),
trackColor: MaterialStateProperty.resolveWith((states) =>
states.contains(MaterialState.selected) ? primary : null)),
states.contains(MaterialState.selected) ? primary : null,),),
inputDecorationTheme: const InputDecorationTheme(
border: OutlineInputBorder(
borderSide: BorderSide(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,10 @@ class _ExpandButtonState extends State<ExpandButton> {
size: widget.size,
),
onTap: () {
context
.read<OrganizerProvider>()
.setExpandedRecursive(widget.organizers, widget.expandTo);
context.read<OrganizerProvider>().setExpandedRecursive(
widget.organizers,
expanded: widget.expandTo,
);
},
),
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ class ComparisonRenderer<CustomTheme> extends StatelessWidget {
child: _buildSingleDevice(
workbenchState: workbenchState,
localizationState: localizationState,
builder: builder),
builder: builder,),
);
case ComparisonSetting.themes:
return _buildThemeComparison(
Expand Down
10 changes: 5 additions & 5 deletions packages/widgetbook/lib/src/workbench/renderer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -89,20 +89,20 @@ class Renderer<CustomTheme> extends StatelessWidget {
builder: useCaseBuilder,
),
);
}),
},),
);
},
),
);
});
}),
},);
},),
);
},
),
);
}),
},),
);
}),
},),
),
],
);
Expand Down
2 changes: 1 addition & 1 deletion packages/widgetbook/lib/src/workbench/workbench.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class Workbench<CustomTheme> extends StatelessWidget {
height: 16,
),
Expanded(
child: Container(
child: DecoratedBox(
decoration: BoxDecoration(
borderRadius: Radii.defaultRadius,
color: context.colorScheme.surface,
Expand Down
5 changes: 3 additions & 2 deletions packages/widgetbook/lib/src/workbench/workbench_provider.dart
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,12 @@ class WorkbenchProvider<CustomTheme>
}

void changedComparisonSetting(ComparisonSetting comparisonSetting) {
var setting = comparisonSetting;
if (state.comparisonSetting == comparisonSetting) {
comparisonSetting = ComparisonSetting.none;
setting = ComparisonSetting.none;
}

final newState = resetComparisonSetting(comparisonSetting);
final newState = resetComparisonSetting(setting);

switch (comparisonSetting) {
case ComparisonSetting.none:
Expand Down
4 changes: 2 additions & 2 deletions packages/widgetbook/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -517,7 +517,7 @@ packages:
name: very_good_analysis
url: "https://pub.dartlang.org"
source: hosted
version: "2.3.0"
version: "3.0.0"
vm_service:
dependency: transitive
description:
Expand Down Expand Up @@ -568,5 +568,5 @@ packages:
source: hosted
version: "3.1.0"
sdks:
dart: ">=2.17.0-0 <3.0.0"
dart: ">=2.17.0 <3.0.0"
flutter: ">=2.0.0"
4 changes: 2 additions & 2 deletions packages/widgetbook/test/src/knobs/bool_knob_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ void main() {
initialValue: true,
)
? 'Hi'
: 'Bye')
]),
: 'Bye',)
],),
);
expect(find.text('Hi'), findsOneWidget);
await tester.pumpAndSettle();
Expand Down
6 changes: 3 additions & 3 deletions packages/widgetbook/test/src/knobs/knobs_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ void main() {
initialValue: true,
)
? 'Hi'
: 'Bye'),
: 'Bye',),
...knobsNotifier.all().map((e) => e.build())
],
);
Expand All @@ -61,7 +61,7 @@ void main() {
await tester.pumpWidgetWithMaterialApp(ChangeNotifierProvider(
create: (context) => knobsNotifier,
child: Builder(builder: useCase.builder),
));
),);
expect(knobsNotifier.all().length, equals(1));

expect(
Expand All @@ -71,7 +71,7 @@ void main() {
label: 'label',
value: true,
)
]));
]),);
},
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ void main() {
text = 'wont happen';
}
return [Text(text)];
}),
},),
);

expect(find.text('idk'), findsOneWidget);
Expand Down Expand Up @@ -89,7 +89,7 @@ void main() {
text = 'wont happen';
}
return [Text(text)];
}),
},),
);

expect(find.text('idk'), findsOneWidget);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,15 @@ void main() {
final text = value ?? 'default';

return [Text(text)];
}),
},),
);

expect(find.text('default'), findsOneWidget);

await tester.tap(find.byKey(const Key('label-nullableCheckbox')));
await tester.pumpAndSettle();
await tester.enterText(
find.byKey(const Key('label-textKnob')), 'awesome');
find.byKey(const Key('label-textKnob')), 'awesome',);
await tester.pumpAndSettle();
expect(find.text('awesome'), findsWidgets);
expect(find.text('default'), findsNothing);
Expand All @@ -56,15 +56,15 @@ void main() {
final text = value ?? 'default';

return [Text(text)];
}),
},),
);

expect(find.text('default'), findsOneWidget);

await tester.tap(find.byKey(const Key('label-nullableCheckbox')));
await tester.pumpAndSettle();
await tester.enterText(
find.byKey(const Key('label-textKnob')), 'awesome');
find.byKey(const Key('label-textKnob')), 'awesome',);
await tester.pumpAndSettle();
expect(find.text('awesome'), findsWidgets);
expect(find.text('default'), findsNothing);
Expand Down
Loading

0 comments on commit 04dd9f1

Please sign in to comment.