This commit is contained in:
2026-03-25 14:45:58 +03:00
parent b617e3acf6
commit d2278523bd
7 changed files with 148 additions and 3 deletions
+22
View File
@@ -165,6 +165,28 @@ class HapticNotifier extends StateNotifier<bool> {
}
}
final showCurrencyConversionsProvider =
StateNotifierProvider<ShowCurrencyConversionsNotifier, bool>((ref) {
return ShowCurrencyConversionsNotifier();
});
class ShowCurrencyConversionsNotifier extends StateNotifier<bool> {
ShowCurrencyConversionsNotifier() : super(true) {
_load();
}
Future<void> _load() async {
final prefs = await SharedPreferences.getInstance();
state = prefs.getBool('show_currency_conversions') ?? true;
}
Future<void> toggle(bool value) async {
final prefs = await SharedPreferences.getInstance();
await prefs.setBool('show_currency_conversions', value);
state = value;
}
}
final exportProvider = Provider<ExportService>((ref) {
return ExportService(ref);
});
+3
View File
@@ -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),
@@ -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),
),
],
),
);
}
}