-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: Refactored date and time inputs to use text input
- Loading branch information
1 parent
60a4afb
commit 57c72f4
Showing
14 changed files
with
1,022 additions
and
531 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:zeta_example/widgets.dart'; | ||
import 'package:zeta_flutter/zeta_flutter.dart'; | ||
|
||
class TextInputExample extends StatelessWidget { | ||
static const name = 'TextInput'; | ||
|
||
const TextInputExample({super.key}); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
GlobalKey<ZetaTextInputState> key = GlobalKey<ZetaTextInputState>(); | ||
return ExampleScaffold( | ||
name: 'Text Input', | ||
child: Center( | ||
child: SingleChildScrollView( | ||
child: Padding( | ||
padding: EdgeInsets.all(16), | ||
child: Column( | ||
children: [ | ||
ZetaTextInput( | ||
size: ZetaWidgetSize.large, | ||
key: key, | ||
placeholder: 'Placeholder', | ||
prefixText: '£', | ||
label: 'Label', | ||
requirementLevel: ZetaFormFieldRequirement.mandatory, | ||
errorText: 'Error text', | ||
disabled: false, | ||
hintText: 'hint text', | ||
suffix: IconButton( | ||
icon: Icon(ZetaIcons.add_alert_round), | ||
onPressed: () {}, | ||
), | ||
), | ||
ZetaButton( | ||
label: 'Clear', | ||
onPressed: () => key.currentState?.reset(), | ||
), | ||
ZetaTextInput( | ||
placeholder: 'Placeholder', | ||
prefixText: '£', | ||
), | ||
ZetaTextInput( | ||
size: ZetaWidgetSize.small, | ||
placeholder: 'Placeholder', | ||
prefix: IconButton( | ||
iconSize: 12, | ||
icon: Icon( | ||
ZetaIcons.add_alert_round, | ||
), | ||
onPressed: () {}, | ||
), | ||
), | ||
const SizedBox(height: 8), | ||
ZetaTextInput( | ||
placeholder: 'Placeholder', | ||
prefix: Icon( | ||
ZetaIcons.star_round, | ||
size: 20, | ||
), | ||
), | ||
ZetaTextInput( | ||
size: ZetaWidgetSize.small, | ||
placeholder: 'Placeholder', | ||
suffixText: 'kg', | ||
prefixText: '£', | ||
), | ||
].divide(const SizedBox(height: 12)).toList(), | ||
), | ||
), | ||
), | ||
)); | ||
} | ||
} |
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
51 changes: 51 additions & 0 deletions
51
example/widgetbook/pages/components/text_input_widgetbook.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,51 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:widgetbook/widgetbook.dart'; | ||
import 'package:zeta_flutter/zeta_flutter.dart'; | ||
|
||
import '../../test/test_components.dart'; | ||
|
||
Widget textInputUseCase(BuildContext context) { | ||
return WidgetbookTestWidget( | ||
widget: StatefulBuilder( | ||
builder: (context, setState) { | ||
final label = context.knobs.string( | ||
label: 'Label', | ||
initialValue: 'Label', | ||
); | ||
final errorText = context.knobs.stringOrNull( | ||
label: 'Error message', | ||
initialValue: 'Oops! Error hint text', | ||
); | ||
final hintText = context.knobs.string( | ||
label: 'Hint', | ||
initialValue: 'Default hint text', | ||
); | ||
final rounded = context.knobs.boolean(label: 'Rounded', initialValue: true); | ||
final disabled = context.knobs.boolean(label: 'Disabled', initialValue: false); | ||
final size = context.knobs.list<ZetaWidgetSize>( | ||
label: 'Size', | ||
options: ZetaWidgetSize.values, | ||
labelBuilder: (size) => size.name, | ||
); | ||
|
||
return Padding( | ||
padding: const EdgeInsets.all(ZetaSpacing.x5), | ||
child: ZetaTextInput( | ||
size: size, | ||
rounded: rounded, | ||
disabled: disabled, | ||
label: label, | ||
hintText: hintText, | ||
errorText: errorText, | ||
prefixText: '£', | ||
suffix: IconButton( | ||
icon: Icon(ZetaIcons.star_round), | ||
onPressed: () {}, | ||
), | ||
onChange: (value) {}, | ||
), | ||
); | ||
}, | ||
), | ||
); | ||
} |
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
Oops, something went wrong.