mirror of
https://github.com/koloideal/Casha.git
synced 2026-06-10 10:25:28 +03:00
update
This commit is contained in:
@@ -106,6 +106,34 @@ final themeProvider = StateNotifierProvider<ThemeModeNotifier, ThemeMode>((
|
||||
return ThemeModeNotifier(prefs);
|
||||
});
|
||||
|
||||
enum CardTextColorMode { white, adaptive, black }
|
||||
|
||||
class CardTextColorNotifier extends StateNotifier<CardTextColorMode> {
|
||||
static const _key = 'card_text_color';
|
||||
final SharedPreferences _prefs;
|
||||
|
||||
CardTextColorNotifier(this._prefs)
|
||||
: super(_fromString(_prefs.getString(_key)));
|
||||
|
||||
static CardTextColorMode _fromString(String? value) {
|
||||
return CardTextColorMode.values.firstWhere(
|
||||
(e) => e.name == value,
|
||||
orElse: () => CardTextColorMode.adaptive,
|
||||
);
|
||||
}
|
||||
|
||||
void set(CardTextColorMode mode) {
|
||||
state = mode;
|
||||
_prefs.setString(_key, mode.name);
|
||||
}
|
||||
}
|
||||
|
||||
final cardTextColorProvider =
|
||||
StateNotifierProvider<CardTextColorNotifier, CardTextColorMode>((ref) {
|
||||
final prefs = ref.watch(sharedPreferencesProvider);
|
||||
return CardTextColorNotifier(prefs);
|
||||
});
|
||||
|
||||
final exchangeRateServiceProvider = Provider<ExchangeRateService>((ref) {
|
||||
final prefs = ref.watch(sharedPreferencesProvider);
|
||||
return ExchangeRateService(prefs);
|
||||
|
||||
@@ -7,6 +7,7 @@ import '../../core/services/haptic_service.dart';
|
||||
import '../dashboard/provider.dart';
|
||||
import 'provider.dart';
|
||||
import 'widgets/theme_section.dart';
|
||||
import 'widgets/card_text_color_section.dart';
|
||||
import 'widgets/haptic_section.dart';
|
||||
import 'widgets/language_section.dart';
|
||||
import 'widgets/currency_section.dart';
|
||||
@@ -45,9 +46,11 @@ class SettingsScreen extends ConsumerWidget {
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () async {
|
||||
final biometricEnabled = await BiometricService.isEnabled();
|
||||
final biometricEnabled =
|
||||
await BiometricService.isEnabled();
|
||||
if (biometricEnabled) {
|
||||
final authenticated = await BiometricService.authenticate();
|
||||
final authenticated =
|
||||
await BiometricService.authenticate();
|
||||
if (!authenticated) {
|
||||
Navigator.pop(ctx2);
|
||||
return;
|
||||
@@ -55,7 +58,7 @@ class SettingsScreen extends ConsumerWidget {
|
||||
}
|
||||
ref.read(transactionsProvider.notifier).clearAll();
|
||||
Navigator.pop(ctx2);
|
||||
|
||||
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
content: Row(
|
||||
@@ -122,6 +125,8 @@ class SettingsScreen extends ConsumerWidget {
|
||||
children: [
|
||||
const ThemeSection(),
|
||||
const SizedBox(height: 16),
|
||||
const CardTextColorSection(),
|
||||
const SizedBox(height: 16),
|
||||
const HapticSection(),
|
||||
const SizedBox(height: 16),
|
||||
const _BiometricSection(),
|
||||
|
||||
@@ -0,0 +1,160 @@
|
||||
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 CardTextColorSection extends ConsumerWidget {
|
||||
const CardTextColorSection({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final s = ref.watch(stringsProvider);
|
||||
final textColorMode = ref.watch(cardTextColorProvider);
|
||||
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: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
Container(
|
||||
padding: const EdgeInsets.all(10),
|
||||
decoration: BoxDecoration(
|
||||
color: AppColors.accent.withOpacity(0.15),
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
),
|
||||
child: const Icon(
|
||||
Icons.text_fields_rounded,
|
||||
color: AppColors.accent,
|
||||
size: 20,
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 12),
|
||||
Text(
|
||||
s.cardTextColor,
|
||||
style: Theme.of(context).textTheme.titleMedium?.copyWith(
|
||||
fontWeight: FontWeight.w600,
|
||||
color: Theme.of(context).colorScheme.onSurface,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: _CardTextColorOption(
|
||||
label: s.cardTextColorWhite,
|
||||
icon: Icons.brightness_high_rounded,
|
||||
isSelected: textColorMode == CardTextColorMode.white,
|
||||
onTap: () => ref
|
||||
.read(cardTextColorProvider.notifier)
|
||||
.set(CardTextColorMode.white),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
Expanded(
|
||||
child: _CardTextColorOption(
|
||||
label: s.cardTextColorAdaptive,
|
||||
icon: Icons.auto_awesome_rounded,
|
||||
isSelected: textColorMode == CardTextColorMode.adaptive,
|
||||
onTap: () => ref
|
||||
.read(cardTextColorProvider.notifier)
|
||||
.set(CardTextColorMode.adaptive),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
Expanded(
|
||||
child: _CardTextColorOption(
|
||||
label: s.cardTextColorBlack,
|
||||
icon: Icons.brightness_low_rounded,
|
||||
isSelected: textColorMode == CardTextColorMode.black,
|
||||
onTap: () => ref
|
||||
.read(cardTextColorProvider.notifier)
|
||||
.set(CardTextColorMode.black),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _CardTextColorOption extends StatelessWidget {
|
||||
final String label;
|
||||
final IconData icon;
|
||||
final bool isSelected;
|
||||
final VoidCallback onTap;
|
||||
|
||||
const _CardTextColorOption({
|
||||
required this.label,
|
||||
required this.icon,
|
||||
required this.isSelected,
|
||||
required this.onTap,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final isDark = Theme.of(context).brightness == Brightness.dark;
|
||||
|
||||
return GestureDetector(
|
||||
onTap: onTap,
|
||||
child: AnimatedContainer(
|
||||
duration: const Duration(milliseconds: 200),
|
||||
padding: const EdgeInsets.symmetric(vertical: 12),
|
||||
decoration: BoxDecoration(
|
||||
color: isSelected
|
||||
? AppColors.accent.withOpacity(0.15)
|
||||
: (isDark
|
||||
? Colors.white.withOpacity(0.05)
|
||||
: Colors.black.withOpacity(0.03)),
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
border: Border.all(
|
||||
color: isSelected
|
||||
? AppColors.accent
|
||||
: (isDark
|
||||
? Colors.white.withOpacity(0.1)
|
||||
: Colors.black.withOpacity(0.08)),
|
||||
width: isSelected ? 2 : 1,
|
||||
),
|
||||
),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Icon(
|
||||
icon,
|
||||
color: isSelected
|
||||
? AppColors.accent
|
||||
: Theme.of(context).colorScheme.onSurface.withOpacity(0.5),
|
||||
size: 22,
|
||||
),
|
||||
const SizedBox(height: 6),
|
||||
Text(
|
||||
label,
|
||||
style: TextStyle(
|
||||
fontSize: 11,
|
||||
fontWeight: isSelected ? FontWeight.w600 : FontWeight.normal,
|
||||
color: isSelected
|
||||
? AppColors.accent
|
||||
: Theme.of(context).colorScheme.onSurface.withOpacity(0.6),
|
||||
),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user