Improved design
This commit is contained in:
parent
6ab3874bca
commit
2b312ff74d
|
@ -1,5 +1,6 @@
|
||||||
import 'package:cached_network_image/cached_network_image.dart';
|
import 'package:cached_network_image/cached_network_image.dart';
|
||||||
import 'package:famedlysdk/famedlysdk.dart';
|
import 'package:famedlysdk/famedlysdk.dart';
|
||||||
|
import 'package:fluffychat/utils/string_color.dart';
|
||||||
import 'package:flutter/foundation.dart';
|
import 'package:flutter/foundation.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
@ -7,10 +8,11 @@ import 'matrix.dart';
|
||||||
|
|
||||||
class Avatar extends StatelessWidget {
|
class Avatar extends StatelessWidget {
|
||||||
final MxContent mxContent;
|
final MxContent mxContent;
|
||||||
|
final String name;
|
||||||
final double size;
|
final double size;
|
||||||
final Function onTap;
|
final Function onTap;
|
||||||
|
|
||||||
const Avatar(this.mxContent, {this.size = 40, this.onTap, Key key})
|
const Avatar(this.mxContent, this.name, {this.size = 40, this.onTap, Key key})
|
||||||
: super(key: key);
|
: super(key: key);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
@ -21,6 +23,12 @@ class Avatar extends StatelessWidget {
|
||||||
height: size * MediaQuery.of(context).devicePixelRatio,
|
height: size * MediaQuery.of(context).devicePixelRatio,
|
||||||
method: ThumbnailMethod.scale,
|
method: ThumbnailMethod.scale,
|
||||||
);
|
);
|
||||||
|
String fallbackLetters = "@";
|
||||||
|
if ((name?.length ?? 0) >= 2) {
|
||||||
|
fallbackLetters = name.substring(0, 2);
|
||||||
|
} else if ((name?.length ?? 0) == 1) {
|
||||||
|
fallbackLetters = name;
|
||||||
|
}
|
||||||
return InkWell(
|
return InkWell(
|
||||||
onTap: onTap,
|
onTap: onTap,
|
||||||
child: CircleAvatar(
|
child: CircleAvatar(
|
||||||
|
@ -34,9 +42,9 @@ class Avatar extends StatelessWidget {
|
||||||
src,
|
src,
|
||||||
)
|
)
|
||||||
: null,
|
: null,
|
||||||
backgroundColor: Theme.of(context).secondaryHeaderColor,
|
backgroundColor: name?.color ?? Theme.of(context).secondaryHeaderColor,
|
||||||
child: mxContent.mxc.isEmpty
|
child: mxContent.mxc.isEmpty
|
||||||
? Text("@", style: TextStyle(color: Colors.blueGrey))
|
? Text(fallbackLetters, style: TextStyle(color: Colors.white))
|
||||||
: null,
|
: null,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
|
@ -86,7 +86,7 @@ class ChatListItem extends StatelessWidget {
|
||||||
return Material(
|
return Material(
|
||||||
color: activeChat ? Color(0xFFE8E8E8) : Colors.white,
|
color: activeChat ? Color(0xFFE8E8E8) : Colors.white,
|
||||||
child: ListTile(
|
child: ListTile(
|
||||||
leading: Avatar(room.avatar),
|
leading: Avatar(room.avatar, room.displayname),
|
||||||
title: Row(
|
title: Row(
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
Expanded(
|
Expanded(
|
||||||
|
|
|
@ -4,6 +4,7 @@ import 'package:fluffychat/components/dialogs/redact_message_dialog.dart';
|
||||||
import 'package:fluffychat/components/message_content.dart';
|
import 'package:fluffychat/components/message_content.dart';
|
||||||
import 'package:fluffychat/utils/app_route.dart';
|
import 'package:fluffychat/utils/app_route.dart';
|
||||||
import 'package:fluffychat/utils/date_time_extension.dart';
|
import 'package:fluffychat/utils/date_time_extension.dart';
|
||||||
|
import 'package:fluffychat/utils/string_color.dart';
|
||||||
import 'package:fluffychat/views/content_web_view.dart';
|
import 'package:fluffychat/views/content_web_view.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
|
@ -144,7 +145,7 @@ class Message extends StatelessWidget {
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
color: ownMessage
|
color: ownMessage
|
||||||
? textColor
|
? textColor
|
||||||
: Theme.of(context).primaryColor,
|
: event.sender.calcDisplayname().color,
|
||||||
fontWeight: FontWeight.bold,
|
fontWeight: FontWeight.bold,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
@ -172,6 +173,7 @@ class Message extends StatelessWidget {
|
||||||
? SizedBox(width: 40)
|
? SizedBox(width: 40)
|
||||||
: Avatar(
|
: Avatar(
|
||||||
event.sender.avatarUrl,
|
event.sender.avatarUrl,
|
||||||
|
event.sender.calcDisplayname(),
|
||||||
onTap: () => Navigator.of(context).push(
|
onTap: () => Navigator.of(context).push(
|
||||||
AppRoute.defaultRoute(
|
AppRoute.defaultRoute(
|
||||||
context,
|
context,
|
||||||
|
@ -187,7 +189,7 @@ class Message extends StatelessWidget {
|
||||||
|
|
||||||
return Padding(
|
return Padding(
|
||||||
padding: EdgeInsets.only(
|
padding: EdgeInsets.only(
|
||||||
left: 8.0, right: 8.0, bottom: sameSender ? 4.0 : 12.0),
|
left: 8.0, right: 8.0, bottom: sameSender ? 4.0 : 8.0),
|
||||||
child: Row(
|
child: Row(
|
||||||
crossAxisAlignment: CrossAxisAlignment.end,
|
crossAxisAlignment: CrossAxisAlignment.end,
|
||||||
mainAxisAlignment: rowMainAxisAlignment,
|
mainAxisAlignment: rowMainAxisAlignment,
|
||||||
|
|
|
@ -117,7 +117,7 @@ class ParticipantListItem extends StatelessWidget {
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
subtitle: Text(user.id),
|
subtitle: Text(user.id),
|
||||||
leading: Avatar(user.avatarUrl),
|
leading: Avatar(user.avatarUrl, user.calcDisplayname()),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,11 @@ class StateMessage extends StatelessWidget {
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
if (event.type == EventTypes.Redaction) return Container();
|
if (event.type == EventTypes.Redaction) return Container();
|
||||||
return Padding(
|
return Padding(
|
||||||
padding: const EdgeInsets.all(8.0),
|
padding: const EdgeInsets.only(
|
||||||
|
left: 8.0,
|
||||||
|
right: 8.0,
|
||||||
|
bottom: 8.0,
|
||||||
|
),
|
||||||
child: Opacity(
|
child: Opacity(
|
||||||
opacity: 0.5,
|
opacity: 0.5,
|
||||||
child: Bubble(
|
child: Bubble(
|
||||||
|
|
13
lib/utils/string_color.dart
Normal file
13
lib/utils/string_color.dart
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
extension StringColor on String {
|
||||||
|
Color get color {
|
||||||
|
double number = 0.0;
|
||||||
|
for (var i = 0; i < this.length; i++) {
|
||||||
|
number += this.codeUnitAt(i);
|
||||||
|
}
|
||||||
|
number = (number % 10) * 25.5;
|
||||||
|
print(number);
|
||||||
|
return HSLColor.fromAHSL(1, number, 1, 0.35).toColor();
|
||||||
|
}
|
||||||
|
}
|
|
@ -214,12 +214,18 @@ class _ChatDetailsState extends State<ChatDetails> {
|
||||||
: Container(),
|
: Container(),
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
: i < members.length + 1
|
: i < members.length + 1 && false
|
||||||
? ParticipantListItem(members[i - 1])
|
? ParticipantListItem(members[i - 1])
|
||||||
: ListTile(
|
: ListTile(
|
||||||
title: Text(
|
title: Text(
|
||||||
"Load more ${actualMembersCount - members.length} participants"),
|
"Load more ${actualMembersCount - members.length} participants"),
|
||||||
leading: Icon(Icons.refresh),
|
leading: CircleAvatar(
|
||||||
|
backgroundColor: Colors.white,
|
||||||
|
child: Icon(
|
||||||
|
Icons.refresh,
|
||||||
|
color: Colors.grey,
|
||||||
|
),
|
||||||
|
),
|
||||||
onTap: () => requestMoreMembersAction(context),
|
onTap: () => requestMoreMembersAction(context),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
|
@ -68,7 +68,10 @@ class InvitationSelection extends StatelessWidget {
|
||||||
return ListView.builder(
|
return ListView.builder(
|
||||||
itemCount: contacts.length,
|
itemCount: contacts.length,
|
||||||
itemBuilder: (BuildContext context, int i) => ListTile(
|
itemBuilder: (BuildContext context, int i) => ListTile(
|
||||||
leading: Avatar(contacts[i].avatarUrl),
|
leading: Avatar(
|
||||||
|
contacts[i].avatarUrl,
|
||||||
|
contacts[i].calcDisplayname(),
|
||||||
|
),
|
||||||
title: Text(contacts[i].calcDisplayname()),
|
title: Text(contacts[i].calcDisplayname()),
|
||||||
subtitle: Text(contacts[i].id),
|
subtitle: Text(contacts[i].id),
|
||||||
onTap: () => inviteAction(context, contacts[i].id),
|
onTap: () => inviteAction(context, contacts[i].id),
|
||||||
|
|
Loading…
Reference in a new issue