Skip to content

Commit

Permalink
feat: Update text input design (#467)
Browse files Browse the repository at this point in the history
  • Loading branch information
witwash authored Oct 24, 2023
1 parent 24d762b commit 5167e44
Show file tree
Hide file tree
Showing 8 changed files with 166 additions and 181 deletions.
39 changes: 18 additions & 21 deletions optimus/lib/src/common/field_error.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,30 +6,27 @@ class OptimusFieldError extends StatelessWidget {
const OptimusFieldError({
super.key,
required this.error,
this.isEnabled = true,
});

final String error;
final bool isEnabled;

@override
Widget build(BuildContext context) => Row(
mainAxisSize: MainAxisSize.min,
children: [
Padding(
padding: const EdgeInsets.only(right: spacing150),
child: Icon(
OptimusIcons.error_circle,
size: 16,
color: context.tokens.textAlertDanger,
),
),
OptimusCaption(
child: Text(
error,
style: TextStyle(
color: context.tokens.textAlertDanger,
),
),
),
],
);
Widget build(BuildContext context) {
final color = isEnabled
? context.tokens.textAlertDanger
: context.tokens.textDisabled;

return Row(
mainAxisSize: MainAxisSize.min,
children: [
Padding(
padding: const EdgeInsets.only(right: spacing150),
child: Icon(OptimusIcons.error_circle, size: 16, color: color),
),
OptimusCaption(child: Text(error, style: TextStyle(color: color))),
],
);
}
}
25 changes: 16 additions & 9 deletions optimus/lib/src/common/field_label.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,27 @@ class OptimusFieldLabel extends StatelessWidget {
super.key,
required this.label,
this.isRequired = false,
this.isEnabled = true,
});

final String label;
final bool isRequired;
final bool isEnabled;

@override
Widget build(BuildContext context) => Padding(
padding: const EdgeInsets.only(bottom: 2),
child: OptimusLabel(
variation: Variation.variationSecondary,
child: Text(
isRequired ? '$label *' : label,
style: TextStyle(color: context.tokens.textStaticPrimary),
),
Widget build(BuildContext context) {
final tokens = OptimusTheme.of(context).tokens;
final color = isEnabled ? tokens.textStaticPrimary : tokens.textDisabled;

return Padding(
padding: const EdgeInsets.only(bottom: 2),
child: OptimusLabel(
variation: Variation.variationSecondary,
child: Text(
isRequired ? '$label *' : label,
style: TextStyle(color: color),
),
);
),
);
}
}
Loading

0 comments on commit 5167e44

Please sign in to comment.