@@ -11,6 +11,8 @@ import '../model/autocomplete.dart';
11
11
import '../model/compose.dart' ;
12
12
import '../model/narrow.dart' ;
13
13
import 'compose_box.dart' ;
14
+ import 'text.dart' ;
15
+ import 'theme.dart' ;
14
16
15
17
abstract class AutocompleteField <QueryT extends AutocompleteQuery , ResultT extends AutocompleteResult > extends StatefulWidget {
16
18
const AutocompleteField ({
@@ -218,6 +220,8 @@ class ComposeAutocomplete extends AutocompleteField<ComposeAutocompleteQuery, Co
218
220
219
221
@override
220
222
Widget buildItem (BuildContext context, int index, ComposeAutocompleteResult option) {
223
+ final designVariables = DesignVariables .of (context);
224
+
221
225
final child = switch (option) {
222
226
MentionAutocompleteResult () => _MentionAutocompleteItem (
223
227
option: option, narrow: narrow),
@@ -227,6 +231,9 @@ class ComposeAutocomplete extends AutocompleteField<ComposeAutocompleteQuery, Co
227
231
onTap: () {
228
232
_onTapOption (context, option);
229
233
},
234
+ highlightColor: designVariables.editorButtonPressedBg,
235
+ splashFactory: NoSplash .splashFactory,
236
+ borderRadius: BorderRadius .circular (5 ),
230
237
child: child);
231
238
}
232
239
}
@@ -237,14 +244,14 @@ class _MentionAutocompleteItem extends StatelessWidget {
237
244
final MentionAutocompleteResult option;
238
245
final Narrow narrow;
239
246
240
- Widget wildcardLabel (WildcardMentionOption wildcardOption, {
247
+ String wildcardSublabel (WildcardMentionOption wildcardOption, {
241
248
required BuildContext context,
242
249
required PerAccountStore store,
243
250
}) {
244
251
final isDmNarrow = narrow is DmNarrow ;
245
252
final isChannelWildcardAvailable = store.zulipFeatureLevel >= 247 ; // TODO(server-9)
246
253
final localizations = ZulipLocalizations .of (context);
247
- final description = switch (wildcardOption) {
254
+ return switch (wildcardOption) {
248
255
WildcardMentionOption .all || WildcardMentionOption .everyone => isDmNarrow
249
256
? localizations.wildcardMentionAllDmDescription
250
257
: isChannelWildcardAvailable
@@ -256,32 +263,61 @@ class _MentionAutocompleteItem extends StatelessWidget {
256
263
: localizations.wildcardMentionStreamDescription,
257
264
WildcardMentionOption .topic => localizations.wildcardMentionTopicDescription,
258
265
};
259
- return Text .rich (TextSpan (text: '${wildcardOption .canonicalString } ' , children: [
260
- TextSpan (text: description, style: TextStyle (fontSize: 12 ,
261
- color: DefaultTextStyle .of (context).style.color? .withValues (alpha: 0.8 )))]));
262
266
}
263
267
264
268
@override
265
269
Widget build (BuildContext context) {
266
270
final store = PerAccountStoreWidget .of (context);
271
+ final designVariables = DesignVariables .of (context);
272
+
267
273
Widget avatar;
268
- Widget label;
274
+ String label;
275
+ String ? sublabel;
269
276
switch (option) {
270
277
case UserMentionAutocompleteResult (: var userId):
271
278
final user = store.getUser (userId)! ; // must exist because UserMentionAutocompleteResult
272
- avatar = Avatar (userId: userId, size: 32 , borderRadius: 3 ); // web uses 21px
273
- label = Text (user.fullName);
279
+ avatar = Avatar (userId: userId, size: 36 , borderRadius: 4 );
280
+ label = user.fullName;
281
+ sublabel = store.userDisplayEmail (user);
274
282
case WildcardMentionAutocompleteResult (: var wildcardOption):
275
- avatar = const Icon (ZulipIcons .three_person, size: 29 ); // web uses 19px
276
- label = wildcardLabel (wildcardOption, context: context, store: store);
283
+ avatar = SizedBox .square (dimension: 36 ,
284
+ child: const Icon (ZulipIcons .three_person, size: 24 ));
285
+ label = wildcardOption.canonicalString;
286
+ sublabel = wildcardSublabel (wildcardOption, context: context, store: store);
277
287
}
278
288
289
+ final labelWidget = Text (
290
+ label,
291
+ style: TextStyle (
292
+ fontSize: 18 ,
293
+ height: 20 / 18 ,
294
+ color: designVariables.contextMenuItemLabel,
295
+ ).merge (weightVariableTextStyle (context,
296
+ wght: sublabel == null ? 500 : 600 )),
297
+ overflow: TextOverflow .ellipsis,
298
+ maxLines: 1 );
299
+
300
+ final sublabelWidget = sublabel == null ? null : Text (
301
+ sublabel,
302
+ style: TextStyle (
303
+ fontSize: 14 ,
304
+ height: 16 / 14 ,
305
+ color: designVariables.contextMenuItemMeta),
306
+ overflow: TextOverflow .ellipsis,
307
+ maxLines: 1 );
308
+
279
309
return Padding (
280
- padding: const EdgeInsets . symmetric (horizontal : 16.0 , vertical : 8.0 ),
310
+ padding: const EdgeInsetsDirectional . fromSTEB ( 4 , 4 , 8 , 4 ),
281
311
child: Row (children: [
282
312
avatar,
283
- const SizedBox (width: 8 ),
284
- label,
313
+ const SizedBox (width: 6 ),
314
+ Expanded (child: Column (
315
+ mainAxisSize: MainAxisSize .min,
316
+ crossAxisAlignment: CrossAxisAlignment .start,
317
+ children: [
318
+ labelWidget,
319
+ if (sublabelWidget != null ) sublabelWidget,
320
+ ])),
285
321
]));
286
322
}
287
323
}
0 commit comments