From 1c3b506d4b1de417e497ce2e06d785913d1059fa Mon Sep 17 00:00:00 2001 From: kolo Date: Sun, 22 Mar 2026 01:21:29 +0300 Subject: [PATCH] stableee --- lib/core/l10n/app_strings.dart | 12 ++---------- lib/core/l10n/locale_provider.dart | 1 - lib/core/services/haptic_service.dart | 4 ---- lib/features/add_transaction/screen.dart | 15 +-------------- lib/features/dashboard/provider.dart | 4 ---- lib/features/settings/provider.dart | 1 - lib/main.dart | 1 - 7 files changed, 3 insertions(+), 35 deletions(-) diff --git a/lib/core/l10n/app_strings.dart b/lib/core/l10n/app_strings.dart index 7ba684d..e893bbc 100644 --- a/lib/core/l10n/app_strings.dart +++ b/lib/core/l10n/app_strings.dart @@ -7,7 +7,6 @@ class AppStrings { bool get _ru => locale == AppLocale.ru; - // ── Dashboard ── String get appTitle => _ru ? 'Мои финансы' : 'My Finances'; String get totalBalance => _ru ? 'ОБЩИЙ БАЛАНС' : 'TOTAL BALANCE'; String get tapAndHoldToEdit => _ru ? 'удерживайте для редактирования' : 'tap and hold to edit'; @@ -27,7 +26,6 @@ class AppStrings { String get noTransactions => _ru ? 'Транзакции не найдены' : 'No transactions found'; String get addFirstTx => _ru ? 'Нажмите + чтобы добавить первую транзакцию' : 'Tap + to add your first transaction'; - // ── Add/Edit transaction screen ── String get addTransaction => _ru ? 'Новая транзакция' : 'Add Transaction'; String get editTransaction => _ru ? 'Редактировать' : 'Edit Transaction'; String get amount => _ru ? 'Сумма' : 'Amount'; @@ -46,7 +44,6 @@ class AppStrings { String get noteOptional => _ru ? 'Заметка (необязательно)' : 'Note (optional)'; String get addNote => _ru ? 'Добавить заметку...' : 'Add a note...'; - // ── Settings ── String get settings => _ru ? 'Настройки' : 'Settings'; String get managePreferences => _ru ? 'Управление настройками' : 'Manage your preferences'; String get appearance => _ru ? 'Внешний вид' : 'Appearance'; @@ -86,12 +83,10 @@ class AppStrings { String get allTransactionsWillBeDeleted => _ru ? 'Все транзакции будут удалены навсегда. Восстановить их будет невозможно.' : 'All transactions will be deleted forever. There is no way to recover them.'; String get dangerZone => _ru ? 'Опасная зона' : 'Danger Zone'; - // ── Navigation ── String get navDashboard => _ru ? 'Главная' : 'Dashboard'; String get navCategories => _ru ? 'Категории' : 'Categories'; String get navSettings => _ru ? 'Настройки' : 'Settings'; - // ── Categories ── String get categories => _ru ? 'Категории' : 'Categories'; String get rankedByAmount => _ru ? 'По сумме' : 'Ranked by Amount'; String get addCategory => _ru ? 'Добавить категорию' : 'Add Category'; @@ -106,9 +101,8 @@ class AppStrings { String get total => _ru ? 'Всего' : 'Total'; String get lastSixMonths => _ru ? 'Последние 6 месяцев' : 'Last 6 Months'; - // ── Built-in category names (translated for display only, stored in English) ── String categoryLabel(String key) { - if (!_ru) return key; // English: return key as-is + if (!_ru) return key; const map = { 'Food': 'Еда', 'Transport': 'Транспорт', @@ -131,10 +125,9 @@ class AppStrings { 'Business': 'Бизнес', 'Savings': 'Накопления', }; - return map[key] ?? key; // fallback to English key if not in map + return map[key] ?? key; } - // ── Color editor overlay ── String get colorPrimary => _ru ? 'Основной' : 'Primary'; String get colorSecondary => _ru ? 'Второй' : 'Secondary'; String get colorSolid => _ru ? 'Однотон' : 'Solid'; @@ -145,6 +138,5 @@ class AppStrings { String get reset => _ru ? 'Сброс' : 'Reset'; String get apply => _ru ? 'Применить' : 'Apply'; - // ── Date locale code for intl DateFormat ── String get dateLocale => _ru ? 'ru_RU' : 'en_US'; } diff --git a/lib/core/l10n/locale_provider.dart b/lib/core/l10n/locale_provider.dart index 4092b19..946bff1 100644 --- a/lib/core/l10n/locale_provider.dart +++ b/lib/core/l10n/locale_provider.dart @@ -7,7 +7,6 @@ class LocaleNotifier extends Notifier { @override AppLocale build() { - // Load persisted locale synchronously via ref final prefs = ref.read(sharedPreferencesProvider); final saved = prefs.getString(_key); return saved == 'ru' ? AppLocale.ru : AppLocale.en; diff --git a/lib/core/services/haptic_service.dart b/lib/core/services/haptic_service.dart index 178b6c7..e8795c2 100644 --- a/lib/core/services/haptic_service.dart +++ b/lib/core/services/haptic_service.dart @@ -18,25 +18,21 @@ class HapticService { await prefs.setBool(_key, value); } - // Light tap — filter chips, toggles, small interactions static void light() { if (!_enabled) return; HapticFeedback.lightImpact(); } - // Medium — confirm button, apply, save static void medium() { if (!_enabled) return; HapticFeedback.mediumImpact(); } - // Heavy — long press on balance card static void heavy() { if (!_enabled) return; HapticFeedback.heavyImpact(); } - // Selection click — switching tabs, filter chips static void selection() { if (!_enabled) return; HapticFeedback.selectionClick(); diff --git a/lib/features/add_transaction/screen.dart b/lib/features/add_transaction/screen.dart index 020fa8c..2605b71 100644 --- a/lib/features/add_transaction/screen.dart +++ b/lib/features/add_transaction/screen.dart @@ -81,30 +81,22 @@ class _AddTransactionScreenState extends ConsumerState } String? _validateAndParseAmount(String raw) { - // trim whitespace final trimmed = raw.trim(); - // empty check - if (trimmed.isEmpty) return null; // returns null = invalid, show dialog + if (trimmed.isEmpty) return null; - // replace comma with dot for European locale input final normalized = trimmed.replaceAll(',', '.'); - // only digits and one dot allowed final validPattern = RegExp(r'^\d+\.?\d*$'); if (!validPattern.hasMatch(normalized)) return null; - // parse final value = double.tryParse(normalized); if (value == null) return null; - // must be greater than zero if (value <= 0) return null; - // must not exceed reasonable max (prevent overflow) if (value > 999_999_999) return null; - // must not have more than 2 decimal places final parts = normalized.split('.'); if (parts.length == 2 && parts[1].length > 2) return null; @@ -128,7 +120,6 @@ class _AddTransactionScreenState extends ConsumerState final amount = double.parse(parsed); final state = ref.read(addTransactionProvider(widget.initial)); - // Combine date and time final finalDateTime = DateTime( _selectedDate.year, _selectedDate.month, @@ -168,8 +159,6 @@ class _AddTransactionScreenState extends ConsumerState } Future _pickDate() async { - // Note: Using showDatePicker (system bottom sheet) which cannot be resized from Flutter. - // The calendar height is controlled by the system and varies by platform. final picked = await showDatePicker( context: context, initialDate: _selectedDate, @@ -370,7 +359,6 @@ class _AddTransactionScreenState extends ConsumerState Row( crossAxisAlignment: CrossAxisAlignment.start, children: [ - // DATE column Expanded( child: Column( crossAxisAlignment: CrossAxisAlignment.start, @@ -420,7 +408,6 @@ class _AddTransactionScreenState extends ConsumerState ), ), const SizedBox(width: 12), - // TIME column Expanded( child: Column( crossAxisAlignment: CrossAxisAlignment.start, diff --git a/lib/features/dashboard/provider.dart b/lib/features/dashboard/provider.dart index de894e2..261ae31 100644 --- a/lib/features/dashboard/provider.dart +++ b/lib/features/dashboard/provider.dart @@ -115,7 +115,6 @@ final filteredTransactionsProvider = Provider>((ref) { var filtered = txs; - // Apply time filter first if (timeFilter == TimeFilter.lastMonth) { final now = DateTime.now(); final start = DateTime(now.year, now.month, 1); @@ -126,14 +125,12 @@ final filteredTransactionsProvider = Provider>((ref) { ).toList(); } - // Apply type filter if (typeFilter == TransactionFilter.income) { filtered = filtered.where((t) => t.type == TransactionType.income).toList(); } else if (typeFilter == TransactionFilter.expense) { filtered = filtered.where((t) => t.type == TransactionType.expense).toList(); } - // Apply search query if (query.isNotEmpty) { filtered = filtered.where((t) { final matchesCategory = t.category.toLowerCase().contains(query); @@ -150,7 +147,6 @@ final recentTransactionsProvider = Provider>((ref) { return ref.watch(filteredTransactionsProvider).take(20).toList(); }); -// Loaded card colors state class CardColors { final Color primary; final Color secondary; diff --git a/lib/features/settings/provider.dart b/lib/features/settings/provider.dart index 6093d52..7644100 100644 --- a/lib/features/settings/provider.dart +++ b/lib/features/settings/provider.dart @@ -127,7 +127,6 @@ class HapticNotifier extends StateNotifier { Future toggle(bool value) async { await HapticService.setEnabled(value); state = value; - // Give tactile confirmation when turning ON if (value) HapticFeedback.mediumImpact(); } } diff --git a/lib/main.dart b/lib/main.dart index d85fa95..031acd5 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -10,7 +10,6 @@ import 'features/dashboard/provider.dart'; void main() async { WidgetsFlutterBinding.ensureInitialized(); - // Initialize date formatting for both locales await initializeDateFormatting('en_US', null); await initializeDateFormatting('ru_RU', null); await initializeDateFormatting('en', null);