-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into feat/small-fixes-remix
- Loading branch information
Showing
13 changed files
with
2,222 additions
and
5 deletions.
There are no files selected for viewing
49 changes: 49 additions & 0 deletions
49
packages/remix/demo/lib/components/textfield_use_case.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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', | ||
), | ||
), | ||
), | ||
), | ||
), | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
packages/remix/lib/src/components/textfield/attributes/attributes.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} |
74 changes: 74 additions & 0 deletions
74
packages/remix/lib/src/components/textfield/attributes/attributes.g.dart
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
132 changes: 132 additions & 0 deletions
132
packages/remix/lib/src/components/textfield/textfield.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |
Oops, something went wrong.