chore: Improve avatar designg

Signed-off-by: Krille <c.kussowski@famedly.com>
pull/1754/head
Krille 5 months ago
parent 782d0577a2
commit e0525940ba
No known key found for this signature in database
GPG Key ID: E067ECD60F1A0652

@ -1,15 +1,14 @@
import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/l10n.dart';
import 'package:matrix/matrix.dart';
import 'package:fluffychat/config/app_config.dart';
import 'package:fluffychat/utils/date_time_extension.dart';
import 'package:fluffychat/utils/matrix_sdk_extensions/matrix_locals.dart';
import 'package:fluffychat/widgets/avatar.dart';
import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/l10n.dart';
import 'package:matrix/matrix.dart';
class RoomCreationStateEvent extends StatelessWidget {
final Event event;
const RoomCreationStateEvent({required this.event, super.key});
@override
@ -21,28 +20,32 @@ class RoomCreationStateEvent extends StatelessWidget {
return Padding(
padding: const EdgeInsets.only(bottom: 32.0),
child: Center(
child: Material(
color: theme.colorScheme.surface.withAlpha(128),
borderRadius: BorderRadius.circular(AppConfig.borderRadius),
child: Padding(
padding: const EdgeInsets.all(16.0),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Avatar(
mxContent: event.room.avatar,
name: roomName,
size: Avatar.defaultSize * 2,
),
Text(
roomName,
style: theme.textTheme.headlineSmall,
),
Text(
'${event.originServerTs.localizedTime(context)} | ${l10n.countParticipants((event.room.summary.mJoinedMemberCount ?? 1) + (event.room.summary.mInvitedMemberCount ?? 0))}',
style: theme.textTheme.labelSmall,
),
],
child: ConstrainedBox(
constraints: const BoxConstraints(maxWidth: 256),
child: Material(
color: theme.colorScheme.surfaceContainer,
borderRadius: BorderRadius.circular(AppConfig.borderRadius),
child: Padding(
padding: const EdgeInsets.all(16.0),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Avatar(
mxContent: event.room.avatar,
name: roomName,
size: Avatar.defaultSize * 2,
),
Text(
roomName,
style: theme.textTheme.bodyLarge,
),
const SizedBox(height: 8),
Text(
'${event.originServerTs.localizedTime(context)} | ${l10n.countParticipants((event.room.summary.mJoinedMemberCount ?? 1) + (event.room.summary.mInvitedMemberCount ?? 0))}',
style: theme.textTheme.labelSmall,
),
],
),
),
),
),

@ -1,10 +1,8 @@
import 'package:flutter/material.dart';
import 'package:matrix/matrix.dart';
import 'package:fluffychat/utils/string_color.dart';
import 'package:fluffychat/widgets/mxc_image.dart';
import 'package:fluffychat/widgets/presence_builder.dart';
import 'package:flutter/material.dart';
import 'package:matrix/matrix.dart';
class Avatar extends StatelessWidget {
final Uri? mxContent;
@ -37,31 +35,13 @@ class Avatar extends StatelessWidget {
Widget build(BuildContext context) {
final theme = Theme.of(context);
var fallbackLetters = '@';
final name = this.name;
if (name != null) {
if (name.runes.length >= 2) {
fallbackLetters = String.fromCharCodes(name.runes, 0, 2);
} else if (name.runes.length == 1) {
fallbackLetters = name;
}
}
final fallbackLetters =
name == null || name.isEmpty ? '@' : name.substring(0, 1);
final noPic = mxContent == null ||
mxContent.toString().isEmpty ||
mxContent.toString() == 'null';
final textColor = name?.lightColorAvatar;
final textWidget = Container(
color: textColor,
alignment: Alignment.center,
child: Text(
fallbackLetters,
style: TextStyle(
color: Colors.white,
fontWeight: FontWeight.bold,
fontSize: (size / 3).roundToDouble(),
),
),
);
final borderRadius = this.borderRadius ?? BorderRadius.circular(size / 2);
final presenceUserId = this.presenceUserId;
final container = Stack(
@ -79,7 +59,25 @@ class Avatar extends StatelessWidget {
),
clipBehavior: Clip.hardEdge,
child: noPic
? textWidget
? Container(
decoration: BoxDecoration(
gradient: LinearGradient(
colors: [name!.lightColorAvatar, name.color],
begin: Alignment.topLeft,
end: Alignment.bottomRight,
),
),
alignment: Alignment.center,
child: Text(
fallbackLetters,
textAlign: TextAlign.center,
style: TextStyle(
color: Colors.white,
fontWeight: FontWeight.bold,
fontSize: (size / 2.5).roundToDouble(),
),
),
)
: MxcImage(
client: client,
key: ValueKey(mxContent.toString()),

Loading…
Cancel
Save