Skip to content

Commit

Permalink
create select trigger
Browse files Browse the repository at this point in the history
  • Loading branch information
tilucasoli committed Dec 18, 2024
1 parent 1b956e8 commit 692d010
Show file tree
Hide file tree
Showing 6 changed files with 256 additions and 287 deletions.
12 changes: 5 additions & 7 deletions packages/remix/demo/lib/components/select.dart
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 @@ -43,13 +42,12 @@ class _SelectDemoState extends State<SelectDemo> {
child: Select<String>(
value: selectedValue,
onChanged: (value) => setState(() => selectedValue = value),
trigger: (spec) => spec(
trigger: SelectTrigger(
text: selectedValue,
trailingIcon: m.Icons.keyboard_arrow_down_rounded,
),
disabled: context.knobs.boolean(
label: 'disabled',
initialValue: false,
disabled: context.knobs.boolean(
label: 'disabled',
initialValue: false,
),
),
variants: [context.knobs.variant(FortalezaSelectStyle.variants)],
items: List.generate(
Expand Down
13 changes: 6 additions & 7 deletions packages/remix/lib/src/components/select/select.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,22 @@ import 'package:mix/mix.dart';
import 'package:mix_annotations/mix_annotations.dart';

import '../../core/theme/remix_theme.dart';
import '../../helpers/component_builder.dart';
import '../../helpers/object_ext.dart';
import '../../helpers/overlay.dart';
import '../../helpers/spec/composited_transform_follower_spec.dart';

part 'button/select_button.dart';
part 'button/select_button_widget.dart';
part 'item/select_menu.dart';
part 'item/select_menu_widget.dart';
part 'select.g.dart';
part 'select_style.dart';
part 'select_widget.dart';
part 'trigger/select_trigger.dart';
part 'trigger/select_trigger_widget.dart';

@MixableSpec()
class SelectSpec extends Spec<SelectSpec> with _$SelectSpec, Diagnosticable {
@MixableProperty(dto: MixableFieldDto(type: 'SelectButtonSpecAttribute'))
final SelectButtonSpec button;
@MixableProperty(dto: MixableFieldDto(type: 'SelectTriggerSpecAttribute'))
final SelectTriggerSpec button;

@MixableProperty(dto: MixableFieldDto(type: 'SelectMenuSpecAttribute'))
final SelectMenuSpec menu;
Expand All @@ -39,13 +38,13 @@ class SelectSpec extends Spec<SelectSpec> with _$SelectSpec, Diagnosticable {
static const from = _$SelectSpec.from;

const SelectSpec({
SelectButtonSpec? button,
SelectTriggerSpec? button,
SelectMenuSpec? menu,
SelectMenuItemSpec? item,
CompositedTransformFollowerSpec? position,
super.modifiers,
super.animated,
}) : button = button ?? const SelectButtonSpec(),
}) : button = button ?? const SelectTriggerSpec(),
item = item ?? const SelectMenuItemSpec(),
menu = menu ?? const SelectMenuSpec(),
position = position ?? const CompositedTransformFollowerSpec();
Expand Down
Loading

0 comments on commit 692d010

Please sign in to comment.