✨ Able to render fediverse posts
This commit is contained in:
58
lib/widgets/activitypub/actor_profile.dart
Normal file
58
lib/widgets/activitypub/actor_profile.dart
Normal file
@@ -0,0 +1,58 @@
|
||||
import 'package:cached_network_image/cached_network_image.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:island/models/activitypub.dart';
|
||||
import 'package:material_symbols_icons/symbols.dart';
|
||||
|
||||
class ActorAvatarWidget extends StatelessWidget {
|
||||
final SnActivityPubActor actor;
|
||||
final double radius;
|
||||
|
||||
const ActorAvatarWidget({super.key, required this.actor, this.radius = 16});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final avatarUrl = actor.avatarUrl;
|
||||
if (avatarUrl == null) {
|
||||
return CircleAvatar(
|
||||
radius: radius,
|
||||
backgroundColor: Theme.of(context).colorScheme.surfaceContainer,
|
||||
child: Icon(
|
||||
Symbols.person,
|
||||
color: Theme.of(context).colorScheme.onSurfaceVariant,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
return Stack(
|
||||
children: [
|
||||
CircleAvatar(
|
||||
backgroundImage: CachedNetworkImageProvider(avatarUrl),
|
||||
radius: radius,
|
||||
backgroundColor: Theme.of(context).colorScheme.surfaceContainer,
|
||||
child: Icon(
|
||||
Symbols.person,
|
||||
color: Theme.of(context).colorScheme.onSurfaceVariant,
|
||||
),
|
||||
),
|
||||
Positioned(
|
||||
right: 0,
|
||||
bottom: 0,
|
||||
child: CircleAvatar(
|
||||
backgroundImage: actor.instance.iconUrl != null
|
||||
? CachedNetworkImageProvider(actor.instance.iconUrl!)
|
||||
: null,
|
||||
radius: radius * 0.4,
|
||||
backgroundColor: Theme.of(context).colorScheme.primary,
|
||||
child: actor.instance.iconUrl == null
|
||||
? Icon(
|
||||
Symbols.public,
|
||||
size: radius * 0.6,
|
||||
color: Theme.of(context).colorScheme.onPrimary,
|
||||
)
|
||||
: null,
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user