add badge on unread messages

This commit is contained in:
Salvatore Giordano
2020-10-28 11:05:58 +01:00
parent d1d7bd6f7e
commit 5ec32086d3
9 changed files with 43 additions and 11 deletions
+1 -1
View File
@@ -1 +1 @@
0289cdadbd29bab804f275e3c5907d07
89eb023669fee58472de747080d78b5a
+6
View File
@@ -80,6 +80,8 @@ PODS:
- Flutter (1.0.0)
- flutter_apns (0.0.1):
- Flutter
- flutter_app_badger (0.0.1):
- Flutter
- flutter_keyboard_visibility (0.0.1):
- Flutter
- flutter_local_notifications (0.0.1):
@@ -160,6 +162,7 @@ DEPENDENCIES:
- firebase_messaging (from `.symlinks/plugins/firebase_messaging/ios`)
- Flutter (from `Flutter`)
- flutter_apns (from `.symlinks/plugins/flutter_apns/ios`)
- flutter_app_badger (from `.symlinks/plugins/flutter_app_badger/ios`)
- flutter_keyboard_visibility (from `.symlinks/plugins/flutter_keyboard_visibility/ios`)
- flutter_local_notifications (from `.symlinks/plugins/flutter_local_notifications/ios`)
- image_picker (from `.symlinks/plugins/image_picker/ios`)
@@ -207,6 +210,8 @@ EXTERNAL SOURCES:
:path: Flutter
flutter_apns:
:path: ".symlinks/plugins/flutter_apns/ios"
flutter_app_badger:
:path: ".symlinks/plugins/flutter_app_badger/ios"
flutter_keyboard_visibility:
:path: ".symlinks/plugins/flutter_keyboard_visibility/ios"
flutter_local_notifications:
@@ -244,6 +249,7 @@ SPEC CHECKSUMS:
FirebaseMessaging: 29543feb343b09546ab3aa04d008ee8595b43c44
Flutter: 0e3d915762c693b495b44d77113d4970485de6ec
flutter_apns: f516b118e423fe7c0a38771180549c4d6cb67c2f
flutter_app_badger: 65de4d6f0c34a891df49e6cfb8a1c0496426fa68
flutter_keyboard_visibility: 0339d06371254c3eb25eeb90ba8d17dca8f9c069
flutter_local_notifications: 0c0b1ae97e741e1521e4c1629a459d04b9aec743
FMDB: 2ce00b547f966261cd18927a3ddb07cb6f3db82a
@@ -322,6 +322,7 @@
"${BUILT_PRODUCTS_DIR}/SwiftyGif/SwiftyGif.framework",
"${BUILT_PRODUCTS_DIR}/file_picker/file_picker.framework",
"${BUILT_PRODUCTS_DIR}/flutter_apns/flutter_apns.framework",
"${BUILT_PRODUCTS_DIR}/flutter_app_badger/flutter_app_badger.framework",
"${BUILT_PRODUCTS_DIR}/flutter_keyboard_visibility/flutter_keyboard_visibility.framework",
"${BUILT_PRODUCTS_DIR}/flutter_local_notifications/flutter_local_notifications.framework",
"${BUILT_PRODUCTS_DIR}/image_picker/image_picker.framework",
@@ -350,6 +351,7 @@
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/SwiftyGif.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/file_picker.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/flutter_apns.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/flutter_app_badger.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/flutter_keyboard_visibility.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/flutter_local_notifications.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/image_picker.framework",
+4
View File
@@ -54,5 +54,9 @@
</array>
<key>UIViewControllerBasedStatusBarAppearance</key>
<false/>
<key>UIBackgroundModes</key>
<array>
<string>remote-notification</string>
</array>
</dict>
</plist>
+1 -1
View File
@@ -1,6 +1,6 @@
name: example
description: A new Flutter project.
version: 1.0.31+33
version: 1.0.33+35
environment:
sdk: ">=2.2.2 <3.0.0"
+5 -2
View File
@@ -218,13 +218,16 @@ class MessageActionsModal extends StatelessWidget {
StreamIcons.edit,
size: 22,
color:
StreamChatTheme.of(context).primaryIconTheme.color,
StreamChatTheme.of(context).primaryIconTheme.color,
),
onPressed: () {},
),
Text(
'Edit message',
style: Theme.of(context).textTheme.headline6.copyWith(fontWeight: FontWeight.bold),
style: Theme.of(context)
.textTheme
.headline6
.copyWith(fontWeight: FontWeight.bold),
),
IconButton(
icon: Icon(
+15 -7
View File
@@ -192,7 +192,7 @@ class MessageInputState extends State<MessageInput> {
padding: const EdgeInsets.all(8.0),
child: _buildTextField(context),
),
if(widget.parentMessage != null)
if (widget.parentMessage != null)
Padding(
padding: const EdgeInsets.symmetric(horizontal: 8.0),
child: _buildDmCheckbox(),
@@ -222,7 +222,11 @@ class MessageInputState extends State<MessageInput> {
Widget _buildDmCheckbox() {
return Row(
children: [
Checkbox(value: _sendAsDm, onChanged: (val) => setState(() {_sendAsDm = val;})),
Checkbox(
value: _sendAsDm,
onChanged: (val) => setState(() {
_sendAsDm = val;
})),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 8.0),
child: Text('Send also as direct message'),
@@ -316,9 +320,11 @@ class MessageInputState extends State<MessageInput> {
var matchedCommandsList = StreamChannel.of(context)
.channel
.config
.commands.where((element) => element.name == s.substring(1)).toList();
.commands
.where((element) => element.name == s.substring(1))
.toList();
if(matchedCommandsList.length == 1) {
if (matchedCommandsList.length == 1) {
_chosenCommand = matchedCommandsList[0];
textEditingController.clear();
_messageIsPresent = false;
@@ -796,8 +802,8 @@ class MessageInputState extends State<MessageInput> {
return Center(
child: InkWell(
child: Padding(
padding: EdgeInsets.only(
left: 8.0, right: padding, top: 8.0, bottom: 8.0),
padding:
EdgeInsets.only(left: 8.0, right: padding, top: 8.0, bottom: 8.0),
child: Icon(StreamIcons.attach),
),
onTap: () {
@@ -1053,7 +1059,9 @@ class MessageInputState extends State<MessageInput> {
child: Transform.rotate(
angle: widget.editMessage == null ? -pi / 2 : 0,
child: Icon(
widget.editMessage == null ? StreamIcons.send_message : StreamIcons.check_send,
widget.editMessage == null
? StreamIcons.send_message
: StreamIcons.check_send,
color: StreamChatTheme.of(context).accentColor,
),
),
+8
View File
@@ -2,6 +2,7 @@ import 'dart:async';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter_app_badger/flutter_app_badger.dart';
import 'package:stream_chat/stream_chat.dart';
import 'package:stream_chat_flutter/src/stream_chat_theme.dart';
@@ -186,6 +187,13 @@ class StreamChatState extends State<StreamChat> with WidgetsBindingObserver {
void initState() {
super.initState();
WidgetsBinding.instance.addObserver(this);
client.state.totalUnreadCountStream.listen((count) {
if (count > 0) {
FlutterAppBadger.updateBadgeCount(count);
} else {
FlutterAppBadger.removeBadge();
}
});
}
StreamSubscription _newMessageSubscription;
+1
View File
@@ -11,6 +11,7 @@ environment:
dependencies:
flutter:
sdk: flutter
flutter_app_badger: ^1.1.2
photo_view: ^0.10.1
rxdart: ^0.24.1
jiffy: ^3.0.1