mirror of
https://gitlab.com/famedly/fluffychat.git
synced 2024-12-18 02:42:34 +01:00
feat: add ability to mark a room as unread
This also add tooltips to all the room context actions.
This commit is contained in:
parent
a791831e6d
commit
fe2b391046
@ -1,12 +1,12 @@
|
|||||||
import 'package:adaptive_dialog/adaptive_dialog.dart';
|
import 'package:adaptive_dialog/adaptive_dialog.dart';
|
||||||
import 'package:flushbar/flushbar_helper.dart';
|
|
||||||
import 'package:circular_check_box/circular_check_box.dart';
|
import 'package:circular_check_box/circular_check_box.dart';
|
||||||
import 'package:famedlysdk/famedlysdk.dart';
|
import 'package:famedlysdk/famedlysdk.dart';
|
||||||
import 'package:fluffychat/utils/matrix_locals.dart';
|
|
||||||
import 'package:fluffychat/views/chat.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:fluffychat/utils/event_extension.dart';
|
import 'package:fluffychat/utils/event_extension.dart';
|
||||||
|
import 'package:fluffychat/utils/matrix_locals.dart';
|
||||||
import 'package:fluffychat/utils/room_status_extension.dart';
|
import 'package:fluffychat/utils/room_status_extension.dart';
|
||||||
|
import 'package:fluffychat/views/chat.dart';
|
||||||
|
import 'package:flushbar/flushbar_helper.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_gen/gen_l10n/l10n.dart';
|
import 'package:flutter_gen/gen_l10n/l10n.dart';
|
||||||
import 'package:pedantic/pedantic.dart';
|
import 'package:pedantic/pedantic.dart';
|
||||||
|
|
||||||
@ -249,23 +249,25 @@ class ChatListItem extends StatelessWidget {
|
|||||||
color: Theme.of(context).primaryColor,
|
color: Theme.of(context).primaryColor,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
if (room.notificationCount > 0)
|
if (room.isUnread)
|
||||||
Container(
|
Container(
|
||||||
padding: EdgeInsets.symmetric(horizontal: 7),
|
padding: EdgeInsets.symmetric(horizontal: 7),
|
||||||
height: 20,
|
height: room.notificationCount > 0 ? 20 : 14,
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: room.highlightCount > 0
|
color: room.highlightCount > 0 || room.markedUnread
|
||||||
? Colors.red
|
? Colors.red
|
||||||
: Theme.of(context).primaryColor,
|
: Theme.of(context).primaryColor,
|
||||||
borderRadius: BorderRadius.circular(20),
|
borderRadius: BorderRadius.circular(20),
|
||||||
),
|
),
|
||||||
child: Center(
|
child: Center(
|
||||||
child: Text(
|
child: room.notificationCount > 0
|
||||||
|
? Text(
|
||||||
room.notificationCount.toString(),
|
room.notificationCount.toString(),
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
color: Colors.white,
|
color: Colors.white,
|
||||||
),
|
),
|
||||||
),
|
)
|
||||||
|
: Container(),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
@ -1665,6 +1665,21 @@
|
|||||||
"type": "text",
|
"type": "text",
|
||||||
"placeholders": {}
|
"placeholders": {}
|
||||||
},
|
},
|
||||||
|
"toggleFavorite": "Toggle Favorite",
|
||||||
|
"@toggleFavorite": {
|
||||||
|
"type": "text",
|
||||||
|
"placeholders": {}
|
||||||
|
},
|
||||||
|
"toggleMuted": "Toggle Muted",
|
||||||
|
"@toggleMuted": {
|
||||||
|
"type": "text",
|
||||||
|
"placeholders": {}
|
||||||
|
},
|
||||||
|
"toggleUnread": "Mark Read/Unread",
|
||||||
|
"@toggleUnread": {
|
||||||
|
"type": "text",
|
||||||
|
"placeholders": {}
|
||||||
|
},
|
||||||
"tryToSendAgain": "Try to send again",
|
"tryToSendAgain": "Try to send again",
|
||||||
"@tryToSendAgain": {
|
"@tryToSendAgain": {
|
||||||
"type": "text",
|
"type": "text",
|
||||||
|
@ -4,7 +4,6 @@ import 'dart:math';
|
|||||||
|
|
||||||
import 'package:adaptive_dialog/adaptive_dialog.dart';
|
import 'package:adaptive_dialog/adaptive_dialog.dart';
|
||||||
import 'package:famedlysdk/famedlysdk.dart';
|
import 'package:famedlysdk/famedlysdk.dart';
|
||||||
|
|
||||||
import 'package:file_picker_cross/file_picker_cross.dart';
|
import 'package:file_picker_cross/file_picker_cross.dart';
|
||||||
import 'package:fluffychat/components/adaptive_page_layout.dart';
|
import 'package:fluffychat/components/adaptive_page_layout.dart';
|
||||||
import 'package:fluffychat/components/avatar.dart';
|
import 'package:fluffychat/components/avatar.dart';
|
||||||
@ -34,8 +33,8 @@ import 'package:swipe_to_action/swipe_to_action.dart';
|
|||||||
|
|
||||||
import '../components/dialogs/send_file_dialog.dart';
|
import '../components/dialogs/send_file_dialog.dart';
|
||||||
import '../components/input_bar.dart';
|
import '../components/input_bar.dart';
|
||||||
import '../utils/matrix_file_extension.dart';
|
|
||||||
import '../config/app_config.dart';
|
import '../config/app_config.dart';
|
||||||
|
import '../utils/matrix_file_extension.dart';
|
||||||
import 'chat_details.dart';
|
import 'chat_details.dart';
|
||||||
import 'chat_list.dart';
|
import 'chat_list.dart';
|
||||||
|
|
||||||
@ -181,9 +180,7 @@ class _ChatState extends State<_Chat> {
|
|||||||
if (timeline == null) {
|
if (timeline == null) {
|
||||||
timeline = await room.getTimeline(onUpdate: updateView);
|
timeline = await room.getTimeline(onUpdate: updateView);
|
||||||
if (timeline.events.isNotEmpty) {
|
if (timeline.events.isNotEmpty) {
|
||||||
unawaited(room
|
unawaited(room.setUnread(false).catchError((err) {
|
||||||
.sendReadReceipt(timeline.events.first.eventId)
|
|
||||||
.catchError((err) {
|
|
||||||
if (err is MatrixException && err.errcode == 'M_FORBIDDEN') {
|
if (err is MatrixException && err.errcode == 'M_FORBIDDEN') {
|
||||||
// ignore if the user is not in the room (still joining)
|
// ignore if the user is not in the room (still joining)
|
||||||
return;
|
return;
|
||||||
@ -484,7 +481,6 @@ class _ChatState extends State<_Chat> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
final typingText = room.getLocalizedTypingText(context);
|
final typingText = room.getLocalizedTypingText(context);
|
||||||
|
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
appBar: AppBar(
|
appBar: AppBar(
|
||||||
leading: selectMode
|
leading: selectMode
|
||||||
@ -624,7 +620,7 @@ class _ChatState extends State<_Chat> {
|
|||||||
timeline != null &&
|
timeline != null &&
|
||||||
timeline.events.isNotEmpty &&
|
timeline.events.isNotEmpty &&
|
||||||
Matrix.of(context).webHasFocus) {
|
Matrix.of(context).webHasFocus) {
|
||||||
room.sendReadReceipt(timeline.events.first.eventId);
|
room.sendReadMarker(timeline.events.first.eventId);
|
||||||
}
|
}
|
||||||
|
|
||||||
final filteredEvents = getFilteredEvents();
|
final filteredEvents = getFilteredEvents();
|
||||||
|
@ -140,6 +140,13 @@ class _ChatListState extends State<ChatList> {
|
|||||||
super.dispose();
|
super.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<void> _toggleUnread(BuildContext context) {
|
||||||
|
final room = Matrix.of(context).client.getRoomById(_selectedRoomIds.single);
|
||||||
|
return SimpleDialogs(context).tryRequestWithLoadingDialog(
|
||||||
|
room.setUnread(!room.isUnread),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
Future<void> _toggleFavouriteRoom(BuildContext context) {
|
Future<void> _toggleFavouriteRoom(BuildContext context) {
|
||||||
final room = Matrix.of(context).client.getRoomById(_selectedRoomIds.single);
|
final room = Matrix.of(context).client.getRoomById(_selectedRoomIds.single);
|
||||||
return SimpleDialogs(context).tryRequestWithLoadingDialog(
|
return SimpleDialogs(context).tryRequestWithLoadingDialog(
|
||||||
@ -226,16 +233,25 @@ class _ChatListState extends State<ChatList> {
|
|||||||
: [
|
: [
|
||||||
if (_selectedRoomIds.length == 1)
|
if (_selectedRoomIds.length == 1)
|
||||||
IconButton(
|
IconButton(
|
||||||
|
tooltip: L10n.of(context).toggleUnread,
|
||||||
|
icon: Icon(Icons.mark_chat_unread_outlined),
|
||||||
|
onPressed: () => _toggleUnread(context),
|
||||||
|
),
|
||||||
|
if (_selectedRoomIds.length == 1)
|
||||||
|
IconButton(
|
||||||
|
tooltip: L10n.of(context).toggleFavorite,
|
||||||
icon: Icon(Icons.favorite_border_outlined),
|
icon: Icon(Icons.favorite_border_outlined),
|
||||||
onPressed: () => _toggleFavouriteRoom(context),
|
onPressed: () => _toggleFavouriteRoom(context),
|
||||||
),
|
),
|
||||||
if (_selectedRoomIds.length == 1)
|
if (_selectedRoomIds.length == 1)
|
||||||
IconButton(
|
IconButton(
|
||||||
icon: Icon(Icons.notifications_none_outlined),
|
icon: Icon(Icons.notifications_none_outlined),
|
||||||
|
tooltip: L10n.of(context).toggleMuted,
|
||||||
onPressed: () => _toggleMuted(context),
|
onPressed: () => _toggleMuted(context),
|
||||||
),
|
),
|
||||||
IconButton(
|
IconButton(
|
||||||
icon: Icon(Icons.archive_outlined),
|
icon: Icon(Icons.archive_outlined),
|
||||||
|
tooltip: L10n.of(context).archive,
|
||||||
onPressed: () => _archiveAction(context),
|
onPressed: () => _archiveAction(context),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
48
pubspec.lock
48
pubspec.lock
@ -70,7 +70,7 @@ packages:
|
|||||||
name: async
|
name: async
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.5.0-nullsafety.1"
|
version: "2.5.0-nullsafety.3"
|
||||||
base58check:
|
base58check:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@ -84,7 +84,7 @@ packages:
|
|||||||
name: boolean_selector
|
name: boolean_selector
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.1.0-nullsafety.1"
|
version: "2.1.0-nullsafety.3"
|
||||||
cached_network_image:
|
cached_network_image:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
@ -105,14 +105,14 @@ packages:
|
|||||||
name: characters
|
name: characters
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.1.0-nullsafety.3"
|
version: "1.1.0-nullsafety.5"
|
||||||
charcode:
|
charcode:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: charcode
|
name: charcode
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.2.0-nullsafety.1"
|
version: "1.2.0-nullsafety.3"
|
||||||
circular_check_box:
|
circular_check_box:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
@ -133,14 +133,14 @@ packages:
|
|||||||
name: clock
|
name: clock
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.1.0-nullsafety.1"
|
version: "1.1.0-nullsafety.3"
|
||||||
collection:
|
collection:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: collection
|
name: collection
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.15.0-nullsafety.3"
|
version: "1.15.0-nullsafety.5"
|
||||||
convert:
|
convert:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@ -203,13 +203,13 @@ packages:
|
|||||||
name: fake_async
|
name: fake_async
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.2.0-nullsafety.1"
|
version: "1.2.0-nullsafety.3"
|
||||||
famedlysdk:
|
famedlysdk:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
path: "."
|
path: "."
|
||||||
ref: "20ae1ae20e51840643988768620cc9900f83231c"
|
ref: "5167e92913784937fb7ec5bd4f64072c50924e19"
|
||||||
resolved-ref: "20ae1ae20e51840643988768620cc9900f83231c"
|
resolved-ref: "5167e92913784937fb7ec5bd4f64072c50924e19"
|
||||||
url: "https://gitlab.com/famedly/famedlysdk.git"
|
url: "https://gitlab.com/famedly/famedlysdk.git"
|
||||||
source: git
|
source: git
|
||||||
version: "0.0.1"
|
version: "0.0.1"
|
||||||
@ -547,7 +547,7 @@ packages:
|
|||||||
name: js
|
name: js
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.6.3-nullsafety.2"
|
version: "0.6.3-nullsafety.3"
|
||||||
localstorage:
|
localstorage:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
@ -575,7 +575,7 @@ packages:
|
|||||||
name: matcher
|
name: matcher
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.12.10-nullsafety.1"
|
version: "0.12.10-nullsafety.3"
|
||||||
matrix_file_e2ee:
|
matrix_file_e2ee:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@ -596,7 +596,7 @@ packages:
|
|||||||
name: meta
|
name: meta
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.3.0-nullsafety.3"
|
version: "1.3.0-nullsafety.6"
|
||||||
mime:
|
mime:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@ -710,7 +710,7 @@ packages:
|
|||||||
name: path
|
name: path
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.8.0-nullsafety.1"
|
version: "1.8.0-nullsafety.3"
|
||||||
path_drawing:
|
path_drawing:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@ -946,7 +946,7 @@ packages:
|
|||||||
name: source_span
|
name: source_span
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.8.0-nullsafety.2"
|
version: "1.8.0-nullsafety.4"
|
||||||
sqflite:
|
sqflite:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
@ -981,21 +981,21 @@ packages:
|
|||||||
name: stack_trace
|
name: stack_trace
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.10.0-nullsafety.1"
|
version: "1.10.0-nullsafety.6"
|
||||||
stream_channel:
|
stream_channel:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: stream_channel
|
name: stream_channel
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.1.0-nullsafety.1"
|
version: "2.1.0-nullsafety.3"
|
||||||
string_scanner:
|
string_scanner:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: string_scanner
|
name: string_scanner
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.1.0-nullsafety.1"
|
version: "1.1.0-nullsafety.3"
|
||||||
swipe_to_action:
|
swipe_to_action:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
@ -1016,28 +1016,28 @@ packages:
|
|||||||
name: term_glyph
|
name: term_glyph
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.2.0-nullsafety.1"
|
version: "1.2.0-nullsafety.3"
|
||||||
test:
|
test:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: test
|
name: test
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.16.0-nullsafety.5"
|
version: "1.16.0-nullsafety.12"
|
||||||
test_api:
|
test_api:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: test_api
|
name: test_api
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.2.19-nullsafety.2"
|
version: "0.2.19-nullsafety.6"
|
||||||
test_core:
|
test_core:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: test_core
|
name: test_core
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.3.12-nullsafety.5"
|
version: "0.3.12-nullsafety.11"
|
||||||
timezone:
|
timezone:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@ -1058,7 +1058,7 @@ packages:
|
|||||||
name: typed_data
|
name: typed_data
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.3.0-nullsafety.3"
|
version: "1.3.0-nullsafety.5"
|
||||||
universal_html:
|
universal_html:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
@ -1142,7 +1142,7 @@ packages:
|
|||||||
name: vector_math
|
name: vector_math
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.1.0-nullsafety.3"
|
version: "2.1.0-nullsafety.5"
|
||||||
vm_service:
|
vm_service:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@ -1214,5 +1214,5 @@ packages:
|
|||||||
source: hosted
|
source: hosted
|
||||||
version: "0.1.2"
|
version: "0.1.2"
|
||||||
sdks:
|
sdks:
|
||||||
dart: ">=2.10.2 <2.11.0"
|
dart: ">=2.12.0-0.0 <=2.12.0-29.10.beta"
|
||||||
flutter: ">=1.22.2 <2.0.0"
|
flutter: ">=1.22.2 <2.0.0"
|
||||||
|
@ -13,7 +13,7 @@ dependencies:
|
|||||||
famedlysdk:
|
famedlysdk:
|
||||||
git:
|
git:
|
||||||
url: https://gitlab.com/famedly/famedlysdk.git
|
url: https://gitlab.com/famedly/famedlysdk.git
|
||||||
ref: 20ae1ae20e51840643988768620cc9900f83231c
|
ref: 5167e92913784937fb7ec5bd4f64072c50924e19
|
||||||
|
|
||||||
localstorage: ^3.0.3+6
|
localstorage: ^3.0.3+6
|
||||||
file_picker_cross: 4.2.2
|
file_picker_cross: 4.2.2
|
||||||
|
Loading…
Reference in New Issue
Block a user