mirror of
https://github.com/koloideal/Casha.git
synced 2026-06-10 10:25:28 +03:00
update
This commit is contained in:
@@ -1,10 +1,12 @@
|
||||
import 'dart:io';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:path_provider/path_provider.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
import '../../core/constants.dart';
|
||||
import '../../core/services/haptic_service.dart';
|
||||
import '../../shared/services/exchange_rate_service.dart';
|
||||
import '../../shared/utils/currency_utils.dart';
|
||||
import '../../shared/providers/amount_format_provider.dart';
|
||||
@@ -103,6 +105,27 @@ final ratesInitProvider = FutureProvider<void>((ref) async {
|
||||
await ref.read(exchangeRateServiceProvider).fetchRates();
|
||||
});
|
||||
|
||||
final hapticEnabledProvider = StateNotifierProvider<HapticNotifier, bool>((ref) {
|
||||
return HapticNotifier();
|
||||
});
|
||||
|
||||
class HapticNotifier extends StateNotifier<bool> {
|
||||
HapticNotifier() : super(true) {
|
||||
_load();
|
||||
}
|
||||
|
||||
Future<void> _load() async {
|
||||
state = HapticService.isEnabled;
|
||||
}
|
||||
|
||||
Future<void> toggle(bool value) async {
|
||||
await HapticService.setEnabled(value);
|
||||
state = value;
|
||||
// Give tactile confirmation when turning ON
|
||||
if (value) HapticFeedback.mediumImpact();
|
||||
}
|
||||
}
|
||||
|
||||
final exportProvider = Provider<ExportService>((ref) {
|
||||
return ExportService(ref);
|
||||
});
|
||||
|
||||
@@ -5,6 +5,7 @@ import 'package:go_router/go_router.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
import '../../core/constants.dart';
|
||||
import '../../core/services/biometric_service.dart';
|
||||
import '../../core/services/haptic_service.dart';
|
||||
import '../../shared/utils/currency_utils.dart';
|
||||
import '../../shared/providers/amount_format_provider.dart';
|
||||
import '../dashboard/provider.dart';
|
||||
@@ -191,6 +192,64 @@ class _SettingsScreenState extends ConsumerState<SettingsScreen> {
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
|
||||
Consumer(
|
||||
builder: (context, ref, _) {
|
||||
final enabled = ref.watch(hapticEnabledProvider);
|
||||
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.vibration_rounded,
|
||||
color: AppColors.accent,
|
||||
size: 20,
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 12),
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
'Haptic Feedback',
|
||||
style: Theme.of(context).textTheme.titleMedium?.copyWith(
|
||||
fontWeight: FontWeight.w600,
|
||||
color: Theme.of(context).colorScheme.onSurface,
|
||||
),
|
||||
),
|
||||
Text(
|
||||
'Vibration on interactions',
|
||||
style: Theme.of(context).textTheme.bodySmall?.copyWith(
|
||||
color: Theme.of(context).colorScheme.onSurface.withOpacity(0.6),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
Switch(
|
||||
value: enabled,
|
||||
onChanged: (val) => ref.read(hapticEnabledProvider.notifier).toggle(val),
|
||||
activeColor: const Color(0xFF7C6DED),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
|
||||
const _BiometricSection(),
|
||||
|
||||
Container(
|
||||
@@ -584,6 +643,7 @@ class _BiometricSectionState extends State<_BiometricSection> {
|
||||
if (val) {
|
||||
final ok = await BiometricService.authenticate();
|
||||
if (!ok) return;
|
||||
HapticService.light();
|
||||
}
|
||||
await BiometricService.setEnabled(val);
|
||||
if (mounted) setState(() => _enabled = val);
|
||||
|
||||
Reference in New Issue
Block a user