Skip to content

Commit d22af3c

Browse files
committed
refactor(demo): create AppTextField wrapper component
1 parent 3ee0bf3 commit d22af3c

3 files changed

Lines changed: 30 additions & 14 deletions

File tree

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import 'package:flutter/material.dart';
2+
3+
class AppTextField extends TextField {
4+
const AppTextField({
5+
super.key,
6+
super.controller,
7+
super.decoration,
8+
super.keyboardType,
9+
super.onChanged,
10+
super.textAlign,
11+
super.style,
12+
super.maxLines,
13+
super.autocorrect = false,
14+
});
15+
}

examples/demo/lib/widgets/dialogs.dart

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import 'package:flutter/material.dart';
44

55
import '../services/tooltip_helper.dart';
66
import '../theme.dart';
7+
import 'app_text_field.dart';
78

89
// Single input dialog (login, email, sms)
910
class SingleInputDialog extends StatefulWidget {
@@ -42,7 +43,7 @@ class _SingleInputDialogState extends State<SingleInputDialog> {
4243
width: double.maxFinite,
4344
child: Semantics(
4445
label: '${widget.fieldLabel}_input',
45-
child: TextField(
46+
child: AppTextField(
4647
controller: _controller,
4748
decoration: InputDecoration(labelText: widget.fieldLabel),
4849
keyboardType: widget.keyboardType,
@@ -109,7 +110,7 @@ class _PairInputDialogState extends State<PairInputDialog> {
109110
Expanded(
110111
child: Semantics(
111112
label: '${widget.keyLabel}_input',
112-
child: TextField(
113+
child: AppTextField(
113114
controller: _keyController,
114115
decoration: InputDecoration(labelText: widget.keyLabel),
115116
onChanged: (_) => setState(() {}),
@@ -120,7 +121,7 @@ class _PairInputDialogState extends State<PairInputDialog> {
120121
Expanded(
121122
child: Semantics(
122123
label: '${widget.valueLabel}_input',
123-
child: TextField(
124+
child: AppTextField(
124125
controller: _valueController,
125126
decoration: InputDecoration(labelText: widget.valueLabel),
126127
onChanged: (_) => setState(() {}),
@@ -231,7 +232,7 @@ class _MultiPairInputDialogState extends State<MultiPairInputDialog> {
231232
Row(
232233
children: [
233234
Expanded(
234-
child: TextField(
235+
child: AppTextField(
235236
controller: _keyControllers[i],
236237
decoration: InputDecoration(
237238
labelText: widget.keyLabel,
@@ -241,7 +242,7 @@ class _MultiPairInputDialogState extends State<MultiPairInputDialog> {
241242
),
242243
const SizedBox(width: 8),
243244
Expanded(
244-
child: TextField(
245+
child: AppTextField(
245246
controller: _valueControllers[i],
246247
decoration: InputDecoration(
247248
labelText: widget.valueLabel,
@@ -380,7 +381,7 @@ class _LoginDialogState extends State<LoginDialog> {
380381
width: double.maxFinite,
381382
child: Semantics(
382383
label: 'external_user_id_input',
383-
child: TextField(
384+
child: AppTextField(
384385
controller: _controller,
385386
decoration: const InputDecoration(labelText: 'External User Id'),
386387
onChanged: (_) => setState(() {}),
@@ -468,14 +469,14 @@ class _OutcomeDialogState extends State<OutcomeDialog> {
468469
),
469470
),
470471
const SizedBox(height: 8),
471-
TextField(
472+
AppTextField(
472473
controller: _nameController,
473474
decoration: const InputDecoration(labelText: 'Outcome Name'),
474475
onChanged: (_) => setState(() {}),
475476
),
476477
if (_type == OutcomeType.withValue) ...[
477478
const SizedBox(height: 12),
478-
TextField(
479+
AppTextField(
479480
controller: _valueController,
480481
decoration: const InputDecoration(labelText: 'Value'),
481482
keyboardType:
@@ -563,13 +564,13 @@ class _TrackEventDialogState extends State<TrackEventDialog> {
563564
child: Column(
564565
mainAxisSize: MainAxisSize.min,
565566
children: [
566-
TextField(
567+
AppTextField(
567568
controller: _nameController,
568569
decoration: const InputDecoration(labelText: 'Event Name'),
569570
onChanged: (_) => setState(() {}),
570571
),
571572
const SizedBox(height: 12),
572-
TextField(
573+
AppTextField(
573574
controller: _propsController,
574575
decoration: InputDecoration(
575576
labelText: 'Properties (optional, JSON)',
@@ -642,13 +643,13 @@ class _CustomNotificationDialogState extends State<CustomNotificationDialog> {
642643
child: Column(
643644
mainAxisSize: MainAxisSize.min,
644645
children: [
645-
TextField(
646+
AppTextField(
646647
controller: _titleController,
647648
decoration: const InputDecoration(labelText: 'Title'),
648649
onChanged: (_) => setState(() {}),
649650
),
650651
const SizedBox(height: 12),
651-
TextField(
652+
AppTextField(
652653
controller: _bodyController,
653654
decoration: const InputDecoration(labelText: 'Body'),
654655
onChanged: (_) => setState(() {}),

examples/demo/lib/widgets/sections/live_activities_section.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import 'package:provider/provider.dart';
33

44
import '../../theme.dart';
55
import '../../viewmodels/app_viewmodel.dart';
6+
import '../app_text_field.dart';
67
import '../action_button.dart';
78
import '../section_card.dart';
89

@@ -138,7 +139,7 @@ class _InputRow extends StatelessWidget {
138139
),
139140
),
140141
Expanded(
141-
child: TextField(
142+
child: AppTextField(
142143
controller: controller,
143144
textAlign: TextAlign.right,
144145
style: const TextStyle(fontSize: 14, color: Color(0xFF212121)),
@@ -149,7 +150,6 @@ class _InputRow extends StatelessWidget {
149150
contentPadding: EdgeInsets.symmetric(vertical: 4),
150151
isDense: true,
151152
),
152-
autocorrect: false,
153153
onChanged: onChanged,
154154
),
155155
),

0 commit comments

Comments
 (0)