design: Nicer selected mark on chatlists

This commit is contained in:
Christian Pauly 2021-07-31 20:28:21 +02:00
parent 1a23e5fa23
commit 42f64393c8
2 changed files with 11 additions and 43 deletions

View File

@ -17,7 +17,6 @@ import '../avatar.dart';
import '../../pages/send_file_dialog.dart';
import 'package:future_loading_dialog/future_loading_dialog.dart';
import '../matrix.dart';
import '../mouse_over_builder.dart';
enum ArchivedRoomAction { delete, rejoin }
@ -152,20 +151,17 @@ class ChatListItem extends StatelessWidget {
color: FluffyThemes.chatListItemColor(context, activeChat, selected),
child: ListTile(
onLongPress: onLongPress,
leading: MouseOverBuilder(
builder: (context, hover) =>
onLongPress != null && (hover || selected)
? Container(
width: Avatar.defaultSize,
height: Avatar.defaultSize,
alignment: Alignment.center,
child: Checkbox(
value: selected,
onChanged: (_) => onLongPress(),
),
)
: Avatar(room.avatar, room.displayname),
),
leading: selected
? Container(
width: Avatar.defaultSize,
height: Avatar.defaultSize,
child: Material(
color: Theme.of(context).primaryColor,
borderRadius: BorderRadius.circular(Avatar.defaultSize),
child: Icon(Icons.check, color: Colors.white),
),
)
: Avatar(room.avatar, room.displayname, onTap: onLongPress),
title: Row(
children: <Widget>[
Expanded(

View File

@ -1,28 +0,0 @@
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,
);
}
}