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

feat: Accordion interaction based on open variable #546

Merged
merged 13 commits into from
Dec 26, 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
12 changes: 12 additions & 0 deletions packages/mix/lib/src/attributes/animated/animated_data.dart
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,18 @@ class AnimatedData {
return AnimatedDataDto(duration: duration, curve: curve, onEnd: _onEnd);
}

AnimatedData copyWith({
Duration? duration,
Curve? curve,
VoidCallback? onEnd,
}) {
return AnimatedData(
duration: duration ?? this.duration,
curve: curve ?? this.curve,
onEnd: onEnd ?? this.onEnd,
);
}

@override
bool operator ==(Object other) {
if (identical(this, other)) return true;
Expand Down
2 changes: 2 additions & 0 deletions packages/remix/demo/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@
*.swp
.DS_Store
.atom/
.build/
.buildlog/
.history
.svn/
.swiftpm/
migrate_working_dir/

# IntelliJ related
Expand Down
15 changes: 12 additions & 3 deletions packages/remix/demo/lib/components/accordion_use_case.dart
Original file line number Diff line number Diff line change
@@ -1,21 +1,27 @@
import 'package:demo/addons/icon_data_knob.dart';
import 'package:demo/helpers/use_case_state.dart';
import 'package:flutter/material.dart' as m;
import 'package:flutter/widgets.dart';
import 'package:mix/mix.dart';
import 'package:remix/remix.dart';
import 'package:widgetbook/widgetbook.dart';
import 'package:widgetbook_annotation/widgetbook_annotation.dart' as widgetbook;

final _accordionKey = GlobalKey();

@widgetbook.UseCase(
name: 'Accordion Component',
type: Accordion,
)
Widget buildAccordionUseCase(BuildContext context) {
final knobState = WidgetbookState.of(context);

return Scaffold(
body: Center(
child: SizedBox(
width: 300,
child: Accordion(
key: _accordionKey,
header: (spec) => AccordionHeaderSpecWidget(
title: context.knobs.string(
label: 'Title',
Expand All @@ -33,11 +39,14 @@ Widget buildAccordionUseCase(BuildContext context) {
),
spec: spec,
),
initiallyExpanded: true,
content: (spec) => TextSpecWidget(
expanded:
context.knobs.boolean(label: 'Expanded', initialValue: true),
content: const StyledText(
'Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry\'s standard dummy text ever since the 1500s',
spec: spec,
),
onChanged: (value) {
knobState.updateKnob('Expanded', !value);
},
),
),
),
Expand Down
95 changes: 95 additions & 0 deletions packages/remix/demo/lib/components/dropdown_menu.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
import 'package:flutter/material.dart' as m;
import 'package:flutter/widgets.dart';
import 'package:remix/remix.dart';
import 'package:widgetbook_annotation/widgetbook_annotation.dart' as widgetbook;

@widgetbook.UseCase(
name: 'DropdownMenu Component',
type: DropdownMenu,
)
Widget buildDropdownMenu(BuildContext context) {
return const Scaffold(
body: Center(
child: DropdownMenuDemo(),
),
);
}

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

@override
State<DropdownMenuDemo> createState() => _DropdownMenuDemoState();
}

enum MenuItem {
home,
profile,
}

class _DropdownMenuDemoState extends State<DropdownMenuDemo> {
bool open = false;
@override
Widget build(BuildContext context) {
return Center(
child: DropdownMenu(
trigger: IconButton(
m.Icons.menu,
onPressed: () {
setState(() {
open = !open;
});
},
),
onPressOutside: () {
setState(() {
open = false;
});
},
open: open,
items: [
const DropdownMenuItem(
text: 'Features',
variants: [
DropdownMenuStyle.itemLabel,
],
),
DropdownMenuItem(
text: 'home',
onPress: () {
setState(() {
open = false;
});
showToast(
context: context,
entry: ToastEntry(
builder: (context, actions) => const Toast(
title: 'home was selected',
),
),
);
},
),
DropdownMenuItem(
text: 'profile',
onPress: () {
setState(() {
open = false;
});
showToast(
context: context,
entry: ToastEntry(
builder: (context, actions) => const Toast(
title: 'profile was selected',
),
),
);
},
),
],
),
);
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import 'package:demo/helpers/knob_builder.dart';
import 'package:flutter/material.dart' as m;
import 'package:flutter/widgets.dart';
import 'package:remix/remix.dart';
import 'package:remix/themes/fortaleza.dart';
Expand Down Expand Up @@ -41,15 +40,16 @@ class _SelectDemoState extends State<SelectDemo> {
SizedBox(
width: 200,
child: Select<String>(
disabled:
context.knobs.boolean(label: 'disabled', initialValue: false),
variants: [context.knobs.variant(FortalezaSelectStyle.variants)],
value: selectedValue,
onChanged: (value) => setState(() => selectedValue = value),
button: (spec) => spec(
trigger: SelectTrigger(
text: selectedValue,
trailingIcon: m.Icons.keyboard_arrow_down_rounded,
disabled: context.knobs.boolean(
label: 'disabled',
initialValue: false,
),
),
variants: [context.knobs.variant(FortalezaSelectStyle.variants)],
items: List.generate(
items.length,
(index) => SelectMenuItem<String>(
Expand Down
52 changes: 30 additions & 22 deletions packages/remix/demo/lib/main.directories.g.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,18 @@ import 'package:demo/components/checkbox_use_case.dart' as _i8;
import 'package:demo/components/chip_use_case.dart' as _i9;
import 'package:demo/components/dialog_use_case.dart' as _i10;
import 'package:demo/components/divider_use_case.dart' as _i11;
import 'package:demo/components/icon_button_use_case.dart' as _i12;
import 'package:demo/components/menu_item_use_case.dart' as _i13;
import 'package:demo/components/progress_use_case.dart' as _i14;
import 'package:demo/components/radio_use_case.dart' as _i15;
import 'package:demo/components/segmented_control_use_case.dart' as _i16;
import 'package:demo/components/select_use_case.dart' as _i17;
import 'package:demo/components/slider.dart' as _i18;
import 'package:demo/components/spinner_use_case.dart' as _i19;
import 'package:demo/components/switch_use_case.dart' as _i20;
import 'package:demo/components/textfield_use_case.dart' as _i21;
import 'package:demo/components/toast_use_case.dart' as _i22;
import 'package:demo/components/dropdown_menu.dart' as _i12;
import 'package:demo/components/icon_button_use_case.dart' as _i13;
import 'package:demo/components/menu_item_use_case.dart' as _i14;
import 'package:demo/components/progress_use_case.dart' as _i15;
import 'package:demo/components/radio_use_case.dart' as _i16;
import 'package:demo/components/segmented_control_use_case.dart' as _i17;
import 'package:demo/components/select.dart' as _i18;
import 'package:demo/components/slider.dart' as _i19;
import 'package:demo/components/spinner_use_case.dart' as _i20;
import 'package:demo/components/switch_use_case.dart' as _i21;
import 'package:demo/components/textfield_use_case.dart' as _i22;
import 'package:demo/components/toast_use_case.dart' as _i23;
import 'package:widgetbook/widgetbook.dart' as _i1;

final directories = <_i1.WidgetbookNode>[
Expand Down Expand Up @@ -106,81 +107,88 @@ final directories = <_i1.WidgetbookNode>[
builder: _i11.buildDivider,
),
),
_i1.WidgetbookLeafComponent(
name: 'DropdownMenu',
useCase: _i1.WidgetbookUseCase(
name: 'DropdownMenu Component',
builder: _i12.buildDropdownMenu,
),
),
_i1.WidgetbookLeafComponent(
name: 'IconButton',
useCase: _i1.WidgetbookUseCase(
name: 'Button Component',
builder: _i12.buildButtonUseCase,
builder: _i13.buildButtonUseCase,
),
),
_i1.WidgetbookLeafComponent(
name: 'MenuItem',
useCase: _i1.WidgetbookUseCase(
name: 'Menu Item Component',
builder: _i13.buildButtonUseCase,
builder: _i14.buildButtonUseCase,
),
),
_i1.WidgetbookLeafComponent(
name: 'Progress',
useCase: _i1.WidgetbookUseCase(
name: 'Progress Component',
builder: _i14.buildProgressUseCase,
builder: _i15.buildProgressUseCase,
),
),
_i1.WidgetbookLeafComponent(
name: 'Radio',
useCase: _i1.WidgetbookUseCase(
name: 'Radio Component',
builder: _i15.buildRadioUseCase,
builder: _i16.buildRadioUseCase,
),
),
_i1.WidgetbookLeafComponent(
name: 'SegmentedControl',
useCase: _i1.WidgetbookUseCase(
name: 'SegmentedControl Component',
builder: _i16.buildAccordionUseCase,
builder: _i17.buildAccordionUseCase,
),
),
_i1.WidgetbookLeafComponent(
name: 'Select',
useCase: _i1.WidgetbookUseCase(
name: 'Select Component',
builder: _i17.buildSelect,
builder: _i18.buildSelect,
),
),
_i1.WidgetbookLeafComponent(
name: 'Slider',
useCase: _i1.WidgetbookUseCase(
name: 'Slider Component',
builder: _i18.buildButtonUseCase,
builder: _i19.buildButtonUseCase,
),
),
_i1.WidgetbookLeafComponent(
name: 'Spinner',
useCase: _i1.WidgetbookUseCase(
name: 'Spinner Component',
builder: _i19.buildSpinnerUseCase,
builder: _i20.buildSpinnerUseCase,
),
),
_i1.WidgetbookLeafComponent(
name: 'Switch',
useCase: _i1.WidgetbookUseCase(
name: 'Switch Component',
builder: _i20.buildSwitchUseCase,
builder: _i21.buildSwitchUseCase,
),
),
_i1.WidgetbookLeafComponent(
name: 'TextField',
useCase: _i1.WidgetbookUseCase(
name: 'TextField Component',
builder: _i21.buildButtonUseCase,
builder: _i22.buildButtonUseCase,
),
),
_i1.WidgetbookLeafComponent(
name: 'Toast',
useCase: _i1.WidgetbookUseCase(
name: 'Toast Component',
builder: _i22.buildButtonUseCase,
builder: _i23.buildButtonUseCase,
),
),
],
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
// This is a generated file; do not edit or check into version control.
FLUTTER_ROOT=/Users/lucasoliveira/fvm/versions/stable
FLUTTER_APPLICATION_PATH=/Users/lucasoliveira/Developer/Projects/hairday/packages/mix/packages/remix/demo
FLUTTER_APPLICATION_PATH=/Users/lucasoliveira/Developer/Mix/PoCs/remix_toast/packages/mix/packages/remix/demo
COCOAPODS_PARALLEL_CODE_SIGN=true
FLUTTER_TARGET=/Users/lucasoliveira/Developer/Projects/hairday/packages/mix/packages/remix/demo/lib/main.dart
FLUTTER_TARGET=/Users/lucasoliveira/Developer/Mix/PoCs/remix_toast/packages/mix/packages/remix/demo/lib/main.dart
FLUTTER_BUILD_DIR=build
FLUTTER_BUILD_NAME=1.0.0
FLUTTER_BUILD_NUMBER=1
DART_OBFUSCATION=false
TRACK_WIDGET_CREATION=true
TREE_SHAKE_ICONS=false
PACKAGE_CONFIG=/Users/lucasoliveira/Developer/Projects/hairday/packages/mix/packages/remix/demo/.dart_tool/package_config.json
PACKAGE_CONFIG=/Users/lucasoliveira/Developer/Mix/PoCs/remix_toast/packages/mix/packages/remix/demo/.dart_tool/package_config.json
Loading
Loading