feat: Implement mouse select chat list items
This commit is contained in:
parent
bd597d39c2
commit
6d41136587
|
@ -1,4 +1,5 @@
|
|||
import 'package:bot_toast/bot_toast.dart';
|
||||
import 'package:circular_check_box/circular_check_box.dart';
|
||||
import 'package:famedlysdk/famedlysdk.dart';
|
||||
import 'package:fluffychat/utils/matrix_locals.dart';
|
||||
import 'package:fluffychat/views/chat.dart';
|
||||
|
@ -13,6 +14,7 @@ import '../avatar.dart';
|
|||
import '../dialogs/send_file_dialog.dart';
|
||||
import '../dialogs/simple_dialogs.dart';
|
||||
import '../matrix.dart';
|
||||
import '../mouse_over_builder.dart';
|
||||
import '../theme_switcher.dart';
|
||||
|
||||
class ChatListItem extends StatelessWidget {
|
||||
|
@ -128,7 +130,20 @@ class ChatListItem extends StatelessWidget {
|
|||
color: chatListItemColor(context, activeChat, selected),
|
||||
child: ListTile(
|
||||
onLongPress: onLongPress,
|
||||
leading: Avatar(room.avatar, room.displayname),
|
||||
leading: MouseOverBuilder(
|
||||
builder: (context, hover) =>
|
||||
onLongPress != null && (hover || selected)
|
||||
? Container(
|
||||
width: Avatar.defaultSize,
|
||||
height: Avatar.defaultSize,
|
||||
alignment: Alignment.center,
|
||||
child: CircularCheckBox(
|
||||
value: selected,
|
||||
onChanged: (_) => onLongPress(),
|
||||
),
|
||||
)
|
||||
: Avatar(room.avatar, room.displayname),
|
||||
),
|
||||
title: Row(
|
||||
children: <Widget>[
|
||||
Expanded(
|
||||
|
|
28
lib/components/mouse_over_builder.dart
Normal file
28
lib/components/mouse_over_builder.dart
Normal file
|
@ -0,0 +1,28 @@
|
|||
import 'package:flutter/material.dart';
|
||||
|
||||
class MouseOverBuilder extends StatefulWidget {
|
||||
final Function(BuildContext, bool) builder;
|
||||
|
||||
const MouseOverBuilder({Key key, this.builder}) : super(key: key);
|
||||
@override
|
||||
_MouseOverBuilderState createState() => _MouseOverBuilderState();
|
||||
}
|
||||
|
||||
class _MouseOverBuilderState extends State<MouseOverBuilder> {
|
||||
bool _hover = false;
|
||||
|
||||
void _toggleHover(bool hover) {
|
||||
if (_hover != hover) {
|
||||
setState(() => _hover = hover);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return MouseRegion(
|
||||
onEnter: (_) => _toggleHover(true),
|
||||
onExit: (_) => _toggleHover(false),
|
||||
child: widget.builder != null ? widget.builder(context, _hover) : null,
|
||||
);
|
||||
}
|
||||
}
|
|
@ -420,9 +420,7 @@ class _ChatListState extends State<ChatList> {
|
|||
),
|
||||
),
|
||||
),
|
||||
floatingActionButton:
|
||||
(AdaptivePageLayout.columnMode(context) ||
|
||||
selectMode != SelectMode.normal)
|
||||
floatingActionButton: AdaptivePageLayout.columnMode(context)
|
||||
? null
|
||||
: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
|
@ -441,8 +439,7 @@ class _ChatListState extends State<ChatList> {
|
|||
SizedBox(height: 16.0),
|
||||
FloatingActionButton(
|
||||
child: Icon(Icons.add),
|
||||
backgroundColor:
|
||||
Theme.of(context).primaryColor,
|
||||
backgroundColor: Theme.of(context).primaryColor,
|
||||
onPressed: () => Navigator.of(context)
|
||||
.pushAndRemoveUntil(
|
||||
AppRoute.defaultRoute(
|
||||
|
@ -532,11 +529,7 @@ class _ChatListState extends State<ChatList> {
|
|||
(BuildContext context, int i) {
|
||||
if (i == 0) {
|
||||
final displayPresences =
|
||||
Matrix.of(context)
|
||||
.userStatuses
|
||||
.isNotEmpty &&
|
||||
selectMode ==
|
||||
SelectMode.normal;
|
||||
selectMode != SelectMode.share;
|
||||
final displayShareStatus =
|
||||
selectMode ==
|
||||
SelectMode.share &&
|
||||
|
|
11
pubspec.lock
11
pubspec.lock
|
@ -99,6 +99,13 @@ packages:
|
|||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.2.0-nullsafety.1"
|
||||
circular_check_box:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: circular_check_box
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.0.4"
|
||||
cli_util:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
@ -526,7 +533,7 @@ packages:
|
|||
name: meta
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.3.0-nullsafety.3"
|
||||
version: "1.3.0-nullsafety.4"
|
||||
mime:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
@ -862,7 +869,7 @@ packages:
|
|||
name: stack_trace
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.10.0-nullsafety.1"
|
||||
version: "1.10.0-nullsafety.2"
|
||||
stream_channel:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
|
|
@ -60,6 +60,7 @@ dependencies:
|
|||
flutter_olm: ^1.0.1
|
||||
intl: ^0.16.1
|
||||
intl_translation: ^0.17.9
|
||||
circular_check_box: ^1.0.4
|
||||
flutter_localizations:
|
||||
sdk: flutter
|
||||
sqflite: ^1.1.7 # Still used to obtain the database location
|
||||
|
|
Loading…
Reference in a new issue