Skip to content

Commit d51eb68

Browse files
author
Aleksandr Sokolovskii
committed
added Shimmer effect for outgoing messages
1 parent 6702eac commit d51eb68

File tree

3 files changed

+29
-10
lines changed

3 files changed

+29
-10
lines changed

flutter_client/lib/theme.dart

+2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ final ThemeData kIOSTheme = new ThemeData(
77
);
88

99
final ThemeData kDefaultTheme = ThemeData.light();
10+
final Color shimmerBaseColor = Colors.black; /*Colors.white;*/
11+
final Color shimmerHighlightColor = Colors.grey[200]; /*Colors.grey[700];*/
1012

1113
bool isIOS(BuildContext context) {
1214
return Theme.of(context).platform == TargetPlatform.iOS;

flutter_client/lib/widgets/chat_message_outgoing.dart

+25-10
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
import 'package:flutter/material.dart';
22

3+
import 'package:shimmer/shimmer.dart';
4+
35
import 'package:flutter_client/models/message_outgoing.dart';
6+
import 'package:flutter_client/theme.dart';
47

58
import 'chat_message.dart';
69

@@ -35,16 +38,7 @@ class ChatMessageOutgoing extends StatelessWidget implements ChatMessage {
3538
child: CircleAvatar(child: Text(_name[0])),
3639
),
3740
Expanded(
38-
child: Column(
39-
crossAxisAlignment: CrossAxisAlignment.start,
40-
children: <Widget>[
41-
Text(_name, style: Theme.of(context).textTheme.subhead),
42-
Container(
43-
margin: EdgeInsets.only(top: 5.0),
44-
child: Text(message.text),
45-
),
46-
],
47-
),
41+
child: _getMessageContent(context),
4842
),
4943
Container(
5044
child: Icon(message.status == MessageOutgoingStatus.SENT
@@ -56,4 +50,25 @@ class ChatMessageOutgoing extends StatelessWidget implements ChatMessage {
5650
),
5751
);
5852
}
53+
54+
Widget _getMessageContent(BuildContext context) {
55+
var content = Column(
56+
crossAxisAlignment: CrossAxisAlignment.start,
57+
children: <Widget>[
58+
Text(_name, style: Theme.of(context).textTheme.subhead),
59+
Container(
60+
margin: EdgeInsets.only(top: 5.0),
61+
child: Text(message.text),
62+
),
63+
],
64+
);
65+
if (message.status != MessageOutgoingStatus.SENT) {
66+
return Shimmer.fromColors(
67+
baseColor: shimmerBaseColor,
68+
highlightColor: shimmerHighlightColor,
69+
child: content,
70+
);
71+
}
72+
return content;
73+
}
5974
}

flutter_client/pubspec.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ dependencies:
2525

2626
rxdart: ^0.20.0
2727

28+
shimmer: ^1.0.0
29+
2830
dev_dependencies:
2931
flutter_test:
3032
sdk: flutter

0 commit comments

Comments
 (0)