From d2278523bdc7737176f794032de0680fa7465be7 Mon Sep 17 00:00:00 2001 From: kolo Date: Wed, 25 Mar 2026 14:45:58 +0300 Subject: [PATCH] update --- lib/core/l10n/app_strings.dart | 5 ++ .../account_editor_overlay.dart | 20 ++++++ .../account_editor_overlay/delete_dialog.dart | 25 ++++++- .../dashboard/widgets/balance_card.dart | 4 +- lib/features/settings/provider.dart | 22 ++++++ lib/features/settings/screen.dart | 3 + .../widgets/currency_conversions_section.dart | 72 +++++++++++++++++++ 7 files changed, 148 insertions(+), 3 deletions(-) create mode 100644 lib/features/settings/widgets/currency_conversions_section.dart diff --git a/lib/core/l10n/app_strings.dart b/lib/core/l10n/app_strings.dart index 23318aa..9b39b9c 100644 --- a/lib/core/l10n/app_strings.dart +++ b/lib/core/l10n/app_strings.dart @@ -184,5 +184,10 @@ class AppStrings { String get accountsInfoLimit => _ru ? 'Максимум 5 счетов.' : 'Maximum 5 accounts.'; + String get currencyConversions => + _ru ? 'Конвертация валют' : 'Currency conversions'; + String get showConversionsOnCard => + _ru ? 'Показывать на карточке' : 'Show on balance card'; + String get dateLocale => _ru ? 'ru_RU' : 'en_US'; } diff --git a/lib/features/dashboard/widgets/account_editor_overlay/account_editor_overlay.dart b/lib/features/dashboard/widgets/account_editor_overlay/account_editor_overlay.dart index 1ce1a48..803896b 100644 --- a/lib/features/dashboard/widgets/account_editor_overlay/account_editor_overlay.dart +++ b/lib/features/dashboard/widgets/account_editor_overlay/account_editor_overlay.dart @@ -368,6 +368,16 @@ class _AccountEditorOverlayState extends State { decoration: BoxDecoration( color: Theme.of(widget.context).colorScheme.surface, shape: BoxShape.circle, + border: + Theme.of(widget.context).brightness == + Brightness.dark + ? Border.all( + color: Theme.of( + widget.context, + ).colorScheme.onSurface.withOpacity(0.3), + width: 1, + ) + : null, boxShadow: [ BoxShadow( color: Colors.red.withOpacity(0.2), @@ -393,6 +403,16 @@ class _AccountEditorOverlayState extends State { decoration: BoxDecoration( color: Theme.of(widget.context).colorScheme.surface, shape: BoxShape.circle, + border: + Theme.of(widget.context).brightness == + Brightness.dark + ? Border.all( + color: Theme.of( + widget.context, + ).colorScheme.onSurface.withOpacity(0.3), + width: 1, + ) + : null, boxShadow: [ BoxShadow( color: Colors.black.withOpacity(0.3), diff --git a/lib/features/dashboard/widgets/account_editor_overlay/delete_dialog.dart b/lib/features/dashboard/widgets/account_editor_overlay/delete_dialog.dart index be7570d..add2984 100644 --- a/lib/features/dashboard/widgets/account_editor_overlay/delete_dialog.dart +++ b/lib/features/dashboard/widgets/account_editor_overlay/delete_dialog.dart @@ -34,7 +34,20 @@ class AccountDeleteDialog extends ConsumerWidget { 'Are you sure you want to delete this account? All associated transactions will also be permanently deleted.', ), actions: [ - TextButton(onPressed: onCancel, child: const Text('Cancel')), + TextButton( + onPressed: onCancel, + style: Theme.of(context).brightness == Brightness.dark + ? TextButton.styleFrom( + side: BorderSide( + color: Theme.of( + context, + ).colorScheme.onSurface.withOpacity(0.3), + width: 1, + ), + ) + : null, + child: const Text('Cancel'), + ), TextButton( onPressed: () async { if (editingAccount == null) return; @@ -57,6 +70,16 @@ class AccountDeleteDialog extends ConsumerWidget { HapticService.medium(); } }, + style: Theme.of(context).brightness == Brightness.dark + ? TextButton.styleFrom( + side: BorderSide( + color: Theme.of( + context, + ).colorScheme.onSurface.withOpacity(0.3), + width: 1, + ), + ) + : null, child: const Text( 'Delete', style: TextStyle(color: Colors.red), diff --git a/lib/features/dashboard/widgets/balance_card.dart b/lib/features/dashboard/widgets/balance_card.dart index ac1c2c0..a406338 100644 --- a/lib/features/dashboard/widgets/balance_card.dart +++ b/lib/features/dashboard/widgets/balance_card.dart @@ -130,8 +130,8 @@ class BalanceCardState extends ConsumerState final s = ref.watch(stringsProvider); final rates = ref.read(exchangeRateServiceProvider); final fmt = ref.watch(amountFormatProvider); + final showConversions = ref.watch(showCurrencyConversionsProvider); - // Use account-specific colors if provided, otherwise use global colors final globalColors = ref.watch(cardColorsProvider); final savedColors = widget.accountColors ?? globalColors; final primary = widget.previewPrimary ?? savedColors.primary; @@ -259,7 +259,7 @@ class BalanceCardState extends ConsumerState ], ), ), - if (widget.balance != 0) ...[ + if (widget.balance != 0 && showConversions) ...[ const SizedBox(width: 16), Container( width: 1, diff --git a/lib/features/settings/provider.dart b/lib/features/settings/provider.dart index f3ca27b..01f6bae 100644 --- a/lib/features/settings/provider.dart +++ b/lib/features/settings/provider.dart @@ -165,6 +165,28 @@ class HapticNotifier extends StateNotifier { } } +final showCurrencyConversionsProvider = + StateNotifierProvider((ref) { + return ShowCurrencyConversionsNotifier(); + }); + +class ShowCurrencyConversionsNotifier extends StateNotifier { + ShowCurrencyConversionsNotifier() : super(true) { + _load(); + } + + Future _load() async { + final prefs = await SharedPreferences.getInstance(); + state = prefs.getBool('show_currency_conversions') ?? true; + } + + Future toggle(bool value) async { + final prefs = await SharedPreferences.getInstance(); + await prefs.setBool('show_currency_conversions', value); + state = value; + } +} + final exportProvider = Provider((ref) { return ExportService(ref); }); diff --git a/lib/features/settings/screen.dart b/lib/features/settings/screen.dart index 7dcac72..859e7fb 100644 --- a/lib/features/settings/screen.dart +++ b/lib/features/settings/screen.dart @@ -9,6 +9,7 @@ import 'provider.dart'; import 'widgets/theme_section.dart'; import 'widgets/card_text_color_section.dart'; import 'widgets/haptic_section.dart'; +import 'widgets/currency_conversions_section.dart'; import 'widgets/language_section.dart'; import 'widgets/currency_section.dart'; import 'widgets/amount_format_section.dart'; @@ -129,6 +130,8 @@ class SettingsScreen extends ConsumerWidget { const SizedBox(height: 16), const HapticSection(), const SizedBox(height: 16), + const CurrencyConversionsSection(), + const SizedBox(height: 16), const _BiometricSection(), const LanguageSection(), const SizedBox(height: 16), diff --git a/lib/features/settings/widgets/currency_conversions_section.dart b/lib/features/settings/widgets/currency_conversions_section.dart new file mode 100644 index 0000000..b1c0dae --- /dev/null +++ b/lib/features/settings/widgets/currency_conversions_section.dart @@ -0,0 +1,72 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_riverpod/flutter_riverpod.dart'; +import '../../../core/constants.dart'; +import '../../../core/l10n/locale_provider.dart'; +import '../provider.dart'; + +class CurrencyConversionsSection extends ConsumerWidget { + const CurrencyConversionsSection({super.key}); + + @override + Widget build(BuildContext context, WidgetRef ref) { + final s = ref.watch(stringsProvider); + final enabled = ref.watch(showCurrencyConversionsProvider); + 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: Row( + children: [ + Container( + padding: const EdgeInsets.all(10), + decoration: BoxDecoration( + color: AppColors.accent.withOpacity(0.15), + borderRadius: BorderRadius.circular(12), + ), + child: const Icon( + Icons.currency_exchange_rounded, + color: AppColors.accent, + size: 20, + ), + ), + const SizedBox(width: 12), + Expanded( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + s.currencyConversions, + style: Theme.of(context).textTheme.titleMedium?.copyWith( + fontWeight: FontWeight.w600, + color: Theme.of(context).colorScheme.onSurface, + ), + ), + Text( + s.showConversionsOnCard, + style: Theme.of(context).textTheme.bodySmall?.copyWith( + color: Theme.of( + context, + ).colorScheme.onSurface.withOpacity(0.6), + ), + ), + ], + ), + ), + Switch( + value: enabled, + onChanged: (val) => + ref.read(showCurrencyConversionsProvider.notifier).toggle(val), + activeThumbColor: const Color(0xFF7C6DED), + ), + ], + ), + ); + } +}