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: Chip component #504

Merged
merged 49 commits into from
Oct 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
ef7c826
Create remix app
tilucasoli Oct 8, 2024
7e2393b
lint review
tilucasoli Oct 8, 2024
884c678
Update remix_app.dart
tilucasoli Oct 8, 2024
aaf6f89
create dialog component
tilucasoli Oct 8, 2024
9a1f654
Create dialog
tilucasoli Oct 8, 2024
a63cfb9
remove comments
tilucasoli Oct 8, 2024
c77523a
Update dialog.dart
tilucasoli Oct 8, 2024
170dd96
create toast
tilucasoli Oct 9, 2024
81a33b5
scaffold
tilucasoli Oct 9, 2024
308adf7
Update remix_app.dart
tilucasoli Oct 9, 2024
d4cd98e
adapt demo to new RemixApp
tilucasoli Oct 9, 2024
bfd5648
lint fixes
tilucasoli Oct 9, 2024
7b825c5
dialog
tilucasoli Oct 9, 2024
a75433a
fix widgetbook
tilucasoli Oct 9, 2024
02f7ecd
dialog
tilucasoli Oct 9, 2024
b029d4c
small fixes
tilucasoli Oct 10, 2024
7e45a21
chip
tilucasoli Oct 11, 2024
5a27a7a
chip component
tilucasoli Oct 11, 2024
2a15100
lint fixes
tilucasoli Oct 14, 2024
8ffd1df
Create remix app
tilucasoli Oct 8, 2024
374a0e0
lint review
tilucasoli Oct 8, 2024
dad0e1e
Update remix_app.dart
tilucasoli Oct 8, 2024
a72e0b4
create dialog component
tilucasoli Oct 8, 2024
84600d6
Create dialog
tilucasoli Oct 8, 2024
6d22a94
remove comments
tilucasoli Oct 8, 2024
b62f2cd
Update dialog.dart
tilucasoli Oct 8, 2024
43052c5
create toast
tilucasoli Oct 9, 2024
058b046
scaffold
tilucasoli Oct 9, 2024
6a6b0a3
Update remix_app.dart
tilucasoli Oct 9, 2024
30dbc8e
adapt demo to new RemixApp
tilucasoli Oct 9, 2024
f3029b8
lint fixes
tilucasoli Oct 9, 2024
db0de02
dialog
tilucasoli Oct 9, 2024
205054e
fix widgetbook
tilucasoli Oct 9, 2024
e27b9db
dialog
tilucasoli Oct 9, 2024
2027e85
small fixes
tilucasoli Oct 10, 2024
476ae07
create scaffold as a component
tilucasoli Oct 17, 2024
8b31f36
toast fixes
tilucasoli Oct 17, 2024
acf1b7e
fix card
tilucasoli Oct 17, 2024
346e9ce
create toast
tilucasoli Oct 9, 2024
462d16d
adapt demo to new RemixApp
tilucasoli Oct 9, 2024
8aa9819
chip
tilucasoli Oct 11, 2024
23702df
chip component
tilucasoli Oct 11, 2024
78cf5da
lint fixes
tilucasoli Oct 14, 2024
d7bc05c
rebase
tilucasoli Oct 17, 2024
249743d
fix conflicts
tilucasoli Oct 17, 2024
6e4dd07
generated files
tilucasoli Oct 17, 2024
5fb535c
Merge branch 'main' into feat/chip
tilucasoli Oct 17, 2024
62d8cc9
Update main.directories.g.dart
tilucasoli Oct 17, 2024
343ecbd
Update remix.dart
tilucasoli Oct 17, 2024
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 .fvmrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"flutter": "3.19.0",
"flutter": "stable",
"flavors": {
"prod": "stable",
"mincompat": "3.19.0"
Expand Down
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"source.fixAll": "explicit",
"source.dcm.fixAll": "explicit"
},
"dart.flutterSdkPath": ".fvm/versions/3.19.0",
"dart.flutterSdkPath": ".fvm/versions/stable",
"dart.lineLength": 80,
"search.exclude": {
"**/.fvm/versions": true
Expand Down
48 changes: 48 additions & 0 deletions packages/remix/demo/lib/components/chip_use_case.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import 'package:demo/addons/icon_data_knob.dart';
import 'package:demo/helpers/knob_builder.dart';
import 'package:demo/helpers/use_case_state.dart';
import 'package:flutter/widgets.dart';
import 'package:remix/remix.dart';
import 'package:widgetbook/widgetbook.dart';
import 'package:widgetbook_annotation/widgetbook_annotation.dart' as widgetbook;

final _key = GlobalKey();

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

return KeyedSubtree(
key: _key,
child: Scaffold(
body: Center(
child: Chip(
value: context.knobs.boolean(label: 'Checked', initialValue: true),
onChanged: (value) => knobState.updateKnob('Checked', value),
variants: [
context.knobs.variant(FortalezaChipStyle.variants),
],
label: context.knobs.string(
label: 'Label',
initialValue: 'Chip',
),
disabled: context.knobs.boolean(
label: 'Disabled',
initialValue: false,
),
iconLeft: context.knobs.iconData(
label: 'Icon left',
initialValue: null,
),
iconRight: context.knobs.iconData(
label: 'Icon right',
initialValue: null,
),
),
),
),
);
}
53 changes: 33 additions & 20 deletions packages/remix/demo/lib/main.directories.g.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,17 @@ import 'package:demo/components/button_use_case.dart' as _i5;
import 'package:demo/components/callout_use_case.dart' as _i6;
import 'package:demo/components/card_use_case.dart' as _i7;
import 'package:demo/components/checkbox_use_case.dart' as _i8;
import 'package:demo/components/dialog_use_case.dart' as _i9;
import 'package:demo/components/divider_use_case.dart' as _i10;
import 'package:demo/components/icon_button_use_case.dart' as _i11;
import 'package:demo/components/progress_use_case.dart' as _i12;
import 'package:demo/components/radio_use_case.dart' as _i13;
import 'package:demo/components/segmented_control_use_case.dart' as _i14;
import 'package:demo/components/select_use_case.dart' as _i15;
import 'package:demo/components/spinner_use_case.dart' as _i16;
import 'package:demo/components/switch_use_case.dart' as _i17;
import 'package:demo/components/toast_use_case.dart' as _i18;
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/progress_use_case.dart' as _i13;
import 'package:demo/components/radio_use_case.dart' as _i14;
import 'package:demo/components/segmented_control_use_case.dart' as _i15;
import 'package:demo/components/select_use_case.dart' as _i16;
import 'package:demo/components/spinner_use_case.dart' as _i17;
import 'package:demo/components/switch_use_case.dart' as _i18;
import 'package:demo/components/toast_use_case.dart' as _i19;
import 'package:widgetbook/widgetbook.dart' as _i1;

