first google play release for internal testing

This commit is contained in:
2026-07-10 17:32:02 +03:00
parent e3c60c4775
commit 861a9abd02
11 changed files with 684 additions and 685 deletions
+71 -43
View File
@@ -1,4 +1,5 @@
import 'package:flutter_riverpod/flutter_riverpod.dart';
import '../../shared/models/account.dart';
import '../../shared/models/transaction.dart';
import '../dashboard/provider.dart';
import '../settings/provider.dart';
@@ -35,81 +36,88 @@ class _StatsTimeFilterNotifier extends Notifier<StatsTimeFilter> {
});
}
String _statsTargetCurrency(Ref ref) {
final index = ref.watch(activeAccountIndexProvider);
final accountsAsync = ref.watch(accountsProvider);
final globalCurrency = ref.watch(currencyProvider).code;
if (index > 0) {
final accounts = accountsAsync.value ?? [];
if (index <= accounts.length) {
return accounts[index - 1].currency;
}
String _resolveTargetCurrency(
int activeIndex,
List<Account> accounts,
String globalCurrency,
) {
if (activeIndex > 0 && activeIndex <= accounts.length) {
return accounts[activeIndex - 1].currency;
}
return globalCurrency;
}
CurrencyInfo _statsCurrencyInfo(Ref ref) {
final code = _statsTargetCurrency(ref);
return CurrencyInfo(currencyMap[code]?.symbol ?? '\$', code);
}
List<Transaction> _statsScopedTransactions(Ref ref) {
final txs = ref.watch(accountFilteredTransactionsProvider);
final timeFilter = ref.watch(statsTimeFilterProvider);
List<Transaction> _filterScopedTransactions(
List<Transaction> txs,
StatsTimeFilter timeFilter,
) {
var filtered = txs.where((t) => t.category != 'Transfer');
if (timeFilter == StatsTimeFilter.month) {
final now = DateTime.now();
filtered = filtered.where(
(t) => t.date.year == now.year && t.date.month == now.month,
);
}
return filtered.toList();
}
double _convertAmount(Ref ref, Transaction t) {
final exchange = ref.watch(exchangeRateServiceProvider);
return exchange.convert(
t.amount,
t.currencyCode,
_statsTargetCurrency(ref),
);
}
final statsCurrencyProvider = Provider<CurrencyInfo>((ref) {
return _statsCurrencyInfo(ref);
final index = ref.watch(activeAccountIndexProvider);
final accountsAsync = ref.watch(accountsProvider);
final globalCurrency = ref.watch(currencyProvider).code;
final accounts = accountsAsync.value ?? [];
final code = _resolveTargetCurrency(index, accounts, globalCurrency);
return CurrencyInfo(currencyMap[code]?.symbol ?? '\$', code);
});
final statsScopedTransactionsProvider = Provider<List<Transaction>>((ref) {
return _statsScopedTransactions(ref);
});
final statsScopedTransactionsProvider = Provider<List<Transaction>>((ref) {
final txs = ref.watch(accountFilteredTransactionsProvider);
final timeFilter = ref.watch(statsTimeFilterProvider);
return _filterScopedTransactions(txs, timeFilter);
});
final statsIncomeTotalProvider = Provider<double>((ref) {
final exchange = ref.watch(exchangeRateServiceProvider);
final index = ref.watch(activeAccountIndexProvider);
final accountsAsync = ref.watch(accountsProvider);
final globalCurrency = ref.watch(currencyProvider).code;
final accounts = accountsAsync.value ?? [];
final target = _resolveTargetCurrency(index, accounts, globalCurrency);
return ref
.watch(statsScopedTransactionsProvider)
.where((t) => t.type == TransactionType.income)
.fold(0.0, (sum, t) => sum + _convertAmount(ref, t));
.fold(0.0, (sum, t) => sum + exchange.convert(t.amount, t.currencyCode, target));
});
final statsExpenseTotalProvider = Provider<double>((ref) {
final exchange = ref.watch(exchangeRateServiceProvider);
final index = ref.watch(activeAccountIndexProvider);
final accountsAsync = ref.watch(accountsProvider);
final globalCurrency = ref.watch(currencyProvider).code;
final accounts = accountsAsync.value ?? [];
final target = _resolveTargetCurrency(index, accounts, globalCurrency);
return ref
.watch(statsScopedTransactionsProvider)
.where((t) => t.type == TransactionType.expense)
.fold(0.0, (sum, t) => sum + _convertAmount(ref, t));
.fold(0.0, (sum, t) => sum + exchange.convert(t.amount, t.currencyCode, target));
});
final statsSummaryProvider = Provider<StatsSummary>((ref) {
final statsSummaryProvider = Provider<StatsSummary>((ref) {
final exchange = ref.watch(exchangeRateServiceProvider);
final index = ref.watch(activeAccountIndexProvider);
final accountsAsync = ref.watch(accountsProvider);
final globalCurrency = ref.watch(currencyProvider).code;
final accounts = accountsAsync.value ?? [];
final target = _resolveTargetCurrency(index, accounts, globalCurrency);
final transactions = ref.watch(statsScopedTransactionsProvider);
var income = 0.0;
var expense = 0.0;
var incomeCount = 0;
var expenseCount = 0;
for (final transaction in transactions) {
final amount = _convertAmount(ref, transaction);
final amount = exchange.convert(transaction.amount, transaction.currencyCode, target);
if (transaction.type == TransactionType.income) {
income += amount;
incomeCount++;
@@ -128,22 +136,34 @@ final statsExpenseTotalProvider = Provider<double>((ref) {
averageIncome: incomeCount == 0 ? 0 : income / incomeCount,
averageExpense: expenseCount == 0 ? 0 : expense / expenseCount,
);
});
});
final categoryExpenseProvider = Provider<Map<String, double>>((ref) {
final exchange = ref.watch(exchangeRateServiceProvider);
final index = ref.watch(activeAccountIndexProvider);
final accountsAsync = ref.watch(accountsProvider);
final globalCurrency = ref.watch(currencyProvider).code;
final accounts = accountsAsync.value ?? [];
final target = _resolveTargetCurrency(index, accounts, globalCurrency);
final map = <String, double>{};
for (final t in ref.watch(statsScopedTransactionsProvider)) {
if (t.type != TransactionType.expense) continue;
map[t.category] = (map[t.category] ?? 0) + _convertAmount(ref, t);
map[t.category] = (map[t.category] ?? 0) + exchange.convert(t.amount, t.currencyCode, target);
}
return map;
});
final categoryIncomeProvider = Provider<Map<String, double>>((ref) {
final exchange = ref.watch(exchangeRateServiceProvider);
final index = ref.watch(activeAccountIndexProvider);
final accountsAsync = ref.watch(accountsProvider);
final globalCurrency = ref.watch(currencyProvider).code;
final accounts = accountsAsync.value ?? [];
final target = _resolveTargetCurrency(index, accounts, globalCurrency);
final map = <String, double>{};
for (final t in ref.watch(statsScopedTransactionsProvider)) {
if (t.type != TransactionType.income) continue;
map[t.category] = (map[t.category] ?? 0) + _convertAmount(ref, t);
map[t.category] = (map[t.category] ?? 0) + exchange.convert(t.amount, t.currencyCode, target);
}
return map;
});
@@ -151,7 +171,11 @@ final categoryIncomeProvider = Provider<Map<String, double>>((ref) {
final monthlyBreakdownProvider = Provider<List<MonthlyData>>((ref) {
final txs = ref.watch(accountFilteredTransactionsProvider);
final exchange = ref.watch(exchangeRateServiceProvider);
final target = _statsTargetCurrency(ref);
final index = ref.watch(activeAccountIndexProvider);
final accountsAsync = ref.watch(accountsProvider);
final globalCurrency = ref.watch(currencyProvider).code;
final accounts = accountsAsync.value ?? [];
final target = _resolveTargetCurrency(index, accounts, globalCurrency);
final now = DateTime.now();
final months = <MonthlyData>[];
@@ -177,7 +201,11 @@ final monthlyBreakdownProvider = Provider<List<MonthlyData>>((ref) {
final monthlyIncomeBreakdownProvider = Provider<List<MonthlyData>>((ref) {
final txs = ref.watch(accountFilteredTransactionsProvider);
final exchange = ref.watch(exchangeRateServiceProvider);
final target = _statsTargetCurrency(ref);
final index = ref.watch(activeAccountIndexProvider);
final accountsAsync = ref.watch(accountsProvider);
final globalCurrency = ref.watch(currencyProvider).code;
final accounts = accountsAsync.value ?? [];
final target = _resolveTargetCurrency(index, accounts, globalCurrency);
final now = DateTime.now();
final months = <MonthlyData>[];
@@ -63,9 +63,7 @@ class _AccountEditorOverlayState extends State<AccountEditorOverlay> {
return;
}
dash.setState(() {
dash.tempAccountName = _nameController.text;
});
dash.tempAccountName = _nameController.text;
dash.overlayEntry?.markNeedsBuild();
});
}
@@ -411,9 +409,7 @@ class _AccountEditorOverlayState extends State<AccountEditorOverlay> {
onTap: () {
setState(() {
_selectedCurrency = entry.$1;
dash.setState(() {
dash.tempAccountCurrency = entry.$1;
});
dash.tempAccountCurrency = entry.$1;
dash.overlayEntry?.markNeedsBuild();
_showCurrencyDropdown = false;
});
@@ -57,16 +57,14 @@ class AccountColorPanel extends StatelessWidget {
);
void onHSVChanged(HSVColor hsv) {
if (dashboardState.editingPrimary) {
dashboardState.tempPrimaryHSV = hsv;
dashboardState.tempPrimary = hsv.toColor();
} else {
dashboardState.tempSecondaryHSV = hsv;
dashboardState.tempSecondary = hsv.toColor();
}
setPanelState(() {});
dashboardState.setState(() {
if (dashboardState.editingPrimary) {
dashboardState.tempPrimaryHSV = hsv;
dashboardState.tempPrimary = hsv.toColor();
} else {
dashboardState.tempSecondaryHSV = hsv;
dashboardState.tempSecondary = hsv.toColor();
}
});
dashboardState.overlayEntry?.markNeedsBuild();
}
@@ -106,18 +104,16 @@ class AccountColorPanel extends StatelessWidget {
: dashboardState.tempPrimary,
isDimmed: isSolid,
onTap: () {
dashboardState.setState(() {
if (isSolid)
if (Theme.of(dashboardContext).brightness ==
Brightness.dark) {
dashboardState.tempDarkGradientType =
CardColorService.defaultGradientDark;
} else {
dashboardState.tempLightGradientType =
CardColorService.defaultGradientLight;
}
dashboardState.editingPrimary = true;
});
if (isSolid)
if (Theme.of(dashboardContext).brightness ==
Brightness.dark) {
dashboardState.tempDarkGradientType =
GradientType.linear;
} else {
dashboardState.tempLightGradientType =
GradientType.linear;
}
dashboardState.editingPrimary = true;
setPanelState(() {});
dashboardState.overlayEntry?.markNeedsBuild();
},
@@ -132,18 +128,16 @@ class AccountColorPanel extends StatelessWidget {
color: dashboardState.tempSecondary,
isDimmed: isSolid,
onTap: () {
dashboardState.setState(() {
if (isSolid)
if (Theme.of(dashboardContext).brightness ==
Brightness.dark) {
dashboardState.tempDarkGradientType =
CardColorService.defaultGradientDark;
} else {
dashboardState.tempLightGradientType =
CardColorService.defaultGradientLight;
}
dashboardState.editingPrimary = false;
});
if (isSolid)
if (Theme.of(dashboardContext).brightness ==
Brightness.dark) {
dashboardState.tempDarkGradientType =
GradientType.linear;
} else {
dashboardState.tempLightGradientType =
GradientType.linear;
}
dashboardState.editingPrimary = false;
setPanelState(() {});
dashboardState.overlayEntry?.markNeedsBuild();
},
@@ -164,17 +158,15 @@ class AccountColorPanel extends StatelessWidget {
onTap: isSolid
? null
: () {
dashboardState.setState(() {
if (Theme.of(dashboardContext).brightness ==
Brightness.dark) {
dashboardState.tempDarkGradientType =
GradientType.solid;
} else {
dashboardState.tempLightGradientType =
GradientType.solid;
}
dashboardState.editingPrimary = true;
});
if (Theme.of(dashboardContext).brightness ==
Brightness.dark) {
dashboardState.tempDarkGradientType =
GradientType.solid;
} else {
dashboardState.tempLightGradientType =
GradientType.solid;
}
dashboardState.editingPrimary = true;
setPanelState(() {});
dashboardState.overlayEntry?.markNeedsBuild();
},
@@ -292,10 +284,7 @@ class AccountColorPanel extends StatelessWidget {
children: [
GestureDetector(
onTap: () {
dashboardState.setState(
() => dashboardState.editingPrimary =
true,
);
dashboardState.editingPrimary = true;
setPanelState(() {});
dashboardState.overlayEntry
?.markNeedsBuild();
@@ -350,11 +339,7 @@ class AccountColorPanel extends StatelessWidget {
if (!isSolid)
GestureDetector(
onTap: () {
dashboardState.setState(
() =>
dashboardState.editingPrimary =
false,
);
dashboardState.editingPrimary = false;
setPanelState(() {});
dashboardState.overlayEntry
?.markNeedsBuild();
@@ -420,13 +405,8 @@ class AccountColorPanel extends StatelessWidget {
),
),
SizedBox(height: layout.controlSpacing),
IgnorePointer(
ignoring: isSolid,
child: AnimatedOpacity(
duration: const Duration(milliseconds: 200),
opacity: isSolid ? 0.3 : 1.0,
child: Row(
children: GradientType.values
Row(
children: GradientType.values
.where((t) => t != GradientType.solid)
.map((type) {
final isSelected = activeGradientType == type;
@@ -452,19 +432,15 @@ class AccountColorPanel extends StatelessWidget {
padding: const EdgeInsets.only(right: 6),
child: GestureDetector(
onTap: () {
dashboardState.setState(
() {
if (Theme.of(dashboardContext)
.brightness ==
Brightness.dark) {
dashboardState.tempDarkGradientType =
type;
} else {
dashboardState.tempLightGradientType =
type;
}
},
);
if (Theme.of(dashboardContext)
.brightness ==
Brightness.dark) {
dashboardState.tempDarkGradientType =
type;
} else {
dashboardState.tempLightGradientType =
type;
}
setPanelState(() {});
dashboardState.overlayEntry
?.markNeedsBuild();
@@ -526,10 +502,8 @@ class AccountColorPanel extends StatelessWidget {
),
),
);
})
.toList(),
),
),
})
.toList(),
),
SizedBox(height: layout.controlSpacing),
Row(
@@ -546,19 +520,17 @@ class AccountColorPanel extends StatelessWidget {
final defS = isDarkTheme
? CardColorService.defaultSecondary
: CardColorService.defaultSecondaryLight;
dashboardState.setState(() {
dashboardState.tempPrimary = defP;
dashboardState.tempSecondary = defS;
dashboardState.tempPrimaryHSV = HSVColor.fromColor(
defP,
);
dashboardState.tempSecondaryHSV =
HSVColor.fromColor(defS);
dashboardState.tempPrimary = defP;
dashboardState.tempSecondary = defS;
dashboardState.tempPrimaryHSV = HSVColor.fromColor(
defP,
);
dashboardState.tempSecondaryHSV =
HSVColor.fromColor(defS);
dashboardState.tempLightGradientType =
CardColorService.defaultGradientLight;
dashboardState.tempDarkGradientType =
CardColorService.defaultGradientDark;
});
setPanelState(() {});
dashboardState.overlayEntry?.markNeedsBuild();
},
@@ -186,16 +186,14 @@ class _FullScreenBlurOverlayState extends State<FullScreenBlurOverlay> {
);
void onHSVChanged(HSVColor hsv) {
if (dash.editingPrimary) {
dash.tempPrimaryHSV = hsv;
dash.tempPrimary = hsv.toColor();
} else {
dash.tempSecondaryHSV = hsv;
dash.tempSecondary = hsv.toColor();
}
setPanelState(() {});
dash.setState(() {
if (dash.editingPrimary) {
dash.tempPrimaryHSV = hsv;
dash.tempPrimary = hsv.toColor();
} else {
dash.tempSecondaryHSV = hsv;
dash.tempSecondary = hsv.toColor();
}
});
dash.overlayEntry?.markNeedsBuild();
}
@@ -233,19 +231,17 @@ class _FullScreenBlurOverlayState extends State<FullScreenBlurOverlay> {
: dash.tempPrimary,
isDimmed: isSolid,
onTap: () {
dash.setState(() {
if (isSolid) {
if (Theme.of(widget.context).brightness ==
Brightness.dark) {
dash.tempDarkGradientType =
CardColorService.defaultGradientDark;
} else {
dash.tempLightGradientType =
CardColorService.defaultGradientLight;
}
if (isSolid) {
if (Theme.of(widget.context).brightness ==
Brightness.dark) {
dash.tempDarkGradientType =
GradientType.linear;
} else {
dash.tempLightGradientType =
GradientType.linear;
}
dash.editingPrimary = true;
});
}
dash.editingPrimary = true;
setPanelState(() {});
dash.overlayEntry?.markNeedsBuild();
},
@@ -259,19 +255,17 @@ class _FullScreenBlurOverlayState extends State<FullScreenBlurOverlay> {
color: dash.tempSecondary,
isDimmed: isSolid,
onTap: () {
dash.setState(() {
if (isSolid) {
if (Theme.of(widget.context).brightness ==
Brightness.dark) {
dash.tempDarkGradientType =
CardColorService.defaultGradientDark;
} else {
dash.tempLightGradientType =
CardColorService.defaultGradientLight;
}
if (isSolid) {
if (Theme.of(widget.context).brightness ==
Brightness.dark) {
dash.tempDarkGradientType =
GradientType.linear;
} else {
dash.tempLightGradientType =
GradientType.linear;
}
dash.editingPrimary = false;
});
}
dash.editingPrimary = false;
setPanelState(() {});
dash.overlayEntry?.markNeedsBuild();
},
@@ -291,17 +285,15 @@ class _FullScreenBlurOverlayState extends State<FullScreenBlurOverlay> {
onTap: isSolid
? null
: () {
dash.setState(() {
if (Theme.of(widget.context).brightness ==
Brightness.dark) {
dash.tempDarkGradientType =
GradientType.solid;
} else {
dash.tempLightGradientType =
GradientType.solid;
}
dash.editingPrimary = true;
});
if (Theme.of(widget.context).brightness ==
Brightness.dark) {
dash.tempDarkGradientType =
GradientType.solid;
} else {
dash.tempLightGradientType =
GradientType.solid;
}
dash.editingPrimary = true;
setPanelState(() {});
dash.overlayEntry?.markNeedsBuild();
},
@@ -418,9 +410,7 @@ class _FullScreenBlurOverlayState extends State<FullScreenBlurOverlay> {
children: [
GestureDetector(
onTap: () {
dash.setState(
() => dash.editingPrimary = true,
);
dash.editingPrimary = true;
setPanelState(() {});
dash.overlayEntry?.markNeedsBuild();
},
@@ -471,9 +461,7 @@ class _FullScreenBlurOverlayState extends State<FullScreenBlurOverlay> {
if (!isSolid)
GestureDetector(
onTap: () {
dash.setState(
() => dash.editingPrimary = false,
);
dash.editingPrimary = false;
setPanelState(() {});
dash.overlayEntry?.markNeedsBuild();
},
@@ -532,13 +520,8 @@ class _FullScreenBlurOverlayState extends State<FullScreenBlurOverlay> {
),
),
SizedBox(height: layout.controlSpacing),
IgnorePointer(
ignoring: isSolid,
child: AnimatedOpacity(
duration: const Duration(milliseconds: 200),
opacity: isSolid ? 0.3 : 1.0,
child: Row(
children: GradientType.values
Row(
children: GradientType.values
.where((t) => t != GradientType.solid)
.map((type) {
final isSelected = activeGradientType == type;
@@ -564,14 +547,12 @@ class _FullScreenBlurOverlayState extends State<FullScreenBlurOverlay> {
padding: const EdgeInsets.only(right: 6),
child: GestureDetector(
onTap: () {
dash.setState(() {
if (Theme.of(widget.context).brightness ==
Brightness.dark) {
dash.tempDarkGradientType = type;
} else {
dash.tempLightGradientType = type;
}
});
if (Theme.of(widget.context).brightness ==
Brightness.dark) {
dash.tempDarkGradientType = type;
} else {
dash.tempLightGradientType = type;
}
setPanelState(() {});
dash.overlayEntry?.markNeedsBuild();
},
@@ -632,10 +613,8 @@ class _FullScreenBlurOverlayState extends State<FullScreenBlurOverlay> {
),
),
);
})
.toList(),
),
),
})
.toList(),
),
SizedBox(height: layout.controlSpacing),
Row(
@@ -652,16 +631,14 @@ class _FullScreenBlurOverlayState extends State<FullScreenBlurOverlay> {
final defS = isDarkTheme
? CardColorService.defaultSecondary
: CardColorService.defaultSecondaryLight;
dash.setState(() {
dash.tempPrimary = defP;
dash.tempSecondary = defS;
dash.tempPrimaryHSV = HSVColor.fromColor(defP);
dash.tempSecondaryHSV = HSVColor.fromColor(defS);
dash.tempLightGradientType =
CardColorService.defaultGradientLight;
dash.tempDarkGradientType =
CardColorService.defaultGradientDark;
});
dash.tempPrimary = defP;
dash.tempSecondary = defS;
dash.tempPrimaryHSV = HSVColor.fromColor(defP);
dash.tempSecondaryHSV = HSVColor.fromColor(defS);
dash.tempLightGradientType =
CardColorService.defaultGradientLight;
dash.tempDarkGradientType =
CardColorService.defaultGradientDark;
setPanelState(() {});
dash.overlayEntry?.markNeedsBuild();
},
@@ -2,9 +2,7 @@ import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import '../../../core/constants.dart';
import '../../../core/l10n/locale_provider.dart';
import '../../../core/services/haptic_service.dart';
import '../../../shared/providers/current_user_provider.dart';
import '../../../shared/models/user_model.dart';
class PremiumSection extends ConsumerWidget {
const PremiumSection({super.key});
@@ -66,16 +64,6 @@ class PremiumSection extends ConsumerWidget {
],
),
),
Switch(
value: user.isVip,
onChanged: (value) async {
HapticService.light();
await ref.read(currentUserProvider.notifier).setPlan(
value ? UserPlan.vip : UserPlan.free,
);
},
activeThumbColor: const Color(0xFF7C6DED),
),
],
),
],