This repository has been archived by the owner on Sep 9, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Craftplacer
committed
May 23, 2023
1 parent
ddbd432
commit 82d64e2
Showing
3 changed files
with
120 additions
and
123 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
import "package:flutter/material.dart"; | ||
import "package:kaiteki/di.dart"; | ||
import "package:kaiteki/fediverse/model/user/user.dart"; | ||
import "package:kaiteki/utils/extensions.dart"; | ||
|
||
class UserCard extends ConsumerWidget { | ||
/// The user to display. If null, a placeholder will be displayed. | ||
final User? user; | ||
|
||
final List<Widget> actions; | ||
|
||
const UserCard(this.user, {super.key, this.actions = const []}); | ||
|
||
@override | ||
Widget build(BuildContext context, WidgetRef ref) { | ||
final handleTextStyle = Theme.of(context).textTheme.bodyMedium?.copyWith( | ||
color: Theme.of(context).colorScheme.onSurfaceVariant, | ||
); | ||
final displayNameTextStyle = | ||
Theme.of(context).textTheme.bodyLarge?.copyWith( | ||
color: Theme.of(context).colorScheme.onSurface, | ||
); | ||
return Card( | ||
child: Column( | ||
crossAxisAlignment: CrossAxisAlignment.stretch, | ||
children: [ | ||
ClipRRect( | ||
borderRadius: BorderRadius.circular(12.0), | ||
child: AspectRatio( | ||
aspectRatio: 16 / 9, | ||
child: user?.bannerUrl.nullTransform( | ||
(url) => Image.network( | ||
url.toString(), | ||
fit: BoxFit.cover, | ||
), | ||
), | ||
), | ||
), | ||
Padding( | ||
padding: const EdgeInsets.all(16.0), | ||
child: Column( | ||
crossAxisAlignment: CrossAxisAlignment.stretch, | ||
children: [ | ||
Row( | ||
children: [ | ||
Expanded( | ||
child: Column( | ||
crossAxisAlignment: CrossAxisAlignment.start, | ||
children: [ | ||
Text.rich( | ||
user?.renderDisplayName(context, ref) ?? | ||
const TextSpan(text: "..."), | ||
maxLines: 1, | ||
overflow: TextOverflow.fade, | ||
softWrap: false, | ||
style: displayNameTextStyle, | ||
), | ||
Text( | ||
user?.handle.toString() ?? "...", | ||
maxLines: 1, | ||
overflow: TextOverflow.ellipsis, | ||
softWrap: false, | ||
style: handleTextStyle, | ||
), | ||
], | ||
), | ||
), | ||
...actions, | ||
], | ||
), | ||
const SizedBox(height: 8), | ||
if (user?.description != null) | ||
Text.rich( | ||
user?.renderDescription(context, ref) ?? | ||
const TextSpan( | ||
text: "...", | ||
), | ||
overflow: TextOverflow.ellipsis, | ||
maxLines: 2, | ||
), | ||
], | ||
), | ||
), | ||
], | ||
), | ||
); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters