-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3f06181
commit 6b3d198
Showing
10 changed files
with
260 additions
and
52 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import 'package:cave/cave.dart'; | ||
import 'package:flutter/material.dart'; | ||
import 'package:widgetbook_annotation/widgetbook_annotation.dart' as widgetbook; | ||
|
||
@widgetbook.UseCase( | ||
name: 'DevFest FormField', | ||
type: DevfestTextFormField, | ||
) | ||
Widget devfestTextField(BuildContext context) { | ||
return StatefulBuilder(builder: (context, setState) { | ||
return Scaffold( | ||
backgroundColor: DevFestTheme.of(context).backgroundColor, | ||
body: Center( | ||
child: Padding( | ||
padding: const EdgeInsets.symmetric(horizontal: 16.0), | ||
child: Column( | ||
mainAxisAlignment: MainAxisAlignment.center, | ||
children: [ | ||
const DevfestTextFormField( | ||
title: 'Email Address', | ||
hint: 'eg [email protected]', | ||
), | ||
const SizedBox(height: 16), | ||
DevfestTextFormField( | ||
title: 'Ticket ID', | ||
hint: 'eg 413-012-ABC', | ||
autovalidateMode: AutovalidateMode.always, | ||
validator: (value) => | ||
'The ticket ID or Email address is incorrect. Please try again', | ||
), | ||
], | ||
), | ||
), | ||
), | ||
); | ||
}); | ||
} |
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
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 |
---|---|---|
@@ -1 +1,75 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:flutter_screenutil/flutter_screenutil.dart'; | ||
|
||
import '../constants.dart'; | ||
import '../themes/colors.dart'; | ||
import '../themes/text_field_theme.dart'; | ||
import '../themes/theme_data.dart'; | ||
|
||
class DevfestTextFormField extends StatelessWidget { | ||
const DevfestTextFormField({ | ||
super.key, | ||
this.title, | ||
this.controller, | ||
this.hint, | ||
this.info, | ||
TextInputType? keyboardType, | ||
Color? iconColor, | ||
this.onChanged, | ||
this.validator, | ||
this.textInputAction, | ||
this.autovalidateMode, | ||
}) : keyboardType = keyboardType ?? TextInputType.text, | ||
iconColor = iconColor ?? DevfestColors.grey10; | ||
final String? title; | ||
final String? info; | ||
final String? hint; | ||
final TextEditingController? controller; | ||
final TextInputType keyboardType; | ||
final Color iconColor; | ||
final ValueChanged<String>? onChanged; | ||
final String? Function(String?)? validator; | ||
final TextInputAction? textInputAction; | ||
final AutovalidateMode? autovalidateMode; | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
final textFieldTheme = DevFestTheme.of(context).textFieldTheme ?? | ||
DevfestTextFieldTheme.light(); | ||
return Column( | ||
crossAxisAlignment: CrossAxisAlignment.start, | ||
children: [ | ||
if (title != null) ...[ | ||
Text( | ||
title!, | ||
style: DevFestTheme.of(context).textTheme?.bodyBody3Medium, | ||
), | ||
Constants.smallVerticalGutter.verticalSpace, | ||
], | ||
TextFormField( | ||
controller: controller, | ||
keyboardType: keyboardType, | ||
onChanged: onChanged, | ||
validator: validator, | ||
textInputAction: textInputAction, | ||
autovalidateMode: autovalidateMode ?? AutovalidateMode.disabled, | ||
// cursorColor: DevFestTheme.of(context).onBackgroundColor, | ||
style: textFieldTheme.style, | ||
decoration: InputDecoration( | ||
hintText: hint, | ||
hintStyle: textFieldTheme.hintStyle, | ||
errorStyle: textFieldTheme.errorStyle, | ||
errorMaxLines: 2, | ||
contentPadding: const EdgeInsets.all(16), | ||
border: textFieldTheme.border, | ||
enabledBorder: textFieldTheme.enabledBorder, | ||
focusedBorder: textFieldTheme.focusedBorder, | ||
errorBorder: textFieldTheme.errorBorder, | ||
focusedErrorBorder: textFieldTheme.errorBorder, | ||
), | ||
), | ||
Constants.largeVerticalGutter.verticalSpace, | ||
], | ||
); | ||
} | ||
} |
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 |
---|---|---|
@@ -1,2 +1,3 @@ | ||
export 'bottom_nav.dart'; | ||
export 'buttons.dart'; | ||
export 'text_field.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
Oops, something went wrong.