mirror of
https://github.com/koloideal/Casha.git
synced 2026-06-10 10:25:28 +03:00
update
This commit is contained in:
@@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
import '../../core/l10n/locale_provider.dart';
|
||||
import '../../core/services/card_color_service.dart';
|
||||
import '../../core/services/haptic_service.dart';
|
||||
import '../settings/provider.dart';
|
||||
@@ -115,6 +116,7 @@ class _DashboardScreenState extends ConsumerState<DashboardScreen> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final s = ref.watch(stringsProvider);
|
||||
final balance = ref.watch(totalBalanceProvider);
|
||||
final income = ref.watch(totalIncomeProvider);
|
||||
final expense = ref.watch(totalExpenseProvider);
|
||||
@@ -131,7 +133,7 @@ class _DashboardScreenState extends ConsumerState<DashboardScreen> {
|
||||
scrolledUnderElevation: 0,
|
||||
titleSpacing: 20,
|
||||
title: Text(
|
||||
'Casha',
|
||||
s.appTitle,
|
||||
style: Theme.of(context).textTheme.headlineMedium?.copyWith(
|
||||
fontWeight: FontWeight.w800,
|
||||
color: Theme.of(context).colorScheme.onSurface,
|
||||
@@ -143,7 +145,7 @@ class _DashboardScreenState extends ConsumerState<DashboardScreen> {
|
||||
padding: const EdgeInsets.only(right: 20),
|
||||
child: Center(
|
||||
child: Text(
|
||||
DateFormat('MMMM yyyy').format(DateTime.now()),
|
||||
DateFormat('MMMM yyyy', s.dateLocale).format(DateTime.now()),
|
||||
style: Theme.of(context).textTheme.bodyMedium?.copyWith(
|
||||
color: Theme.of(context).colorScheme.onSurface.withOpacity(0.5),
|
||||
fontWeight: FontWeight.w500,
|
||||
@@ -161,7 +163,7 @@ class _DashboardScreenState extends ConsumerState<DashboardScreen> {
|
||||
backgroundColor: const Color(0xFF7C6DED),
|
||||
foregroundColor: Colors.white,
|
||||
icon: const Icon(Icons.add),
|
||||
label: const Text('Add', style: TextStyle(fontWeight: FontWeight.w600)),
|
||||
label: Text(s.add, style: const TextStyle(fontWeight: FontWeight.w600)),
|
||||
),
|
||||
floatingActionButtonLocation: FloatingActionButtonLocation.endFloat,
|
||||
body: SafeArea(
|
||||
@@ -188,6 +190,7 @@ class _DashboardScreenState extends ConsumerState<DashboardScreen> {
|
||||
income: income,
|
||||
expense: expense,
|
||||
currencyInfo: currencyInfo,
|
||||
strings: s,
|
||||
),
|
||||
if (budget != null) ...[
|
||||
const SizedBox(height: 16),
|
||||
@@ -195,6 +198,7 @@ class _DashboardScreenState extends ConsumerState<DashboardScreen> {
|
||||
spent: monthExpense,
|
||||
budget: budget,
|
||||
currencyInfo: currencyInfo,
|
||||
strings: s,
|
||||
),
|
||||
],
|
||||
const SizedBox(height: 24),
|
||||
@@ -203,12 +207,13 @@ class _DashboardScreenState extends ConsumerState<DashboardScreen> {
|
||||
focusNode: _searchFocusNode,
|
||||
onTap: _scrollToSearch,
|
||||
ref: ref,
|
||||
strings: s,
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
const FilterChips(),
|
||||
FilterChips(strings: s),
|
||||
const SizedBox(height: 20),
|
||||
Text(
|
||||
'Transactions',
|
||||
s.transactions,
|
||||
style: Theme.of(context).textTheme.titleMedium?.copyWith(
|
||||
fontWeight: FontWeight.w600,
|
||||
color: Theme.of(context).colorScheme.onSurface,
|
||||
@@ -220,9 +225,9 @@ class _DashboardScreenState extends ConsumerState<DashboardScreen> {
|
||||
),
|
||||
),
|
||||
if (recent.isEmpty)
|
||||
const SliverFillRemaining(
|
||||
SliverFillRemaining(
|
||||
hasScrollBody: false,
|
||||
child: EmptyState(),
|
||||
child: EmptyState(strings: s),
|
||||
)
|
||||
else
|
||||
SliverPadding(
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import '../../../core/l10n/app_strings.dart';
|
||||
import '../../../shared/providers/amount_format_provider.dart';
|
||||
import '../../../shared/utils/currency_utils.dart';
|
||||
import '../../settings/provider.dart';
|
||||
@@ -9,11 +10,13 @@ class BudgetProgress extends ConsumerWidget {
|
||||
final double spent;
|
||||
final double budget;
|
||||
final CurrencyInfo currencyInfo;
|
||||
final AppStrings strings;
|
||||
const BudgetProgress({
|
||||
super.key,
|
||||
required this.spent,
|
||||
required this.budget,
|
||||
required this.currencyInfo,
|
||||
required this.strings,
|
||||
});
|
||||
|
||||
Border? _themeBorder(BuildContext context) {
|
||||
@@ -51,7 +54,7 @@ class BudgetProgress extends ConsumerWidget {
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
'Monthly Budget',
|
||||
strings.monthlyBudget,
|
||||
style: Theme.of(context).textTheme.bodyMedium?.copyWith(
|
||||
color: Theme.of(
|
||||
context,
|
||||
@@ -95,7 +98,7 @@ class BudgetProgress extends ConsumerWidget {
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
'Spent: ${formatAmount(currencyInfo.symbol, spent, fmt)}',
|
||||
'${strings.spent}: ${formatAmount(currencyInfo.symbol, spent, fmt)}',
|
||||
style: Theme.of(context).textTheme.bodySmall?.copyWith(
|
||||
color: Theme.of(
|
||||
context,
|
||||
@@ -103,7 +106,7 @@ class BudgetProgress extends ConsumerWidget {
|
||||
),
|
||||
),
|
||||
Text(
|
||||
'Limit: ${formatAmount(currencyInfo.symbol, budget, fmt)}',
|
||||
'${strings.limit}: ${formatAmount(currencyInfo.symbol, budget, fmt)}',
|
||||
style: Theme.of(context).textTheme.bodySmall?.copyWith(
|
||||
color: Theme.of(
|
||||
context,
|
||||
|
||||
@@ -2,6 +2,8 @@ import 'dart:ui';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_colorpicker/flutter_colorpicker.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import '../../../core/l10n/app_strings.dart';
|
||||
import '../../../core/l10n/locale_provider.dart';
|
||||
import '../../../core/services/card_color_service.dart';
|
||||
import '../../../core/services/haptic_service.dart';
|
||||
import '../../settings/provider.dart';
|
||||
@@ -96,6 +98,10 @@ class _FullScreenBlurOverlayState extends State<FullScreenBlurOverlay> {
|
||||
),
|
||||
child: StatefulBuilder(
|
||||
builder: (ctx, setPanelState) {
|
||||
final s = AppStrings(
|
||||
ProviderScope.containerOf(widget.context).read(localeProvider),
|
||||
);
|
||||
|
||||
void onHSVChanged(HSVColor hsv) {
|
||||
setPanelState(() {});
|
||||
dash.setState(() {
|
||||
@@ -125,7 +131,7 @@ class _FullScreenBlurOverlayState extends State<FullScreenBlurOverlay> {
|
||||
children: [
|
||||
Expanded(
|
||||
child: PanelTab(
|
||||
label: 'Primary',
|
||||
label: s.colorPrimary,
|
||||
isSelected: dash.editingPrimary,
|
||||
color: dash.tempPrimary,
|
||||
isDimmed: isSolid,
|
||||
@@ -142,7 +148,7 @@ class _FullScreenBlurOverlayState extends State<FullScreenBlurOverlay> {
|
||||
const SizedBox(width: 6),
|
||||
Expanded(
|
||||
child: PanelTab(
|
||||
label: 'Secondary',
|
||||
label: s.colorSecondary,
|
||||
isSelected: !dash.editingPrimary,
|
||||
color: dash.tempSecondary,
|
||||
isDimmed: isSolid,
|
||||
@@ -196,7 +202,7 @@ class _FullScreenBlurOverlayState extends State<FullScreenBlurOverlay> {
|
||||
),
|
||||
),
|
||||
child: Text(
|
||||
'Solid',
|
||||
s.colorSolid,
|
||||
style: TextStyle(
|
||||
fontSize: 11,
|
||||
fontWeight: isSolid
|
||||
@@ -391,10 +397,10 @@ class _FullScreenBlurOverlayState extends State<FullScreenBlurOverlay> {
|
||||
.map((type) {
|
||||
final isSelected = dash.tempGradientType == type;
|
||||
final label = switch (type) {
|
||||
GradientType.linear => 'Linear',
|
||||
GradientType.linearReverse => 'Reverse',
|
||||
GradientType.radial => 'Radial',
|
||||
GradientType.sweep => 'Sweep',
|
||||
GradientType.linear => s.gradientLinear,
|
||||
GradientType.linearReverse => s.gradientReverse,
|
||||
GradientType.radial => s.gradientRadial,
|
||||
GradientType.sweep => s.gradientSweep,
|
||||
GradientType.solid => '',
|
||||
};
|
||||
final icon = switch (type) {
|
||||
@@ -498,8 +504,8 @@ class _FullScreenBlurOverlayState extends State<FullScreenBlurOverlay> {
|
||||
dash.overlayEntry?.markNeedsBuild();
|
||||
},
|
||||
icon: const Icon(Icons.restart_alt_rounded, size: 15),
|
||||
label: const Text('Reset',
|
||||
style: TextStyle(fontSize: 13)),
|
||||
label: Text(s.reset,
|
||||
style: const TextStyle(fontSize: 13)),
|
||||
style: OutlinedButton.styleFrom(
|
||||
foregroundColor: Theme.of(widget.context)
|
||||
.colorScheme
|
||||
@@ -529,8 +535,8 @@ class _FullScreenBlurOverlayState extends State<FullScreenBlurOverlay> {
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(12)),
|
||||
),
|
||||
child: const Text('Apply',
|
||||
style: TextStyle(
|
||||
child: Text(s.apply,
|
||||
style: const TextStyle(
|
||||
fontWeight: FontWeight.w700, fontSize: 14)),
|
||||
),
|
||||
),
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import '../../../core/constants.dart';
|
||||
import '../../../core/l10n/app_strings.dart';
|
||||
import '../../../core/services/haptic_service.dart';
|
||||
import '../provider.dart';
|
||||
|
||||
class FilterChips extends ConsumerWidget {
|
||||
const FilterChips({super.key});
|
||||
final AppStrings strings;
|
||||
const FilterChips({super.key, required this.strings});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
@@ -16,13 +18,13 @@ class FilterChips extends ConsumerWidget {
|
||||
return Row(
|
||||
children: [
|
||||
_FilterChip(
|
||||
label: 'All Time',
|
||||
label: strings.filterAllTime,
|
||||
isSelected: timeFilter == TimeFilter.allTime,
|
||||
onTap: () => ref.read(timeFilterProvider.notifier).state = TimeFilter.allTime,
|
||||
),
|
||||
const SizedBox(width: 6),
|
||||
_FilterChip(
|
||||
label: 'Month',
|
||||
label: strings.filterMonth,
|
||||
isSelected: timeFilter == TimeFilter.lastMonth,
|
||||
onTap: () => ref.read(timeFilterProvider.notifier).state = TimeFilter.lastMonth,
|
||||
),
|
||||
@@ -37,20 +39,20 @@ class FilterChips extends ConsumerWidget {
|
||||
),
|
||||
),
|
||||
_FilterChip(
|
||||
label: 'All',
|
||||
label: strings.filterAll,
|
||||
isSelected: typeFilter == TransactionFilter.all,
|
||||
onTap: () => ref.read(transactionFilterProvider.notifier).state = TransactionFilter.all,
|
||||
),
|
||||
const SizedBox(width: 6),
|
||||
_FilterChip(
|
||||
label: 'Income',
|
||||
label: strings.filterIncome,
|
||||
isSelected: typeFilter == TransactionFilter.income,
|
||||
color: AppColors.income,
|
||||
onTap: () => ref.read(transactionFilterProvider.notifier).state = TransactionFilter.income,
|
||||
),
|
||||
const SizedBox(width: 6),
|
||||
_FilterChip(
|
||||
label: 'Expense',
|
||||
label: strings.filterExpense,
|
||||
isSelected: typeFilter == TransactionFilter.expense,
|
||||
color: AppColors.expense,
|
||||
onTap: () => ref.read(transactionFilterProvider.notifier).state = TransactionFilter.expense,
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import '../../../core/l10n/app_strings.dart';
|
||||
import '../provider.dart';
|
||||
|
||||
class SearchBar extends StatelessWidget {
|
||||
@@ -7,12 +8,14 @@ class SearchBar extends StatelessWidget {
|
||||
final FocusNode focusNode;
|
||||
final VoidCallback onTap;
|
||||
final WidgetRef ref;
|
||||
final AppStrings strings;
|
||||
const SearchBar({
|
||||
super.key,
|
||||
required this.controller,
|
||||
required this.focusNode,
|
||||
required this.onTap,
|
||||
required this.ref,
|
||||
required this.strings,
|
||||
});
|
||||
|
||||
@override
|
||||
@@ -23,7 +26,7 @@ class SearchBar extends StatelessWidget {
|
||||
focusNode: focusNode,
|
||||
onTap: onTap,
|
||||
decoration: InputDecoration(
|
||||
hintText: 'Search transactions...',
|
||||
hintText: strings.searchHint,
|
||||
prefixIcon: Icon(
|
||||
Icons.search_rounded,
|
||||
color: Theme.of(context).colorScheme.onSurface.withOpacity(0.6),
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import '../../../core/constants.dart';
|
||||
import '../../../core/l10n/app_strings.dart';
|
||||
import '../../../shared/providers/amount_format_provider.dart';
|
||||
import '../../../shared/utils/currency_utils.dart';
|
||||
import '../../settings/provider.dart';
|
||||
@@ -10,11 +11,13 @@ class SummaryRow extends StatelessWidget {
|
||||
final double income;
|
||||
final double expense;
|
||||
final CurrencyInfo currencyInfo;
|
||||
final AppStrings strings;
|
||||
const SummaryRow({
|
||||
super.key,
|
||||
required this.income,
|
||||
required this.expense,
|
||||
required this.currencyInfo,
|
||||
required this.strings,
|
||||
});
|
||||
|
||||
@override
|
||||
@@ -23,7 +26,7 @@ class SummaryRow extends StatelessWidget {
|
||||
children: [
|
||||
Expanded(
|
||||
child: SummaryCard(
|
||||
label: 'Income',
|
||||
label: strings.income,
|
||||
amount: income,
|
||||
color: AppColors.income,
|
||||
icon: Icons.arrow_downward_rounded,
|
||||
@@ -33,7 +36,7 @@ class SummaryRow extends StatelessWidget {
|
||||
const SizedBox(width: 12),
|
||||
Expanded(
|
||||
child: SummaryCard(
|
||||
label: 'Expenses',
|
||||
label: strings.expenses,
|
||||
amount: expense,
|
||||
color: AppColors.expense,
|
||||
icon: Icons.arrow_upward_rounded,
|
||||
|
||||
@@ -3,6 +3,8 @@ import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
import '../../../core/constants.dart';
|
||||
import '../../../core/l10n/app_strings.dart';
|
||||
import '../../../core/l10n/locale_provider.dart';
|
||||
import '../../../shared/models/transaction.dart';
|
||||
import '../../../shared/providers/amount_format_provider.dart';
|
||||
import '../../../shared/utils/currency_utils.dart';
|
||||
@@ -18,6 +20,7 @@ class TransactionTile extends ConsumerWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final s = ref.watch(stringsProvider);
|
||||
final fmt = ref.watch(amountFormatProvider);
|
||||
final isIncome = transaction.type == TransactionType.income;
|
||||
final color = isIncome ? AppColors.income : AppColors.expense;
|
||||
@@ -51,7 +54,7 @@ class TransactionTile extends ConsumerWidget {
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
transaction.category,
|
||||
s.categoryLabel(transaction.category),
|
||||
style: Theme.of(context).textTheme.bodyMedium?.copyWith(
|
||||
fontWeight: FontWeight.w600,
|
||||
color: Theme.of(context).colorScheme.onSurface,
|
||||
@@ -69,7 +72,7 @@ class TransactionTile extends ConsumerWidget {
|
||||
)
|
||||
else
|
||||
Text(
|
||||
DateFormat('MMM d, yyyy · HH:mm').format(transaction.date),
|
||||
DateFormat('d MMM yyyy · HH:mm', s.dateLocale).format(transaction.date),
|
||||
style: Theme.of(context).textTheme.bodySmall?.copyWith(
|
||||
color: Theme.of(
|
||||
context,
|
||||
@@ -94,7 +97,8 @@ class TransactionTile extends ConsumerWidget {
|
||||
}
|
||||
|
||||
class EmptyState extends StatelessWidget {
|
||||
const EmptyState({super.key});
|
||||
final AppStrings strings;
|
||||
const EmptyState({super.key, required this.strings});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@@ -116,7 +120,7 @@ class EmptyState extends StatelessWidget {
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
Text(
|
||||
'No transactions found',
|
||||
strings.noTransactions,
|
||||
style: Theme.of(context).textTheme.titleMedium?.copyWith(
|
||||
color: Theme.of(context).colorScheme.onSurface,
|
||||
fontWeight: FontWeight.w600,
|
||||
@@ -124,7 +128,7 @@ class EmptyState extends StatelessWidget {
|
||||
),
|
||||
const SizedBox(height: 6),
|
||||
Text(
|
||||
'Tap + to add your first transaction',
|
||||
strings.addFirstTx,
|
||||
style: Theme.of(context).textTheme.bodyMedium?.copyWith(
|
||||
color: Theme.of(context).colorScheme.onSurface.withOpacity(0.6),
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user