Skip to content

Commit

Permalink
Merge branch 'main' into feat/small-fixes-remix
Browse files Browse the repository at this point in the history
  • Loading branch information
tilucasoli authored Nov 7, 2024
2 parents cba6a46 + d48517f commit 7beafb6
Show file tree
Hide file tree
Showing 13 changed files with 2,222 additions and 5 deletions.
49 changes: 49 additions & 0 deletions packages/remix/demo/lib/components/textfield_use_case.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import 'package:demo/addons/icon_data_knob.dart';
import 'package:flutter/material.dart' as m;
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: 'TextField Component',
type: TextField,
)
Widget buildButtonUseCase(BuildContext context) {
final iconKnob = context.knobs.iconData(label: 'icons', initialValue: null);
return KeyedSubtree(
key: _key,
child: Scaffold(
body: Center(
child: SizedBox(
width: 300,
child: TextField(
suffix: context.knobs
.boolean(label: 'SuffixWidget', initialValue: false)
? IconButton(
m.Icons.close_rounded,
variants: const [FortalezaIconButtonStyle.soft],
onPressed: () {},
)
: null,
prefixBuilder: iconKnob != null ? (spec) => spec(iconKnob) : null,
maxLines: context.knobs.int.input(
label: 'Max Lines',
initialValue: 1,
),
hintText: context.knobs.string(
label: 'Hint Text',
initialValue: 'Hint Text',
),
helperText: context.knobs.string(
label: 'Helper Text',
initialValue: 'Helper Text',
),
),
),
),
),
);
}
17 changes: 15 additions & 2 deletions packages/remix/demo/lib/main.directories.g.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ 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/toast_use_case.dart' as _i21;
import 'package:demo/components/textfield_use_case.dart' as _i21;
import 'package:demo/components/toast_use_case.dart' as _i22;
import 'package:widgetbook/widgetbook.dart' as _i1;

