|
| 1 | +import 'package:auto_route/auto_route.dart'; |
| 2 | +import 'package:catalog/catalog.dart'; |
| 3 | +import 'package:catalog/widgets/app_text_fields.dart'; |
| 4 | +import 'package:flutter/material.dart'; |
| 5 | +import 'package:flutter_screenutil/flutter_screenutil.dart'; |
| 6 | +import 'package:gallery/catalog/catalog_scaffold_screen.dart'; |
| 7 | + |
| 8 | +@RoutePage() |
| 9 | +class CatalogTextFieldsScreen extends StatefulWidget { |
| 10 | + const CatalogTextFieldsScreen({super.key}); |
| 11 | + |
| 12 | + @override |
| 13 | + State<CatalogTextFieldsScreen> createState() => |
| 14 | + _CatalogTextFieldsScreenState(); |
| 15 | +} |
| 16 | + |
| 17 | +class _CatalogTextFieldsScreenState extends State<CatalogTextFieldsScreen> { |
| 18 | + int _characterCount = 0; |
| 19 | + final labelTextController = TextEditingController(); |
| 20 | + final textAreaTextController = TextEditingController(); |
| 21 | + |
| 22 | + @override |
| 23 | + Widget build(BuildContext context) => CatalogScaffold( |
| 24 | + title: 'TEXT FIELDS', |
| 25 | + child: Container( |
| 26 | + margin: const EdgeInsets.all(20), |
| 27 | + child: Column( |
| 28 | + children: [ |
| 29 | + AppTextField( |
| 30 | + controller: labelTextController, |
| 31 | + labelText: 'Label', |
| 32 | + helperText: 'Helper text', |
| 33 | + hintText: 'Text', |
| 34 | + suffixIcon: Icon( |
| 35 | + Icons.close, |
| 36 | + color: context.theme.colors.textColor.shade200, |
| 37 | + ), |
| 38 | + prefixIcon: Icon( |
| 39 | + Icons.close, |
| 40 | + color: context.theme.colors.textColor.shade200, |
| 41 | + ), |
| 42 | + keyboardType: TextInputType.emailAddress, |
| 43 | + ), |
| 44 | + SizedBox(height: 10.h), |
| 45 | + AppTextField( |
| 46 | + keyboardType: TextInputType.multiline, |
| 47 | + controller: textAreaTextController, |
| 48 | + maxLength: 100, |
| 49 | + labelText: 'Label', |
| 50 | + hintText: 'Text', |
| 51 | + currentLength: _characterCount, |
| 52 | + onChange: (value) { |
| 53 | + setState(() { |
| 54 | + _characterCount = value.length; |
| 55 | + }); |
| 56 | + }, |
| 57 | + minLines: 8, |
| 58 | + maxLines: 10, |
| 59 | + ), |
| 60 | + SizedBox(height: 10.h), |
| 61 | + ], |
| 62 | + ), |
| 63 | + ), |
| 64 | + ); |
| 65 | +} |
0 commit comments