Skip to content

Commit 7409f0b

Browse files
committed
compose [nfc]: Rename controller classes
I'll be giving these a common base class, and with the current pattern the natural name would be ComposeTextEditingController... which would look far too close to ContentTextEditingController. Instead, rename them to a pattern where they can each have the base class's name plus a word.
1 parent 74b2008 commit 7409f0b

File tree

4 files changed

+15
-15
lines changed

4 files changed

+15
-15
lines changed

lib/model/autocomplete.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import '../widgets/compose_box.dart';
77
import 'narrow.dart';
88
import 'store.dart';
99

10-
extension Autocomplete on ContentTextEditingController {
10+
extension Autocomplete on ComposeContentController {
1111
AutocompleteIntent? autocompleteIntent() {
1212
if (!selection.isValid || !selection.isNormalized) {
1313
// We don't require [isCollapsed] to be true because we've seen that

lib/widgets/compose_box.dart

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ enum TopicValidationError {
2727
}
2828
}
2929

30-
class TopicTextEditingController extends TextEditingController {
30+
class ComposeTopicController extends TextEditingController {
3131
// TODO: subscribe to this value:
3232
// https://zulip.com/help/require-topics
3333
final mandatory = true;
@@ -67,7 +67,7 @@ enum ContentValidationError {
6767
}
6868
}
6969

70-
class ContentTextEditingController extends TextEditingController {
70+
class ComposeContentController extends TextEditingController {
7171
int _nextUploadTag = 0;
7272

7373
final Map<int, ({String filename, String placeholder})> _uploads = {};
@@ -159,7 +159,7 @@ class _ContentInput extends StatefulWidget {
159159
});
160160

161161
final Narrow narrow;
162-
final ContentTextEditingController controller;
162+
final ComposeContentController controller;
163163
final FocusNode focusNode;
164164
final String hintText;
165165

@@ -239,8 +239,8 @@ class _StreamContentInput extends StatefulWidget {
239239
});
240240

241241
final StreamNarrow narrow;
242-
final ContentTextEditingController controller;
243-
final TopicTextEditingController topicController;
242+
final ComposeContentController controller;
243+
final ComposeTopicController topicController;
244244
final FocusNode focusNode;
245245

246246
@override
@@ -304,7 +304,7 @@ class _File {
304304

305305
Future<void> _uploadFiles({
306306
required BuildContext context,
307-
required ContentTextEditingController contentController,
307+
required ComposeContentController contentController,
308308
required FocusNode contentFocusNode,
309309
required Iterable<_File> files,
310310
}) async {
@@ -365,7 +365,7 @@ Future<void> _uploadFiles({
365365
abstract class _AttachUploadsButton extends StatelessWidget {
366366
const _AttachUploadsButton({required this.contentController, required this.contentFocusNode});
367367

368-
final ContentTextEditingController contentController;
368+
final ComposeContentController contentController;
369369
final FocusNode contentFocusNode;
370370

371371
IconData get icon;
@@ -529,8 +529,8 @@ class _StreamSendButton extends StatefulWidget {
529529
});
530530

531531
final StreamNarrow narrow;
532-
final TopicTextEditingController topicController;
533-
final ContentTextEditingController contentController;
532+
final ComposeTopicController topicController;
533+
final ComposeContentController contentController;
534534

535535
@override
536536
State<_StreamSendButton> createState() => _StreamSendButtonState();
@@ -668,8 +668,8 @@ class _StreamComposeBox extends StatefulWidget {
668668
}
669669

670670
class _StreamComposeBoxState extends State<_StreamComposeBox> {
671-
final _topicController = TopicTextEditingController();
672-
final _contentController = ContentTextEditingController();
671+
final _topicController = ComposeTopicController();
672+
final _contentController = ComposeContentController();
673673
final _contentFocusNode = FocusNode();
674674

675675
@override

test/model/autocomplete_checks.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import 'package:checks/checks.dart';
22
import 'package:zulip/model/autocomplete.dart';
33
import 'package:zulip/widgets/compose_box.dart';
44

5-
extension ContentTextEditingControllerChecks on Subject<ContentTextEditingController> {
5+
extension ComposeContentControllerChecks on Subject<ComposeContentController> {
66
Subject<AutocompleteIntent?> get autocompleteIntent => has((c) => c.autocompleteIntent(), 'autocompleteIntent');
77
}
88

test/model/autocomplete_test.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import 'test_store.dart';
1515
import 'autocomplete_checks.dart';
1616

1717
void main() {
18-
group('ContentTextEditingController.autocompleteIntent', () {
18+
group('ComposeContentController.autocompleteIntent', () {
1919
parseMarkedText(String markedText) {
2020
final TextSelection selection;
2121
int? expectedSyntaxStart;
@@ -67,7 +67,7 @@ void main() {
6767
? 'in ${jsonEncode(markedText)}, query ${jsonEncode(expectedQuery.raw)}'
6868
: 'no query in ${jsonEncode(markedText)}';
6969
test(description, () {
70-
final controller = ContentTextEditingController();
70+
final controller = ComposeContentController();
7171
final parsed = parseMarkedText(markedText);
7272
assert((expectedQuery == null) == (parsed.expectedSyntaxStart == null));
7373
controller.value = parsed.value;

0 commit comments

Comments
 (0)