⚗️ Experimental user first badge showing on chat
This commit is contained in:
parent
d11069a2be
commit
f746e06f65
@ -10,6 +10,7 @@ class AccountImage extends StatelessWidget {
|
|||||||
final Color? foregroundColor;
|
final Color? foregroundColor;
|
||||||
final double? radius;
|
final double? radius;
|
||||||
final Widget? fallbackWidget;
|
final Widget? fallbackWidget;
|
||||||
|
final Widget? badge;
|
||||||
|
|
||||||
const AccountImage({
|
const AccountImage({
|
||||||
super.key,
|
super.key,
|
||||||
@ -18,6 +19,7 @@ class AccountImage extends StatelessWidget {
|
|||||||
this.foregroundColor,
|
this.foregroundColor,
|
||||||
this.radius,
|
this.radius,
|
||||||
this.fallbackWidget,
|
this.fallbackWidget,
|
||||||
|
this.badge,
|
||||||
});
|
});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -26,26 +28,36 @@ class AccountImage extends StatelessWidget {
|
|||||||
final url = sn.getAttachmentUrl(content ?? '');
|
final url = sn.getAttachmentUrl(content ?? '');
|
||||||
|
|
||||||
final devicePixelRatio = MediaQuery.of(context).devicePixelRatio;
|
final devicePixelRatio = MediaQuery.of(context).devicePixelRatio;
|
||||||
return CircleAvatar(
|
return Stack(
|
||||||
key: Key('attachment-${content.hashCode}'),
|
children: [
|
||||||
radius: radius,
|
CircleAvatar(
|
||||||
backgroundColor: backgroundColor,
|
key: Key('attachment-${content.hashCode}'),
|
||||||
backgroundImage: (content?.isNotEmpty ?? false)
|
radius: radius,
|
||||||
? ResizeImage(
|
backgroundColor: backgroundColor,
|
||||||
UniversalImage.provider(url),
|
backgroundImage: (content?.isNotEmpty ?? false)
|
||||||
width: ((radius ?? 20) * devicePixelRatio * 2).round(),
|
? ResizeImage(
|
||||||
height: ((radius ?? 20) * devicePixelRatio * 2).round(),
|
UniversalImage.provider(url),
|
||||||
policy: ResizeImagePolicy.fit,
|
width: ((radius ?? 20) * devicePixelRatio * 2).round(),
|
||||||
)
|
height: ((radius ?? 20) * devicePixelRatio * 2).round(),
|
||||||
: null,
|
policy: ResizeImagePolicy.fit,
|
||||||
child: (content?.isEmpty ?? true)
|
)
|
||||||
? (fallbackWidget ??
|
: null,
|
||||||
Icon(
|
child: (content?.isEmpty ?? true)
|
||||||
Symbols.account_circle,
|
? (fallbackWidget ??
|
||||||
size: radius != null ? radius! * 1.2 : 24,
|
Icon(
|
||||||
color: foregroundColor,
|
Symbols.account_circle,
|
||||||
))
|
size: radius != null ? radius! * 1.2 : 24,
|
||||||
: null,
|
color: foregroundColor,
|
||||||
|
))
|
||||||
|
: null,
|
||||||
|
),
|
||||||
|
if (badge != null)
|
||||||
|
Positioned(
|
||||||
|
right: -4,
|
||||||
|
bottom: -4,
|
||||||
|
child: badge!,
|
||||||
|
),
|
||||||
|
],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,6 +11,7 @@ import 'package:styled_widget/styled_widget.dart';
|
|||||||
import 'package:surface/providers/config.dart';
|
import 'package:surface/providers/config.dart';
|
||||||
import 'package:surface/providers/user_directory.dart';
|
import 'package:surface/providers/user_directory.dart';
|
||||||
import 'package:surface/providers/userinfo.dart';
|
import 'package:surface/providers/userinfo.dart';
|
||||||
|
import 'package:surface/screens/account/profile_page.dart';
|
||||||
import 'package:surface/types/chat.dart';
|
import 'package:surface/types/chat.dart';
|
||||||
import 'package:surface/widgets/account/account_image.dart';
|
import 'package:surface/widgets/account/account_image.dart';
|
||||||
import 'package:surface/widgets/account/account_popover.dart';
|
import 'package:surface/widgets/account/account_popover.dart';
|
||||||
@ -105,6 +106,22 @@ class ChatMessage extends StatelessWidget {
|
|||||||
GestureDetector(
|
GestureDetector(
|
||||||
child: AccountImage(
|
child: AccountImage(
|
||||||
content: user?.avatar,
|
content: user?.avatar,
|
||||||
|
badge: (user?.badges.isNotEmpty ?? false)
|
||||||
|
? Icon(
|
||||||
|
kBadgesMeta[user!.badges.first.type]?.$2 ??
|
||||||
|
Symbols.question_mark,
|
||||||
|
color: kBadgesMeta[user!.badges.first.type]?.$3,
|
||||||
|
fill: 1,
|
||||||
|
size: 18,
|
||||||
|
shadows: [
|
||||||
|
Shadow(
|
||||||
|
offset: Offset(1, 1),
|
||||||
|
blurRadius: 5.0,
|
||||||
|
color: Color.fromARGB(150, 0, 0, 0),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
)
|
||||||
|
: null,
|
||||||
),
|
),
|
||||||
onTap: () {
|
onTap: () {
|
||||||
if (user == null) return;
|
if (user == null) return;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user