final directories = <_i1.WidgetbookNode>[
Expand Down Expand Up @@ -116,14 +117,26 @@ final directories = <_i1.WidgetbookNode>[
)
],
),
_i1.WidgetbookFolder(
name: 'chip',
children: [
_i1.WidgetbookLeafComponent(
name: 'Chip',
useCase: _i1.WidgetbookUseCase(
name: 'Chip Component',
builder: _i9.buildChipUseCase,
),
)
],
),
_i1.WidgetbookFolder(
name: 'dialog',
children: [
_i1.WidgetbookLeafComponent(
name: 'Dialog',
useCase: _i1.WidgetbookUseCase(
name: 'Dialog Component',
builder: _i9.buildButtonUseCase,
builder: _i10.buildButtonUseCase,
),
)
],
Expand All @@ -135,7 +148,7 @@ final directories = <_i1.WidgetbookNode>[
name: 'Divider',
useCase: _i1.WidgetbookUseCase(
name: 'Divider Component',
builder: _i10.buildDivider,
builder: _i11.buildDivider,
),
)
],
Expand All @@ -147,7 +160,7 @@ final directories = <_i1.WidgetbookNode>[
name: 'IconButton',
useCase: _i1.WidgetbookUseCase(
name: 'Button Component',
builder: _i11.buildButtonUseCase,
builder: _i12.buildButtonUseCase,
),
)
],
Expand All @@ -159,7 +172,7 @@ final directories = <_i1.WidgetbookNode>[
name: 'Progress',
useCase: _i1.WidgetbookUseCase(
name: 'Progress Component',
builder: _i12.buildProgressUseCase,
builder: _i13.buildProgressUseCase,
),
)
],
Expand All @@ -171,7 +184,7 @@ final directories = <_i1.WidgetbookNode>[
name: 'Radio',
useCase: _i1.WidgetbookUseCase(
name: 'Radio Component',
builder: _i13.buildRadioUseCase,
builder: _i14.buildRadioUseCase,
),
)
],
Expand All @@ -183,7 +196,7 @@ final directories = <_i1.WidgetbookNode>[
name: 'SegmentedControl',
useCase: _i1.WidgetbookUseCase(
name: 'SegmentedControl Component',
builder: _i14.buildAccordionUseCase,
builder: _i15.buildAccordionUseCase,
),
)
],
Expand All @@ -195,7 +208,7 @@ final directories = <_i1.WidgetbookNode>[
name: 'Select',
useCase: _i1.WidgetbookUseCase(
name: 'Select Component',
builder: _i15.buildSelect,
builder: _i16.buildSelect,
),
)
],
Expand All @@ -207,7 +220,7 @@ final directories = <_i1.WidgetbookNode>[
name: 'Spinner',
useCase: _i1.WidgetbookUseCase(
name: 'Spinner Component',
builder: _i16.buildSpinnerUseCase,
builder: _i17.buildSpinnerUseCase,
),
)
],
Expand All @@ -219,7 +232,7 @@ final directories = <_i1.WidgetbookNode>[
name: 'Switch',
useCase: _i1.WidgetbookUseCase(
name: 'Switch Component',
builder: _i17.buildSwitchUseCase,
builder: _i18.buildSwitchUseCase,
),
)
],
Expand All @@ -231,7 +244,7 @@ final directories = <_i1.WidgetbookNode>[
name: 'Toast',
useCase: _i1.WidgetbookUseCase(
name: 'Toast Component',
builder: _i18.buildButtonUseCase,
builder: _i19.buildButtonUseCase,
),
)
],
Expand Down
28 changes: 12 additions & 16 deletions packages/remix/lib/remix.dart
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
/// /\\\\ /\\\\ /\\\\\\\\\\\ /\\\ /\\\
/// \/\\\\\\ /\\\\\\ \/////\\\/// \///\\\ /\\\/
/// \/\\\//\\\ /\\\//\\\ \/\\\ \///\\\\\\/
/// \/\\\\///\\\/\\\/ \/\\\ \/\\\ \//\\\\
/// \/\\\ \///\\\/ \/\\\ \/\\\ \/\\\\
/// \/\\\ \/// \/\\\ \/\\\ /\\\\\\
/// \/\\\ \/\\\ \/\\\ /\\\////\\\
/// \/\\\ \/\\\ /\\\\\\\\\\\ /\\\/ \///\\\
/// \/// \/// \/////////// \/// \///
///
/// https://fluttermix.com
/// /\\\\ /\\\\ /\\\\\\\\\\\ /\\\ /\\\
/// \/\\\\\\ /\\\\\\ \/////\\\/// \///\\\ /\\\/
/// \/\\\//\\\ /\\\//\\\ \/\\\ \///\\\\\\/
/// \/\\\\///\\\/\\\/ \/\\\ \/\\\ \//\\\\
/// \/\\\ \///\\\/ \/\\\ \/\\\ \/\\\\
/// \/\\\ \/// \/\\\ \/\\\ /\\\\\\
/// \/\\\ \/\\\ \/\\\ /\\\////\\\
/// \/\\\ \/\\\ /\\\\\\\\\\\ /\\\/ \///\\\
/// \/// \/// \/////////// \/// \///
///
/// https://fluttermix.com
///
/// /\///////////////////////////////////////////////////\
/// \/\ ***** GENERATED CODE ***** \ \
/// \/\ ** DO NOT EDIT THIS FILE ** \ \
Expand All @@ -20,7 +20,6 @@ library remix;

