mirror of
https://github.com/koloideal/Casha.git
synced 2026-06-10 10:25:28 +03:00
update
This commit is contained in:
@@ -68,6 +68,7 @@ class AppShell extends ConsumerWidget {
|
|||||||
final s = ref.watch(stringsProvider);
|
final s = ref.watch(stringsProvider);
|
||||||
final idx = _locationToIndex(context);
|
final idx = _locationToIndex(context);
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
|
extendBody: true,
|
||||||
body: child,
|
body: child,
|
||||||
bottomNavigationBar: NavigationBar(
|
bottomNavigationBar: NavigationBar(
|
||||||
selectedIndex: idx,
|
selectedIndex: idx,
|
||||||
|
|||||||
@@ -18,67 +18,49 @@ class SettingsScreen extends ConsumerWidget {
|
|||||||
|
|
||||||
void _confirmClearData(BuildContext context, WidgetRef ref) {
|
void _confirmClearData(BuildContext context, WidgetRef ref) {
|
||||||
final s = ref.read(stringsProvider);
|
final s = ref.read(stringsProvider);
|
||||||
|
|
||||||
showDialog(
|
showDialog(
|
||||||
context: context,
|
context: context,
|
||||||
|
|
||||||
builder: (ctx) => AlertDialog(
|
builder: (ctx) => AlertDialog(
|
||||||
title: Text(s.clearDataConfirm),
|
title: Text(s.clearDataConfirm),
|
||||||
|
|
||||||
content: Text(s.clearDataWarning),
|
content: Text(s.clearDataWarning),
|
||||||
|
|
||||||
actions: [
|
actions: [
|
||||||
TextButton(
|
TextButton(
|
||||||
onPressed: () => Navigator.pop(ctx),
|
onPressed: () => Navigator.pop(ctx),
|
||||||
|
|
||||||
child: Text(s.cancel),
|
child: Text(s.cancel),
|
||||||
),
|
),
|
||||||
|
|
||||||
TextButton(
|
TextButton(
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
Navigator.pop(ctx);
|
Navigator.pop(ctx);
|
||||||
|
|
||||||
showDialog(
|
showDialog(
|
||||||
context: context,
|
context: context,
|
||||||
|
|
||||||
builder: (ctx2) => AlertDialog(
|
builder: (ctx2) => AlertDialog(
|
||||||
title: Text(s.areYouSure),
|
title: Text(s.areYouSure),
|
||||||
|
|
||||||
content: Text(s.allTransactionsWillBeDeleted),
|
content: Text(s.allTransactionsWillBeDeleted),
|
||||||
|
|
||||||
actions: [
|
actions: [
|
||||||
TextButton(
|
TextButton(
|
||||||
onPressed: () => Navigator.pop(ctx2),
|
onPressed: () => Navigator.pop(ctx2),
|
||||||
|
|
||||||
child: Text(s.noKeepThem),
|
child: Text(s.noKeepThem),
|
||||||
),
|
),
|
||||||
|
|
||||||
TextButton(
|
TextButton(
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
ref.read(transactionsProvider.notifier).clearAll();
|
ref.read(transactionsProvider.notifier).clearAll();
|
||||||
|
|
||||||
Navigator.pop(ctx2);
|
Navigator.pop(ctx2);
|
||||||
|
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
SnackBar(content: Text(s.allTransactionsDeleted)),
|
SnackBar(content: Text(s.allTransactionsDeleted)),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|
||||||
style: TextButton.styleFrom(
|
style: TextButton.styleFrom(
|
||||||
foregroundColor: const Color(0xFFE05C6B),
|
foregroundColor: const Color(0xFFE05C6B),
|
||||||
),
|
),
|
||||||
|
|
||||||
child: Text(s.yesDeleteEverything),
|
child: Text(s.yesDeleteEverything),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|
||||||
style: TextButton.styleFrom(
|
style: TextButton.styleFrom(
|
||||||
foregroundColor: const Color(0xFFE05C6B),
|
foregroundColor: const Color(0xFFE05C6B),
|
||||||
),
|
),
|
||||||
|
|
||||||
child: Text(s.delete),
|
child: Text(s.delete),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
@@ -92,25 +74,19 @@ class SettingsScreen extends ConsumerWidget {
|
|||||||
|
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
backgroundColor: Theme.of(context).scaffoldBackgroundColor,
|
backgroundColor: Theme.of(context).scaffoldBackgroundColor,
|
||||||
|
|
||||||
appBar: AppBar(
|
appBar: AppBar(
|
||||||
title: Column(
|
title: Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
|
||||||
children: [
|
children: [
|
||||||
Text(
|
Text(
|
||||||
s.settings,
|
s.settings,
|
||||||
|
|
||||||
style: Theme.of(context).textTheme.titleLarge?.copyWith(
|
style: Theme.of(context).textTheme.titleLarge?.copyWith(
|
||||||
fontWeight: FontWeight.w700,
|
fontWeight: FontWeight.w700,
|
||||||
|
|
||||||
color: Theme.of(context).colorScheme.onSurface,
|
color: Theme.of(context).colorScheme.onSurface,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
||||||
Text(
|
Text(
|
||||||
s.managePreferences,
|
s.managePreferences,
|
||||||
|
|
||||||
style: Theme.of(context).textTheme.bodySmall?.copyWith(
|
style: Theme.of(context).textTheme.bodySmall?.copyWith(
|
||||||
color: Theme.of(context).colorScheme.onSurface.withOpacity(0.6),
|
color: Theme.of(context).colorScheme.onSurface.withOpacity(0.6),
|
||||||
),
|
),
|
||||||
@@ -118,86 +94,56 @@ class SettingsScreen extends ConsumerWidget {
|
|||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
||||||
body: ListView(
|
body: ListView(
|
||||||
physics: const ClampingScrollPhysics(),
|
physics: const ClampingScrollPhysics(),
|
||||||
|
padding: const EdgeInsets.fromLTRB(20, 16, 20, 100),
|
||||||
padding: const EdgeInsets.fromLTRB(20, 16, 20, 40),
|
|
||||||
|
|
||||||
children: [
|
children: [
|
||||||
const ThemeSection(),
|
const ThemeSection(),
|
||||||
|
|
||||||
const SizedBox(height: 16),
|
const SizedBox(height: 16),
|
||||||
|
|
||||||
const HapticSection(),
|
const HapticSection(),
|
||||||
|
|
||||||
const SizedBox(height: 16),
|
const SizedBox(height: 16),
|
||||||
|
|
||||||
const _BiometricSection(),
|
const _BiometricSection(),
|
||||||
|
|
||||||
const LanguageSection(),
|
const LanguageSection(),
|
||||||
|
|
||||||
const SizedBox(height: 16),
|
const SizedBox(height: 16),
|
||||||
|
|
||||||
const CurrencySection(),
|
const CurrencySection(),
|
||||||
|
|
||||||
const SizedBox(height: 16),
|
const SizedBox(height: 16),
|
||||||
|
|
||||||
const AmountFormatSection(),
|
const AmountFormatSection(),
|
||||||
|
|
||||||
const SizedBox(height: 16),
|
const SizedBox(height: 16),
|
||||||
|
|
||||||
const BudgetSection(),
|
const BudgetSection(),
|
||||||
|
|
||||||
const SizedBox(height: 24),
|
const SizedBox(height: 24),
|
||||||
|
|
||||||
Text(
|
Text(
|
||||||
s.dangerZone,
|
s.dangerZone,
|
||||||
|
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontSize: 12,
|
fontSize: 12,
|
||||||
|
|
||||||
letterSpacing: 1.2,
|
letterSpacing: 1.2,
|
||||||
|
|
||||||
color: const Color(0xFFE05C6B).withOpacity(0.8),
|
color: const Color(0xFFE05C6B).withOpacity(0.8),
|
||||||
|
|
||||||
fontWeight: FontWeight.w600,
|
fontWeight: FontWeight.w600,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
||||||
const SizedBox(height: 8),
|
const SizedBox(height: 8),
|
||||||
|
|
||||||
SizedBox(
|
SizedBox(
|
||||||
width: double.infinity,
|
width: double.infinity,
|
||||||
|
|
||||||
child: OutlinedButton.icon(
|
child: OutlinedButton.icon(
|
||||||
onPressed: () => _confirmClearData(context, ref),
|
onPressed: () => _confirmClearData(context, ref),
|
||||||
|
|
||||||
icon: const Icon(Icons.delete_forever, color: Color(0xFFE05C6B)),
|
icon: const Icon(Icons.delete_forever, color: Color(0xFFE05C6B)),
|
||||||
|
|
||||||
label: Text(
|
label: Text(
|
||||||
s.clearAllTransactions,
|
s.clearAllTransactions,
|
||||||
|
|
||||||
style: const TextStyle(color: Color(0xFFE05C6B)),
|
style: const TextStyle(color: Color(0xFFE05C6B)),
|
||||||
),
|
),
|
||||||
|
|
||||||
style: OutlinedButton.styleFrom(
|
style: OutlinedButton.styleFrom(
|
||||||
side: BorderSide(
|
side: BorderSide(
|
||||||
color: const Color(0xFFE05C6B).withOpacity(0.5),
|
color: const Color(0xFFE05C6B).withOpacity(0.5),
|
||||||
),
|
),
|
||||||
|
|
||||||
padding: const EdgeInsets.symmetric(vertical: 14),
|
padding: const EdgeInsets.symmetric(vertical: 14),
|
||||||
|
|
||||||
shape: RoundedRectangleBorder(
|
shape: RoundedRectangleBorder(
|
||||||
borderRadius: BorderRadius.circular(12),
|
borderRadius: BorderRadius.circular(12),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
||||||
const SizedBox(height: 32),
|
const SizedBox(height: 32),
|
||||||
|
|
||||||
const _FooterWidget(),
|
const _FooterWidget(),
|
||||||
|
const SizedBox(height: 8),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
@@ -210,11 +156,9 @@ class _FooterWidget extends StatelessWidget {
|
|||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final isDark = Theme.of(context).brightness == Brightness.dark;
|
final isDark = Theme.of(context).brightness == Brightness.dark;
|
||||||
|
|
||||||
final baseColor = isDark
|
final baseColor = isDark
|
||||||
? Colors.white.withOpacity(0.25)
|
? Colors.white.withOpacity(0.25)
|
||||||
: Colors.black.withOpacity(0.25);
|
: Colors.black.withOpacity(0.25);
|
||||||
|
|
||||||
final emphasisColor = isDark
|
final emphasisColor = isDark
|
||||||
? Colors.white.withOpacity(0.35)
|
? Colors.white.withOpacity(0.35)
|
||||||
: Colors.black.withOpacity(0.35);
|
: Colors.black.withOpacity(0.35);
|
||||||
@@ -222,33 +166,24 @@ class _FooterWidget extends StatelessWidget {
|
|||||||
return Center(
|
return Center(
|
||||||
child: RichText(
|
child: RichText(
|
||||||
textAlign: TextAlign.center,
|
textAlign: TextAlign.center,
|
||||||
|
|
||||||
text: TextSpan(
|
text: TextSpan(
|
||||||
style: TextStyle(fontSize: 13, color: baseColor),
|
style: TextStyle(fontSize: 13, color: baseColor),
|
||||||
|
|
||||||
children: [
|
children: [
|
||||||
TextSpan(
|
TextSpan(
|
||||||
text: 'casha',
|
text: 'casha',
|
||||||
|
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontWeight: FontWeight.bold,
|
fontWeight: FontWeight.bold,
|
||||||
|
|
||||||
color: emphasisColor,
|
color: emphasisColor,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
||||||
const TextSpan(
|
const TextSpan(
|
||||||
text: ' powered with ❤️ by ',
|
text: ' powered with ❤️ by ',
|
||||||
|
|
||||||
style: TextStyle(fontStyle: FontStyle.italic),
|
style: TextStyle(fontStyle: FontStyle.italic),
|
||||||
),
|
),
|
||||||
|
|
||||||
TextSpan(
|
TextSpan(
|
||||||
text: 'kolo',
|
text: 'kolo',
|
||||||
|
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontWeight: FontWeight.bold,
|
fontWeight: FontWeight.bold,
|
||||||
|
|
||||||
color: emphasisColor,
|
color: emphasisColor,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -268,134 +203,107 @@ class _BiometricSection extends ConsumerStatefulWidget {
|
|||||||
|
|
||||||
class _BiometricSectionState extends ConsumerState<_BiometricSection> {
|
class _BiometricSectionState extends ConsumerState<_BiometricSection> {
|
||||||
bool _available = false;
|
bool _available = false;
|
||||||
|
|
||||||
bool _enabled = false;
|
bool _enabled = false;
|
||||||
|
|
||||||
bool _loading = true;
|
bool _loading = true;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
|
|
||||||
_load();
|
_load();
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> _load() async {
|
Future _load() async {
|
||||||
final available = await BiometricService.isAvailable();
|
final available = await BiometricService.isAvailable();
|
||||||
|
|
||||||
final enabled = await BiometricService.isEnabled();
|
final enabled = await BiometricService.isEnabled();
|
||||||
|
|
||||||
if (mounted) {
|
if (mounted) {
|
||||||
setState(() {
|
setState(() {
|
||||||
_available = available;
|
_available = available;
|
||||||
|
|
||||||
_enabled = enabled;
|
_enabled = enabled;
|
||||||
|
|
||||||
_loading = false;
|
_loading = false;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> _onToggle(bool val) async {
|
Future _onToggle(bool val) async {
|
||||||
if (val) {
|
if (val) {
|
||||||
final ok = await BiometricService.authenticate();
|
final ok = await BiometricService.authenticate();
|
||||||
|
|
||||||
if (!ok) return;
|
if (!ok) return;
|
||||||
|
|
||||||
HapticService.light();
|
HapticService.light();
|
||||||
}
|
}
|
||||||
|
|
||||||
await BiometricService.setEnabled(val);
|
await BiometricService.setEnabled(val);
|
||||||
|
|
||||||
if (mounted) setState(() => _enabled = val);
|
if (mounted) setState(() => _enabled = val);
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
if (_loading || !_available) return const SizedBox.shrink();
|
|
||||||
|
|
||||||
final s = ref.watch(stringsProvider);
|
final s = ref.watch(stringsProvider);
|
||||||
|
|
||||||
final isDark = Theme.of(context).brightness == Brightness.dark;
|
final isDark = Theme.of(context).brightness == Brightness.dark;
|
||||||
|
|
||||||
return Column(
|
return Visibility(
|
||||||
children: [
|
visible: !_loading && _available,
|
||||||
Container(
|
maintainSize: true,
|
||||||
padding: const EdgeInsets.all(20),
|
maintainAnimation: true,
|
||||||
|
maintainState: true,
|
||||||
decoration: BoxDecoration(
|
child: Column(
|
||||||
color: Theme.of(context).colorScheme.surface,
|
children: [
|
||||||
|
Container(
|
||||||
borderRadius: BorderRadius.circular(16),
|
padding: const EdgeInsets.all(20),
|
||||||
|
decoration: BoxDecoration(
|
||||||
border: isDark
|
color: Theme.of(context).colorScheme.surface,
|
||||||
? null
|
borderRadius: BorderRadius.circular(16),
|
||||||
: Border.all(color: const Color(0xFFDDDDEE), width: 1),
|
border: isDark
|
||||||
),
|
? null
|
||||||
|
: Border.all(color: const Color(0xFFDDDDEE), width: 1),
|
||||||
child: Row(
|
),
|
||||||
children: [
|
child: Row(
|
||||||
Container(
|
children: [
|
||||||
padding: const EdgeInsets.all(10),
|
Container(
|
||||||
|
padding: const EdgeInsets.all(10),
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: AppColors.accent.withOpacity(0.15),
|
color: AppColors.accent.withOpacity(0.15),
|
||||||
|
borderRadius: BorderRadius.circular(12),
|
||||||
borderRadius: BorderRadius.circular(12),
|
),
|
||||||
|
child: const Icon(
|
||||||
|
Icons.fingerprint,
|
||||||
|
color: AppColors.accent,
|
||||||
|
size: 20,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
|
const SizedBox(width: 12),
|
||||||
child: const Icon(
|
Expanded(
|
||||||
Icons.fingerprint,
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
color: AppColors.accent,
|
children: [
|
||||||
|
Text(
|
||||||
size: 20,
|
s.biometricLock,
|
||||||
),
|
style: Theme.of(context).textTheme.titleMedium
|
||||||
),
|
?.copyWith(
|
||||||
|
fontWeight: FontWeight.w600,
|
||||||
const SizedBox(width: 12),
|
color: Theme.of(context).colorScheme.onSurface,
|
||||||
|
),
|
||||||
Expanded(
|
|
||||||
child: Column(
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
|
||||||
|
|
||||||
children: [
|
|
||||||
Text(
|
|
||||||
s.biometricLock,
|
|
||||||
|
|
||||||
style: Theme.of(context).textTheme.titleMedium?.copyWith(
|
|
||||||
fontWeight: FontWeight.w600,
|
|
||||||
|
|
||||||
color: Theme.of(context).colorScheme.onSurface,
|
|
||||||
),
|
),
|
||||||
),
|
Text(
|
||||||
|
s.requireFingerprint,
|
||||||
Text(
|
style: Theme.of(context).textTheme.bodySmall?.copyWith(
|
||||||
s.requireFingerprint,
|
color: Theme.of(
|
||||||
|
context,
|
||||||
style: Theme.of(context).textTheme.bodySmall?.copyWith(
|
).colorScheme.onSurface.withOpacity(0.6),
|
||||||
color: Theme.of(
|
),
|
||||||
context,
|
|
||||||
).colorScheme.onSurface.withOpacity(0.6),
|
|
||||||
),
|
),
|
||||||
),
|
],
|
||||||
],
|
),
|
||||||
),
|
),
|
||||||
),
|
Switch(
|
||||||
|
value: _enabled,
|
||||||
Switch(
|
onChanged: _onToggle,
|
||||||
value: _enabled,
|
activeThumbColor: const Color(0xFF7C6DED),
|
||||||
|
),
|
||||||
onChanged: _onToggle,
|
],
|
||||||
|
),
|
||||||
activeThumbColor: const Color(0xFF7C6DED),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
),
|
const SizedBox(height: 16),
|
||||||
|
],
|
||||||
const SizedBox(height: 16),
|
),
|
||||||
],
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user