Merge branch 'master' into feature/notifications
This commit is contained in:
@@ -1,3 +1,7 @@
|
|||||||
|
## 0.1.18
|
||||||
|
|
||||||
|
- Add message list date separators
|
||||||
|
|
||||||
## 0.1.17
|
## 0.1.17
|
||||||
|
|
||||||
- Add dark theme
|
- Add dark theme
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:jiffy/jiffy.dart';
|
||||||
import 'package:stream_chat/stream_chat.dart';
|
import 'package:stream_chat/stream_chat.dart';
|
||||||
import 'package:visibility_detector/visibility_detector.dart';
|
import 'package:visibility_detector/visibility_detector.dart';
|
||||||
|
|
||||||
@@ -166,39 +167,111 @@ class _MessageListViewState extends State<MessageListView> {
|
|||||||
i < _messages.length - 1 ? _messages[i + 1] : null;
|
i < _messages.length - 1 ? _messages[i + 1] : null;
|
||||||
final nextMessage = i > 0 ? _messages[i - 1] : null;
|
final nextMessage = i > 0 ? _messages[i - 1] : null;
|
||||||
|
|
||||||
|
Widget messageWidget;
|
||||||
|
|
||||||
if (i == 0) {
|
if (i == 0) {
|
||||||
return _buildBottomMessage(
|
messageWidget = _buildBottomMessage(
|
||||||
streamChannel,
|
streamChannel,
|
||||||
previousMessage,
|
previousMessage,
|
||||||
message,
|
message,
|
||||||
context,
|
context,
|
||||||
);
|
);
|
||||||
}
|
} else if (i == _messages.length - 1) {
|
||||||
|
messageWidget = _buildTopMessage(
|
||||||
if (i == _messages.length - 1) {
|
|
||||||
return _buildTopMessage(
|
|
||||||
message,
|
message,
|
||||||
nextMessage,
|
nextMessage,
|
||||||
streamChannel,
|
streamChannel,
|
||||||
context,
|
context,
|
||||||
);
|
);
|
||||||
|
} else {
|
||||||
|
if (widget.messageBuilder != null) {
|
||||||
|
messageWidget = Builder(
|
||||||
|
key: ValueKey<String>('MESSAGE-${message.id}'),
|
||||||
|
builder: (_) => widget.messageBuilder(context, message, i),
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
messageWidget = MessageWidget(
|
||||||
|
key: ValueKey<String>('MESSAGE-${message.id}'),
|
||||||
|
previousMessage: previousMessage,
|
||||||
|
message: message,
|
||||||
|
nextMessage: nextMessage,
|
||||||
|
onThreadTap: _onThreadTap,
|
||||||
|
showOtherMessageUsername: widget.showOtherMessageUsername,
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (widget.messageBuilder != null) {
|
if (nextMessage != null &&
|
||||||
return Builder(
|
!Jiffy(message.createdAt.toLocal())
|
||||||
key: ValueKey<String>('MESSAGE-${message.id}'),
|
.isSame(nextMessage.createdAt.toLocal(), Units.DAY)) {
|
||||||
builder: (_) => widget.messageBuilder(context, message, i),
|
final divider = Expanded(
|
||||||
|
child: Padding(
|
||||||
|
padding: const EdgeInsets.symmetric(horizontal: 8.0),
|
||||||
|
child: Divider(),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
final createdAt = Jiffy(nextMessage.createdAt.toLocal());
|
||||||
|
final now = DateTime.now();
|
||||||
|
final hourInfo = createdAt.format('h:mm a');
|
||||||
|
|
||||||
|
String dayInfo;
|
||||||
|
if (Jiffy(createdAt).isSame(now, Units.DAY)) {
|
||||||
|
dayInfo = 'TODAY';
|
||||||
|
} else if (Jiffy(createdAt)
|
||||||
|
.isSame(now.subtract(Duration(days: 1)), Units.DAY)) {
|
||||||
|
dayInfo = 'YESTERDAY';
|
||||||
|
} else {
|
||||||
|
dayInfo = createdAt.format('EEEE').toUpperCase();
|
||||||
|
}
|
||||||
|
|
||||||
|
return Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||||
|
children: <Widget>[
|
||||||
|
messageWidget,
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.only(top: 24.0),
|
||||||
|
child: Row(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
|
children: <Widget>[
|
||||||
|
divider,
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.symmetric(horizontal: 32.0),
|
||||||
|
child: Text.rich(
|
||||||
|
TextSpan(
|
||||||
|
children: [
|
||||||
|
TextSpan(
|
||||||
|
text: dayInfo,
|
||||||
|
style: TextStyle(
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
TextSpan(text: ' AT'),
|
||||||
|
TextSpan(text: ' $hourInfo'),
|
||||||
|
],
|
||||||
|
style: TextStyle(
|
||||||
|
fontWeight: FontWeight.normal,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 10,
|
||||||
|
color: Theme.of(context)
|
||||||
|
.textTheme
|
||||||
|
.title
|
||||||
|
.color
|
||||||
|
.withOpacity(.5),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
divider,
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return MessageWidget(
|
return messageWidget;
|
||||||
key: ValueKey<String>('MESSAGE-${message.id}'),
|
|
||||||
previousMessage: previousMessage,
|
|
||||||
message: message,
|
|
||||||
nextMessage: nextMessage,
|
|
||||||
onThreadTap: _onThreadTap,
|
|
||||||
showOtherMessageUsername: widget.showOtherMessageUsername,
|
|
||||||
);
|
|
||||||
},
|
},
|
||||||
childCount: _messages.length + 2,
|
childCount: _messages.length + 2,
|
||||||
findChildIndexCallback: (key) {
|
findChildIndexCallback: (key) {
|
||||||
|
|||||||
+2
-2
@@ -1,7 +1,7 @@
|
|||||||
name: stream_chat_flutter
|
name: stream_chat_flutter
|
||||||
homepage: https://github.com/GetStream/stream-chat-flutter
|
homepage: https://github.com/GetStream/stream-chat-flutter
|
||||||
description: Stream Chat official Flutter SDK. Build your own chat experience using Dart and Flutter.
|
description: Stream Chat official Flutter SDK. Build your own chat experience using Dart and Flutter.
|
||||||
version: 0.1.17
|
version: 0.1.18
|
||||||
|
|
||||||
environment:
|
environment:
|
||||||
sdk: ">=2.3.0 <3.0.0"
|
sdk: ">=2.3.0 <3.0.0"
|
||||||
@@ -19,7 +19,7 @@ dependencies:
|
|||||||
chewie: ^0.9.10
|
chewie: ^0.9.10
|
||||||
file_picker: ^1.6.0
|
file_picker: ^1.6.0
|
||||||
image_picker: ^0.6.4
|
image_picker: ^0.6.4
|
||||||
flutter_keyboard_visibility: ^0.7.0
|
flutter_keyboard_visibility: ^0.8.0
|
||||||
stream_chat:
|
stream_chat:
|
||||||
path: ../stream_chat_dart
|
path: ../stream_chat_dart
|
||||||
visibility_detector: ^0.1.4
|
visibility_detector: ^0.1.4
|
||||||
|
|||||||
Reference in New Issue
Block a user