Skip to content

Commit ed53ec0

Browse files
committed
refactor: rename controller variable for clarity in ConversationChatView
1 parent 06b3f67 commit ed53ec0

File tree

1 file changed

+15
-14
lines changed

1 file changed

+15
-14
lines changed

lib/screens/conversations/views/chat.dart

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@ import '/imports.dart';
77
class ConversationChatView extends StatelessWidget {
88
final realtimeService = Get.find<RealtimeService>();
99

10-
final ConversationChatController c;
10+
final ConversationChatController controller;
1111
final int conversation_id;
1212

1313
ConversationChatView({
1414
super.key,
1515
required this.conversation_id,
1616
MessageInfo? initial_message,
17-
}) : c = Get.putOrFind(
17+
}) : controller = Get.putOrFind(
1818
() => ConversationChatController(
1919
conversation_id: conversation_id,
2020
initial_message: initial_message,
@@ -25,7 +25,7 @@ class ConversationChatView extends StatelessWidget {
2525
@override
2626
Widget build(BuildContext context) {
2727
return Obx(() {
28-
final info = c.info.value;
28+
final info = controller.info.value;
2929

3030
return Scaffold(
3131
appBar: AppBar(
@@ -50,7 +50,7 @@ class ConversationChatView extends StatelessWidget {
5050
overflow: TextOverflow.ellipsis,
5151
),
5252
subtitle: Text(t.view_details),
53-
onTap: c.showContactDetail,
53+
onTap: controller.showContactDetail,
5454
);
5555
}
5656
return Container();
@@ -62,12 +62,12 @@ class ConversationChatView extends StatelessWidget {
6262
onPressed: () {
6363
switch (info.status) {
6464
case ConversationStatus.open:
65-
c.changeStatus(ConversationStatus.resolved);
65+
controller.changeStatus(ConversationStatus.resolved);
6666
break;
6767

6868
case ConversationStatus.resolved:
6969
case ConversationStatus.snoozed:
70-
c.changeStatus(ConversationStatus.open);
70+
controller.changeStatus(ConversationStatus.open);
7171
break;
7272

7373
default:
@@ -94,17 +94,17 @@ class ConversationChatView extends StatelessWidget {
9494
children: [
9595
Expanded(
9696
child: Obx(() {
97-
if (c.error.value.isNotEmpty) {
97+
if (controller.error.value.isNotEmpty) {
9898
return buildError(context);
9999
}
100100
return buildMessages();
101101
}),
102102
),
103-
ConversationInput(id: c.conversation_id),
103+
ConversationInput(id: controller.conversation_id),
104104
],
105105
),
106106
Obx(() {
107-
final loading = c.loading.value;
107+
final loading = controller.loading.value;
108108
if (loading) {
109109
return Positioned.fill(
110110
child: Align(
@@ -124,20 +124,20 @@ class ConversationChatView extends StatelessWidget {
124124
Widget buildError(BuildContext context) {
125125
return error(
126126
context,
127-
message: c.error.value,
127+
message: controller.error.value,
128128
onRetry: () {
129-
c.getConversation();
130-
c.getMessages();
129+
controller.getConversation();
130+
controller.getMessages();
131131
},
132132
);
133133
}
134134

135135
Widget buildMessages() {
136136
return Obx(() {
137-
final messages = c.messages.value;
137+
final messages = controller.messages.value;
138138

139139
return ListView.builder(
140-
controller: c.scrollController,
140+
controller: controller.scrollController,
141141
reverse: true,
142142
padding: EdgeInsets.only(left: 8, right: 8, top: 8),
143143
itemCount: messages.length,
@@ -153,6 +153,7 @@ class ConversationChatView extends StatelessWidget {
153153
return Padding(
154154
padding: const EdgeInsets.only(bottom: 8),
155155
child: Message(
156+
controller: controller,
156157
info: item,
157158
borderRadius: BorderRadius.only(
158159
topLeft: Radius.circular(topLeft),

0 commit comments

Comments
 (0)