131 lines
4.2 KiB
Dart
131 lines
4.2 KiB
Dart
import 'package:flutter/material.dart';
|
|
import '../../core/theme/app_colors.dart';
|
|
import '../../l10n/app_strings.dart';
|
|
import 'pred_card.dart';
|
|
|
|
/// Shared with [WalletOverviewScreen] so Home and Wallet stay in sync.
|
|
const kHideBalancePrefsKey = 'wallet_hide_balance';
|
|
|
|
/// Compact available-balance strip for Home (privacy-aware).
|
|
class BalanceHeroCard extends StatelessWidget {
|
|
const BalanceHeroCard({
|
|
super.key,
|
|
required this.amountLabel,
|
|
required this.obscured,
|
|
required this.onVisibilityToggle,
|
|
});
|
|
|
|
/// Visible amount text, or a masked placeholder when [obscured].
|
|
final String amountLabel;
|
|
final bool obscured;
|
|
final VoidCallback onVisibilityToggle;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final s = context.strings;
|
|
final isDark = Theme.of(context).brightness == Brightness.dark;
|
|
return Container(
|
|
key: const Key('home_balance_hero'),
|
|
width: double.infinity,
|
|
padding: const EdgeInsets.fromLTRB(14, 12, 6, 12),
|
|
decoration: BoxDecoration(
|
|
gradient: AppColors.heroGradient(isDark),
|
|
borderRadius: BorderRadius.circular(16),
|
|
border: Border.all(color: AppColors.primary.withValues(alpha: 0.25)),
|
|
),
|
|
child: Row(
|
|
children: [
|
|
Expanded(
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Text(
|
|
s.availableBalance,
|
|
style: Theme.of(context).textTheme.labelMedium?.copyWith(
|
|
color: isDark
|
|
? AppColors.textSecondary
|
|
: const Color(0xFF475569),
|
|
fontWeight: FontWeight.w600,
|
|
),
|
|
),
|
|
const SizedBox(height: 4),
|
|
Text(
|
|
amountLabel,
|
|
maxLines: 1,
|
|
overflow: TextOverflow.ellipsis,
|
|
style: Theme.of(context).textTheme.titleLarge?.copyWith(
|
|
fontWeight: FontWeight.w900,
|
|
letterSpacing: obscured ? 2 : 0,
|
|
color: isDark
|
|
? AppColors.textPrimary
|
|
: const Color(0xFF0F172A),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
IconButton(
|
|
key: const Key('home_balance_visibility'),
|
|
tooltip: obscured ? s.showBalance : s.hideBalance,
|
|
onPressed: onVisibilityToggle,
|
|
icon: Icon(
|
|
obscured
|
|
? Icons.visibility_outlined
|
|
: Icons.visibility_off_outlined,
|
|
color: isDark ? AppColors.textSecondary : const Color(0xFF64748B),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
}
|
|
|
|
class QuickActionGrid extends StatelessWidget {
|
|
const QuickActionGrid({super.key, required this.actions});
|
|
|
|
final List<QuickAction> actions;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Row(
|
|
children: actions.map((a) {
|
|
return Expanded(
|
|
child: Padding(
|
|
padding: EdgeInsets.only(right: a == actions.last ? 0 : 10),
|
|
child: PredCard(
|
|
padding: const EdgeInsets.symmetric(vertical: 18, horizontal: 12),
|
|
onTap: a.onTap,
|
|
child: Column(
|
|
children: [
|
|
Container(
|
|
padding: const EdgeInsets.all(10),
|
|
decoration: BoxDecoration(
|
|
color: AppColors.primary.withValues(alpha: 0.12),
|
|
borderRadius: BorderRadius.circular(14),
|
|
),
|
|
child: Icon(a.icon, color: AppColors.primary),
|
|
),
|
|
const SizedBox(height: 10),
|
|
Text(
|
|
a.label,
|
|
textAlign: TextAlign.center,
|
|
style: Theme.of(context).textTheme.labelLarge,
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}).toList(),
|
|
);
|
|
}
|
|
}
|
|
|
|
class QuickAction {
|
|
const QuickAction({required this.icon, required this.label, required this.onTap});
|
|
final IconData icon;
|
|
final String label;
|
|
final VoidCallback onTap;
|
|
}
|