mirror of
https://github.com/koloideal/Casha.git
synced 2026-08-08 17:51:14 +03:00
step
This commit is contained in:
@@ -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) {
|
||||
|
||||
@@ -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,
|
||||
),
|
||||
),
|
||||
],
|
||||
|
||||
Reference in New Issue
Block a user