Files
zapstore/lib/widgets/common/stack_link_card.dart
T

112 lines
3.8 KiB
Dart

import 'package:flutter/material.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';
import 'package:models/models.dart';
import 'package:zapstore/utils/extensions.dart';
import 'package:zapstore/utils/nostr_route.dart';
/// Shared stack link card used in profile and user screens.
/// Shows stack name, app count badge, and padlock icon for private stacks.
class StackLinkCard extends ConsumerWidget {
const StackLinkCard({super.key, required this.stack, this.displayName});
final AppStack stack;
final String? displayName;
bool get _isEncrypted => stack.content.isNotEmpty;
@override
Widget build(BuildContext context, WidgetRef ref) {
final appCount = _isEncrypted
? (stack.isDecrypted ? stack.privateAppIds.length : null)
: stack.event
.getTagSetValues('a')
.where((id) => id.startsWith('32267:'))
.length;
final title = displayName ?? stack.name ?? stack.identifier;
return Padding(
padding: const EdgeInsets.fromLTRB(16, 0, 16, 0),
child: InkWell(
onTap: () => pushStack(
context,
stack.identifier,
author: stack.pubkey,
kind: stack.event.kind,
),
borderRadius: BorderRadius.circular(12),
child: Container(
width: double.infinity,
padding: const EdgeInsets.all(16),
decoration: BoxDecoration(
color: Theme.of(context).colorScheme.surfaceContainerHighest,
borderRadius: BorderRadius.circular(12),
border: Border.all(
color: Theme.of(
context,
).colorScheme.outline.withValues(alpha: 0.2),
),
),
child: Row(
children: [
Expanded(
child: Row(
children: [
Flexible(
child: Text(
title,
style: context.textTheme.titleMedium?.copyWith(
fontWeight: FontWeight.w600,
),
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
),
if (_isEncrypted) ...[
const SizedBox(width: 6),
Icon(
Icons.lock,
size: 16,
color: Theme.of(context).colorScheme.onSurfaceVariant,
),
],
if (appCount != null && appCount > 0) ...[
const SizedBox(width: 8),
Container(
padding: const EdgeInsets.symmetric(
horizontal: 8,
vertical: 4,
),
decoration: BoxDecoration(
color: Theme.of(
context,
).colorScheme.surfaceContainerHigh,
borderRadius: BorderRadius.circular(12),
),
child: Text(
'$appCount',
style: context.textTheme.labelSmall?.copyWith(
color: Theme.of(
context,
).colorScheme.onSurfaceVariant,
fontWeight: FontWeight.w600,
),
),
),
],
],
),
),
const SizedBox(width: 12),
Icon(
Icons.chevron_right,
color: Theme.of(context).colorScheme.onSurfaceVariant,
),
],
),
),
),
);
}
}