Skip to content

Commit

Permalink
upd
Browse files Browse the repository at this point in the history
  • Loading branch information
witwash committed Oct 2, 2024
1 parent f2fc41c commit be668f8
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 37 deletions.
22 changes: 0 additions & 22 deletions optimus_widgetbook/lib/components/common/common.dart

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,14 @@ Widget createDefaultStyle(BuildContext context) {
);
final duration =
knobs.int.slider(label: 'Duration', initialValue: 1, min: 0, max: 5);
final contentAlign = knobs.alignmentKnob;
final contentAlign = knobs.alignmentKnob();

return Padding(
padding: const EdgeInsets.all(16),
child: Stack(
children: [
Align(
alignment: contentAlign.$1,
alignment: contentAlign,
child: OptimusTooltipWrapper(
text: Text(text),
autoHideDuration: Duration(seconds: duration),
Expand All @@ -46,7 +46,7 @@ Widget createDefaultStyle(BuildContext context) {
child: const Icon(OptimusIcons.alert_circle),
),
),
if (contentAlign.$1 != Alignment.center)
if (contentAlign != Alignment.center)
Center(
child: SizedBox(
width: 400,
Expand Down
4 changes: 2 additions & 2 deletions optimus_widgetbook/lib/components/forms/select_input.dart
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,10 @@ class _SelectInputStoryState extends State<SelectInputStory> {
final allowMultipleSelection =
k.boolean(label: 'Multiselect', initialValue: true);

final alignment = k.alignmentKnob;
final alignment = k.alignmentKnob();

return Align(
alignment: alignment.$1,
alignment: alignment,
child: ConstrainedBox(
constraints: const BoxConstraints(maxWidth: 400),
child: OptimusSelectInput<String>(
Expand Down
4 changes: 2 additions & 2 deletions optimus_widgetbook/lib/components/layout/inline_dialog.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ class _InlineDialogStoryState extends State<InlineDialogStory> {
Widget build(BuildContext context) {
final k = context.knobs;
final hasActions = k.boolean(label: 'Has actions', initialValue: false);
final position = k.alignmentKnob;
final position = k.alignmentKnob();

return Align(
alignment: position.$1,
alignment: position,
child: OptimusButton(
key: _anchor,
onPressed: () => DialogWrapper.of(context)?.showInline(
Expand Down
1 change: 0 additions & 1 deletion optimus_widgetbook/lib/components/list/expanded_list.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import 'package:flutter/widgets.dart';
import 'package:optimus/optimus.dart';
import 'package:optimus_widgetbook/components/common/common.dart';
import 'package:optimus_widgetbook/utils.dart';
import 'package:widgetbook/widgetbook.dart';
import 'package:widgetbook_annotation/widgetbook_annotation.dart' as widgetbook;
Expand Down
1 change: 0 additions & 1 deletion optimus_widgetbook/lib/components/list/list_tile.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import 'package:dfunc/dfunc.dart';
import 'package:flutter/widgets.dart';
import 'package:optimus/optimus.dart';
import 'package:optimus_widgetbook/components/common/common.dart';
import 'package:optimus_widgetbook/utils.dart';
import 'package:widgetbook/widgetbook.dart';
import 'package:widgetbook_annotation/widgetbook_annotation.dart' as widgetbook;
Expand Down
30 changes: 24 additions & 6 deletions optimus_widgetbook/lib/utils.dart
Original file line number Diff line number Diff line change
@@ -1,31 +1,49 @@
import 'package:flutter/widgets.dart';
import 'package:optimus/optimus.dart';
import 'package:optimus_widgetbook/components/common/common.dart';
import 'package:widgetbook/widgetbook.dart';

final List<IconDetails> exampleIcons = optimusIcons.take(10).toList();
final List<AlignmentGeometry> alignments = [
Alignment.center,
Alignment.centerLeft,
Alignment.centerRight,
Alignment.topLeft,
Alignment.topRight,
Alignment.bottomLeft,
Alignment.bottomRight,
];

const longText = '''
Nascetur nec convallis tempor sagittis ligula. Mauris aenean curae vestibulum
aenean fames posuere consequat turpis. Cursus lectus rutrum dolor condimentum
rhoncus tincidunt rutrum. Hac amet class vivamus rhoncus condimentum; penatibus
risus magnis. Penatibus nulla venenatis nulla praesent mauris. Morbi feugiat
rhoncus ridiculus varius faucibus commodo tincidunt ipsum molestie. Volutpat
semper aptent viverra facilisi nam nibh suscipit purus himenaeos. Himenaeos
quisque ultrices condimentum mauris a diam.''';

extension KnobsBuilderExt on KnobsBuilder {
OptimusWidgetSize get widgetSizeKnob => list(
label: 'Size',
options: OptimusWidgetSize.values,
labelBuilder: (value) => value.name,
);

IconDetails optimusIconKnob({required String label}) => list(
IconDetails optimusIconKnob({String label = 'Icon'}) => list(
label: label,
options: exampleIcons,
labelBuilder: (value) => value.name,
);

IconDetails? optimusIconOrNullKnob({required String label}) => listOrNull(
IconDetails? optimusIconOrNullKnob({String label = 'Icon'}) => listOrNull(
label: label,
options: exampleIcons,
labelBuilder: (value) => value?.name ?? 'None',
);

(Alignment, String) get alignmentKnob => list(
label: 'Alignment',
AlignmentGeometry alignmentKnob({String label = 'Alignment'}) => list(
label: label,
options: alignments,
labelBuilder: (value) => value.$2,
);

bool get isEnabledKnob => boolean(label: 'Enabled', initialValue: true);
Expand Down

0 comments on commit be668f8

Please sign in to comment.