Skip to content

Commit

Permalink
toast
Browse files Browse the repository at this point in the history
  • Loading branch information
tilucasoli committed Nov 7, 2024
1 parent 54036e2 commit 2a00103
Show file tree
Hide file tree
Showing 7 changed files with 71 additions and 53 deletions.
3 changes: 3 additions & 0 deletions packages/remix/lib/src/components/spinner/spinner_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@ part of 'spinner.dart';
class Spinner extends StatelessWidget {
const Spinner({super.key, this.style, this.variants = const []});

/// {@macro remix.component.style}
final SpinnerStyle? style;

/// {@macro remix.component.variants}
final List<Variant> variants;

@override
Expand Down
9 changes: 9 additions & 0 deletions packages/remix/lib/src/components/switch/switch_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,19 @@ class Switch extends StatefulWidget {
this.variants = const [],
});

/// Whether the switch is on or off.
final bool value;

/// {@macro remix.component.onChanged}
final ValueChanged<bool> onChanged;

/// {@macro remix.component.style}
final SwitchStyle? style;

/// {@macro remix.component.disabled}
final bool disabled;

/// {@macro remix.component.variants}
final List<Variant> variants;

@override
Expand Down
12 changes: 6 additions & 6 deletions packages/remix/lib/src/components/toast/toast.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ part 'toast_widget.dart';
@MixableSpec()
base class ToastSpec extends Spec<ToastSpec> with _$ToastSpec, Diagnosticable {
final BoxSpec container;
final FlexSpec containerFlex;
final FlexSpec textContentFlex;
final FlexSpec layout;
final FlexSpec textLayout;
final TextSpec title;
final TextSpec description;

Expand All @@ -29,15 +29,15 @@ base class ToastSpec extends Spec<ToastSpec> with _$ToastSpec, Diagnosticable {

const ToastSpec({
BoxSpec? container,
FlexSpec? containerFlex,
FlexSpec? textContentFlex,
FlexSpec? layout,
FlexSpec? textLayout,
TextSpec? title,
TextSpec? description,
super.modifiers,
super.animated,
}) : container = container ?? const BoxSpec(),
containerFlex = containerFlex ?? const FlexSpec(),
textContentFlex = textContentFlex ?? const FlexSpec(),
layout = layout ?? const FlexSpec(),
textLayout = textLayout ?? const FlexSpec(),
title = title ?? const TextSpec(),
description = description ?? const TextSpec();

Expand Down
70 changes: 33 additions & 37 deletions packages/remix/lib/src/components/toast/toast.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions packages/remix/lib/src/components/toast/toast_style.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ class ToastStyle extends SpecStyle<ToastSpecUtility> {
..margin.all(20)
..constraints.minWidth(300);

final containerFlexStyle = $.containerFlex.chain
final layoutFlexStyle = $.layout.chain
..direction.horizontal()
..mainAxisAlignment.spaceBetween()
..mainAxisSize.min()
..gap(16);

final textContentFlexStyle = $.textContentFlex.chain
final textLayoutFlexStyle = $.textLayout.chain
..direction.vertical()
..crossAxisAlignment.start()
..gap(4)
Expand All @@ -37,8 +37,8 @@ class ToastStyle extends SpecStyle<ToastSpecUtility> {

return Style.create([
containerStyle,
containerFlexStyle,
textContentFlexStyle,
layoutFlexStyle,
textLayoutFlexStyle,
titleStyle,
descriptionStyle,
]);
Expand Down
8 changes: 4 additions & 4 deletions packages/remix/lib/src/components/toast/toast_theme.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ class FortalezaToastStyle extends ToastStyle {
..padding.all.$space(4)
..margin.all.$space(4);

final containerFlexStyle = $.containerFlex.gap.$space(5);
final layoutStyle = $.layout.gap.$space(5);

final textContentFlexStyle = $.textContentFlex.gap.$space(1);
final textLayoutStyle = $.textLayout.gap.$space(1);

final titleStyle = $.title.chain
..style.$text(2)
Expand All @@ -29,8 +29,8 @@ class FortalezaToastStyle extends ToastStyle {
return Style.create([
super.makeStyle(spec).call(),
containerStyle,
containerFlexStyle,
textContentFlexStyle,
layoutStyle,
textLayoutStyle,
titleStyle,
descriptionStyle,
]);
Expand Down
14 changes: 12 additions & 2 deletions packages/remix/lib/src/components/toast/toast_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,22 @@ class Toast extends StatelessWidget {
this.variants = const [],
});

/// The title text displayed in the toast.
final String title;

/// The description text displayed below the title.
final String? description;

/// Optional widget displayed on the right side of the toast.
final Widget? trailing;

/// Optional widget displayed on the left side of the toast.
final Widget? leading;

/// {@macro remix.component.style}
final ToastStyle? style;

/// {@macro remix.component.variants}
final List<Variant> variants;

@override
Expand All @@ -30,11 +40,11 @@ class Toast extends StatelessWidget {
final spec = ToastSpec.of(context);

return spec.container(
child: spec.containerFlex(
child: spec.layout(
direction: Axis.horizontal,
children: [
if (leading != null) leading!,
spec.textContentFlex(
spec.textLayout(
direction: Axis.vertical,
children: [
spec.title(title),
Expand Down

0 comments on commit 2a00103

Please sign in to comment.