/// APP
export 'src/app/remix_app.dart';

/// COMPONENTS
export 'src/components/accordion/accordion.dart';
export 'src/components/avatar/avatar.dart';
Expand All @@ -30,28 +29,25 @@ export 'src/components/callout/callout.dart';
export 'src/components/card/card.dart';
export 'src/components/checkbox/checkbox.dart';
export 'src/components/checkbox_group/checkbox_group.dart';
export 'src/components/chip/chip.dart';
export 'src/components/dialog/dialog.dart';
export 'src/components/divider/divider.dart';
export 'src/components/icon_button/icon_button.dart';
export 'src/components/progress/progress.dart';
export 'src/components/radio/radio.dart';

/// LAYOUT
export 'src/components/scaffold/scaffold.dart';
export 'src/components/segmented_control/segmented_control.dart';
export 'src/components/select/select.dart';
export 'src/components/spinner/spinner.dart';
export 'src/components/switch/switch.dart';
export 'src/components/toast/toast.dart';

/// HELPERS
export 'src/helpers/color_palette.dart';
export 'src/helpers/color_utils.dart';
export 'src/helpers/component_builder.dart';
export 'src/helpers/context_ext.dart';
export 'src/helpers/spec/composited_transform_follower_spec.dart';
export 'src/helpers/utility_extension.dart';

/// THEME
export 'src/theme/remix_theme.dart';
export 'src/theme/remix_tokens.dart';
45 changes: 45 additions & 0 deletions packages/remix/lib/src/components/chip/chip.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import 'package:flutter/foundation.dart';
import 'package:flutter/rendering.dart';
import 'package:flutter/widgets.dart';
import 'package:mix/mix.dart';
import 'package:mix_annotations/mix_annotations.dart';

import '../../theme/remix_theme.dart';
import '../../theme/remix_tokens.dart';

part 'chip.g.dart';

part 'chip_style.dart';
part 'chip_theme.dart';
part 'chip_widget.dart';

@MixableSpec()
class ChipSpec extends Spec<ChipSpec> with _$ChipSpec, Diagnosticable {
final FlexSpec flex;
final BoxSpec container;
final IconSpec icon;
final TextSpec label;

/// {@macro button_spec_of}
static const of = _$ChipSpec.of;

static const from = _$ChipSpec.from;

const ChipSpec({
BoxSpec? container,
FlexSpec? flex,
IconSpec? icon,
TextSpec? label,
super.modifiers,
super.animated,
}) : flex = flex ?? const FlexSpec(),
container = container ?? const BoxSpec(),
icon = icon ?? const IconSpec(),
label = label ?? const TextSpec();

@override
void debugFillProperties(DiagnosticPropertiesBuilder properties) {
super.debugFillProperties(properties);
_debugFillProperties(properties);
}
}
Loading
Loading