This commit is contained in:
2026-06-28 18:33:46 +03:00
parent 65ea30339d
commit 4727835402
22 changed files with 534 additions and 54 deletions
@@ -33,7 +33,15 @@ class AccountScopeChips extends ConsumerWidget {
HapticService.selection();
},
),
const SizedBox(width: 6),
if (accounts.isNotEmpty) ...[
const SizedBox(width: 8),
Container(
width: 1,
height: 16,
color: Theme.of(context).colorScheme.onSurface.withOpacity(0.15),
),
const SizedBox(width: 8),
],
...accounts.asMap().entries.map((entry) {
final index = entry.key + 1;
final account = entry.value;
+3 -1
View File
@@ -7,6 +7,7 @@ import '../../core/utils/result.dart';
import '../../data/database/app_database.dart' as db;
import '../../data/repositories/transaction_repository.dart';
import '../../data/repositories/account_repository.dart';
import '../../shared/feature_flags/feature_flags_provider.dart';
import '../../shared/models/transaction.dart';
import '../../shared/models/account.dart';
import '../../shared/services/storage_service.dart';
@@ -27,7 +28,8 @@ final transactionRepositoryProvider = Provider<TransactionRepository>((ref) {
final accountRepositoryProvider = Provider<AccountRepository>((ref) {
final db = ref.watch(appDatabaseProvider);
return AccountRepository(db);
final flags = ref.watch(featureFlagsProvider);
return AccountRepository(db, flags);
});
final storageServiceProvider = Provider<StorageService>((ref) {
+25 -10
View File
@@ -5,7 +5,9 @@ import 'package:intl/intl.dart';
import '../../core/l10n/locale_provider.dart';
import '../../core/services/card_color_service.dart';
import '../../core/services/haptic_service.dart';
import '../../data/repositories/account_repository.dart';
import '../../shared/models/account.dart';
import '../../shared/feature_flags/feature_flags_provider.dart';
import '../settings/provider.dart';
import 'provider.dart';
import 'widgets/account_editor_overlay/account_editor_overlay.dart';
@@ -56,6 +58,7 @@ class _DashboardScreenState extends ConsumerState<DashboardScreen> {
bool isAddingAccount = false;
void _onCardLongPress() {
if (!ref.read(featureFlagsProvider).canEditCardColors) return;
final colors = ref.read(cardColorsProvider);
savedPrimary = colors.primary;
savedSecondary = colors.secondary;
@@ -179,15 +182,25 @@ class _DashboardScreenState extends ConsumerState<DashboardScreen> {
createdAt: DateTime.now(),
);
final newId = await ref.read(accountRepositoryProvider).add(newAccount);
try {
final newId = await ref.read(accountRepositoryProvider).add(newAccount);
await CardColorService.save(
tempPrimary,
tempSecondary,
tempLightGradientType,
tempDarkGradientType,
accountId: newId,
);
await CardColorService.save(
tempPrimary,
tempSecondary,
tempLightGradientType,
tempDarkGradientType,
accountId: newId,
);
} on FeatureLimitException {
if (mounted) {
final s = ref.read(stringsProvider);
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(content: Text(s.accountLimitReached)),
);
}
return;
}
} else if (editingAccount != null) {
await ref
.read(accountCardColorsProvider(editingAccount!.id).notifier)
@@ -279,8 +292,9 @@ class _DashboardScreenState extends ConsumerState<DashboardScreen> {
final activeIndex = ref.watch(activeAccountIndexProvider);
final accountsAsync = ref.watch(accountsProvider);
final accountCount = accountsAsync.value?.length ?? 0;
final maxAccounts = ref.watch(featureFlagsProvider).maxAccounts;
final isOnAddAccountPage =
accountCount < 5 && activeIndex == accountCount + 1;
accountCount < maxAccounts && activeIndex == accountCount + 1;
return Scaffold(
backgroundColor: Theme.of(context).scaffoldBackgroundColor,
@@ -438,6 +452,7 @@ class _AccountsInfoBlock extends ConsumerWidget {
@override
Widget build(BuildContext context, WidgetRef ref) {
final s = ref.watch(stringsProvider);
final maxAccounts = ref.watch(featureFlagsProvider).maxAccounts;
final onSurface = Theme.of(context).colorScheme.onSurface;
return Padding(
padding: const EdgeInsets.only(bottom: 60),
@@ -479,7 +494,7 @@ class _AccountsInfoBlock extends ConsumerWidget {
const SizedBox(height: 8),
_InfoRow(
icon: Icons.lock_outline_rounded,
text: s.accountsInfoLimit,
text: s.accountsLimitLabel(maxAccounts),
),
],
),
@@ -5,6 +5,7 @@ import '../../../../core/constants.dart';
import '../../../../core/utils/card_layout.dart';
import '../../../../shared/models/account.dart';
import '../../../../shared/models/transaction.dart';
import '../../../../shared/feature_flags/feature_flags_provider.dart';
import '../../../../shared/widgets/byn_sign.dart';
import '../../../settings/provider.dart';
import '../../provider.dart';
@@ -93,9 +94,10 @@ class _AccountEditorOverlayState extends State<AccountEditorOverlay> {
builder: (context, ref, _) {
final exchangeService = ref.watch(exchangeRateServiceProvider);
final cardHeight = ref.watch(cardHeightProvider);
final isPremium = ref.watch(featureFlagsProvider).canEditCardColors;
final editorPanelTop = cardTop + cardHeight + layout.sectionGap;
final colorPanelTop = editorPanelTop + editorPanelHeight + layout.sectionGap;
final colorPanelHeight = layout.colorPanelHeight(mq, colorPanelTop);
final colorPanelHeight = isPremium ? layout.colorPanelHeight(mq, colorPanelTop) : 0.0;
double previewBalance = 0.0;
if (!dash.isAddingAccount) {
@@ -249,36 +251,38 @@ class _AccountEditorOverlayState extends State<AccountEditorOverlay> {
),
),
),
Positioned(
top: colorPanelTop,
left: 20,
right: 20,
child: GestureDetector(
onTap: () {
if (_showCurrencyDropdown) {
setState(() {
_showCurrencyDropdown = false;
});
}
},
behavior: HitTestBehavior.opaque,
child: AccountColorPanel(
dashboardState: dash,
dashboardContext: widget.context,
panelHeight: colorPanelHeight,
layout: layout,
isDuplicateName: _isDuplicateName,
onDuplicateError: () {
setState(() => _showDuplicateError = true);
Future.delayed(const Duration(seconds: 3), () {
if (mounted) {
setState(() => _showDuplicateError = false);
}
});
if (isPremium) ...[
Positioned(
top: colorPanelTop,
left: 20,
right: 20,
child: GestureDetector(
onTap: () {
if (_showCurrencyDropdown) {
setState(() {
_showCurrencyDropdown = false;
});
}
},
behavior: HitTestBehavior.opaque,
child: AccountColorPanel(
dashboardState: dash,
dashboardContext: widget.context,
panelHeight: colorPanelHeight,
layout: layout,
isDuplicateName: _isDuplicateName,
onDuplicateError: () {
setState(() => _showDuplicateError = true);
Future.delayed(const Duration(seconds: 3), () {
if (mounted) {
setState(() => _showDuplicateError = false);
}
});
},
),
),
),
),
],
if (_showCurrencyDropdown)
Positioned(
top: editorPanelTop + 62,
@@ -9,6 +9,7 @@ import '../../../core/utils/card_layout.dart';
import '../../../shared/utils/card_gradient.dart';
import '../../../core/services/haptic_service.dart';
import '../../../shared/providers/amount_format_provider.dart';
import '../../../shared/feature_flags/feature_flags_provider.dart';
import '../../../shared/widgets/byn_sign.dart';
import '../../settings/provider.dart';
import '../provider.dart';
@@ -110,6 +111,7 @@ class BalanceCardState extends ConsumerState<BalanceCard>
.toList();
final textColorMode = ref.watch(cardTextColorProvider);
final canEditCardColors = ref.watch(featureFlagsProvider).canEditCardColors;
final Color onCard = switch (textColorMode) {
CardTextColorMode.white => Colors.white,
CardTextColorMode.black => Colors.black,
@@ -324,12 +326,13 @@ class BalanceCardState extends ConsumerState<BalanceCard>
],
),
),
Positioned(
bottom: 8,
left: 0,
right: 0,
child: Text(
s.tapAndHoldToEdit,
if (canEditCardColors)
Positioned(
bottom: 8,
left: 0,
right: 0,
child: Text(
s.tapAndHoldToEdit,
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 9,
@@ -5,6 +5,7 @@ import '../../../core/utils/card_layout.dart';
import '../../../core/services/haptic_service.dart';
import '../../../shared/models/account.dart';
import '../../../shared/models/transaction.dart';
import '../../../shared/feature_flags/feature_flags_provider.dart';
import '../../settings/provider.dart';
import '../provider.dart';
import 'balance_card.dart';
@@ -60,10 +61,11 @@ class _BalanceCardCarouselState extends ConsumerState<BalanceCardCarousel> {
final accountsAsync = ref.watch(accountsProvider);
final activeIndex = ref.watch(activeAccountIndexProvider);
final cardHeight = ref.watch(cardHeightProvider);
final maxAccounts = ref.watch(featureFlagsProvider).maxAccounts;
return accountsAsync.when(
data: (accounts) {
final totalPages = 1 + accounts.length + (accounts.length < 5 ? 1 : 0);
final totalPages = 1 + accounts.length + (accounts.length < maxAccounts ? 1 : 0);
return Column(
children: [
@@ -7,6 +7,7 @@ import '../../../core/l10n/locale_provider.dart';
import '../../../core/services/card_color_service.dart';
import '../../../core/services/haptic_service.dart';
import '../../../core/utils/card_layout.dart';
import '../../../shared/feature_flags/feature_flags_provider.dart';
import '../../settings/provider.dart';
import '../provider.dart';
import 'balance_card.dart';
@@ -42,6 +43,7 @@ class _FullScreenBlurOverlayState extends State<FullScreenBlurOverlay> {
return Consumer(
builder: (context, ref, _) {
final cardHeight = ref.watch(cardHeightProvider);
final isPremium = ref.watch(featureFlagsProvider).canEditCardHeight;
final heightDelta = (kBalanceCardHeight - cardHeight) / 2;
final adjustedCardTop = cardTop + heightDelta;
final panelTop = adjustedCardTop + cardHeight + layout.cardPreviewGap;
@@ -90,7 +92,7 @@ class _FullScreenBlurOverlayState extends State<FullScreenBlurOverlay> {
? dash.tempDarkGradientType
: dash.tempLightGradientType,
cardHeight: cardHeight,
resizeHandle: _CornerResizeHandle(
resizeHandle: isPremium ? _CornerResizeHandle(
cardHeight: cardHeight,
onHeightChanged: (newHeight) {
ref.read(cardHeightProvider.notifier).set(newHeight);
@@ -98,7 +100,7 @@ class _FullScreenBlurOverlayState extends State<FullScreenBlurOverlay> {
HapticService.selection();
}
},
),
) : null,
),
),
],
+3
View File
@@ -14,6 +14,7 @@ import 'widgets/language_section.dart';
import 'widgets/currency_section.dart';
import 'widgets/amount_format_section.dart';
import 'widgets/categories_section.dart';
import 'widgets/premium_section.dart';
class SettingsScreen extends ConsumerWidget {
const SettingsScreen({super.key});
@@ -116,6 +117,8 @@ class SettingsScreen extends ConsumerWidget {
physics: const ClampingScrollPhysics(),
padding: const EdgeInsets.fromLTRB(20, 16, 20, 40),
children: [
const PremiumSection(),
const SizedBox(height: 16),
const ThemeSection(),
const SizedBox(height: 16),
const CardTextColorSection(),
@@ -0,0 +1,85 @@
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 '../../../shared/providers/current_user_provider.dart';
import '../../../shared/models/user_model.dart';
class PremiumSection extends ConsumerWidget {
const PremiumSection({super.key});
@override
Widget build(BuildContext context, WidgetRef ref) {
final s = ref.watch(stringsProvider);
final user = ref.watch(currentUserProvider);
final isDark = Theme.of(context).brightness == Brightness.dark;
return Container(
padding: const EdgeInsets.all(20),
decoration: BoxDecoration(
color: Theme.of(context).colorScheme.surface,
borderRadius: BorderRadius.circular(16),
border: isDark
? null
: Border.all(color: const Color(0xFFDDDDEE), width: 1),
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
children: [
Container(
padding: const EdgeInsets.all(10),
decoration: BoxDecoration(
color: (user.isVip ? AppColors.accent : AppColors.warning)
.withOpacity(0.15),
borderRadius: BorderRadius.circular(12),
),
child: Icon(
user.isVip ? Icons.workspace_premium_rounded : Icons.lock_outline_rounded,
color: user.isVip ? AppColors.accent : AppColors.warning,
size: 20,
),
),
const SizedBox(width: 12),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
s.premiumStatus,
style: Theme.of(context).textTheme.titleMedium?.copyWith(
fontWeight: FontWeight.w600,
color: Theme.of(context).colorScheme.onSurface,
),
),
Text(
s.premiumDescription,
style: Theme.of(context).textTheme.bodySmall?.copyWith(
color: Theme.of(context)
.colorScheme
.onSurface
.withOpacity(0.6),
),
),
],
),
),
Switch(
value: user.isVip,
onChanged: (value) async {
HapticService.light();
await ref.read(currentUserProvider.notifier).setPlan(
value ? UserPlan.vip : UserPlan.free,
);
},
activeThumbColor: const Color(0xFF7C6DED),
),
],
),
],
),
);
}
}