final directories = <_i1.WidgetbookNode>[
Expand Down Expand Up @@ -263,14 +264,26 @@ final directories = <_i1.WidgetbookNode>[
)
],
),
_i1.WidgetbookFolder(
name: 'textfield',
children: [
_i1.WidgetbookLeafComponent(
name: 'TextField',
useCase: _i1.WidgetbookUseCase(
name: 'TextField Component',
builder: _i21.buildButtonUseCase,
),
)
],
),
_i1.WidgetbookFolder(
name: 'toast',
children: [
_i1.WidgetbookLeafComponent(
name: 'Toast',
useCase: _i1.WidgetbookUseCase(
name: 'Toast Component',
builder: _i21.buildButtonUseCase,
builder: _i22.buildButtonUseCase,
),
)
],
Expand Down
1 change: 1 addition & 0 deletions packages/remix/lib/remix.dart
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ export 'src/components/slider/slider.dart';
export 'src/components/spinner/spinner.dart';
export 'src/components/switch/switch.dart';
export 'src/components/toast/toast.dart';
export 'src/components/textfield/textfield.dart';

/// HELPERS
export 'src/helpers/color_palette.dart';
Expand Down
2 changes: 0 additions & 2 deletions packages/remix/lib/src/components/progress/progress.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ part 'progress_style.dart';
part 'progress_theme.dart';
part 'progress_widget.dart';

final $progress = ProgressSpecUtility.self;

@MixableSpec()
base class ProgressSpec extends Spec<ProgressSpec>
with _$ProgressSpec, Diagnosticable {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import 'dart:ui';

import 'package:mix/mix.dart';
import 'package:mix_annotations/mix_annotations.dart';

part 'attributes.g.dart';

@MixableEnumUtility()
final class BoxHeightStyleUtility<T extends Attribute>
extends MixUtility<T, BoxHeightStyle> with _$BoxHeightStyleUtility {
const BoxHeightStyleUtility(super.builder);
}

@MixableEnumUtility()
final class BoxWidthStyleUtility<T extends Attribute>
extends MixUtility<T, BoxWidthStyle> with _$BoxWidthStyleUtility {
const BoxWidthStyleUtility(super.builder);
}

@MixableEnumUtility()
final class BrightnessUtility<T extends Attribute>
extends MixUtility<T, Brightness> with _$BrightnessUtility {
const BrightnessUtility(super.builder);
}

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

132 changes: 132 additions & 0 deletions packages/remix/lib/src/components/textfield/textfield.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
import 'dart:ui';

import 'package:flutter/cupertino.dart'
show
CupertinoColors,
cupertinoDesktopTextSelectionHandleControls,
cupertinoTextSelectionHandleControls;
import 'package:flutter/foundation.dart';
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart' as m;
import 'package:flutter/services.dart';
import 'package:flutter/widgets.dart';
import 'package:mix/mix.dart';
import 'package:mix_annotations/mix_annotations.dart';

import '../../helpers/component_builder.dart';
import '../../theme/remix_theme.dart';
import '../../theme/remix_tokens.dart';
import 'attributes/attributes.dart';

part 'textfield.g.dart';
part 'textfield_style.dart';
part 'textfield_theme.dart';
part 'textfield_widget.dart';

@MixableSpec()
class TextFieldSpec extends Spec<TextFieldSpec>
with _$TextFieldSpec, Diagnosticable {
final TextStyle style;
final TextAlign textAlign;

final bool floatingLabel;

final StrutStyle? strutStyle;
final TextWidthBasis textWidthBasis;

final double cursorWidth;
final double? cursorHeight;
final Radius? cursorRadius;
final Color cursorColor;
final Offset cursorOffset;
final bool paintCursorAboveText;
final bool cursorOpacityAnimates;
final Color backgroundCursorColor;
final Color? selectionColor;

final BoxHeightStyle selectionHeightStyle;
final BoxWidthStyle selectionWidthStyle;

final EdgeInsets scrollPadding;
final Clip clipBehavior;

final Brightness keyboardAppearance;
final Color? autocorrectionTextRectColor;

final BoxSpec container;
final FlexSpec containerLayout;
final FlexSpec contentLayout;
final TextStyle? hintTextStyle;
final TextSpec helperText;
final IconSpec icon;
final double floatingLabelHeight;
final TextStyle? floatingLabelStyle;

@MixableProperty(dto: MixableFieldDto(type: TextHeightBehaviorDto))
final TextHeightBehavior? textHeightBehavior;

static const of = _$TextFieldSpec.of;

static const from = _$TextFieldSpec.from;

const TextFieldSpec({
TextStyle? style,
TextAlign? textAlign,
this.strutStyle,
this.textHeightBehavior,
TextWidthBasis? textWidthBasis,
double? cursorWidth,
this.cursorHeight,
this.cursorRadius,
Color? cursorColor,
Offset? cursorOffset,
bool? paintCursorAboveText,
Color? backgroundCursorColor,
this.selectionColor,
BoxHeightStyle? selectionHeightStyle,
BoxWidthStyle? selectionWidthStyle,
EdgeInsets? scrollPadding,
Clip? clipBehavior,
Brightness? keyboardAppearance,
this.autocorrectionTextRectColor,
bool? cursorOpacityAnimates,
BoxSpec? container,
FlexSpec? containerLayout,
this.hintTextStyle,
TextSpec? helperText,
IconSpec? icon,
FlexSpec? contentLayout,
bool? floatingLabel,
double? floatingLabelHeight,
this.floatingLabelStyle,
super.animated,
super.modifiers,
}) : style = style ?? const TextStyle(),
textAlign = textAlign ?? TextAlign.start,
textWidthBasis = textWidthBasis ?? TextWidthBasis.parent,
cursorWidth = cursorWidth ?? 2.0,
cursorColor = cursorColor ?? m.Colors.black54,
cursorOffset = cursorOffset ?? Offset.zero,
paintCursorAboveText = paintCursorAboveText ?? false,
cursorOpacityAnimates = cursorOpacityAnimates ?? false,
backgroundCursorColor =
backgroundCursorColor ?? CupertinoColors.inactiveGray,
selectionHeightStyle = selectionHeightStyle ?? BoxHeightStyle.tight,
selectionWidthStyle = selectionWidthStyle ?? BoxWidthStyle.tight,
scrollPadding = scrollPadding ?? const EdgeInsets.all(20.0),
clipBehavior = clipBehavior ?? Clip.hardEdge,
keyboardAppearance = keyboardAppearance ?? Brightness.light,
container = container ?? const BoxSpec(),
helperText = helperText ?? const TextSpec(),
containerLayout = containerLayout ?? const FlexSpec(),
icon = icon ?? const IconSpec(),
contentLayout = contentLayout ?? const FlexSpec(),
floatingLabel = floatingLabel ?? false,
floatingLabelHeight = floatingLabelHeight ?? 14;

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

0 comments on commit 7beafb6

Please sign in to comment.