This commit is contained in:
2026-06-21 14:45:30 +03:00
parent 127a917eac
commit 3961327bdb
16 changed files with 852 additions and 396 deletions
@@ -0,0 +1,107 @@
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import '../../../core/constants.dart';
import '../../../core/l10n/locale_provider.dart';
import '../../../core/services/haptic_service.dart';
import '../../dashboard/provider.dart';
class AccountScopeChips extends ConsumerWidget {
const AccountScopeChips({super.key});
@override
Widget build(BuildContext context, WidgetRef ref) {
final s = ref.watch(stringsProvider);
final accountsAsync = ref.watch(accountsProvider);
final activeIndex = ref.watch(activeAccountIndexProvider);
final isDark = Theme.of(context).brightness == Brightness.dark;
return accountsAsync.when(
data: (accounts) {
if (accounts.isEmpty) return const SizedBox.shrink();
return SingleChildScrollView(
scrollDirection: Axis.horizontal,
clipBehavior: Clip.none,
child: Row(
children: [
_ScopeChip(
label: s.allAccounts,
isSelected: activeIndex == 0,
isDark: isDark,
onTap: () {
ref.read(activeAccountIndexProvider.notifier).set(0);
HapticService.selection();
},
),
const SizedBox(width: 6),
...accounts.asMap().entries.map((entry) {
final index = entry.key + 1;
final account = entry.value;
return Padding(
padding: const EdgeInsets.only(right: 6),
child: _ScopeChip(
label: account.name,
isSelected: activeIndex == index,
isDark: isDark,
onTap: () {
ref.read(activeAccountIndexProvider.notifier).set(index);
HapticService.selection();
},
),
);
}),
],
),
);
},
loading: () => const SizedBox.shrink(),
error: (_, __) => const SizedBox.shrink(),
);
}
}
class _ScopeChip extends StatelessWidget {
final String label;
final bool isSelected;
final bool isDark;
final VoidCallback onTap;
const _ScopeChip({
required this.label,
required this.isSelected,
required this.isDark,
required this.onTap,
});
@override
Widget build(BuildContext context) {
return GestureDetector(
onTap: onTap,
child: AnimatedContainer(
duration: const Duration(milliseconds: 200),
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 6),
decoration: BoxDecoration(
color: isSelected
? AppColors.accent.withOpacity(0.2)
: Theme.of(context).colorScheme.surface,
borderRadius: BorderRadius.circular(20),
border: isSelected
? Border.all(color: AppColors.accent, width: 1.5)
: isDark
? null
: Border.all(color: const Color(0xFFDDDDEE), width: 1),
),
child: Text(
label,
style: TextStyle(
fontSize: 12,
fontWeight: isSelected ? FontWeight.w600 : FontWeight.normal,
color: isSelected
? AppColors.accent
: Theme.of(context).colorScheme.onSurface.withOpacity(0.6),
),
),
),
);
}
}
@@ -0,0 +1,138 @@
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import '../../../core/constants.dart';
import '../../../core/services/card_color_service.dart';
import '../../../shared/providers/amount_format_provider.dart';
import '../../../shared/utils/card_gradient.dart';
import '../../../shared/utils/currency_utils.dart';
import '../../../shared/widgets/byn_sign.dart';
import '../../dashboard/provider.dart';
import '../../settings/provider.dart';
import '../provider.dart';
class StatsHeroCard extends ConsumerWidget {
final double amount;
final String label;
final Color accentColor;
final String scopeLabel;
const StatsHeroCard({
super.key,
required this.amount,
required this.label,
required this.accentColor,
required this.scopeLabel,
});
@override
Widget build(BuildContext context, WidgetRef ref) {
final fmt = ref.watch(amountFormatProvider);
final currencyInfo = ref.watch(statsCurrencyProvider);
final brightness = Theme.of(context).brightness;
final activeAccount = ref.watch(activeAccountProvider);
final globalColors = ref.watch(cardColorsProvider);
final CardColors colors;
if (activeAccount != null) {
colors = ref.watch(accountCardColorsProvider(activeAccount.id));
} else {
colors = globalColors;
}
final primary = Color.lerp(colors.primary, accentColor, 0.35)!;
final secondary = Color.lerp(colors.secondary, accentColor, 0.2)!;
final gradientType = colors.gradientTypeForBrightness(brightness);
final onCard = primary.computeLuminance() > 0.35
? Colors.black
: Colors.white;
return Container(
height: 128,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(20),
gradient: buildCardGradient(primary, secondary, gradientType),
boxShadow: [
BoxShadow(
color: Colors.black.withOpacity(0.35),
blurRadius: 20,
offset: const Offset(0, 8),
),
],
),
child: Padding(
padding: const EdgeInsets.fromLTRB(24, 12, 24, 12),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Container(
padding: const EdgeInsets.symmetric(
horizontal: 10,
vertical: 4,
),
decoration: BoxDecoration(
color: onCard.withOpacity(0.15),
borderRadius: BorderRadius.circular(20),
),
child: Text(
scopeLabel,
style: TextStyle(
fontSize: 11,
fontWeight: FontWeight.w600,
color: onCard.withOpacity(0.85),
letterSpacing: 0.3,
),
),
),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.min,
children: [
Text(
label,
style: TextStyle(
fontSize: 11,
letterSpacing: 1.2,
color: onCard.withOpacity(0.65),
),
),
const SizedBox(height: 2),
FittedBox(
fit: BoxFit.scaleDown,
alignment: Alignment.centerLeft,
child: currencyInfo.code == 'BYN'
? Row(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
BynSign(fontSize: 28, color: onCard),
const SizedBox(width: 2),
Text(
formatAmount('', amount, fmt),
style: TextStyle(
fontSize: 28,
fontWeight: FontWeight.w700,
color: onCard,
),
maxLines: 1,
),
],
)
: Text(
formatAmount(currencyInfo.symbol, amount, fmt),
style: TextStyle(
fontSize: 28,
fontWeight: FontWeight.w700,
color: onCard,
),
maxLines: 1,
),
),
],
),
],
),
),
);
}
}