forked from krille-chan/fluffychat
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
krille-chan#38 Fluffy Chat: moved read receipts to a subfolder and added filter to filter users according to given or not given read receipts krille-chan#38 FluffyChat: hide user who has give read receipt in list of users and read receipts krille-chan#44 FluffyChat: remove required from param onReadReceipt in class Message krille-chan#34 FluffyChat: only admin is allowed to request read receipt fix errors probably introduced by my rebase chat list header: missed vrouter dependency
- Loading branch information
Matthias
committed
Dec 20, 2022
1 parent
88f4ada
commit 646168d
Showing
15 changed files
with
378 additions
and
132 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
import 'package:flutter/cupertino.dart'; | ||
|
||
import 'package:matrix/matrix.dart'; | ||
|
||
import 'package:fluffychat/pages/chat/read_receipt/read_receipt_list_view.dart'; | ||
|
||
class ReadReceiptList extends StatefulWidget { | ||
final Event event; | ||
final Room room; | ||
final Timeline timeline; | ||
|
||
const ReadReceiptList( | ||
{required this.event, | ||
required this.room, | ||
required this.timeline, | ||
Key? key}) | ||
: super(key: key); | ||
|
||
@override | ||
ReadReceiptListController createState() => | ||
ReadReceiptListController(event, room, timeline); | ||
} | ||
|
||
class ReadReceiptListController extends State<ReadReceiptList> { | ||
Event? event; | ||
Room? room; | ||
Timeline? timeline; | ||
List<User> members = []; | ||
Set<Event>? readReceipts; | ||
String filter = "all"; | ||
|
||
ReadReceiptListController( | ||
Event this.event, Room this.room, Timeline this.timeline); | ||
|
||
@override | ||
void initState() { | ||
members = room!.getParticipants(); | ||
readReceipts = | ||
event!.aggregatedEvents(timeline!, RelationshipTypes.readReceipt); | ||
|
||
super.initState(); | ||
} | ||
|
||
bool userHasGivenReadReceipt(int index) { | ||
bool found = false; | ||
final userId = members[index].id; | ||
|
||
for (final event in readReceipts!) { | ||
if (event.senderId == userId) { | ||
found = true; | ||
} | ||
} | ||
|
||
return found; | ||
} | ||
|
||
bool userIsVisible(int index) { | ||
// don't show user who has requested read receipt | ||
if (event!.senderId == members[index].id) { | ||
return false; | ||
} else if (filter == "all") { | ||
return true; | ||
} else { | ||
final hasReadReceipt = userHasGivenReadReceipt(index); | ||
if (filter == "open" && !hasReadReceipt || | ||
filter == "given" && hasReadReceipt) { | ||
return true; | ||
} else { | ||
return false; | ||
} | ||
} | ||
} | ||
|
||
void changeFilter(value) { | ||
setState(() { | ||
filter = value.toString(); | ||
}); | ||
} | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return ReadReceiptListView(this); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import 'package:flutter/material.dart'; | ||
|
||
import 'package:flutter_gen/gen_l10n/l10n.dart'; | ||
import 'package:matrix/matrix.dart'; | ||
|
||
import 'package:fluffychat/pages/chat/read_receipt/read_receipt_list.dart'; | ||
|
||
extension ReadReceiptListDialogExtension on Event { | ||
void showReadReceiptListDialog( | ||
BuildContext context, Room room, Timeline timeline) => | ||
showModalBottomSheet( | ||
context: context, | ||
builder: (context) => ReadReceiptListDialog( | ||
l10n: L10n.of(context)!, | ||
event: this, | ||
room: room, | ||
timeline: timeline, | ||
), | ||
); | ||
} | ||
|
||
class ReadReceiptListDialog extends StatelessWidget { | ||
final Event event; | ||
final L10n l10n; | ||
final Room room; | ||
final Timeline timeline; | ||
|
||
const ReadReceiptListDialog({ | ||
required this.event, | ||
required this.l10n, | ||
required this.room, | ||
required this.timeline, | ||
Key? key, | ||
}) : super(key: key); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return Scaffold( | ||
appBar: AppBar( | ||
title: Text(L10n.of(context)!.readReceipts), | ||
leading: IconButton( | ||
icon: const Icon(Icons.arrow_downward), | ||
onPressed: Navigator.of(context, rootNavigator: false).pop, | ||
tooltip: L10n.of(context)!.close, | ||
), | ||
), | ||
body: ReadReceiptList(event: event, room: room, timeline: timeline)); | ||
} | ||
} |
Oops, something went wrong.