@@ -30,6 +30,7 @@ class MessageListTheme extends ThemeExtension<MessageListTheme> {
3030  static  final  light =  MessageListTheme ._(
3131    dateSeparator:  Colors .black,
3232    dateSeparatorText:  const  HSLColor .fromAHSL (0.75 , 0 , 0 , 0.15 ).toColor (),
33+     dmMessageBgDefault:  const  HSLColor .fromAHSL (1 , 45 , 0.20 , 0.96 ).toColor (),
3334    dmRecipientHeaderBg:  const  HSLColor .fromAHSL (1 , 46 , 0.35 , 0.93 ).toColor (),
3435    messageTimestamp:  const  HSLColor .fromAHSL (0.8 , 0 , 0 , 0.2 ).toColor (),
3536    recipientHeaderText:  const  HSLColor .fromAHSL (1 , 0 , 0 , 0.15 ).toColor (),
@@ -55,6 +56,7 @@ class MessageListTheme extends ThemeExtension<MessageListTheme> {
5556  static  final  dark =  MessageListTheme ._(
5657    dateSeparator:  Colors .white,
5758    dateSeparatorText:  const  HSLColor .fromAHSL (0.75 , 0 , 0 , 1 ).toColor (),
59+     dmMessageBgDefault:  const  HSLColor .fromAHSL (1 , 46 , 0.07 , 0.16 ).toColor (),
5860    dmRecipientHeaderBg:  const  HSLColor .fromAHSL (1 , 46 , 0.15 , 0.2 ).toColor (),
5961    messageTimestamp:  const  HSLColor .fromAHSL (0.8 , 0 , 0 , 0.85 ).toColor (),
6062    recipientHeaderText:  const  HSLColor .fromAHSL (0.8 , 0 , 0 , 1 ).toColor (),
@@ -79,6 +81,7 @@ class MessageListTheme extends ThemeExtension<MessageListTheme> {
7981  MessageListTheme ._({
8082    required  this .dateSeparator,
8183    required  this .dateSeparatorText,
84+     required  this .dmMessageBgDefault,
8285    required  this .dmRecipientHeaderBg,
8386    required  this .messageTimestamp,
8487    required  this .recipientHeaderText,
@@ -103,6 +106,7 @@ class MessageListTheme extends ThemeExtension<MessageListTheme> {
103106
104107  final  Color  dateSeparator;
105108  final  Color  dateSeparatorText;
109+   final  Color  dmMessageBgDefault;
106110  final  Color  dmRecipientHeaderBg;
107111  final  Color  messageTimestamp;
108112  final  Color  recipientHeaderText;
@@ -118,6 +122,7 @@ class MessageListTheme extends ThemeExtension<MessageListTheme> {
118122  MessageListTheme  copyWith ({
119123    Color ?  dateSeparator,
120124    Color ?  dateSeparatorText,
125+     Color ?  dmMessageBgDefault,
121126    Color ?  dmRecipientHeaderBg,
122127    Color ?  messageTimestamp,
123128    Color ?  recipientHeaderText,
@@ -132,6 +137,7 @@ class MessageListTheme extends ThemeExtension<MessageListTheme> {
132137    return  MessageListTheme ._(
133138      dateSeparator:  dateSeparator ??  this .dateSeparator,
134139      dateSeparatorText:  dateSeparatorText ??  this .dateSeparatorText,
140+       dmMessageBgDefault:  dmMessageBgDefault ??  this .dmMessageBgDefault,
135141      dmRecipientHeaderBg:  dmRecipientHeaderBg ??  this .dmRecipientHeaderBg,
136142      messageTimestamp:  messageTimestamp ??  this .messageTimestamp,
137143      recipientHeaderText:  recipientHeaderText ??  this .recipientHeaderText,
@@ -153,6 +159,7 @@ class MessageListTheme extends ThemeExtension<MessageListTheme> {
153159    return  MessageListTheme ._(
154160      dateSeparator:  Color .lerp (dateSeparator, other.dateSeparator, t)! ,
155161      dateSeparatorText:  Color .lerp (dateSeparatorText, other.dateSeparatorText, t)! ,
162+       dmMessageBgDefault:  Color .lerp (dmMessageBgDefault, other.dmMessageBgDefault, t)! ,
156163      dmRecipientHeaderBg:  Color .lerp (dmRecipientHeaderBg, other.dmRecipientHeaderBg, t)! ,
157164      messageTimestamp:  Color .lerp (messageTimestamp, other.messageTimestamp, t)! ,
158165      recipientHeaderText:  Color .lerp (recipientHeaderText, other.recipientHeaderText, t)! ,
@@ -165,6 +172,13 @@ class MessageListTheme extends ThemeExtension<MessageListTheme> {
165172      unsubscribedStreamRecipientHeaderBg:  Color .lerp (unsubscribedStreamRecipientHeaderBg, other.unsubscribedStreamRecipientHeaderBg, t)! ,
166173    );
167174  }
175+ 
176+   Color  getMessageBackgroundColor (Message  message) {
177+     return  switch  (message) {
178+       StreamMessage () =>  streamMessageBgDefault,
179+       DmMessage () =>  dmMessageBgDefault,
180+     };
181+   }
168182}
169183
170184/// The interface for the state of a [MessageListPage] . 
@@ -934,8 +948,9 @@ class DateSeparator extends StatelessWidget {
934948
935949    final  line =  BorderSide (width:  0 , color:  messageListTheme.dateSeparator);
936950
937-     // TODO(#681) use different color for DM messages 
938-     return  ColoredBox (color:  messageListTheme.streamMessageBgDefault,
951+     final  backgroundColor =  messageListTheme.getMessageBackgroundColor (message);
952+ 
953+     return  ColoredBox (color:  backgroundColor,
939954      child:  Padding (
940955        padding:  const  EdgeInsets .symmetric (vertical:  8 , horizontal:  2 ),
941956        child:  Row (children:  [
@@ -976,13 +991,15 @@ class MessageItem extends StatelessWidget {
976991  Widget  build (BuildContext  context) {
977992    final  message =  item.message;
978993    final  messageListTheme =  MessageListTheme .of (context);
994+     final  backgroundColor =  messageListTheme.getMessageBackgroundColor (message);
995+ 
979996    return  StickyHeaderItem (
980997      allowOverflow:  ! item.isLastInBlock,
981998      header:  header,
982999      child:  _UnreadMarker (
9831000        isRead:  message.flags.contains (MessageFlag .read),
9841001        child:  ColoredBox (
985-           color:  messageListTheme.streamMessageBgDefault ,
1002+           color:  backgroundColor ,
9861003          child:  Column (children:  [
9871004            MessageWithPossibleSender (item:  item),
9881005            if  (trailingWhitespace !=  null  &&  item.isLastInBlock) SizedBox (height:  trailingWhitespace! ),
0 commit comments