mirror of
https://github.com/koloideal/Casha.git
synced 2026-06-10 10:25:28 +03:00
update
This commit is contained in:
@@ -36,7 +36,7 @@ class BalanceCard extends ConsumerStatefulWidget {
|
||||
final GradientType? previewGradientType;
|
||||
final String? accountName;
|
||||
final CardColors? accountColors;
|
||||
|
||||
|
||||
const BalanceCard({
|
||||
super.key,
|
||||
required this.balance,
|
||||
@@ -114,13 +114,7 @@ class BalanceCardState extends ConsumerState<BalanceCard>
|
||||
center: Alignment.center,
|
||||
startAngle: 0.0,
|
||||
endAngle: 3.14159 * 2,
|
||||
colors: [
|
||||
primary,
|
||||
secondary,
|
||||
colorDark,
|
||||
secondary,
|
||||
primary,
|
||||
],
|
||||
colors: [primary, secondary, colorDark, secondary, primary],
|
||||
stops: const [0.0, 0.25, 0.5, 0.75, 1.0],
|
||||
);
|
||||
case GradientType.solid:
|
||||
@@ -136,14 +130,14 @@ class BalanceCardState extends ConsumerState<BalanceCard>
|
||||
final s = ref.watch(stringsProvider);
|
||||
final rates = ref.read(exchangeRateServiceProvider);
|
||||
final fmt = ref.watch(amountFormatProvider);
|
||||
|
||||
|
||||
// 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;
|
||||
final secondary = widget.previewSecondary ?? savedColors.secondary;
|
||||
final gradientType = widget.previewGradientType ?? savedColors.gradientType;
|
||||
|
||||
|
||||
final allCurrencies = [
|
||||
('USD', r'$'),
|
||||
('EUR', '€'),
|
||||
@@ -154,6 +148,17 @@ class BalanceCardState extends ConsumerState<BalanceCard>
|
||||
.where((c) => c.$1 != widget.currencyInfo.code)
|
||||
.toList();
|
||||
|
||||
final textColorMode = ref.watch(cardTextColorProvider);
|
||||
final Color onCard;
|
||||
switch (textColorMode) {
|
||||
case CardTextColorMode.white:
|
||||
onCard = Colors.white;
|
||||
case CardTextColorMode.black:
|
||||
onCard = Colors.black;
|
||||
case CardTextColorMode.adaptive:
|
||||
onCard = primary.computeLuminance() > 0.3 ? Colors.black : Colors.white;
|
||||
}
|
||||
|
||||
return GestureDetector(
|
||||
onLongPress: () {
|
||||
HapticService.heavy();
|
||||
@@ -199,7 +204,7 @@ class BalanceCardState extends ConsumerState<BalanceCard>
|
||||
Text(
|
||||
widget.accountName!,
|
||||
style: TextStyle(
|
||||
color: Colors.white.withOpacity(0.7),
|
||||
color: onCard.withOpacity(0.7),
|
||||
fontSize: 12,
|
||||
fontWeight: FontWeight.w500,
|
||||
letterSpacing: 0.3,
|
||||
@@ -229,7 +234,7 @@ class BalanceCardState extends ConsumerState<BalanceCard>
|
||||
style: TextStyle(
|
||||
fontSize: 11,
|
||||
letterSpacing: 1.5,
|
||||
color: Colors.white.withOpacity(0.6),
|
||||
color: onCard.withOpacity(0.6),
|
||||
),
|
||||
),
|
||||
if (widget.accountName == null)
|
||||
@@ -243,10 +248,10 @@ class BalanceCardState extends ConsumerState<BalanceCard>
|
||||
fmt,
|
||||
widget.currencyInfo.symbol,
|
||||
),
|
||||
style: const TextStyle(
|
||||
style: TextStyle(
|
||||
fontSize: 48,
|
||||
fontWeight: FontWeight.w700,
|
||||
color: Colors.white,
|
||||
color: onCard,
|
||||
),
|
||||
maxLines: 1,
|
||||
),
|
||||
@@ -259,7 +264,7 @@ class BalanceCardState extends ConsumerState<BalanceCard>
|
||||
Container(
|
||||
width: 1,
|
||||
height: 70,
|
||||
color: Colors.white.withOpacity(0.15),
|
||||
color: onCard.withOpacity(0.15),
|
||||
),
|
||||
const SizedBox(width: 16),
|
||||
SizedBox(
|
||||
@@ -274,7 +279,9 @@ class BalanceCardState extends ConsumerState<BalanceCard>
|
||||
c.$1,
|
||||
);
|
||||
return Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 3),
|
||||
padding: const EdgeInsets.symmetric(
|
||||
vertical: 3,
|
||||
),
|
||||
child: FittedBox(
|
||||
fit: BoxFit.scaleDown,
|
||||
alignment: Alignment.centerLeft,
|
||||
@@ -283,7 +290,7 @@ class BalanceCardState extends ConsumerState<BalanceCard>
|
||||
style: TextStyle(
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.w500,
|
||||
color: Colors.white.withOpacity(0.65),
|
||||
color: onCard.withOpacity(0.65),
|
||||
),
|
||||
maxLines: 1,
|
||||
),
|
||||
@@ -305,7 +312,7 @@ class BalanceCardState extends ConsumerState<BalanceCard>
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
fontSize: 9,
|
||||
color: Colors.white.withOpacity(0.18),
|
||||
color: onCard.withOpacity(0.18),
|
||||
letterSpacing: 0.6,
|
||||
),
|
||||
),
|
||||
|
||||
@@ -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