Skip to content

Commit

Permalink
some random changes
Browse files Browse the repository at this point in the history
  • Loading branch information
YuJuncen committed Aug 5, 2023
1 parent a1f7a40 commit 3718580
Showing 1 changed file with 18 additions and 19 deletions.
37 changes: 18 additions & 19 deletions lib/components/chat_room.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ import 'package:uuid/uuid.dart';
import 'package:firebase_analytics/firebase_analytics.dart';
import 'package:flutter/services.dart';

import '../repository/chat_room.dart';

enum ChatRoomType {
tablet,
phone,
Expand Down Expand Up @@ -94,11 +96,11 @@ class ListPane extends StatelessWidget {
return SafeArea(
child: Scaffold(
appBar: AppBar(
systemOverlayStyle: SystemUiOverlayStyle(
statusBarBrightness: Theme.of(context).brightness),
backgroundColor: Theme.of(context).colorScheme.background,
toolbarHeight: 0,
),
systemOverlayStyle: SystemUiOverlayStyle(
statusBarBrightness: Theme.of(context).brightness),
backgroundColor: Theme.of(context).colorScheme.background,
toolbarHeight: 0,
),
primary: false,
floatingActionButton: Obx(() => NewChatButton(
pctl: pctl,
Expand All @@ -113,27 +115,24 @@ class ListPane extends StatelessWidget {
children: roomCtrl.roomList
.asMap()
.map((index, room) {
fmt(Message m) {
final pfx = m.source == MessageSource.bot
? "bot#${m.userName}"
: m.source == MessageSource.user
? m.userName
: "<SYS>";
return "$pfx: ${m.message}";
}

final colorSeed = room.createTime.millisecondsSinceEpoch;
final avatarColor = getColor(colorSeed);
return MapEntry(
index,
ListTile(
isThreeLine: false,
subtitle: room.firstMessage != null
? Text.rich(
TextSpan(children: [
TextSpan(
text: "${room.firstMessage!.userName}: ",
style: const TextStyle(
fontSize: 18,
)),
TextSpan(
text: room.firstMessage!.message,
style: const TextStyle(
fontSize: 18,
overflow: TextOverflow.ellipsis,
))
]),
? Text(
fmt(room.firstMessage!),
maxLines: 1,
overflow: TextOverflow.ellipsis,
)
Expand Down

0 comments on commit 3718580

Please sign in to comment.