This commit is contained in:
2026-06-28 14:55:41 +03:00
parent 6fdf4eedf1
commit 2b89545248
9 changed files with 234 additions and 111 deletions
+56
View File
@@ -26,6 +26,14 @@ class AppCategories {
'Shopping', 'Shopping',
'Health', 'Health',
'Entertainment', 'Entertainment',
'Housing',
'Education',
'Travel',
'Utilities',
'Clothing',
'Sports',
'Beauty',
'Pets',
'Other' 'Other'
]; ];
@@ -35,6 +43,8 @@ class AppCategories {
'Gift', 'Gift',
'Investment', 'Investment',
'Refund', 'Refund',
'Business',
'Savings',
'Other' 'Other'
]; ];
@@ -50,11 +60,21 @@ class AppCategories {
'Shopping': Icons.shopping_bag_rounded, 'Shopping': Icons.shopping_bag_rounded,
'Health': Icons.favorite_rounded, 'Health': Icons.favorite_rounded,
'Entertainment': Icons.movie_rounded, 'Entertainment': Icons.movie_rounded,
'Housing': Icons.home_rounded,
'Education': Icons.school_rounded,
'Travel': Icons.flight_rounded,
'Utilities': Icons.bolt_rounded,
'Clothing': Icons.checkroom_rounded,
'Sports': Icons.fitness_center_rounded,
'Beauty': Icons.brush_rounded,
'Pets': Icons.pets_rounded,
'Salary': Icons.work_rounded, 'Salary': Icons.work_rounded,
'Freelance': Icons.laptop_rounded, 'Freelance': Icons.laptop_rounded,
'Gift': Icons.card_giftcard_rounded, 'Gift': Icons.card_giftcard_rounded,
'Investment': Icons.trending_up_rounded, 'Investment': Icons.trending_up_rounded,
'Refund': Icons.money_rounded, 'Refund': Icons.money_rounded,
'Business': Icons.business_center_rounded,
'Savings': Icons.savings_rounded,
'Other': Icons.category_rounded, 'Other': Icons.category_rounded,
}; };
@@ -64,11 +84,21 @@ class AppCategories {
'Shopping': Color(0xFFFFD369), 'Shopping': Color(0xFFFFD369),
'Health': Color(0xFF69FFB4), 'Health': Color(0xFF69FFB4),
'Entertainment': Color(0xFFFF69B4), 'Entertainment': Color(0xFFFF69B4),
'Housing': Color(0xFF69B4FF),
'Education': Color(0xFFFFB469),
'Travel': Color(0xFF69FFB4),
'Utilities': Color(0xFFFFD369),
'Clothing': Color(0xFFFF69B4),
'Sports': Color(0xFF69FFB4),
'Beauty': Color(0xFFFF69B4),
'Pets': Color(0xFFB4FF69),
'Salary': Color(0xFF4CAF8C), 'Salary': Color(0xFF4CAF8C),
'Freelance': Color(0xFF69FFB4), 'Freelance': Color(0xFF69FFB4),
'Gift': Color(0xFFFFB469), 'Gift': Color(0xFFFFB469),
'Investment': Color(0xFF69B4FF), 'Investment': Color(0xFF69B4FF),
'Refund': Color(0xFFB4FF69), 'Refund': Color(0xFFB4FF69),
'Business': Color(0xFFFF8C69),
'Savings': Color(0xFF4CAF8C),
'Other': Color(0xFFB469FF), 'Other': Color(0xFFB469FF),
}; };
@@ -78,11 +108,21 @@ class AppCategories {
'Shopping': 'shopping_bag', 'Shopping': 'shopping_bag',
'Health': 'heart', 'Health': 'heart',
'Entertainment': 'movie', 'Entertainment': 'movie',
'Housing': 'home',
'Education': 'school',
'Travel': 'flight',
'Utilities': 'bolt',
'Clothing': 'checkroom',
'Sports': 'fitness',
'Beauty': 'brush',
'Pets': 'pets',
'Salary': 'work', 'Salary': 'work',
'Freelance': 'laptop', 'Freelance': 'laptop',
'Gift': 'gift', 'Gift': 'gift',
'Investment': 'trending_up', 'Investment': 'trending_up',
'Refund': 'money', 'Refund': 'money',
'Business': 'work',
'Savings': 'savings',
'Other': 'category', 'Other': 'category',
}; };
@@ -108,6 +148,22 @@ class AppCategories {
'Pets': 'Питомцы', 'Pets': 'Питомцы',
'Business': 'Бизнес', 'Business': 'Бизнес',
'Savings': 'Накопления', 'Savings': 'Накопления',
'Dining': 'Ресторан',
'Cafe': 'Кафе',
'Coffee': 'Кофе',
'Restaurant': 'Ресторан',
'Fuel': 'Топливо',
'Taxi': 'Такси',
'Phone': 'Связь',
'Internet': 'Интернет',
'Insurance': 'Страховка',
'Taxes': 'Налоги',
'Medicine': 'Медицина',
'Children': 'Дети',
'Hobby': 'Хобби',
'Music': 'Музыка',
'Games': 'Игры',
'Books': 'Книги',
}; };
} }
+2 -2
View File
@@ -396,7 +396,7 @@ class _AddTransactionScreenState extends ConsumerState<AddTransactionScreen>
child: child!, child: child!,
), ),
); );
if (picked != null) { if (picked != null && mounted) {
setState(() => _selectedDate = picked); setState(() => _selectedDate = picked);
} }
} }
@@ -423,7 +423,7 @@ class _AddTransactionScreenState extends ConsumerState<AddTransactionScreen>
child: child!, child: child!,
), ),
); );
if (picked != null) { if (picked != null && mounted) {
setState(() => _selectedTime = picked); setState(() => _selectedTime = picked);
} }
} }
@@ -27,6 +27,9 @@ class AccountSelector extends ConsumerWidget {
return accountsAsync.when( return accountsAsync.when(
data: (accounts) { data: (accounts) {
if (accounts.isEmpty) {
return const SizedBox.shrink();
}
final txAccountId = ref final txAccountId = ref
.read(addTransactionProvider(initial)) .read(addTransactionProvider(initial))
.selectedAccountId; .selectedAccountId;
+27 -24
View File
@@ -45,18 +45,9 @@ class _CategoriesScreenState extends ConsumerState<CategoriesScreen> {
return Scaffold( return Scaffold(
backgroundColor: Theme.of(context).scaffoldBackgroundColor, backgroundColor: Theme.of(context).scaffoldBackgroundColor,
appBar: AppBar(
title: Text(
s.statistics,
style: Theme.of(context).textTheme.titleLarge?.copyWith(
fontWeight: FontWeight.w700,
color: Theme.of(context).colorScheme.onSurface,
),
),
),
body: SafeArea( body: SafeArea(
child: ListView( child: ListView(
padding: const EdgeInsets.fromLTRB(20, 8, 20, 100), padding: const EdgeInsets.fromLTRB(20, 16, 20, 100),
children: [ children: [
const AccountScopeChips(), const AccountScopeChips(),
const SizedBox(height: 16), const SizedBox(height: 16),
@@ -232,6 +223,9 @@ class _PieChartSection extends ConsumerWidget {
final fmt = ref.watch(amountFormatProvider); final fmt = ref.watch(amountFormatProvider);
final entries = data.entries.toList(); final entries = data.entries.toList();
final accent = isIncome ? AppColors.income : AppColors.expense; final accent = isIncome ? AppColors.income : AppColors.expense;
if (entries.isEmpty) {
return const SizedBox.shrink();
}
final selectedIndex = touchedIndex >= 0 ? touchedIndex : 0; final selectedIndex = touchedIndex >= 0 ? touchedIndex : 0;
final selectedEntry = entries[selectedIndex.clamp(0, entries.length - 1)]; final selectedEntry = entries[selectedIndex.clamp(0, entries.length - 1)];
final selectedAmount = selectedEntry.value; final selectedAmount = selectedEntry.value;
@@ -267,7 +261,9 @@ class _PieChartSection extends ConsumerWidget {
color: color, color: color,
value: val, value: val,
title: isTouched title: isTouched
? '${(val / total * 100).toStringAsFixed(0)}%' ? total > 0
? '${(val / total * 100).toStringAsFixed(0)}%'
: '0%'
: '', : '',
radius: isTouched ? 60 : 52, radius: isTouched ? 60 : 52,
titleStyle: const TextStyle( titleStyle: const TextStyle(
@@ -340,7 +336,9 @@ class _PieChartSection extends ConsumerWidget {
), ),
), ),
Text( Text(
'${(selectedAmount / total * 100).toStringAsFixed(1)}%', total > 0
? '${(selectedAmount / total * 100).toStringAsFixed(1)}%'
: '0%',
style: Theme.of(context).textTheme.bodyMedium?.copyWith( style: Theme.of(context).textTheme.bodyMedium?.copyWith(
fontWeight: FontWeight.w700, fontWeight: FontWeight.w700,
color: accent, color: accent,
@@ -869,7 +867,7 @@ class _TimePeriodToggle extends ConsumerWidget {
color: theme.colorScheme.onSurface.withOpacity(0.06), color: theme.colorScheme.onSurface.withOpacity(0.06),
), ),
), ),
padding: const EdgeInsets.all(4), padding: const EdgeInsets.all(2),
child: Row( child: Row(
children: [ children: [
Expanded( Expanded(
@@ -936,14 +934,17 @@ class _OverviewCard extends ConsumerWidget {
), ),
), ),
const SizedBox(height: 12), const SizedBox(height: 12),
_FormattedAmount( FittedBox(
amount: amount, fit: BoxFit.scaleDown,
currencyInfo: currencyInfo, child: _FormattedAmount(
color: color, amount: amount,
fontSize: 40, currencyInfo: currencyInfo,
fontWeight: FontWeight.w800, color: color,
format: fmt, fontSize: 40,
center: true, fontWeight: FontWeight.w800,
format: fmt,
center: true,
),
), ),
const SizedBox(height: 14), const SizedBox(height: 14),
Text( Text(
@@ -981,7 +982,7 @@ class _IncomeExpenseToggle extends ConsumerWidget {
color: theme.colorScheme.onSurface.withOpacity(0.06), color: theme.colorScheme.onSurface.withOpacity(0.06),
), ),
), ),
padding: const EdgeInsets.all(4), padding: const EdgeInsets.all(2),
child: Row( child: Row(
children: [ children: [
Expanded( Expanded(
@@ -1025,7 +1026,7 @@ class _ToggleChip extends StatelessWidget {
onTap: onTap, onTap: onTap,
child: AnimatedContainer( child: AnimatedContainer(
duration: const Duration(milliseconds: 200), duration: const Duration(milliseconds: 200),
padding: const EdgeInsets.symmetric(vertical: 10), padding: const EdgeInsets.symmetric(vertical: 8, horizontal: 4),
decoration: BoxDecoration( decoration: BoxDecoration(
color: isSelected ? color.withOpacity(0.15) : Colors.transparent, color: isSelected ? color.withOpacity(0.15) : Colors.transparent,
borderRadius: BorderRadius.circular(8), borderRadius: BorderRadius.circular(8),
@@ -1033,8 +1034,10 @@ class _ToggleChip extends StatelessWidget {
child: Text( child: Text(
label, label,
textAlign: TextAlign.center, textAlign: TextAlign.center,
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: TextStyle( style: TextStyle(
fontSize: 14, fontSize: 13,
fontWeight: isSelected ? FontWeight.w700 : FontWeight.w500, fontWeight: isSelected ? FontWeight.w700 : FontWeight.w500,
color: isSelected color: isSelected
? color ? color
+1
View File
@@ -222,6 +222,7 @@ class _DashboardScreenState extends ConsumerState<DashboardScreen> {
}); });
} }
if (!mounted) return;
overlayEntry?.remove(); overlayEntry?.remove();
overlayEntry = null; overlayEntry = null;
setState(() { setState(() {
@@ -1,3 +1,5 @@
import 'dart:async';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart';
import '../../../core/constants.dart'; import '../../../core/constants.dart';
@@ -44,6 +46,11 @@ class _CategoryEditorSheetState extends ConsumerState<CategoryEditorSheet> {
bool _translatingEn = false; bool _translatingEn = false;
bool _translatingRu = false; bool _translatingRu = false;
bool _saving = false; bool _saving = false;
DateTime? _lastTranslateTime;
bool _enOverflow = false;
bool _ruOverflow = false;
Timer? _enOverflowTimer;
Timer? _ruOverflowTimer;
@override @override
void initState() { void initState() {
@@ -62,6 +69,8 @@ class _CategoryEditorSheetState extends ConsumerState<CategoryEditorSheet> {
@override @override
void dispose() { void dispose() {
_enOverflowTimer?.cancel();
_ruOverflowTimer?.cancel();
_enController.dispose(); _enController.dispose();
_ruController.dispose(); _ruController.dispose();
super.dispose(); super.dispose();
@@ -71,21 +80,50 @@ class _CategoryEditorSheetState extends ConsumerState<CategoryEditorSheet> {
if (_enController.text.trim().isNotEmpty && _enSuggestion != null) { if (_enController.text.trim().isNotEmpty && _enSuggestion != null) {
setState(() => _enSuggestion = null); setState(() => _enSuggestion = null);
} }
if (_enController.text.length >= 20) {
_enOverflowTimer?.cancel();
setState(() => _enOverflow = true);
_enOverflowTimer = Timer(const Duration(seconds: 1), () {
if (mounted) setState(() => _enOverflow = false);
});
}
} }
void _onRuChanged() { void _onRuChanged() {
if (_ruController.text.trim().isNotEmpty && _ruSuggestion != null) { if (_ruController.text.trim().isNotEmpty && _ruSuggestion != null) {
setState(() => _ruSuggestion = null); setState(() => _ruSuggestion = null);
} }
if (_ruController.text.length >= 20) {
_ruOverflowTimer?.cancel();
setState(() => _ruOverflow = true);
_ruOverflowTimer = Timer(const Duration(seconds: 1), () {
if (mounted) setState(() => _ruOverflow = false);
});
}
}
bool _isThrottled() {
final now = DateTime.now();
if (_lastTranslateTime != null &&
now.difference(_lastTranslateTime!) < const Duration(seconds: 2)) {
return true;
}
_lastTranslateTime = now;
return false;
} }
Future<void> _translateToRu() async { Future<void> _translateToRu() async {
final source = _enController.text.trim(); final source = _enController.text.trim();
if (source.isEmpty) return; if (source.isEmpty) return;
setState(() => _translatingRu = true); setState(() => _translatingRu = true);
final result = await ref final service = ref.read(translationServiceProvider);
.read(translationServiceProvider) TranslationResult? result;
.translate(source, TranslateDirection.enToRu); if (_isThrottled()) {
final dict = service.dictionaryLookup(source, TranslateDirection.enToRu);
result = dict != null ? TranslationResult(dict, fromCache: true) : null;
} else {
result = await service.translate(source, TranslateDirection.enToRu);
}
if (!mounted) return; if (!mounted) return;
setState(() { setState(() {
_translatingRu = false; _translatingRu = false;
@@ -100,9 +138,14 @@ class _CategoryEditorSheetState extends ConsumerState<CategoryEditorSheet> {
final source = _ruController.text.trim(); final source = _ruController.text.trim();
if (source.isEmpty) return; if (source.isEmpty) return;
setState(() => _translatingEn = true); setState(() => _translatingEn = true);
final result = await ref final service = ref.read(translationServiceProvider);
.read(translationServiceProvider) TranslationResult? result;
.translate(source, TranslateDirection.ruToEn); if (_isThrottled()) {
final dict = service.dictionaryLookup(source, TranslateDirection.ruToEn);
result = dict != null ? TranslationResult(dict, fromCache: true) : null;
} else {
result = await service.translate(source, TranslateDirection.ruToEn);
}
if (!mounted) return; if (!mounted) return;
setState(() { setState(() {
_translatingEn = false; _translatingEn = false;
@@ -122,21 +165,45 @@ class _CategoryEditorSheetState extends ConsumerState<CategoryEditorSheet> {
} }
setState(() => _saving = true); setState(() => _saving = true);
HapticService.medium(); HapticService.medium();
String labelEn = _enController.text.trim();
String labelRu = _ruController.text.trim();
if (labelEn.isEmpty && labelRu.isNotEmpty) {
final result = await ref
.read(translationServiceProvider)
.translate(labelRu, TranslateDirection.ruToEn);
if (result != null && result.text.isNotEmpty) {
labelEn = result.text;
} else {
labelEn = labelRu;
}
} else if (labelRu.isEmpty && labelEn.isNotEmpty) {
final result = await ref
.read(translationServiceProvider)
.translate(labelEn, TranslateDirection.enToRu);
if (result != null && result.text.isNotEmpty) {
labelRu = result.text;
} else {
labelRu = labelEn;
}
}
final actions = ref.read(categoryActionsProvider); final actions = ref.read(categoryActionsProvider);
final existing = widget.existing; final existing = widget.existing;
final result = existing != null && existing.id != null final result = existing != null && existing.id != null
? await actions.edit( ? await actions.edit(
id: existing.id!, id: existing.id!,
type: _type, type: _type,
labelEn: _enController.text, labelEn: labelEn,
labelRu: _ruController.text, labelRu: labelRu,
iconName: _iconName, iconName: _iconName,
colorValue: _colorValue, colorValue: _colorValue,
) )
: await actions.create( : await actions.create(
type: _type, type: _type,
labelEn: _enController.text, labelEn: labelEn,
labelRu: _ruController.text, labelRu: labelRu,
iconName: _iconName, iconName: _iconName,
colorValue: _colorValue, colorValue: _colorValue,
); );
@@ -201,6 +268,7 @@ class _CategoryEditorSheetState extends ConsumerState<CategoryEditorSheet> {
hint: s.nameEnHint, hint: s.nameEnHint,
suggestion: _enSuggestion, suggestion: _enSuggestion,
isTranslating: _translatingEn, isTranslating: _translatingEn,
isOverflow: _enOverflow,
canTranslate: _ruController.text.trim().isNotEmpty, canTranslate: _ruController.text.trim().isNotEmpty,
translatingLabel: s.translating, translatingLabel: s.translating,
applyLabel: s.applyTranslation, applyLabel: s.applyTranslation,
@@ -217,6 +285,7 @@ class _CategoryEditorSheetState extends ConsumerState<CategoryEditorSheet> {
hint: s.nameRuHint, hint: s.nameRuHint,
suggestion: _ruSuggestion, suggestion: _ruSuggestion,
isTranslating: _translatingRu, isTranslating: _translatingRu,
isOverflow: _ruOverflow,
canTranslate: _enController.text.trim().isNotEmpty, canTranslate: _enController.text.trim().isNotEmpty,
translatingLabel: s.translating, translatingLabel: s.translating,
applyLabel: s.applyTranslation, applyLabel: s.applyTranslation,
@@ -384,6 +453,7 @@ class _TranslatableField extends StatelessWidget {
final bool canTranslate; final bool canTranslate;
final String translatingLabel; final String translatingLabel;
final String applyLabel; final String applyLabel;
final bool isOverflow;
final VoidCallback onTranslate; final VoidCallback onTranslate;
final VoidCallback onApply; final VoidCallback onApply;
@@ -393,6 +463,7 @@ class _TranslatableField extends StatelessWidget {
required this.hint, required this.hint,
required this.suggestion, required this.suggestion,
required this.isTranslating, required this.isTranslating,
required this.isOverflow,
required this.canTranslate, required this.canTranslate,
required this.translatingLabel, required this.translatingLabel,
required this.applyLabel, required this.applyLabel,
@@ -424,9 +495,11 @@ class _TranslatableField extends StatelessWidget {
decoration: BoxDecoration( decoration: BoxDecoration(
color: theme.colorScheme.surface, color: theme.colorScheme.surface,
borderRadius: BorderRadius.circular(14), borderRadius: BorderRadius.circular(14),
border: isDark border: isOverflow
? null ? Border.all(color: AppColors.expense, width: 1.5)
: Border.all(color: const Color(0xFFDDDDEE), width: 1), : isDark
? null
: Border.all(color: const Color(0xFFDDDDEE), width: 1),
), ),
child: Row( child: Row(
children: [ children: [
@@ -457,10 +530,12 @@ class _TranslatableField extends StatelessWidget {
TextField( TextField(
controller: controller, controller: controller,
style: theme.textTheme.bodyLarge, style: theme.textTheme.bodyLarge,
maxLength: 20,
decoration: InputDecoration( decoration: InputDecoration(
hintText: showGhost ? '' : hint, hintText: showGhost ? '' : hint,
isDense: true, isDense: true,
filled: false, filled: false,
counterText: '',
enabledBorder: InputBorder.none, enabledBorder: InputBorder.none,
focusedBorder: InputBorder.none, focusedBorder: InputBorder.none,
border: InputBorder.none, border: InputBorder.none,
+54 -70
View File
@@ -111,79 +111,63 @@ class SettingsScreen extends ConsumerWidget {
return Scaffold( return Scaffold(
backgroundColor: Theme.of(context).scaffoldBackgroundColor, backgroundColor: Theme.of(context).scaffoldBackgroundColor,
appBar: AppBar( body: SafeArea(
backgroundColor: Theme.of(context).scaffoldBackgroundColor, child: ListView(
elevation: 0, physics: const ClampingScrollPhysics(),
scrolledUnderElevation: 0, padding: const EdgeInsets.fromLTRB(20, 16, 20, 40),
centerTitle: true, children: [
toolbarHeight: 80, const ThemeSection(),
title: Padding( const SizedBox(height: 16),
padding: const EdgeInsets.symmetric(vertical: 16), const CardTextColorSection(),
child: Text( const SizedBox(height: 16),
'Casha', const HapticSection(),
style: Theme.of(context).textTheme.displaySmall?.copyWith( const SizedBox(height: 16),
fontWeight: FontWeight.w800, const CurrencyConversionsSection(),
color: Theme.of(context).colorScheme.onSurface, const SizedBox(height: 16),
letterSpacing: -0.5, const _BiometricSection(),
const LanguageSection(),
const SizedBox(height: 16),
const CurrencySection(),
const SizedBox(height: 16),
const AmountFormatSection(),
const SizedBox(height: 16),
const CategoriesSection(),
const SizedBox(height: 24),
Text(
s.dangerZone,
style: TextStyle(
fontSize: 12,
letterSpacing: 1.2,
color: const Color(0xFFE05C6B).withOpacity(0.8),
fontWeight: FontWeight.w600,
),
), ),
), const SizedBox(height: 8),
SizedBox(
width: double.infinity,
child: OutlinedButton.icon(
onPressed: () => _confirmClearData(context, ref),
icon: const Icon(Icons.delete_forever, color: Color(0xFFE05C6B)),
label: Text(
s.clearAllTransactions,
style: const TextStyle(color: Color(0xFFE05C6B)),
),
style: OutlinedButton.styleFrom(
side: BorderSide(
color: const Color(0xFFE05C6B).withOpacity(0.5),
),
padding: const EdgeInsets.symmetric(vertical: 14),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(12),
),
),
),
),
const SizedBox(height: 40),
const _FooterWidget(),
],
), ),
), ),
body: ListView(
physics: const ClampingScrollPhysics(),
padding: const EdgeInsets.fromLTRB(20, 16, 20, 40),
children: [
const ThemeSection(),
const SizedBox(height: 16),
const CardTextColorSection(),
const SizedBox(height: 16),
const HapticSection(),
const SizedBox(height: 16),
const CurrencyConversionsSection(),
const SizedBox(height: 16),
const _BiometricSection(),
const LanguageSection(),
const SizedBox(height: 16),
const CurrencySection(),
const SizedBox(height: 16),
const AmountFormatSection(),
const SizedBox(height: 16),
const CategoriesSection(),
const SizedBox(height: 24),
Text(
s.dangerZone,
style: TextStyle(
fontSize: 12,
letterSpacing: 1.2,
color: const Color(0xFFE05C6B).withOpacity(0.8),
fontWeight: FontWeight.w600,
),
),
const SizedBox(height: 8),
SizedBox(
width: double.infinity,
child: OutlinedButton.icon(
onPressed: () => _confirmClearData(context, ref),
icon: const Icon(Icons.delete_forever, color: Color(0xFFE05C6B)),
label: Text(
s.clearAllTransactions,
style: const TextStyle(color: Color(0xFFE05C6B)),
),
style: OutlinedButton.styleFrom(
side: BorderSide(
color: const Color(0xFFE05C6B).withOpacity(0.5),
),
padding: const EdgeInsets.symmetric(vertical: 14),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(12),
),
),
),
),
const SizedBox(height: 40),
const _FooterWidget(),
],
),
); );
} }
} }
@@ -97,6 +97,7 @@ class ExchangeRateService {
final fromRate = currentRates[from] ?? 1.0; final fromRate = currentRates[from] ?? 1.0;
final toRate = currentRates[to] ?? 1.0; final toRate = currentRates[to] ?? 1.0;
if (fromRate == 0) return amount;
final amountInUsd = amount / fromRate; final amountInUsd = amount / fromRate;
return amountInUsd * toRate; return amountInUsd * toRate;
+2 -2
View File
@@ -59,7 +59,7 @@ class TranslationService {
for (final entry in _ruToEn.entries) entry.value.toLowerCase(): entry.key, for (final entry in _ruToEn.entries) entry.value.toLowerCase(): entry.key,
}; };
String? _dictionaryLookup(String input, TranslateDirection direction) { String? dictionaryLookup(String input, TranslateDirection direction) {
final normalized = input.trim().toLowerCase(); final normalized = input.trim().toLowerCase();
if (normalized.isEmpty) return null; if (normalized.isEmpty) return null;
final map = direction == TranslateDirection.ruToEn ? _ruToEn : _enToRu; final map = direction == TranslateDirection.ruToEn ? _ruToEn : _enToRu;
@@ -75,7 +75,7 @@ class TranslationService {
final trimmed = input.trim(); final trimmed = input.trim();
if (trimmed.isEmpty) return null; if (trimmed.isEmpty) return null;
final cached = _dictionaryLookup(trimmed, direction); final cached = dictionaryLookup(trimmed, direction);
if (cached != null) { if (cached != null) {
return TranslationResult(cached, fromCache: true); return TranslationResult(cached, fromCache: true);
} }