💫 Animated profile card

This commit is contained in:
2026-01-07 01:43:46 +08:00
parent 910dafaa43
commit 1b6ccccf32
2 changed files with 190 additions and 192 deletions

View File

@@ -27,16 +27,12 @@ class AccountProfileCard extends HookConsumerWidget {
@override @override
Widget build(BuildContext context, WidgetRef ref) { Widget build(BuildContext context, WidgetRef ref) {
final account = ref.watch(accountProvider(uname)); final account = ref.watch(accountProvider(uname));
final width = final width = math
math.min(MediaQuery.of(context).size.width - 80, 360).toDouble(); .min(MediaQuery.of(context).size.width - 80, 360)
return PopupCard( .toDouble();
elevation: 8,
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12.0)), final child = account.when(
child: SizedBox( data: (data) => Column(
width: width,
child: account.when(
data:
(data) => Column(
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.stretch, crossAxisAlignment: CrossAxisAlignment.stretch,
children: [ children: [
@@ -64,12 +60,9 @@ class AccountProfileCard extends HookConsumerWidget {
size: 12, size: 12,
color: Theme.of(context).colorScheme.onPrimary, color: Theme.of(context).colorScheme.onPrimary,
), ),
backgroundColor: backgroundColor: Theme.of(context).colorScheme.primary,
Theme.of(context).colorScheme.primary,
offset: Offset(4, 28), offset: Offset(4, 28),
child: ProfilePictureWidget( child: ProfilePictureWidget(file: data.profile.picture),
file: data.profile.picture,
),
), ),
onTap: () { onTap: () {
Navigator.pop(context); Navigator.pop(context);
@@ -95,10 +88,7 @@ class AccountProfileCard extends HookConsumerWidget {
], ],
), ),
const Gap(12), const Gap(12),
AccountStatusWidget( AccountStatusWidget(uname: data.name, padding: EdgeInsets.zero),
uname: data.name,
padding: EdgeInsets.zero,
),
Tooltip( Tooltip(
message: 'creditsStatus'.tr(), message: 'creditsStatus'.tr(),
child: Row( child: Row(
@@ -149,9 +139,7 @@ class AccountProfileCard extends HookConsumerWidget {
Text( Text(
tzInfo.$2.formatCustomGlobal('HH:mm'), tzInfo.$2.formatCustomGlobal('HH:mm'),
).fontSize(12), ).fontSize(12),
Text( Text(tzInfo.$1.formatOffsetLocal()).fontSize(12),
tzInfo.$1.formatOffsetLocal(),
).fontSize(12),
], ],
).padding(top: 2); ).padding(top: 2);
} catch (e) { } catch (e) {
@@ -171,11 +159,7 @@ class AccountProfileCard extends HookConsumerWidget {
Row( Row(
spacing: 6, spacing: 6,
children: [ children: [
Icon( Icon(Symbols.stairs, size: 17, fill: 1).padding(right: 2),
Symbols.stairs,
size: 17,
fill: 1,
).padding(right: 2),
Text( Text(
'levelingProgressLevel'.tr( 'levelingProgressLevel'.tr(
args: [data.profile.level.toString()], args: [data.profile.level.toString()],
@@ -206,21 +190,35 @@ class AccountProfileCard extends HookConsumerWidget {
).padding(horizontal: 24, vertical: 16), ).padding(horizontal: 24, vertical: 16),
], ],
), ),
error: error: (err, _) => ResponseErrorWidget(
(err, _) => ResponseErrorWidget(
error: err, error: err,
onRetry: () => ref.invalidate(accountProvider(uname)), onRetry: () => ref.invalidate(accountProvider(uname)),
), ),
loading: loading: () => SizedBox(
() => SizedBox(
width: width, width: width,
height: width, height: width,
child: child: Padding(
Padding(
padding: const EdgeInsets.all(24), padding: const EdgeInsets.all(24),
child: CircularProgressIndicator(), child: CircularProgressIndicator(),
).center(), ).center(),
), ),
);
return PopupCard(
elevation: 8,
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12.0)),
child: AnimatedSize(
duration: const Duration(milliseconds: 200),
curve: Curves.easeInOut,
child: SizedBox(
width: width,
child: AnimatedSwitcher(
duration: const Duration(milliseconds: 200),
transitionBuilder: (Widget child, Animation<double> animation) {
return FadeTransition(opacity: animation, child: child);
},
child: child,
),
), ),
), ),
); );

View File

@@ -422,7 +422,7 @@ class _MentionChipContent extends HookConsumerWidget {
isHovered, isHovered,
); );
}, },
error: (_, __) => Text( error: (_, _) => Text(
alias, alias,
style: TextStyle( style: TextStyle(
color: backgroundColor, color: backgroundColor,