mirror of
https://github.com/koloideal/Casha.git
synced 2026-06-10 10:25:28 +03:00
update
This commit is contained in:
@@ -14,7 +14,7 @@ import 'provider.dart';
|
|||||||
|
|
||||||
// Helper for balance card only - hides .00 decimals
|
// Helper for balance card only - hides .00 decimals
|
||||||
String _smartBalance(double amount, AmountFormat fmt, String symbol) {
|
String _smartBalance(double amount, AmountFormat fmt, String symbol) {
|
||||||
const spaceAfter = {'Br', '₽'};
|
const spaceAfter = {'Br'};
|
||||||
final sep = spaceAfter.contains(symbol) ? ' ' : '';
|
final sep = spaceAfter.contains(symbol) ? ' ' : '';
|
||||||
final isWhole = amount == amount.floorToDouble();
|
final isWhole = amount == amount.floorToDouble();
|
||||||
|
|
||||||
@@ -101,7 +101,9 @@ class _DashboardScreenState extends ConsumerState<DashboardScreen> {
|
|||||||
Text(
|
Text(
|
||||||
DateFormat('MMMM yyyy').format(DateTime.now()),
|
DateFormat('MMMM yyyy').format(DateTime.now()),
|
||||||
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),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
@@ -131,10 +133,18 @@ class _DashboardScreenState extends ConsumerState<DashboardScreen> {
|
|||||||
children: [
|
children: [
|
||||||
_BalanceCard(balance: balance, currencyInfo: currencyInfo),
|
_BalanceCard(balance: balance, currencyInfo: currencyInfo),
|
||||||
const SizedBox(height: 16),
|
const SizedBox(height: 16),
|
||||||
_SummaryRow(income: income, expense: expense, currencyInfo: currencyInfo),
|
_SummaryRow(
|
||||||
|
income: income,
|
||||||
|
expense: expense,
|
||||||
|
currencyInfo: currencyInfo,
|
||||||
|
),
|
||||||
if (budget != null) ...[
|
if (budget != null) ...[
|
||||||
const SizedBox(height: 16),
|
const SizedBox(height: 16),
|
||||||
_BudgetProgress(spent: monthExpense, budget: budget, currencyInfo: currencyInfo),
|
_BudgetProgress(
|
||||||
|
spent: monthExpense,
|
||||||
|
budget: budget,
|
||||||
|
currencyInfo: currencyInfo,
|
||||||
|
),
|
||||||
],
|
],
|
||||||
const SizedBox(height: 24),
|
const SizedBox(height: 24),
|
||||||
_SearchBar(
|
_SearchBar(
|
||||||
@@ -205,7 +215,10 @@ class _SearchBar extends StatelessWidget {
|
|||||||
onTap: onTap,
|
onTap: onTap,
|
||||||
decoration: InputDecoration(
|
decoration: InputDecoration(
|
||||||
hintText: 'Search transactions...',
|
hintText: 'Search transactions...',
|
||||||
prefixIcon: Icon(Icons.search_rounded, color: Theme.of(context).colorScheme.onSurface.withOpacity(0.6)),
|
prefixIcon: Icon(
|
||||||
|
Icons.search_rounded,
|
||||||
|
color: Theme.of(context).colorScheme.onSurface.withOpacity(0.6),
|
||||||
|
),
|
||||||
suffixIcon: controller.text.isNotEmpty
|
suffixIcon: controller.text.isNotEmpty
|
||||||
? IconButton(
|
? IconButton(
|
||||||
icon: const Icon(Icons.clear_rounded, size: 20),
|
icon: const Icon(Icons.clear_rounded, size: 20),
|
||||||
@@ -233,7 +246,10 @@ class _SearchBar extends StatelessWidget {
|
|||||||
borderRadius: BorderRadius.circular(12),
|
borderRadius: BorderRadius.circular(12),
|
||||||
borderSide: BorderSide.none,
|
borderSide: BorderSide.none,
|
||||||
),
|
),
|
||||||
contentPadding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12),
|
contentPadding: const EdgeInsets.symmetric(
|
||||||
|
horizontal: 16,
|
||||||
|
vertical: 12,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
onChanged: (v) => ref.read(searchQueryProvider.notifier).state = v,
|
onChanged: (v) => ref.read(searchQueryProvider.notifier).state = v,
|
||||||
);
|
);
|
||||||
@@ -252,21 +268,24 @@ class _FilterChips extends StatelessWidget {
|
|||||||
_FilterChip(
|
_FilterChip(
|
||||||
label: 'All',
|
label: 'All',
|
||||||
isSelected: selected == TransactionFilter.all,
|
isSelected: selected == TransactionFilter.all,
|
||||||
onTap: () => ref.read(transactionFilterProvider.notifier).state = TransactionFilter.all,
|
onTap: () => ref.read(transactionFilterProvider.notifier).state =
|
||||||
|
TransactionFilter.all,
|
||||||
),
|
),
|
||||||
const SizedBox(width: 8),
|
const SizedBox(width: 8),
|
||||||
_FilterChip(
|
_FilterChip(
|
||||||
label: 'Income',
|
label: 'Income',
|
||||||
isSelected: selected == TransactionFilter.income,
|
isSelected: selected == TransactionFilter.income,
|
||||||
color: AppColors.income,
|
color: AppColors.income,
|
||||||
onTap: () => ref.read(transactionFilterProvider.notifier).state = TransactionFilter.income,
|
onTap: () => ref.read(transactionFilterProvider.notifier).state =
|
||||||
|
TransactionFilter.income,
|
||||||
),
|
),
|
||||||
const SizedBox(width: 8),
|
const SizedBox(width: 8),
|
||||||
_FilterChip(
|
_FilterChip(
|
||||||
label: 'Expense',
|
label: 'Expense',
|
||||||
isSelected: selected == TransactionFilter.expense,
|
isSelected: selected == TransactionFilter.expense,
|
||||||
color: AppColors.expense,
|
color: AppColors.expense,
|
||||||
onTap: () => ref.read(transactionFilterProvider.notifier).state = TransactionFilter.expense,
|
onTap: () => ref.read(transactionFilterProvider.notifier).state =
|
||||||
|
TransactionFilter.expense,
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
@@ -295,16 +314,22 @@ class _FilterChip extends StatelessWidget {
|
|||||||
duration: const Duration(milliseconds: 200),
|
duration: const Duration(milliseconds: 200),
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 14, vertical: 8),
|
padding: const EdgeInsets.symmetric(horizontal: 14, vertical: 8),
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: isSelected ? chipColor.withOpacity(0.2) : Theme.of(context).colorScheme.surface,
|
color: isSelected
|
||||||
|
? chipColor.withOpacity(0.2)
|
||||||
|
: Theme.of(context).colorScheme.surface,
|
||||||
borderRadius: BorderRadius.circular(20),
|
borderRadius: BorderRadius.circular(20),
|
||||||
border: isSelected
|
border: isSelected
|
||||||
? Border.all(color: chipColor, width: 1.5)
|
? Border.all(color: chipColor, width: 1.5)
|
||||||
: (isDark ? null : Border.all(color: const Color(0xFFDDDDEE), width: 1)),
|
: (isDark
|
||||||
|
? null
|
||||||
|
: Border.all(color: const Color(0xFFDDDDEE), width: 1)),
|
||||||
),
|
),
|
||||||
child: Text(
|
child: Text(
|
||||||
label,
|
label,
|
||||||
style: Theme.of(context).textTheme.bodySmall?.copyWith(
|
style: Theme.of(context).textTheme.bodySmall?.copyWith(
|
||||||
color: isSelected ? chipColor : Theme.of(context).colorScheme.onSurface.withOpacity(0.6),
|
color: isSelected
|
||||||
|
? chipColor
|
||||||
|
: Theme.of(context).colorScheme.onSurface.withOpacity(0.6),
|
||||||
fontWeight: isSelected ? FontWeight.w600 : FontWeight.normal,
|
fontWeight: isSelected ? FontWeight.w600 : FontWeight.normal,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -317,7 +342,11 @@ class _BudgetProgress extends ConsumerWidget {
|
|||||||
final double spent;
|
final double spent;
|
||||||
final double budget;
|
final double budget;
|
||||||
final CurrencyInfo currencyInfo;
|
final CurrencyInfo currencyInfo;
|
||||||
const _BudgetProgress({required this.spent, required this.budget, required this.currencyInfo});
|
const _BudgetProgress({
|
||||||
|
required this.spent,
|
||||||
|
required this.budget,
|
||||||
|
required this.currencyInfo,
|
||||||
|
});
|
||||||
|
|
||||||
Border? _themeBorder(BuildContext context) {
|
Border? _themeBorder(BuildContext context) {
|
||||||
final isDark = Theme.of(context).brightness == Brightness.dark;
|
final isDark = Theme.of(context).brightness == Brightness.dark;
|
||||||
@@ -331,12 +360,21 @@ class _BudgetProgress extends ConsumerWidget {
|
|||||||
final isOver = progress > 1.0;
|
final isOver = progress > 1.0;
|
||||||
final displayPercent = (progress * 100).toStringAsFixed(0);
|
final displayPercent = (progress * 100).toStringAsFixed(0);
|
||||||
|
|
||||||
return Container(
|
return ClipRRect(
|
||||||
|
borderRadius: BorderRadius.circular(16),
|
||||||
|
child: Container(
|
||||||
padding: const EdgeInsets.all(16),
|
padding: const EdgeInsets.all(16),
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: Theme.of(context).colorScheme.surface,
|
color: Theme.of(context).colorScheme.surface,
|
||||||
borderRadius: BorderRadius.circular(16),
|
border: Border(
|
||||||
border: _themeBorder(context),
|
left: BorderSide(
|
||||||
|
color: isOver ? const Color(0xFFE05C6B) : const Color(0xFF7C6DED),
|
||||||
|
width: 3,
|
||||||
|
),
|
||||||
|
top: _themeBorder(context)?.top ?? BorderSide.none,
|
||||||
|
right: _themeBorder(context)?.right ?? BorderSide.none,
|
||||||
|
bottom: _themeBorder(context)?.bottom ?? BorderSide.none,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
child: Column(
|
child: Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
@@ -347,13 +385,19 @@ class _BudgetProgress extends ConsumerWidget {
|
|||||||
Text(
|
Text(
|
||||||
'Monthly Budget',
|
'Monthly Budget',
|
||||||
style: Theme.of(context).textTheme.bodyMedium?.copyWith(
|
style: Theme.of(context).textTheme.bodyMedium?.copyWith(
|
||||||
color: Theme.of(context).colorScheme.onSurface.withOpacity(0.6),
|
color: Theme.of(
|
||||||
|
context,
|
||||||
|
).colorScheme.onSurface.withOpacity(0.6),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
Text(
|
Text(
|
||||||
'$displayPercent%',
|
'$displayPercent%',
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
color: isOver ? const Color(0xFFE05C6B) : Theme.of(context).colorScheme.onSurface.withOpacity(0.7),
|
color: isOver
|
||||||
|
? const Color(0xFFE05C6B)
|
||||||
|
: Theme.of(
|
||||||
|
context,
|
||||||
|
).colorScheme.onSurface.withOpacity(0.7),
|
||||||
fontWeight: isOver ? FontWeight.w700 : FontWeight.normal,
|
fontWeight: isOver ? FontWeight.w700 : FontWeight.normal,
|
||||||
fontSize: 12,
|
fontSize: 12,
|
||||||
),
|
),
|
||||||
@@ -365,9 +409,15 @@ class _BudgetProgress extends ConsumerWidget {
|
|||||||
borderRadius: BorderRadius.circular(8),
|
borderRadius: BorderRadius.circular(8),
|
||||||
child: LinearProgressIndicator(
|
child: LinearProgressIndicator(
|
||||||
value: isOver ? 1.0 : progress,
|
value: isOver ? 1.0 : progress,
|
||||||
backgroundColor: Theme.of(context).colorScheme.onSurface.withOpacity(0.1),
|
backgroundColor: Theme.of(
|
||||||
|
context,
|
||||||
|
).colorScheme.onSurface.withOpacity(0.1),
|
||||||
valueColor: AlwaysStoppedAnimation<Color>(
|
valueColor: AlwaysStoppedAnimation<Color>(
|
||||||
isOver ? const Color(0xFFE05C6B) : (progress > 0.8 ? Colors.orange : const Color(0xFF4CAF8C)),
|
isOver
|
||||||
|
? const Color(0xFFE05C6B)
|
||||||
|
: (progress > 0.8
|
||||||
|
? Colors.orange
|
||||||
|
: const Color(0xFF4CAF8C)),
|
||||||
),
|
),
|
||||||
minHeight: 8,
|
minHeight: 8,
|
||||||
),
|
),
|
||||||
@@ -379,19 +429,24 @@ class _BudgetProgress extends ConsumerWidget {
|
|||||||
Text(
|
Text(
|
||||||
'Spent: ${formatAmount(currencyInfo.symbol, spent, fmt)}',
|
'Spent: ${formatAmount(currencyInfo.symbol, spent, fmt)}',
|
||||||
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),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
Text(
|
Text(
|
||||||
'Limit: ${formatAmount(currencyInfo.symbol, budget, fmt)}',
|
'Limit: ${formatAmount(currencyInfo.symbol, budget, fmt)}',
|
||||||
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),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -420,7 +475,8 @@ class _BalanceCardState extends ConsumerState<_BalanceCard>
|
|||||||
duration: const Duration(seconds: 1),
|
duration: const Duration(seconds: 1),
|
||||||
)..repeat();
|
)..repeat();
|
||||||
|
|
||||||
_sub = accelerometerEventStream(
|
_sub =
|
||||||
|
accelerometerEventStream(
|
||||||
samplingPeriod: const Duration(milliseconds: 50),
|
samplingPeriod: const Duration(milliseconds: 50),
|
||||||
).listen((e) {
|
).listen((e) {
|
||||||
_targetTiltY = (e.x / 9.8).clamp(-1.0, 1.0);
|
_targetTiltY = (e.x / 9.8).clamp(-1.0, 1.0);
|
||||||
@@ -439,7 +495,12 @@ class _BalanceCardState extends ConsumerState<_BalanceCard>
|
|||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final rates = ref.read(exchangeRateServiceProvider);
|
final rates = ref.read(exchangeRateServiceProvider);
|
||||||
final fmt = ref.watch(amountFormatProvider);
|
final fmt = ref.watch(amountFormatProvider);
|
||||||
final allCurrencies = [('USD', r'$'), ('EUR', '€'), ('BYN', 'Br'), ('RUB', '₽')];
|
final allCurrencies = [
|
||||||
|
('USD', r'$'),
|
||||||
|
('EUR', '€'),
|
||||||
|
('BYN', 'Br'),
|
||||||
|
('RUB', '₽'),
|
||||||
|
];
|
||||||
final others = allCurrencies
|
final others = allCurrencies
|
||||||
.where((c) => c.$1 != widget.currencyInfo.code)
|
.where((c) => c.$1 != widget.currencyInfo.code)
|
||||||
.toList();
|
.toList();
|
||||||
@@ -451,15 +512,38 @@ class _BalanceCardState extends ConsumerState<_BalanceCard>
|
|||||||
_tiltY += (_targetTiltY - _tiltY) * 0.15;
|
_tiltY += (_targetTiltY - _tiltY) * 0.15;
|
||||||
final isDark = Theme.of(context).brightness == Brightness.dark;
|
final isDark = Theme.of(context).brightness == Brightness.dark;
|
||||||
|
|
||||||
final tiltBrightness = (_tiltX * 0.15 + _tiltY * 0.1).clamp(-0.15, 0.15);
|
final tiltBrightness = (_tiltX * 0.15 + _tiltY * 0.1).clamp(
|
||||||
|
-0.15,
|
||||||
|
0.15,
|
||||||
|
);
|
||||||
final highlightShift = (tiltBrightness * 40).round();
|
final highlightShift = (tiltBrightness * 40).round();
|
||||||
|
|
||||||
final topColor = isDark
|
final topColor = isDark
|
||||||
? Color.fromARGB(255, (0x7C + highlightShift).clamp(0x60, 0xFF), (0x6D + highlightShift).clamp(0x55, 0xFF), 0xED)
|
? Color.fromARGB(
|
||||||
: Color.fromARGB(255, (0x2A + highlightShift).clamp(0x20, 0x40), (0x25 + highlightShift).clamp(0x1A, 0x35), (0x45 + highlightShift).clamp(0x35, 0x55));
|
255,
|
||||||
|
(0x7C + highlightShift).clamp(0x60, 0xFF),
|
||||||
|
(0x6D + highlightShift).clamp(0x55, 0xFF),
|
||||||
|
0xED,
|
||||||
|
)
|
||||||
|
: Color.fromARGB(
|
||||||
|
255,
|
||||||
|
(0x2A + highlightShift).clamp(0x20, 0x40),
|
||||||
|
(0x25 + highlightShift).clamp(0x1A, 0x35),
|
||||||
|
(0x45 + highlightShift).clamp(0x35, 0x55),
|
||||||
|
);
|
||||||
final bottomColor = isDark
|
final bottomColor = isDark
|
||||||
? Color.fromARGB(255, (0x2A - highlightShift).clamp(0x18, 0x40), (0x20 - highlightShift).clamp(0x14, 0x30), (0x60 - highlightShift).clamp(0x45, 0x75))
|
? Color.fromARGB(
|
||||||
: Color.fromARGB(255, (0x14 - highlightShift).clamp(0x0A, 0x20), (0x12 - highlightShift).clamp(0x08, 0x1E), (0x28 - highlightShift).clamp(0x1E, 0x34));
|
255,
|
||||||
|
(0x2A - highlightShift).clamp(0x18, 0x40),
|
||||||
|
(0x20 - highlightShift).clamp(0x14, 0x30),
|
||||||
|
(0x60 - highlightShift).clamp(0x45, 0x75),
|
||||||
|
)
|
||||||
|
: Color.fromARGB(
|
||||||
|
255,
|
||||||
|
(0x14 - highlightShift).clamp(0x0A, 0x20),
|
||||||
|
(0x12 - highlightShift).clamp(0x08, 0x1E),
|
||||||
|
(0x28 - highlightShift).clamp(0x1E, 0x34),
|
||||||
|
);
|
||||||
|
|
||||||
return Transform(
|
return Transform(
|
||||||
alignment: Alignment.center,
|
alignment: Alignment.center,
|
||||||
@@ -475,17 +559,28 @@ class _BalanceCardState extends ConsumerState<_BalanceCard>
|
|||||||
gradient: LinearGradient(
|
gradient: LinearGradient(
|
||||||
begin: const Alignment(-1.0, -1.0),
|
begin: const Alignment(-1.0, -1.0),
|
||||||
end: const Alignment(1.0, 1.0),
|
end: const Alignment(1.0, 1.0),
|
||||||
colors: [topColor, isDark ? const Color(0xFF4A3FA0) : const Color(0xFF1A1530), bottomColor],
|
colors: [
|
||||||
|
topColor,
|
||||||
|
isDark ? const Color(0xFF4A3FA0) : const Color(0xFF1A1530),
|
||||||
|
bottomColor,
|
||||||
|
],
|
||||||
stops: const [0.0, 0.5, 1.0],
|
stops: const [0.0, 0.5, 1.0],
|
||||||
),
|
),
|
||||||
boxShadow: [
|
boxShadow: [
|
||||||
BoxShadow(color: Colors.black.withOpacity(0.4), blurRadius: 20, offset: const Offset(0, 8)),
|
BoxShadow(
|
||||||
|
color: Colors.black.withOpacity(0.4),
|
||||||
|
blurRadius: 20,
|
||||||
|
offset: const Offset(0, 8),
|
||||||
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
child: ClipRRect(
|
child: ClipRRect(
|
||||||
borderRadius: BorderRadius.circular(20),
|
borderRadius: BorderRadius.circular(20),
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 24, vertical: 20),
|
padding: const EdgeInsets.symmetric(
|
||||||
|
horizontal: 24,
|
||||||
|
vertical: 20,
|
||||||
|
),
|
||||||
child: Row(
|
child: Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
crossAxisAlignment: CrossAxisAlignment.center,
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
@@ -496,14 +591,29 @@ class _BalanceCardState extends ConsumerState<_BalanceCard>
|
|||||||
mainAxisAlignment: MainAxisAlignment.center,
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
crossAxisAlignment: CrossAxisAlignment.center,
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
children: [
|
children: [
|
||||||
Text('TOTAL BALANCE', style: TextStyle(fontSize: 11, letterSpacing: 1.5, color: Colors.white.withOpacity(0.6))),
|
Text(
|
||||||
|
'TOTAL BALANCE',
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 11,
|
||||||
|
letterSpacing: 1.5,
|
||||||
|
color: Colors.white.withOpacity(0.6),
|
||||||
|
),
|
||||||
|
),
|
||||||
const SizedBox(height: 6),
|
const SizedBox(height: 6),
|
||||||
FittedBox(
|
FittedBox(
|
||||||
fit: BoxFit.scaleDown,
|
fit: BoxFit.scaleDown,
|
||||||
alignment: Alignment.center,
|
alignment: Alignment.center,
|
||||||
child: Text(
|
child: Text(
|
||||||
_smartBalance(widget.balance, fmt, widget.currencyInfo.symbol),
|
_smartBalance(
|
||||||
style: const TextStyle(fontSize: 48, fontWeight: FontWeight.w700, color: Colors.white),
|
widget.balance,
|
||||||
|
fmt,
|
||||||
|
widget.currencyInfo.symbol,
|
||||||
|
),
|
||||||
|
style: const TextStyle(
|
||||||
|
fontSize: 48,
|
||||||
|
fontWeight: FontWeight.w700,
|
||||||
|
color: Colors.white,
|
||||||
|
),
|
||||||
maxLines: 1,
|
maxLines: 1,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -512,7 +622,11 @@ class _BalanceCardState extends ConsumerState<_BalanceCard>
|
|||||||
),
|
),
|
||||||
if (widget.balance != 0) ...[
|
if (widget.balance != 0) ...[
|
||||||
const SizedBox(width: 16),
|
const SizedBox(width: 16),
|
||||||
Container(width: 1, height: 70, color: Colors.white.withOpacity(0.15)),
|
Container(
|
||||||
|
width: 1,
|
||||||
|
height: 70,
|
||||||
|
color: Colors.white.withOpacity(0.15),
|
||||||
|
),
|
||||||
const SizedBox(width: 16),
|
const SizedBox(width: 16),
|
||||||
SizedBox(
|
SizedBox(
|
||||||
width: 110,
|
width: 110,
|
||||||
@@ -520,7 +634,11 @@ class _BalanceCardState extends ConsumerState<_BalanceCard>
|
|||||||
mainAxisAlignment: MainAxisAlignment.center,
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: others.map((c) {
|
children: others.map((c) {
|
||||||
final converted = rates.convert(widget.balance, widget.currencyInfo.code, c.$1);
|
final converted = rates.convert(
|
||||||
|
widget.balance,
|
||||||
|
widget.currencyInfo.code,
|
||||||
|
c.$1,
|
||||||
|
);
|
||||||
return Padding(
|
return Padding(
|
||||||
padding: const EdgeInsets.symmetric(vertical: 3),
|
padding: const EdgeInsets.symmetric(vertical: 3),
|
||||||
child: FittedBox(
|
child: FittedBox(
|
||||||
@@ -528,7 +646,11 @@ class _BalanceCardState extends ConsumerState<_BalanceCard>
|
|||||||
alignment: Alignment.centerLeft,
|
alignment: Alignment.centerLeft,
|
||||||
child: Text(
|
child: Text(
|
||||||
_smartBalance(converted, fmt, c.$2),
|
_smartBalance(converted, fmt, c.$2),
|
||||||
style: TextStyle(fontSize: 14, fontWeight: FontWeight.w500, color: Colors.white.withOpacity(0.65)),
|
style: TextStyle(
|
||||||
|
fontSize: 14,
|
||||||
|
fontWeight: FontWeight.w500,
|
||||||
|
color: Colors.white.withOpacity(0.65),
|
||||||
|
),
|
||||||
maxLines: 1,
|
maxLines: 1,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -552,15 +674,35 @@ class _SummaryRow extends StatelessWidget {
|
|||||||
final double income;
|
final double income;
|
||||||
final double expense;
|
final double expense;
|
||||||
final CurrencyInfo currencyInfo;
|
final CurrencyInfo currencyInfo;
|
||||||
const _SummaryRow({required this.income, required this.expense, required this.currencyInfo});
|
const _SummaryRow({
|
||||||
|
required this.income,
|
||||||
|
required this.expense,
|
||||||
|
required this.currencyInfo,
|
||||||
|
});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Row(
|
return Row(
|
||||||
children: [
|
children: [
|
||||||
Expanded(child: _SummaryCard(label: 'Income', amount: income, color: AppColors.income, icon: Icons.arrow_downward_rounded, currencyInfo: currencyInfo)),
|
Expanded(
|
||||||
|
child: _SummaryCard(
|
||||||
|
label: 'Income',
|
||||||
|
amount: income,
|
||||||
|
color: AppColors.income,
|
||||||
|
icon: Icons.arrow_downward_rounded,
|
||||||
|
currencyInfo: currencyInfo,
|
||||||
|
),
|
||||||
|
),
|
||||||
const SizedBox(width: 12),
|
const SizedBox(width: 12),
|
||||||
Expanded(child: _SummaryCard(label: 'Expenses', amount: expense, color: AppColors.expense, icon: Icons.arrow_upward_rounded, currencyInfo: currencyInfo)),
|
Expanded(
|
||||||
|
child: _SummaryCard(
|
||||||
|
label: 'Expenses',
|
||||||
|
amount: expense,
|
||||||
|
color: AppColors.expense,
|
||||||
|
icon: Icons.arrow_upward_rounded,
|
||||||
|
currencyInfo: currencyInfo,
|
||||||
|
),
|
||||||
|
),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -572,7 +714,13 @@ class _SummaryCard extends ConsumerWidget {
|
|||||||
final Color color;
|
final Color color;
|
||||||
final IconData icon;
|
final IconData icon;
|
||||||
final CurrencyInfo currencyInfo;
|
final CurrencyInfo currencyInfo;
|
||||||
const _SummaryCard({required this.label, required this.amount, required this.color, required this.icon, required this.currencyInfo});
|
const _SummaryCard({
|
||||||
|
required this.label,
|
||||||
|
required this.amount,
|
||||||
|
required this.color,
|
||||||
|
required this.icon,
|
||||||
|
required this.currencyInfo,
|
||||||
|
});
|
||||||
|
|
||||||
Border? _themeBorder(BuildContext context) {
|
Border? _themeBorder(BuildContext context) {
|
||||||
final isDark = Theme.of(context).brightness == Brightness.dark;
|
final isDark = Theme.of(context).brightness == Brightness.dark;
|
||||||
@@ -604,7 +752,14 @@ class _SummaryCard extends ConsumerWidget {
|
|||||||
child: Column(
|
child: Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
Text(label, style: Theme.of(context).textTheme.bodySmall?.copyWith(color: Theme.of(context).colorScheme.onSurface.withOpacity(0.6))),
|
Text(
|
||||||
|
label,
|
||||||
|
style: Theme.of(context).textTheme.bodySmall?.copyWith(
|
||||||
|
color: Theme.of(
|
||||||
|
context,
|
||||||
|
).colorScheme.onSurface.withOpacity(0.6),
|
||||||
|
),
|
||||||
|
),
|
||||||
const SizedBox(height: 2),
|
const SizedBox(height: 2),
|
||||||
Text(
|
Text(
|
||||||
formatAmount(currencyInfo.symbol, amount, fmt),
|
formatAmount(currencyInfo.symbol, amount, fmt),
|
||||||
@@ -637,8 +792,10 @@ class _TransactionTile extends ConsumerWidget {
|
|||||||
final fmt = ref.watch(amountFormatProvider);
|
final fmt = ref.watch(amountFormatProvider);
|
||||||
final isIncome = transaction.type == TransactionType.income;
|
final isIncome = transaction.type == TransactionType.income;
|
||||||
final color = isIncome ? AppColors.income : AppColors.expense;
|
final color = isIncome ? AppColors.income : AppColors.expense;
|
||||||
final catColor = AppCategories.colors[transaction.category] ?? AppColors.accent;
|
final catColor =
|
||||||
final catIcon = AppCategories.icons[transaction.category] ?? Icons.category_rounded;
|
AppCategories.colors[transaction.category] ?? AppColors.accent;
|
||||||
|
final catIcon =
|
||||||
|
AppCategories.icons[transaction.category] ?? Icons.category_rounded;
|
||||||
|
|
||||||
return GestureDetector(
|
return GestureDetector(
|
||||||
onTap: () => context.push('/add', extra: transaction),
|
onTap: () => context.push('/add', extra: transaction),
|
||||||
@@ -675,7 +832,9 @@ class _TransactionTile extends ConsumerWidget {
|
|||||||
Text(
|
Text(
|
||||||
transaction.note!,
|
transaction.note!,
|
||||||
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),
|
||||||
),
|
),
|
||||||
overflow: TextOverflow.ellipsis,
|
overflow: TextOverflow.ellipsis,
|
||||||
)
|
)
|
||||||
@@ -683,7 +842,9 @@ class _TransactionTile extends ConsumerWidget {
|
|||||||
Text(
|
Text(
|
||||||
DateFormat('MMM d, yyyy').format(transaction.date),
|
DateFormat('MMM d, yyyy').format(transaction.date),
|
||||||
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),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
|||||||
+1
-3
@@ -10,9 +10,7 @@ void main() async {
|
|||||||
|
|
||||||
runApp(
|
runApp(
|
||||||
ProviderScope(
|
ProviderScope(
|
||||||
overrides: [
|
overrides: [sharedPreferencesProvider.overrideWithValue(prefs)],
|
||||||
sharedPreferencesProvider.overrideWithValue(prefs),
|
|
||||||
],
|
|
||||||
child: const App(),
|
child: const App(),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import '../../core/constants.dart';
|
|||||||
|
|
||||||
String formatAmount(String symbol, double amount, AmountFormat fmt) {
|
String formatAmount(String symbol, double amount, AmountFormat fmt) {
|
||||||
// Symbols that need a space after them (prefix symbols like Br, ₽ etc.)
|
// Symbols that need a space after them (prefix symbols like Br, ₽ etc.)
|
||||||
const spaceAfter = {'Br', '₽'};
|
const spaceAfter = {'Br'};
|
||||||
final formatted = fmt.format(amount);
|
final formatted = fmt.format(amount);
|
||||||
final sep = spaceAfter.contains(symbol) ? ' ' : '';
|
final sep = spaceAfter.contains(symbol) ? ' ' : '';
|
||||||
return '$symbol$sep$formatted';
|
return '$symbol$sep$formatted';
|
||||||
|
|||||||
Reference in New Issue
Block a user