change: Click on background to clear selected events

This commit is contained in:
S1m 2022-01-03 16:12:09 +00:00 committed by Krille Fear
parent 5ab514cc6f
commit fd7bb7f46c
2 changed files with 159 additions and 141 deletions

View File

@ -682,6 +682,12 @@ class ChatController extends State<Chat> {
showEmojiPicker = false;
});
void clearSingleSelectedEvent() {
if (selectedEvents.length <= 1) {
clearSelectedEvents();
}
}
void editSelectedEventAction() {
final client = currentRoomBundle.firstWhere(
(cl) => selectedEvents.first.senderId == cl.userID,

View File

@ -188,6 +188,8 @@ class ChatView extends StatelessWidget {
children: <Widget>[
TombstoneDisplay(controller),
Expanded(
child: GestureDetector(
onTap: controller.clearSingleSelectedEvent,
child: FutureBuilder<bool>(
future: controller.getTimeline(),
builder: (BuildContext context, snapshot) {
@ -224,38 +226,46 @@ class ChatView extends StatelessWidget {
controller: controller.scrollController,
keyboardDismissBehavior: PlatformInfos.isIOS
? ScrollViewKeyboardDismissBehavior.onDrag
: ScrollViewKeyboardDismissBehavior.manual,
: ScrollViewKeyboardDismissBehavior
.manual,
childrenDelegate: SliverChildBuilderDelegate(
(BuildContext context, int i) {
return i ==
controller.filteredEvents.length + 1
? controller.timeline.isRequestingHistory
controller.filteredEvents.length +
1
? controller
.timeline.isRequestingHistory
? const Center(
child: CircularProgressIndicator
.adaptive(strokeWidth: 2),
child:
CircularProgressIndicator
.adaptive(
strokeWidth: 2),
)
: controller.canLoadMore
? Center(
child: OutlinedButton(
style: OutlinedButton
.styleFrom(
backgroundColor: Theme.of(
context)
backgroundColor: Theme
.of(context)
.scaffoldBackgroundColor,
),
onPressed: controller
.requestHistory,
child: Text(L10n.of(context)
child: Text(
L10n.of(context)
.loadMore),
),
)
: Container()
: i == 0
? Column(
mainAxisSize: MainAxisSize.min,
mainAxisSize:
MainAxisSize.min,
children: [
SeenByRow(controller),
TypingIndicators(controller),
TypingIndicators(
controller),
],
)
: AutoScrollTag(
@ -263,30 +273,31 @@ class ChatView extends StatelessWidget {
.filteredEvents[i - 1]
.eventId),
index: i - 1,
controller:
controller.scrollController,
controller: controller
.scrollController,
child: Swipeable(
key: ValueKey(controller
.filteredEvents[i - 1]
.eventId),
background: const Padding(
padding: EdgeInsets.symmetric(
padding:
EdgeInsets.symmetric(
horizontal: 12.0),
child: Center(
child: Icon(
Icons.reply_outlined),
child: Icon(Icons
.reply_outlined),
),
),
direction:
SwipeDirection.endToStart,
direction: SwipeDirection
.endToStart,
onSwipe: (direction) =>
controller.replyAction(
replyTo: controller
.filteredEvents[
i - 1]),
child: Message(
controller
.filteredEvents[i - 1],
controller.filteredEvents[
i - 1],
onInfoTab: controller
.showEventInfo,
onAvatarTab: (Event event) =>
@ -294,7 +305,8 @@ class ChatView extends StatelessWidget {
context: context,
builder: (c) =>
UserBottomSheet(
user: event.sender,
user: event
.sender,
outerContext:
context,
onMention: () => controller
@ -303,22 +315,22 @@ class ChatView extends StatelessWidget {
'${event.sender.mention} ',
),
),
unfold: controller.unfold,
unfold:
controller.unfold,
onSelect: controller
.onSelectMessage,
scrollToEventId:
(String eventId) =>
controller.scrollToEventId(
controller
.scrollToEventId(
eventId),
longPressSelect: controller
.selectedEvents.isEmpty,
longPressSelect:
controller
.selectedEvents
.isEmpty,
selected: controller
.selectedEvents
.any((e) =>
e.eventId ==
controller
.filteredEvents[i - 1]
.eventId),
.any((e) => e.eventId == controller.filteredEvents[i - 1].eventId),
timeline: controller.timeline,
nextEvent: i < controller.filteredEvents.length ? controller.filteredEvents[i] : null),
),
@ -332,7 +344,7 @@ class ChatView extends StatelessWidget {
),
);
},
),
)),
),
if (controller.room.canSendDefaultMessages &&
controller.room.membership == Membership.join)