Compare commits

...

3 Commits

Author SHA1 Message Date
kolo c4ac692019 update 2026-08-06 21:35:22 +03:00
kolo 861a9abd02 first google play release for internal testing 2026-07-10 17:32:02 +03:00
kolo e3c60c4775 step 2026-07-01 16:20:30 +03:00
39 changed files with 838 additions and 770 deletions
+17 -17
View File
@@ -44,8 +44,8 @@ class AppTheme {
scaffoldBackgroundColor: AppColors.background, scaffoldBackgroundColor: AppColors.background,
colorScheme: const ColorScheme.dark( colorScheme: const ColorScheme.dark(
surface: AppColors.surface, surface: AppColors.surface,
primary: AppColors.accent, primary: const Color(0xFF7C6DED),
secondary: AppColors.accent, secondary: const Color(0xFF7C6DED),
onPrimary: Colors.white, onPrimary: Colors.white,
onSurface: AppColors.textPrimary, onSurface: AppColors.textPrimary,
), ),
@@ -70,11 +70,11 @@ class AppTheme {
), ),
navigationBarTheme: NavigationBarThemeData( navigationBarTheme: NavigationBarThemeData(
backgroundColor: AppColors.surface, backgroundColor: AppColors.surface,
indicatorColor: AppColors.accent.withOpacity(0.2), indicatorColor: const Color(0xFF7C6DED).withOpacity(0.2),
labelTextStyle: WidgetStateProperty.resolveWith((states) { labelTextStyle: WidgetStateProperty.resolveWith((states) {
if (states.contains(WidgetState.selected)) { if (states.contains(WidgetState.selected)) {
return GoogleFonts.poppins( return GoogleFonts.poppins(
color: AppColors.accent, color: const Color(0xFF7C6DED),
fontSize: 12, fontSize: 12,
fontWeight: FontWeight.w600, fontWeight: FontWeight.w600,
); );
@@ -86,7 +86,7 @@ class AppTheme {
}), }),
iconTheme: WidgetStateProperty.resolveWith((states) { iconTheme: WidgetStateProperty.resolveWith((states) {
if (states.contains(WidgetState.selected)) { if (states.contains(WidgetState.selected)) {
return const IconThemeData(color: AppColors.accent); return const IconThemeData(color: const Color(0xFF7C6DED));
} }
return const IconThemeData(color: AppColors.textSecondary); return const IconThemeData(color: AppColors.textSecondary);
}), }),
@@ -104,14 +104,14 @@ class AppTheme {
), ),
focusedBorder: OutlineInputBorder( focusedBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(12), borderRadius: BorderRadius.circular(12),
borderSide: const BorderSide(color: AppColors.accent, width: 1.5), borderSide: const BorderSide(color: const Color(0xFF7C6DED), width: 1.5),
), ),
labelStyle: const TextStyle(color: AppColors.textSecondary), labelStyle: const TextStyle(color: AppColors.textSecondary),
hintStyle: const TextStyle(color: AppColors.textSecondary), hintStyle: const TextStyle(color: AppColors.textSecondary),
), ),
elevatedButtonTheme: ElevatedButtonThemeData( elevatedButtonTheme: ElevatedButtonThemeData(
style: ElevatedButton.styleFrom( style: ElevatedButton.styleFrom(
backgroundColor: AppColors.accent, backgroundColor: const Color(0xFF7C6DED),
foregroundColor: Colors.white, foregroundColor: Colors.white,
minimumSize: const Size(double.infinity, 52), minimumSize: const Size(double.infinity, 52),
shape: RoundedRectangleBorder( shape: RoundedRectangleBorder(
@@ -145,8 +145,8 @@ class AppTheme {
scaffoldBackgroundColor: const Color(0xFFF0F0F7), scaffoldBackgroundColor: const Color(0xFFF0F0F7),
colorScheme: const ColorScheme.light( colorScheme: const ColorScheme.light(
surface: Colors.white, surface: Colors.white,
primary: AppColors.accent, primary: const Color(0xFF7C6DED),
secondary: AppColors.accent, secondary: const Color(0xFF7C6DED),
onPrimary: Colors.white, onPrimary: Colors.white,
onSurface: Color(0xFF1A1A2E), onSurface: Color(0xFF1A1A2E),
), ),
@@ -168,15 +168,15 @@ class AppTheme {
fontSize: 20, fontSize: 20,
fontWeight: FontWeight.w600, fontWeight: FontWeight.w600,
), ),
iconTheme: const IconThemeData(color: AppColors.accent), iconTheme: const IconThemeData(color: const Color(0xFF7C6DED)),
), ),
navigationBarTheme: NavigationBarThemeData( navigationBarTheme: NavigationBarThemeData(
backgroundColor: Colors.white, backgroundColor: Colors.white,
indicatorColor: AppColors.accent.withOpacity(0.2), indicatorColor: const Color(0xFF7C6DED).withOpacity(0.2),
labelTextStyle: WidgetStateProperty.resolveWith((states) { labelTextStyle: WidgetStateProperty.resolveWith((states) {
if (states.contains(WidgetState.selected)) { if (states.contains(WidgetState.selected)) {
return GoogleFonts.poppins( return GoogleFonts.poppins(
color: AppColors.accent, color: const Color(0xFF7C6DED),
fontSize: 12, fontSize: 12,
fontWeight: FontWeight.w600, fontWeight: FontWeight.w600,
); );
@@ -188,7 +188,7 @@ class AppTheme {
}), }),
iconTheme: WidgetStateProperty.resolveWith((states) { iconTheme: WidgetStateProperty.resolveWith((states) {
if (states.contains(WidgetState.selected)) { if (states.contains(WidgetState.selected)) {
return const IconThemeData(color: AppColors.accent); return const IconThemeData(color: const Color(0xFF7C6DED));
} }
return const IconThemeData(color: Color(0xFF9999BB)); return const IconThemeData(color: Color(0xFF9999BB));
}), }),
@@ -206,14 +206,14 @@ class AppTheme {
), ),
focusedBorder: OutlineInputBorder( focusedBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(8), borderRadius: BorderRadius.circular(8),
borderSide: const BorderSide(color: AppColors.accent, width: 1.5), borderSide: const BorderSide(color: const Color(0xFF7C6DED), width: 1.5),
), ),
labelStyle: const TextStyle(color: Color(0xFF9999BB)), labelStyle: const TextStyle(color: Color(0xFF9999BB)),
hintStyle: const TextStyle(color: Color(0xFF9999BB)), hintStyle: const TextStyle(color: Color(0xFF9999BB)),
), ),
elevatedButtonTheme: ElevatedButtonThemeData( elevatedButtonTheme: ElevatedButtonThemeData(
style: ElevatedButton.styleFrom( style: ElevatedButton.styleFrom(
backgroundColor: AppColors.accent, backgroundColor: const Color(0xFF7C6DED),
foregroundColor: Colors.white, foregroundColor: Colors.white,
minimumSize: const Size(double.infinity, 52), minimumSize: const Size(double.infinity, 52),
shape: RoundedRectangleBorder( shape: RoundedRectangleBorder(
@@ -229,10 +229,10 @@ class AppTheme {
color: Color(0xFFDDDDEE), color: Color(0xFFDDDDEE),
thickness: 1, thickness: 1,
), ),
iconTheme: const IconThemeData(color: AppColors.accent), iconTheme: const IconThemeData(color: const Color(0xFF7C6DED)),
chipTheme: ChipThemeData( chipTheme: ChipThemeData(
backgroundColor: const Color(0xFFEEEEF8), backgroundColor: const Color(0xFFEEEEF8),
selectedColor: AppColors.accent, selectedColor: const Color(0xFF7C6DED),
labelStyle: GoogleFonts.poppins( labelStyle: GoogleFonts.poppins(
color: const Color(0xFF1A1A2E), color: const Color(0xFF1A1A2E),
), ),
+13
View File
@@ -332,6 +332,19 @@ class AppStrings {
_ru ? 'Предыдущие покупки не найдены' : 'No previous purchases found'; _ru ? 'Предыдущие покупки не найдены' : 'No previous purchases found';
String get proTapToClose => String get proTapToClose =>
_ru ? 'Нажмите чтобы закрыть' : 'Tap anywhere to close'; _ru ? 'Нажмите чтобы закрыть' : 'Tap anywhere to close';
String get proResetData =>
_ru ? 'Сбросить тестовые данные' : 'Reset Test Data';
String get proResetDataDesc => _ru
? 'Локально отменить подписку для тестирования'
: 'Locally cancel subscription for testing';
String get proResetDataConfirm => _ru
? 'Сбросить подписку? Это локально очистит ваш премиум статус.'
: 'Reset subscription? This will locally clear your premium status.';
String get proResetDataSuccess => _ru
? 'Премиум статус сброшен'
: 'Premium status reset';
String get proRestoreSuccessTitle =>
_ru ? 'Покупки восстановлены!' : 'Purchases Restored!';
String get backupTitle => _ru ? 'Резервная копия' : 'Backup'; String get backupTitle => _ru ? 'Резервная копия' : 'Backup';
String get backupCreate => _ru ? 'Создать резервную копию' : 'Create Backup'; String get backupCreate => _ru ? 'Создать резервную копию' : 'Create Backup';
String get backupRestore => _ru ? 'Восстановить из копии' : 'Restore Backup'; String get backupRestore => _ru ? 'Восстановить из копии' : 'Restore Backup';
+6 -6
View File
@@ -10,14 +10,14 @@ class CardColorService {
static const _keyGradientLight = 'gradient_type_light'; static const _keyGradientLight = 'gradient_type_light';
static const _keyGradientDark = 'gradient_type_dark'; static const _keyGradientDark = 'gradient_type_dark';
static const defaultPrimary = Color(0xFFBEF264); static const defaultPrimary = Color(0xFF4CAF8C);
static const defaultSecondary = Color(0xFF4D7C0F); static const defaultSecondary = Color(0xFF4CAF8C);
static const defaultPrimaryLight = Color(0xFF6A6482); static const defaultPrimaryLight = Color(0xFF4CAF8C);
static const defaultSecondaryLight = Color(0xFF000000); static const defaultSecondaryLight = Color(0xFF4CAF8C);
static const defaultGradientLight = GradientType.sweep; static const defaultGradientLight = GradientType.solid;
static const defaultGradientDark = GradientType.radial; static const defaultGradientDark = GradientType.solid;
static Future<(Color, Color, GradientType, GradientType)> load({ static Future<(Color, Color, GradientType, GradientType)> load({
int? accountId, int? accountId,
+2 -2
View File
@@ -391,7 +391,7 @@ class _AddTransactionScreenState extends ConsumerState<AddTransactionScreen>
data: Theme.of(context).copyWith( data: Theme.of(context).copyWith(
colorScheme: Theme.of( colorScheme: Theme.of(
context, context,
).colorScheme.copyWith(primary: AppColors.accent), ).colorScheme.copyWith(primary: const Color(0xFF7C6DED)),
), ),
child: child!, child: child!,
), ),
@@ -995,7 +995,7 @@ class _ToAccountDropdownOverlay extends ConsumerWidget {
const Icon( const Icon(
Icons.check_rounded, Icons.check_rounded,
size: 16, size: 16,
color: Color(0xFF7C6DED), color: const Color(0xFF7C6DED),
), ),
], ],
], ],
@@ -73,7 +73,7 @@ class AccountSelector extends ConsumerWidget {
const Icon( const Icon(
Icons.account_balance_wallet_rounded, Icons.account_balance_wallet_rounded,
size: 18, size: 18,
color: Color(0xFF7C6DED), color: const Color(0xFF7C6DED),
), ),
const SizedBox(width: 10), const SizedBox(width: 10),
Flexible( Flexible(
@@ -244,7 +244,7 @@ class AccountDropdownOverlay extends ConsumerWidget {
const Icon( const Icon(
Icons.check_rounded, Icons.check_rounded,
size: 16, size: 16,
color: Color(0xFF7C6DED), color: const Color(0xFF7C6DED),
), ),
], ],
], ],
@@ -105,22 +105,22 @@ class _AddCategoryChip extends StatelessWidget {
child: Container( child: Container(
padding: const EdgeInsets.symmetric(horizontal: 14, vertical: 10), padding: const EdgeInsets.symmetric(horizontal: 14, vertical: 10),
decoration: BoxDecoration( decoration: BoxDecoration(
color: AppColors.accent.withOpacity(0.12), color: const Color(0xFF7C6DED).withOpacity(0.12),
borderRadius: BorderRadius.circular(12), borderRadius: BorderRadius.circular(12),
border: Border.all( border: Border.all(
color: AppColors.accent.withOpacity(0.5), color: const Color(0xFF7C6DED).withOpacity(0.5),
width: 1, width: 1,
), ),
), ),
child: Row( child: Row(
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
children: [ children: [
const Icon(Icons.add_rounded, color: AppColors.accent, size: 16), const Icon(Icons.add_rounded, color: const Color(0xFF7C6DED), size: 16),
const SizedBox(width: 6), const SizedBox(width: 6),
Text( Text(
label, label,
style: Theme.of(context).textTheme.bodySmall?.copyWith( style: Theme.of(context).textTheme.bodySmall?.copyWith(
color: AppColors.accent, color: const Color(0xFF7C6DED),
fontWeight: FontWeight.w600, fontWeight: FontWeight.w600,
), ),
), ),
@@ -43,7 +43,7 @@ class NoteField extends StatelessWidget {
), ),
focusedBorder: OutlineInputBorder( focusedBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(12), borderRadius: BorderRadius.circular(12),
borderSide: const BorderSide(color: Color(0xFF7C6DED), width: 1.5), borderSide: BorderSide(color: const Color(0xFF7C6DED), width: 1.5),
), ),
), ),
onChanged: onChanged, onChanged: onChanged,
+67 -39
View File
@@ -1,4 +1,5 @@
import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart';
import '../../shared/models/account.dart';
import '../../shared/models/transaction.dart'; import '../../shared/models/transaction.dart';
import '../dashboard/provider.dart'; import '../dashboard/provider.dart';
import '../settings/provider.dart'; import '../settings/provider.dart';
@@ -35,81 +36,88 @@ class _StatsTimeFilterNotifier extends Notifier<StatsTimeFilter> {
}); });
} }
String _statsTargetCurrency(Ref ref) { String _resolveTargetCurrency(
final index = ref.watch(activeAccountIndexProvider); int activeIndex,
final accountsAsync = ref.watch(accountsProvider); List<Account> accounts,
final globalCurrency = ref.watch(currencyProvider).code; String globalCurrency,
) {
if (index > 0) { if (activeIndex > 0 && activeIndex <= accounts.length) {
final accounts = accountsAsync.value ?? []; return accounts[activeIndex - 1].currency;
if (index <= accounts.length) {
return accounts[index - 1].currency;
} }
}
return globalCurrency; return globalCurrency;
} }
CurrencyInfo _statsCurrencyInfo(Ref ref) { List<Transaction> _filterScopedTransactions(
final code = _statsTargetCurrency(ref); List<Transaction> txs,
return CurrencyInfo(currencyMap[code]?.symbol ?? '\$', code); StatsTimeFilter timeFilter,
} ) {
List<Transaction> _statsScopedTransactions(Ref ref) {
final txs = ref.watch(accountFilteredTransactionsProvider);
final timeFilter = ref.watch(statsTimeFilterProvider);
var filtered = txs.where((t) => t.category != 'Transfer'); var filtered = txs.where((t) => t.category != 'Transfer');
if (timeFilter == StatsTimeFilter.month) { if (timeFilter == StatsTimeFilter.month) {
final now = DateTime.now(); final now = DateTime.now();
filtered = filtered.where( filtered = filtered.where(
(t) => t.date.year == now.year && t.date.month == now.month, (t) => t.date.year == now.year && t.date.month == now.month,
); );
} }
return filtered.toList(); 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) { 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) { final statsScopedTransactionsProvider = Provider<List<Transaction>>((ref) {
return _statsScopedTransactions(ref); final txs = ref.watch(accountFilteredTransactionsProvider);
final timeFilter = ref.watch(statsTimeFilterProvider);
return _filterScopedTransactions(txs, timeFilter);
}); });
final statsIncomeTotalProvider = Provider<double>((ref) { 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 return ref
.watch(statsScopedTransactionsProvider) .watch(statsScopedTransactionsProvider)
.where((t) => t.type == TransactionType.income) .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 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 return ref
.watch(statsScopedTransactionsProvider) .watch(statsScopedTransactionsProvider)
.where((t) => t.type == TransactionType.expense) .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); final transactions = ref.watch(statsScopedTransactionsProvider);
var income = 0.0; var income = 0.0;
var expense = 0.0; var expense = 0.0;
var incomeCount = 0; var incomeCount = 0;
var expenseCount = 0; var expenseCount = 0;
for (final transaction in transactions) { for (final transaction in transactions) {
final amount = _convertAmount(ref, transaction); final amount = exchange.convert(transaction.amount, transaction.currencyCode, target);
if (transaction.type == TransactionType.income) { if (transaction.type == TransactionType.income) {
income += amount; income += amount;
incomeCount++; incomeCount++;
@@ -131,19 +139,31 @@ final statsExpenseTotalProvider = Provider<double>((ref) {
}); });
final categoryExpenseProvider = Provider<Map<String, double>>((ref) { 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>{}; final map = <String, double>{};
for (final t in ref.watch(statsScopedTransactionsProvider)) { for (final t in ref.watch(statsScopedTransactionsProvider)) {
if (t.type != TransactionType.expense) continue; 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; return map;
}); });
final categoryIncomeProvider = Provider<Map<String, double>>((ref) { 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>{}; final map = <String, double>{};
for (final t in ref.watch(statsScopedTransactionsProvider)) { for (final t in ref.watch(statsScopedTransactionsProvider)) {
if (t.type != TransactionType.income) continue; 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; return map;
}); });
@@ -151,7 +171,11 @@ final categoryIncomeProvider = Provider<Map<String, double>>((ref) {
final monthlyBreakdownProvider = Provider<List<MonthlyData>>((ref) { final monthlyBreakdownProvider = Provider<List<MonthlyData>>((ref) {
final txs = ref.watch(accountFilteredTransactionsProvider); final txs = ref.watch(accountFilteredTransactionsProvider);
final exchange = ref.watch(exchangeRateServiceProvider); 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 now = DateTime.now();
final months = <MonthlyData>[]; final months = <MonthlyData>[];
@@ -177,7 +201,11 @@ final monthlyBreakdownProvider = Provider<List<MonthlyData>>((ref) {
final monthlyIncomeBreakdownProvider = Provider<List<MonthlyData>>((ref) { final monthlyIncomeBreakdownProvider = Provider<List<MonthlyData>>((ref) {
final txs = ref.watch(accountFilteredTransactionsProvider); final txs = ref.watch(accountFilteredTransactionsProvider);
final exchange = ref.watch(exchangeRateServiceProvider); 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 now = DateTime.now();
final months = <MonthlyData>[]; final months = <MonthlyData>[];
+4 -4
View File
@@ -456,7 +456,7 @@ class _CategoryItem extends ConsumerWidget {
final isRu = s.locale == AppLocale.ru; final isRu = s.locale == AppLocale.ru;
final catalog = ref.watch(categoryCatalogProvider); final catalog = ref.watch(categoryCatalogProvider);
final fmt = ref.watch(amountFormatProvider); final fmt = ref.watch(amountFormatProvider);
final color = catalog.colorFor(category, AppColors.accent); final color = catalog.colorFor(category, const Color(0xFF7C6DED));
final icon = catalog.iconFor(category); final icon = catalog.iconFor(category);
final pct = total > 0 ? amount / total : 0.0; final pct = total > 0 ? amount / total : 0.0;
@@ -571,7 +571,7 @@ class _SummaryBadgeRow extends ConsumerWidget {
'${(share * 100).toStringAsFixed(1)}%', '${(share * 100).toStringAsFixed(1)}%',
style: Theme.of(context).textTheme.bodyMedium?.copyWith( style: Theme.of(context).textTheme.bodyMedium?.copyWith(
fontWeight: FontWeight.w700, fontWeight: FontWeight.w700,
color: AppColors.accent, color: const Color(0xFF7C6DED),
), ),
), ),
), ),
@@ -874,7 +874,7 @@ class _TimePeriodToggle extends ConsumerWidget {
child: _ToggleChip( child: _ToggleChip(
label: s.filterMonth, label: s.filterMonth,
isSelected: filter == StatsTimeFilter.month, isSelected: filter == StatsTimeFilter.month,
color: AppColors.accent, color: const Color(0xFF7C6DED),
onTap: () => onChanged(StatsTimeFilter.month), onTap: () => onChanged(StatsTimeFilter.month),
), ),
), ),
@@ -882,7 +882,7 @@ class _TimePeriodToggle extends ConsumerWidget {
child: _ToggleChip( child: _ToggleChip(
label: s.filterAllTime, label: s.filterAllTime,
isSelected: filter == StatsTimeFilter.allTime, isSelected: filter == StatsTimeFilter.allTime,
color: AppColors.accent, color: const Color(0xFF7C6DED),
onTap: () => onChanged(StatsTimeFilter.allTime), onTap: () => onChanged(StatsTimeFilter.allTime),
), ),
), ),
@@ -90,11 +90,11 @@ class _ScopeChip extends StatelessWidget {
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 6), padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 6),
decoration: BoxDecoration( decoration: BoxDecoration(
color: isSelected color: isSelected
? AppColors.accent.withOpacity(0.2) ? const Color(0xFF7C6DED).withOpacity(0.2)
: Theme.of(context).colorScheme.surface, : Theme.of(context).colorScheme.surface,
borderRadius: BorderRadius.circular(20), borderRadius: BorderRadius.circular(20),
border: isSelected border: isSelected
? Border.all(color: AppColors.accent, width: 1.5) ? Border.all(color: const Color(0xFF7C6DED), width: 1.5)
: isDark : isDark
? null ? null
: Border.all(color: const Color(0xFFDDDDEE), width: 1), : Border.all(color: const Color(0xFFDDDDEE), width: 1),
@@ -105,7 +105,7 @@ class _ScopeChip extends StatelessWidget {
fontSize: 12, fontSize: 12,
fontWeight: isSelected ? FontWeight.w600 : FontWeight.normal, fontWeight: isSelected ? FontWeight.w600 : FontWeight.normal,
color: isSelected color: isSelected
? AppColors.accent ? const Color(0xFF7C6DED)
: Theme.of(context).colorScheme.onSurface.withOpacity(0.6), : Theme.of(context).colorScheme.onSurface.withOpacity(0.6),
), ),
), ),
+1 -1
View File
@@ -487,7 +487,7 @@ class _AccountsInfoBlock extends ConsumerWidget {
const Icon( const Icon(
Icons.account_balance_wallet_rounded, Icons.account_balance_wallet_rounded,
size: 18, size: 18,
color: Color(0xFF7C6DED), color: const Color(0xFF7C6DED),
), ),
const SizedBox(width: 8), const SizedBox(width: 8),
Text( Text(
@@ -63,9 +63,7 @@ class _AccountEditorOverlayState extends State<AccountEditorOverlay> {
return; return;
} }
dash.setState(() {
dash.tempAccountName = _nameController.text; dash.tempAccountName = _nameController.text;
});
dash.overlayEntry?.markNeedsBuild(); dash.overlayEntry?.markNeedsBuild();
}); });
} }
@@ -411,9 +409,7 @@ class _AccountEditorOverlayState extends State<AccountEditorOverlay> {
onTap: () { onTap: () {
setState(() { setState(() {
_selectedCurrency = entry.$1; _selectedCurrency = entry.$1;
dash.setState(() {
dash.tempAccountCurrency = entry.$1; dash.tempAccountCurrency = entry.$1;
});
dash.overlayEntry?.markNeedsBuild(); dash.overlayEntry?.markNeedsBuild();
_showCurrencyDropdown = false; _showCurrencyDropdown = false;
}); });
@@ -467,7 +463,7 @@ class _AccountEditorOverlayState extends State<AccountEditorOverlay> {
const Icon( const Icon(
Icons.check_rounded, Icons.check_rounded,
size: 14, size: 14,
color: Color(0xFF7C6DED), color: const Color(0xFF7C6DED),
), ),
], ],
], ],
@@ -57,8 +57,6 @@ class AccountColorPanel extends StatelessWidget {
); );
void onHSVChanged(HSVColor hsv) { void onHSVChanged(HSVColor hsv) {
setPanelState(() {});
dashboardState.setState(() {
if (dashboardState.editingPrimary) { if (dashboardState.editingPrimary) {
dashboardState.tempPrimaryHSV = hsv; dashboardState.tempPrimaryHSV = hsv;
dashboardState.tempPrimary = hsv.toColor(); dashboardState.tempPrimary = hsv.toColor();
@@ -66,7 +64,7 @@ class AccountColorPanel extends StatelessWidget {
dashboardState.tempSecondaryHSV = hsv; dashboardState.tempSecondaryHSV = hsv;
dashboardState.tempSecondary = hsv.toColor(); dashboardState.tempSecondary = hsv.toColor();
} }
}); setPanelState(() {});
dashboardState.overlayEntry?.markNeedsBuild(); dashboardState.overlayEntry?.markNeedsBuild();
} }
@@ -106,18 +104,16 @@ class AccountColorPanel extends StatelessWidget {
: dashboardState.tempPrimary, : dashboardState.tempPrimary,
isDimmed: isSolid, isDimmed: isSolid,
onTap: () { onTap: () {
dashboardState.setState(() {
if (isSolid) if (isSolid)
if (Theme.of(dashboardContext).brightness == if (Theme.of(dashboardContext).brightness ==
Brightness.dark) { Brightness.dark) {
dashboardState.tempDarkGradientType = dashboardState.tempDarkGradientType =
CardColorService.defaultGradientDark; GradientType.linear;
} else { } else {
dashboardState.tempLightGradientType = dashboardState.tempLightGradientType =
CardColorService.defaultGradientLight; GradientType.linear;
} }
dashboardState.editingPrimary = true; dashboardState.editingPrimary = true;
});
setPanelState(() {}); setPanelState(() {});
dashboardState.overlayEntry?.markNeedsBuild(); dashboardState.overlayEntry?.markNeedsBuild();
}, },
@@ -132,18 +128,16 @@ class AccountColorPanel extends StatelessWidget {
color: dashboardState.tempSecondary, color: dashboardState.tempSecondary,
isDimmed: isSolid, isDimmed: isSolid,
onTap: () { onTap: () {
dashboardState.setState(() {
if (isSolid) if (isSolid)
if (Theme.of(dashboardContext).brightness == if (Theme.of(dashboardContext).brightness ==
Brightness.dark) { Brightness.dark) {
dashboardState.tempDarkGradientType = dashboardState.tempDarkGradientType =
CardColorService.defaultGradientDark; GradientType.linear;
} else { } else {
dashboardState.tempLightGradientType = dashboardState.tempLightGradientType =
CardColorService.defaultGradientLight; GradientType.linear;
} }
dashboardState.editingPrimary = false; dashboardState.editingPrimary = false;
});
setPanelState(() {}); setPanelState(() {});
dashboardState.overlayEntry?.markNeedsBuild(); dashboardState.overlayEntry?.markNeedsBuild();
}, },
@@ -164,7 +158,6 @@ class AccountColorPanel extends StatelessWidget {
onTap: isSolid onTap: isSolid
? null ? null
: () { : () {
dashboardState.setState(() {
if (Theme.of(dashboardContext).brightness == if (Theme.of(dashboardContext).brightness ==
Brightness.dark) { Brightness.dark) {
dashboardState.tempDarkGradientType = dashboardState.tempDarkGradientType =
@@ -174,7 +167,6 @@ class AccountColorPanel extends StatelessWidget {
GradientType.solid; GradientType.solid;
} }
dashboardState.editingPrimary = true; dashboardState.editingPrimary = true;
});
setPanelState(() {}); setPanelState(() {});
dashboardState.overlayEntry?.markNeedsBuild(); dashboardState.overlayEntry?.markNeedsBuild();
}, },
@@ -292,10 +284,7 @@ class AccountColorPanel extends StatelessWidget {
children: [ children: [
GestureDetector( GestureDetector(
onTap: () { onTap: () {
dashboardState.setState( dashboardState.editingPrimary = true;
() => dashboardState.editingPrimary =
true,
);
setPanelState(() {}); setPanelState(() {});
dashboardState.overlayEntry dashboardState.overlayEntry
?.markNeedsBuild(); ?.markNeedsBuild();
@@ -350,11 +339,7 @@ class AccountColorPanel extends StatelessWidget {
if (!isSolid) if (!isSolid)
GestureDetector( GestureDetector(
onTap: () { onTap: () {
dashboardState.setState( dashboardState.editingPrimary = false;
() =>
dashboardState.editingPrimary =
false,
);
setPanelState(() {}); setPanelState(() {});
dashboardState.overlayEntry dashboardState.overlayEntry
?.markNeedsBuild(); ?.markNeedsBuild();
@@ -420,12 +405,7 @@ class AccountColorPanel extends StatelessWidget {
), ),
), ),
SizedBox(height: layout.controlSpacing), SizedBox(height: layout.controlSpacing),
IgnorePointer( Row(
ignoring: isSolid,
child: AnimatedOpacity(
duration: const Duration(milliseconds: 200),
opacity: isSolid ? 0.3 : 1.0,
child: Row(
children: GradientType.values children: GradientType.values
.where((t) => t != GradientType.solid) .where((t) => t != GradientType.solid)
.map((type) { .map((type) {
@@ -452,8 +432,6 @@ class AccountColorPanel extends StatelessWidget {
padding: const EdgeInsets.only(right: 6), padding: const EdgeInsets.only(right: 6),
child: GestureDetector( child: GestureDetector(
onTap: () { onTap: () {
dashboardState.setState(
() {
if (Theme.of(dashboardContext) if (Theme.of(dashboardContext)
.brightness == .brightness ==
Brightness.dark) { Brightness.dark) {
@@ -463,8 +441,6 @@ class AccountColorPanel extends StatelessWidget {
dashboardState.tempLightGradientType = dashboardState.tempLightGradientType =
type; type;
} }
},
);
setPanelState(() {}); setPanelState(() {});
dashboardState.overlayEntry dashboardState.overlayEntry
?.markNeedsBuild(); ?.markNeedsBuild();
@@ -529,8 +505,6 @@ class AccountColorPanel extends StatelessWidget {
}) })
.toList(), .toList(),
), ),
),
),
SizedBox(height: layout.controlSpacing), SizedBox(height: layout.controlSpacing),
Row( Row(
children: [ children: [
@@ -546,7 +520,6 @@ class AccountColorPanel extends StatelessWidget {
final defS = isDarkTheme final defS = isDarkTheme
? CardColorService.defaultSecondary ? CardColorService.defaultSecondary
: CardColorService.defaultSecondaryLight; : CardColorService.defaultSecondaryLight;
dashboardState.setState(() {
dashboardState.tempPrimary = defP; dashboardState.tempPrimary = defP;
dashboardState.tempSecondary = defS; dashboardState.tempSecondary = defS;
dashboardState.tempPrimaryHSV = HSVColor.fromColor( dashboardState.tempPrimaryHSV = HSVColor.fromColor(
@@ -558,7 +531,6 @@ class AccountColorPanel extends StatelessWidget {
CardColorService.defaultGradientLight; CardColorService.defaultGradientLight;
dashboardState.tempDarkGradientType = dashboardState.tempDarkGradientType =
CardColorService.defaultGradientDark; CardColorService.defaultGradientDark;
});
setPanelState(() {}); setPanelState(() {});
dashboardState.overlayEntry?.markNeedsBuild(); dashboardState.overlayEntry?.markNeedsBuild();
}, },
@@ -29,7 +29,7 @@ String _smartBalance(double amount, AmountFormat fmt, String symbol) {
return symbol.isEmpty ? formatted : '$symbol$formatted'; return symbol.isEmpty ? formatted : '$symbol$formatted';
} }
class BalanceCard extends ConsumerStatefulWidget { class BalanceCard extends StatefulWidget {
final double balance; final double balance;
final CurrencyInfo currencyInfo; final CurrencyInfo currencyInfo;
final VoidCallback? onLongPress; final VoidCallback? onLongPress;
@@ -56,10 +56,10 @@ class BalanceCard extends ConsumerStatefulWidget {
}); });
@override @override
ConsumerState<BalanceCard> createState() => BalanceCardState(); State<BalanceCard> createState() => BalanceCardState();
} }
class BalanceCardState extends ConsumerState<BalanceCard> class BalanceCardState extends State<BalanceCard>
with SingleTickerProviderStateMixin { with SingleTickerProviderStateMixin {
late final AnimationController _controller; late final AnimationController _controller;
double _tiltX = 0.0, _tiltY = 0.0; double _tiltX = 0.0, _tiltY = 0.0;
@@ -92,6 +92,8 @@ class BalanceCardState extends ConsumerState<BalanceCard>
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Consumer(
builder: (context, ref, _) {
final s = ref.watch(stringsProvider); final s = ref.watch(stringsProvider);
final rates = ref.read(exchangeRateServiceProvider); final rates = ref.read(exchangeRateServiceProvider);
final fmt = ref.watch(amountFormatProvider); final fmt = ref.watch(amountFormatProvider);
@@ -357,5 +359,7 @@ class BalanceCardState extends ConsumerState<BalanceCard>
}, },
), ),
); );
},
);
} }
} }
@@ -186,8 +186,6 @@ class _FullScreenBlurOverlayState extends State<FullScreenBlurOverlay> {
); );
void onHSVChanged(HSVColor hsv) { void onHSVChanged(HSVColor hsv) {
setPanelState(() {});
dash.setState(() {
if (dash.editingPrimary) { if (dash.editingPrimary) {
dash.tempPrimaryHSV = hsv; dash.tempPrimaryHSV = hsv;
dash.tempPrimary = hsv.toColor(); dash.tempPrimary = hsv.toColor();
@@ -195,7 +193,7 @@ class _FullScreenBlurOverlayState extends State<FullScreenBlurOverlay> {
dash.tempSecondaryHSV = hsv; dash.tempSecondaryHSV = hsv;
dash.tempSecondary = hsv.toColor(); dash.tempSecondary = hsv.toColor();
} }
}); setPanelState(() {});
dash.overlayEntry?.markNeedsBuild(); dash.overlayEntry?.markNeedsBuild();
} }
@@ -233,19 +231,17 @@ class _FullScreenBlurOverlayState extends State<FullScreenBlurOverlay> {
: dash.tempPrimary, : dash.tempPrimary,
isDimmed: isSolid, isDimmed: isSolid,
onTap: () { onTap: () {
dash.setState(() {
if (isSolid) { if (isSolid) {
if (Theme.of(widget.context).brightness == if (Theme.of(widget.context).brightness ==
Brightness.dark) { Brightness.dark) {
dash.tempDarkGradientType = dash.tempDarkGradientType =
CardColorService.defaultGradientDark; GradientType.linear;
} else { } else {
dash.tempLightGradientType = dash.tempLightGradientType =
CardColorService.defaultGradientLight; GradientType.linear;
} }
} }
dash.editingPrimary = true; dash.editingPrimary = true;
});
setPanelState(() {}); setPanelState(() {});
dash.overlayEntry?.markNeedsBuild(); dash.overlayEntry?.markNeedsBuild();
}, },
@@ -259,19 +255,17 @@ class _FullScreenBlurOverlayState extends State<FullScreenBlurOverlay> {
color: dash.tempSecondary, color: dash.tempSecondary,
isDimmed: isSolid, isDimmed: isSolid,
onTap: () { onTap: () {
dash.setState(() {
if (isSolid) { if (isSolid) {
if (Theme.of(widget.context).brightness == if (Theme.of(widget.context).brightness ==
Brightness.dark) { Brightness.dark) {
dash.tempDarkGradientType = dash.tempDarkGradientType =
CardColorService.defaultGradientDark; GradientType.linear;
} else { } else {
dash.tempLightGradientType = dash.tempLightGradientType =
CardColorService.defaultGradientLight; GradientType.linear;
} }
} }
dash.editingPrimary = false; dash.editingPrimary = false;
});
setPanelState(() {}); setPanelState(() {});
dash.overlayEntry?.markNeedsBuild(); dash.overlayEntry?.markNeedsBuild();
}, },
@@ -291,7 +285,6 @@ class _FullScreenBlurOverlayState extends State<FullScreenBlurOverlay> {
onTap: isSolid onTap: isSolid
? null ? null
: () { : () {
dash.setState(() {
if (Theme.of(widget.context).brightness == if (Theme.of(widget.context).brightness ==
Brightness.dark) { Brightness.dark) {
dash.tempDarkGradientType = dash.tempDarkGradientType =
@@ -301,7 +294,6 @@ class _FullScreenBlurOverlayState extends State<FullScreenBlurOverlay> {
GradientType.solid; GradientType.solid;
} }
dash.editingPrimary = true; dash.editingPrimary = true;
});
setPanelState(() {}); setPanelState(() {});
dash.overlayEntry?.markNeedsBuild(); dash.overlayEntry?.markNeedsBuild();
}, },
@@ -418,9 +410,7 @@ class _FullScreenBlurOverlayState extends State<FullScreenBlurOverlay> {
children: [ children: [
GestureDetector( GestureDetector(
onTap: () { onTap: () {
dash.setState( dash.editingPrimary = true;
() => dash.editingPrimary = true,
);
setPanelState(() {}); setPanelState(() {});
dash.overlayEntry?.markNeedsBuild(); dash.overlayEntry?.markNeedsBuild();
}, },
@@ -471,9 +461,7 @@ class _FullScreenBlurOverlayState extends State<FullScreenBlurOverlay> {
if (!isSolid) if (!isSolid)
GestureDetector( GestureDetector(
onTap: () { onTap: () {
dash.setState( dash.editingPrimary = false;
() => dash.editingPrimary = false,
);
setPanelState(() {}); setPanelState(() {});
dash.overlayEntry?.markNeedsBuild(); dash.overlayEntry?.markNeedsBuild();
}, },
@@ -532,12 +520,7 @@ class _FullScreenBlurOverlayState extends State<FullScreenBlurOverlay> {
), ),
), ),
SizedBox(height: layout.controlSpacing), SizedBox(height: layout.controlSpacing),
IgnorePointer( Row(
ignoring: isSolid,
child: AnimatedOpacity(
duration: const Duration(milliseconds: 200),
opacity: isSolid ? 0.3 : 1.0,
child: Row(
children: GradientType.values children: GradientType.values
.where((t) => t != GradientType.solid) .where((t) => t != GradientType.solid)
.map((type) { .map((type) {
@@ -564,14 +547,12 @@ class _FullScreenBlurOverlayState extends State<FullScreenBlurOverlay> {
padding: const EdgeInsets.only(right: 6), padding: const EdgeInsets.only(right: 6),
child: GestureDetector( child: GestureDetector(
onTap: () { onTap: () {
dash.setState(() {
if (Theme.of(widget.context).brightness == if (Theme.of(widget.context).brightness ==
Brightness.dark) { Brightness.dark) {
dash.tempDarkGradientType = type; dash.tempDarkGradientType = type;
} else { } else {
dash.tempLightGradientType = type; dash.tempLightGradientType = type;
} }
});
setPanelState(() {}); setPanelState(() {});
dash.overlayEntry?.markNeedsBuild(); dash.overlayEntry?.markNeedsBuild();
}, },
@@ -635,8 +616,6 @@ class _FullScreenBlurOverlayState extends State<FullScreenBlurOverlay> {
}) })
.toList(), .toList(),
), ),
),
),
SizedBox(height: layout.controlSpacing), SizedBox(height: layout.controlSpacing),
Row( Row(
children: [ children: [
@@ -652,7 +631,6 @@ class _FullScreenBlurOverlayState extends State<FullScreenBlurOverlay> {
final defS = isDarkTheme final defS = isDarkTheme
? CardColorService.defaultSecondary ? CardColorService.defaultSecondary
: CardColorService.defaultSecondaryLight; : CardColorService.defaultSecondaryLight;
dash.setState(() {
dash.tempPrimary = defP; dash.tempPrimary = defP;
dash.tempSecondary = defS; dash.tempSecondary = defS;
dash.tempPrimaryHSV = HSVColor.fromColor(defP); dash.tempPrimaryHSV = HSVColor.fromColor(defP);
@@ -661,7 +639,6 @@ class _FullScreenBlurOverlayState extends State<FullScreenBlurOverlay> {
CardColorService.defaultGradientLight; CardColorService.defaultGradientLight;
dash.tempDarkGradientType = dash.tempDarkGradientType =
CardColorService.defaultGradientDark; CardColorService.defaultGradientDark;
});
setPanelState(() {}); setPanelState(() {});
dash.overlayEntry?.markNeedsBuild(); dash.overlayEntry?.markNeedsBuild();
}, },
@@ -94,7 +94,7 @@ class _FilterChip extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final chipColor = color ?? AppColors.accent; final chipColor = color ?? const Color(0xFF7C6DED);
final isDark = Theme.of(context).brightness == Brightness.dark; final isDark = Theme.of(context).brightness == Brightness.dark;
return GestureDetector( return GestureDetector(
@@ -52,7 +52,7 @@ class SearchBar extends StatelessWidget {
), ),
focusedBorder: OutlineInputBorder( focusedBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(12), borderRadius: BorderRadius.circular(12),
borderSide: const BorderSide(color: Color(0xFF7C6DED), width: 1.5), borderSide: BorderSide(color: const Color(0xFF7C6DED), width: 1.5),
), ),
border: OutlineInputBorder( border: OutlineInputBorder(
borderRadius: BorderRadius.circular(12), borderRadius: BorderRadius.circular(12),
@@ -471,7 +471,7 @@ class _TransferChip extends StatelessWidget {
label, label,
style: const TextStyle( style: const TextStyle(
fontSize: 11, fontSize: 11,
color: Color(0xFF7C6DED), color: const Color(0xFF7C6DED),
fontWeight: FontWeight.w500, fontWeight: FontWeight.w500,
), ),
overflow: TextOverflow.ellipsis, overflow: TextOverflow.ellipsis,
@@ -334,7 +334,7 @@ class _CategoryEditorSheetState extends ConsumerState<CategoryEditorSheet> {
child: FilledButton( child: FilledButton(
onPressed: _saving ? null : _save, onPressed: _saving ? null : _save,
style: FilledButton.styleFrom( style: FilledButton.styleFrom(
backgroundColor: AppColors.accent, backgroundColor: const Color(0xFF7C6DED),
padding: const EdgeInsets.symmetric(vertical: 16), padding: const EdgeInsets.symmetric(vertical: 16),
shape: RoundedRectangleBorder( shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(14), borderRadius: BorderRadius.circular(14),
@@ -576,7 +576,7 @@ class _TranslatableField extends StatelessWidget {
child: TextButton( child: TextButton(
onPressed: onApply, onPressed: onApply,
style: TextButton.styleFrom( style: TextButton.styleFrom(
foregroundColor: AppColors.accent, foregroundColor: const Color(0xFF7C6DED),
padding: const EdgeInsets.symmetric(horizontal: 10), padding: const EdgeInsets.symmetric(horizontal: 10),
minimumSize: const Size(0, 36), minimumSize: const Size(0, 36),
tapTargetSize: MaterialTapTargetSize.shrinkWrap, tapTargetSize: MaterialTapTargetSize.shrinkWrap,
@@ -592,7 +592,7 @@ class _TranslatableField extends StatelessWidget {
return IconButton( return IconButton(
onPressed: onTranslate, onPressed: onTranslate,
icon: const Icon(Icons.translate_rounded, size: 20), icon: const Icon(Icons.translate_rounded, size: 20),
color: AppColors.accent, color: const Color(0xFF7C6DED),
tooltip: '', tooltip: '',
); );
} }
@@ -68,7 +68,7 @@ class CategoryManagerScreen extends ConsumerWidget {
HapticService.medium(); HapticService.medium();
showCategoryEditor(context); showCategoryEditor(context);
}, },
backgroundColor: AppColors.accent, backgroundColor: const Color(0xFF7C6DED),
foregroundColor: Colors.white, foregroundColor: Colors.white,
icon: const Icon(Icons.add), icon: const Icon(Icons.add),
label: Text( label: Text(
+2 -2
View File
@@ -283,12 +283,12 @@ class _BiometricSectionState extends ConsumerState<_BiometricSection> {
Container( Container(
padding: const EdgeInsets.all(10), padding: const EdgeInsets.all(10),
decoration: BoxDecoration( decoration: BoxDecoration(
color: AppColors.accent.withOpacity(0.15), color: const Color(0xFF7C6DED).withOpacity(0.15),
borderRadius: BorderRadius.circular(12), borderRadius: BorderRadius.circular(12),
), ),
child: const Icon( child: const Icon(
Icons.fingerprint, Icons.fingerprint,
color: AppColors.accent, color: const Color(0xFF7C6DED),
size: 20, size: 20,
), ),
), ),
@@ -33,12 +33,12 @@ class AmountFormatSection extends ConsumerWidget {
Container( Container(
padding: const EdgeInsets.all(10), padding: const EdgeInsets.all(10),
decoration: BoxDecoration( decoration: BoxDecoration(
color: AppColors.accent.withOpacity(0.15), color: const Color(0xFF7C6DED).withOpacity(0.15),
borderRadius: BorderRadius.circular(12), borderRadius: BorderRadius.circular(12),
), ),
child: const Icon( child: const Icon(
Icons.format_list_numbered_rounded, Icons.format_list_numbered_rounded,
color: AppColors.accent, color: const Color(0xFF7C6DED),
size: 20, size: 20,
), ),
), ),
@@ -69,11 +69,11 @@ class AmountFormatSection extends ConsumerWidget {
), ),
decoration: BoxDecoration( decoration: BoxDecoration(
color: isSelected color: isSelected
? AppColors.accent.withOpacity(0.2) ? const Color(0xFF7C6DED).withOpacity(0.2)
: Theme.of(context).scaffoldBackgroundColor, : Theme.of(context).scaffoldBackgroundColor,
borderRadius: BorderRadius.circular(12), borderRadius: BorderRadius.circular(12),
border: isSelected border: isSelected
? Border.all(color: AppColors.accent, width: 1.5) ? Border.all(color: const Color(0xFF7C6DED), width: 1.5)
: (isDark : (isDark
? null ? null
: Border.all( : Border.all(
@@ -88,7 +88,7 @@ class AmountFormatSection extends ConsumerWidget {
format.label, format.label,
style: TextStyle( style: TextStyle(
color: isSelected color: isSelected
? AppColors.accent ? const Color(0xFF7C6DED)
: Theme.of(context).colorScheme.onSurface, : Theme.of(context).colorScheme.onSurface,
fontWeight: isSelected fontWeight: isSelected
? FontWeight.w600 ? FontWeight.w600
@@ -30,12 +30,12 @@ class CardTextColorSection extends ConsumerWidget {
Container( Container(
padding: const EdgeInsets.all(10), padding: const EdgeInsets.all(10),
decoration: BoxDecoration( decoration: BoxDecoration(
color: AppColors.accent.withOpacity(0.15), color: const Color(0xFF7C6DED).withOpacity(0.15),
borderRadius: BorderRadius.circular(12), borderRadius: BorderRadius.circular(12),
), ),
child: const Icon( child: const Icon(
Icons.text_fields_rounded, Icons.text_fields_rounded,
color: AppColors.accent, color: const Color(0xFF7C6DED),
size: 20, size: 20,
), ),
), ),
@@ -116,14 +116,14 @@ class _CardTextColorOption extends StatelessWidget {
padding: const EdgeInsets.symmetric(vertical: 10), padding: const EdgeInsets.symmetric(vertical: 10),
decoration: BoxDecoration( decoration: BoxDecoration(
color: isSelected color: isSelected
? AppColors.accent.withOpacity(0.15) ? const Color(0xFF7C6DED).withOpacity(0.15)
: (isDark : (isDark
? Colors.white.withOpacity(0.05) ? Colors.white.withOpacity(0.05)
: Colors.black.withOpacity(0.03)), : Colors.black.withOpacity(0.03)),
borderRadius: BorderRadius.circular(12), borderRadius: BorderRadius.circular(12),
border: Border.all( border: Border.all(
color: isSelected color: isSelected
? AppColors.accent ? const Color(0xFF7C6DED)
: (isDark : (isDark
? Colors.white.withOpacity(0.1) ? Colors.white.withOpacity(0.1)
: Colors.black.withOpacity(0.08)), : Colors.black.withOpacity(0.08)),
@@ -136,7 +136,7 @@ class _CardTextColorOption extends StatelessWidget {
Icon( Icon(
icon, icon,
color: isSelected color: isSelected
? AppColors.accent ? const Color(0xFF7C6DED)
: Theme.of(context).colorScheme.onSurface.withOpacity(0.5), : Theme.of(context).colorScheme.onSurface.withOpacity(0.5),
size: 22, size: 22,
), ),
@@ -147,7 +147,7 @@ class _CardTextColorOption extends StatelessWidget {
fontSize: 11, fontSize: 11,
fontWeight: isSelected ? FontWeight.w600 : FontWeight.normal, fontWeight: isSelected ? FontWeight.w600 : FontWeight.normal,
color: isSelected color: isSelected
? AppColors.accent ? const Color(0xFF7C6DED)
: Theme.of(context).colorScheme.onSurface.withOpacity(0.6), : Theme.of(context).colorScheme.onSurface.withOpacity(0.6),
), ),
textAlign: TextAlign.center, textAlign: TextAlign.center,
@@ -33,12 +33,12 @@ class CategoriesSection extends ConsumerWidget {
Container( Container(
padding: const EdgeInsets.all(10), padding: const EdgeInsets.all(10),
decoration: BoxDecoration( decoration: BoxDecoration(
color: AppColors.accent.withOpacity(0.15), color: const Color(0xFF7C6DED).withOpacity(0.15),
borderRadius: BorderRadius.circular(12), borderRadius: BorderRadius.circular(12),
), ),
child: const Icon( child: const Icon(
Icons.category_rounded, Icons.category_rounded,
color: AppColors.accent, color: const Color(0xFF7C6DED),
size: 20, size: 20,
), ),
), ),
@@ -27,12 +27,12 @@ class CurrencyConversionsSection extends ConsumerWidget {
Container( Container(
padding: const EdgeInsets.all(10), padding: const EdgeInsets.all(10),
decoration: BoxDecoration( decoration: BoxDecoration(
color: AppColors.accent.withOpacity(0.15), color: const Color(0xFF7C6DED).withOpacity(0.15),
borderRadius: BorderRadius.circular(12), borderRadius: BorderRadius.circular(12),
), ),
child: const Icon( child: const Icon(
Icons.currency_exchange_rounded, Icons.currency_exchange_rounded,
color: AppColors.accent, color: const Color(0xFF7C6DED),
size: 20, size: 20,
), ),
), ),
@@ -31,12 +31,12 @@ class CurrencySection extends ConsumerWidget {
Container( Container(
padding: const EdgeInsets.all(10), padding: const EdgeInsets.all(10),
decoration: BoxDecoration( decoration: BoxDecoration(
color: AppColors.accent.withOpacity(0.15), color: const Color(0xFF7C6DED).withOpacity(0.15),
borderRadius: BorderRadius.circular(12), borderRadius: BorderRadius.circular(12),
), ),
child: const Icon( child: const Icon(
Icons.attach_money_rounded, Icons.attach_money_rounded,
color: AppColors.accent, color: const Color(0xFF7C6DED),
size: 20, size: 20,
), ),
), ),
@@ -68,11 +68,11 @@ class CurrencySection extends ConsumerWidget {
padding: const EdgeInsets.symmetric(vertical: 10), padding: const EdgeInsets.symmetric(vertical: 10),
decoration: BoxDecoration( decoration: BoxDecoration(
color: isSelected color: isSelected
? AppColors.accent.withOpacity(0.2) ? const Color(0xFF7C6DED).withOpacity(0.2)
: Theme.of(context).scaffoldBackgroundColor, : Theme.of(context).scaffoldBackgroundColor,
borderRadius: BorderRadius.circular(12), borderRadius: BorderRadius.circular(12),
border: isSelected border: isSelected
? Border.all(color: AppColors.accent, width: 1.5) ? Border.all(color: const Color(0xFF7C6DED), width: 1.5)
: (isDark : (isDark
? null ? null
: Border.all( : Border.all(
@@ -90,7 +90,7 @@ class CurrencySection extends ConsumerWidget {
child: BynSign( child: BynSign(
fontSize: 24, fontSize: 24,
color: isSelected color: isSelected
? AppColors.accent ? const Color(0xFF7C6DED)
: Theme.of(context).colorScheme.onSurface : Theme.of(context).colorScheme.onSurface
.withOpacity(0.6), .withOpacity(0.6),
), ),
@@ -101,7 +101,7 @@ class CurrencySection extends ConsumerWidget {
style: Theme.of(context).textTheme.titleLarge style: Theme.of(context).textTheme.titleLarge
?.copyWith( ?.copyWith(
color: isSelected color: isSelected
? AppColors.accent ? const Color(0xFF7C6DED)
: Theme.of(context) : Theme.of(context)
.colorScheme .colorScheme
.onSurface .onSurface
@@ -117,7 +117,7 @@ class CurrencySection extends ConsumerWidget {
style: Theme.of(context).textTheme.bodySmall style: Theme.of(context).textTheme.bodySmall
?.copyWith( ?.copyWith(
color: isSelected color: isSelected
? AppColors.accent ? const Color(0xFF7C6DED)
: Theme.of(context).colorScheme.onSurface : Theme.of(context).colorScheme.onSurface
.withOpacity(0.6), .withOpacity(0.6),
fontWeight: isSelected fontWeight: isSelected
@@ -25,12 +25,12 @@ class HapticSection extends ConsumerWidget {
Container( Container(
padding: const EdgeInsets.all(10), padding: const EdgeInsets.all(10),
decoration: BoxDecoration( decoration: BoxDecoration(
color: AppColors.accent.withOpacity(0.15), color: const Color(0xFF7C6DED).withOpacity(0.15),
borderRadius: BorderRadius.circular(12), borderRadius: BorderRadius.circular(12),
), ),
child: const Icon( child: const Icon(
Icons.vibration_rounded, Icons.vibration_rounded,
color: AppColors.accent, color: const Color(0xFF7C6DED),
size: 20, size: 20,
), ),
), ),
@@ -28,12 +28,12 @@ class LanguageSection extends ConsumerWidget {
Container( Container(
padding: const EdgeInsets.all(10), padding: const EdgeInsets.all(10),
decoration: BoxDecoration( decoration: BoxDecoration(
color: AppColors.accent.withOpacity(0.15), color: const Color(0xFF7C6DED).withOpacity(0.15),
borderRadius: BorderRadius.circular(12), borderRadius: BorderRadius.circular(12),
), ),
child: const Icon( child: const Icon(
Icons.language_rounded, Icons.language_rounded,
color: AppColors.accent, color: const Color(0xFF7C6DED),
size: 20, size: 20,
), ),
), ),
@@ -59,11 +59,11 @@ class LanguageSection extends ConsumerWidget {
padding: const EdgeInsets.symmetric(vertical: 12), padding: const EdgeInsets.symmetric(vertical: 12),
decoration: BoxDecoration( decoration: BoxDecoration(
color: currentLocale == AppLocale.en color: currentLocale == AppLocale.en
? AppColors.accent.withOpacity(0.2) ? const Color(0xFF7C6DED).withOpacity(0.2)
: Theme.of(context).scaffoldBackgroundColor, : Theme.of(context).scaffoldBackgroundColor,
borderRadius: BorderRadius.circular(12), borderRadius: BorderRadius.circular(12),
border: currentLocale == AppLocale.en border: currentLocale == AppLocale.en
? Border.all(color: AppColors.accent, width: 1.5) ? Border.all(color: const Color(0xFF7C6DED), 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(
@@ -71,7 +71,7 @@ class LanguageSection extends ConsumerWidget {
textAlign: TextAlign.center, textAlign: TextAlign.center,
style: TextStyle( style: TextStyle(
color: currentLocale == AppLocale.en color: currentLocale == AppLocale.en
? AppColors.accent ? const Color(0xFF7C6DED)
: Theme.of(context).colorScheme.onSurface.withOpacity(0.6), : Theme.of(context).colorScheme.onSurface.withOpacity(0.6),
fontWeight: currentLocale == AppLocale.en ? FontWeight.w600 : FontWeight.normal, fontWeight: currentLocale == AppLocale.en ? FontWeight.w600 : FontWeight.normal,
), ),
@@ -87,11 +87,11 @@ class LanguageSection extends ConsumerWidget {
padding: const EdgeInsets.symmetric(vertical: 12), padding: const EdgeInsets.symmetric(vertical: 12),
decoration: BoxDecoration( decoration: BoxDecoration(
color: currentLocale == AppLocale.ru color: currentLocale == AppLocale.ru
? AppColors.accent.withOpacity(0.2) ? const Color(0xFF7C6DED).withOpacity(0.2)
: Theme.of(context).scaffoldBackgroundColor, : Theme.of(context).scaffoldBackgroundColor,
borderRadius: BorderRadius.circular(12), borderRadius: BorderRadius.circular(12),
border: currentLocale == AppLocale.ru border: currentLocale == AppLocale.ru
? Border.all(color: AppColors.accent, width: 1.5) ? Border.all(color: const Color(0xFF7C6DED), 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(
@@ -99,7 +99,7 @@ class LanguageSection extends ConsumerWidget {
textAlign: TextAlign.center, textAlign: TextAlign.center,
style: TextStyle( style: TextStyle(
color: currentLocale == AppLocale.ru color: currentLocale == AppLocale.ru
? AppColors.accent ? const Color(0xFF7C6DED)
: Theme.of(context).colorScheme.onSurface.withOpacity(0.6), : Theme.of(context).colorScheme.onSurface.withOpacity(0.6),
fontWeight: currentLocale == AppLocale.ru ? FontWeight.w600 : FontWeight.normal, fontWeight: currentLocale == AppLocale.ru ? FontWeight.w600 : FontWeight.normal,
), ),
@@ -2,9 +2,7 @@ import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart';
import '../../../core/constants.dart'; import '../../../core/constants.dart';
import '../../../core/l10n/locale_provider.dart'; import '../../../core/l10n/locale_provider.dart';
import '../../../core/services/haptic_service.dart';
import '../../../shared/providers/current_user_provider.dart'; import '../../../shared/providers/current_user_provider.dart';
import '../../../shared/models/user_model.dart';
class PremiumSection extends ConsumerWidget { class PremiumSection extends ConsumerWidget {
const PremiumSection({super.key}); const PremiumSection({super.key});
@@ -32,13 +30,13 @@ class PremiumSection extends ConsumerWidget {
Container( Container(
padding: const EdgeInsets.all(10), padding: const EdgeInsets.all(10),
decoration: BoxDecoration( decoration: BoxDecoration(
color: (user.isVip ? AppColors.accent : AppColors.warning) color: (user.isVip ? const Color(0xFF7C6DED) : AppColors.warning)
.withOpacity(0.15), .withOpacity(0.15),
borderRadius: BorderRadius.circular(12), borderRadius: BorderRadius.circular(12),
), ),
child: Icon( child: Icon(
user.isVip ? Icons.workspace_premium_rounded : Icons.lock_outline_rounded, user.isVip ? Icons.workspace_premium_rounded : Icons.lock_outline_rounded,
color: user.isVip ? AppColors.accent : AppColors.warning, color: user.isVip ? const Color(0xFF7C6DED) : AppColors.warning,
size: 20, size: 20,
), ),
), ),
@@ -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),
),
], ],
), ),
], ],
@@ -28,7 +28,7 @@ class ThemeSection extends ConsumerWidget {
Container( Container(
padding: const EdgeInsets.all(10), padding: const EdgeInsets.all(10),
decoration: BoxDecoration( decoration: BoxDecoration(
color: AppColors.accent.withOpacity(0.15), color: const Color(0xFF7C6DED).withOpacity(0.15),
borderRadius: BorderRadius.circular(12), borderRadius: BorderRadius.circular(12),
), ),
child: Icon( child: Icon(
@@ -37,7 +37,7 @@ class ThemeSection extends ConsumerWidget {
: themeMode == ThemeMode.light : themeMode == ThemeMode.light
? Icons.light_mode_rounded ? Icons.light_mode_rounded
: Icons.brightness_auto_rounded, : Icons.brightness_auto_rounded,
color: AppColors.accent, color: const Color(0xFF7C6DED),
size: 20, size: 20,
), ),
), ),
@@ -112,12 +112,12 @@ class _ThemeOption extends StatelessWidget {
padding: const EdgeInsets.symmetric(vertical: 10), padding: const EdgeInsets.symmetric(vertical: 10),
decoration: BoxDecoration( decoration: BoxDecoration(
color: isSelected color: isSelected
? AppColors.accent.withOpacity(0.15) ? const Color(0xFF7C6DED).withOpacity(0.15)
: (isDark ? Colors.white.withOpacity(0.05) : Colors.black.withOpacity(0.03)), : (isDark ? Colors.white.withOpacity(0.05) : Colors.black.withOpacity(0.03)),
borderRadius: BorderRadius.circular(12), borderRadius: BorderRadius.circular(12),
border: Border.all( border: Border.all(
color: isSelected color: isSelected
? AppColors.accent ? const Color(0xFF7C6DED)
: (isDark ? Colors.white.withOpacity(0.1) : Colors.black.withOpacity(0.08)), : (isDark ? Colors.white.withOpacity(0.1) : Colors.black.withOpacity(0.08)),
width: isSelected ? 2 : 1, width: isSelected ? 2 : 1,
), ),
@@ -128,7 +128,7 @@ class _ThemeOption extends StatelessWidget {
Icon( Icon(
icon, icon,
color: isSelected color: isSelected
? AppColors.accent ? const Color(0xFF7C6DED)
: Theme.of(context).colorScheme.onSurface.withOpacity(0.5), : Theme.of(context).colorScheme.onSurface.withOpacity(0.5),
size: 22, size: 22,
), ),
@@ -139,7 +139,7 @@ class _ThemeOption extends StatelessWidget {
fontSize: 11, fontSize: 11,
fontWeight: isSelected ? FontWeight.w600 : FontWeight.normal, fontWeight: isSelected ? FontWeight.w600 : FontWeight.normal,
color: isSelected color: isSelected
? AppColors.accent ? const Color(0xFF7C6DED)
: Theme.of(context).colorScheme.onSurface.withOpacity(0.6), : Theme.of(context).colorScheme.onSurface.withOpacity(0.6),
), ),
textAlign: TextAlign.center, textAlign: TextAlign.center,
+4 -1
View File
@@ -1,4 +1,5 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:intl/date_symbol_data_local.dart'; import 'package:intl/date_symbol_data_local.dart';
import 'package:shared_preferences/shared_preferences.dart'; import 'package:shared_preferences/shared_preferences.dart';
@@ -25,7 +26,9 @@ void main() async {
final database = AppDatabase(); final database = AppDatabase();
final billing = PlayBillingService(); final billing = kDebugMode
? DebugBillingService(prefs)
: PlayBillingService();
final premiumManager = PremiumManager(prefs, billing); final premiumManager = PremiumManager(prefs, billing);
await premiumManager.autoRestore(); await premiumManager.autoRestore();
+1 -1
View File
@@ -37,7 +37,7 @@ class PaywallScreen extends ConsumerWidget {
child: const Icon( child: const Icon(
Icons.workspace_premium_rounded, Icons.workspace_premium_rounded,
size: 64, size: 64,
color: Color(0xFF7C6DED), color: const Color(0xFF7C6DED),
), ),
), ),
const SizedBox(height: 24), const SizedBox(height: 24),
@@ -1,6 +1,12 @@
import 'package:flutter/foundation.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart';
import '../../features/dashboard/provider.dart';
import '../services/billing_service.dart'; import '../services/billing_service.dart';
final billingServiceProvider = Provider<BillingService>((ref) { final billingServiceProvider = Provider<BillingService>((ref) {
if (kDebugMode) {
final prefs = ref.watch(sharedPreferencesProvider);
return DebugBillingService(prefs);
}
return PlayBillingService(); return PlayBillingService();
}); });
+2 -2
View File
@@ -107,7 +107,7 @@ class CategoryCatalog {
byKey(key)?.icon ?? Icons.category_rounded; byKey(key)?.icon ?? Icons.category_rounded;
Color colorFor(String key, [Color? fallback]) => Color colorFor(String key, [Color? fallback]) =>
byKey(key)?.color ?? fallback ?? AppColors.accent; byKey(key)?.color ?? fallback ?? const Color(0xFF7C6DED);
String labelFor(String key, bool isRu) { String labelFor(String key, bool isRu) {
final cat = byKey(key); final cat = byKey(key);
@@ -147,7 +147,7 @@ AppCategory _defaultCategory(String key, TransactionType type) {
labelEn: key, labelEn: key,
labelRu: AppCategories.ruLabels[key] ?? key, labelRu: AppCategories.ruLabels[key] ?? key,
icon: categoryIconByName(iconName), icon: categoryIconByName(iconName),
color: AppCategories.colors[key] ?? AppColors.accent, color: AppCategories.colors[key] ?? const Color(0xFF7C6DED),
iconName: iconName, iconName: iconName,
isCustom: false, isCustom: false,
); );
+4 -2
View File
@@ -1,7 +1,9 @@
import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart';
import '../../features/dashboard/provider.dart'; import '../../features/dashboard/provider.dart';
import '../models/user_model.dart';
import '../services/premium_manager.dart'; import '../services/premium_manager.dart';
import 'billing_provider.dart'; import 'billing_provider.dart';
import 'current_user_provider.dart';
final premiumManagerProvider = Provider<PremiumManager>((ref) { final premiumManagerProvider = Provider<PremiumManager>((ref) {
final prefs = ref.watch(sharedPreferencesProvider); final prefs = ref.watch(sharedPreferencesProvider);
@@ -10,8 +12,8 @@ final premiumManagerProvider = Provider<PremiumManager>((ref) {
}); });
final isPremiumProvider = Provider<bool>((ref) { final isPremiumProvider = Provider<bool>((ref) {
final manager = ref.watch(premiumManagerProvider); final user = ref.watch(currentUserProvider);
return manager.isPremium; return user.plan == UserPlan.vip;
}); });
final purchaseTokenProvider = Provider<String?>((ref) { final purchaseTokenProvider = Provider<String?>((ref) {
+121 -116
View File
@@ -1,6 +1,6 @@
import 'dart:async'; import 'dart:async';
import 'package:flutter/foundation.dart';
import 'package:in_app_purchase/in_app_purchase.dart'; import 'package:in_app_purchase/in_app_purchase.dart';
import 'package:shared_preferences/shared_preferences.dart';
class PurchaseResult { class PurchaseResult {
final bool success; final bool success;
@@ -14,6 +14,9 @@ class PurchaseResult {
factory PurchaseResult.failed([String? error]) => factory PurchaseResult.failed([String? error]) =>
PurchaseResult(success: false, error: error); PurchaseResult(success: false, error: error);
factory PurchaseResult.cancelled() =>
const PurchaseResult(success: false);
} }
abstract class BillingService { abstract class BillingService {
@@ -22,24 +25,11 @@ abstract class BillingService {
Future<PurchaseResult> purchasePro(); Future<PurchaseResult> purchasePro();
Future<PurchaseResult> restorePurchases(); Future<PurchaseResult> restorePurchases();
Future<PurchaseResult> queryPastPurchase(); Future<PurchaseResult> queryPastPurchase();
Future<void> completePurchase(String purchaseToken);
Stream<List<PurchaseDetails>> get purchaseStream;
Future<void> dispose(); Future<void> dispose();
} }
class PlayBillingService implements BillingService { class PlayBillingService implements BillingService {
final InAppPurchase _inAppPurchase = InAppPurchase.instance; final InAppPurchase _inAppPurchase = InAppPurchase.instance;
late final StreamSubscription<List<PurchaseDetails>> _sub;
final _controller = StreamController<List<PurchaseDetails>>.broadcast();
PlayBillingService() {
_sub = _inAppPurchase.purchaseStream.listen((purchases) {
_controller.add(purchases);
});
}
@override
Stream<List<PurchaseDetails>> get purchaseStream => _controller.stream;
@override @override
Future<PurchaseResult> purchasePro() async { Future<PurchaseResult> purchasePro() async {
@@ -51,51 +41,26 @@ class PlayBillingService implements BillingService {
final response = await _inAppPurchase.queryProductDetails( final response = await _inAppPurchase.queryProductDetails(
{BillingService.proProductId}, {BillingService.proProductId},
); );
if (response.error != null) {
return PurchaseResult.failed(response.error!.message);
}
if (response.productDetails.isEmpty) { if (response.productDetails.isEmpty) {
return PurchaseResult.failed('Product not found'); return PurchaseResult.failed('Product not found');
} }
final product = response.productDetails.first; final product = response.productDetails.first;
final purchaseParam = PurchaseParam(productDetails: product); return _waitForPurchase(
timeout: const Duration(minutes: 2),
timeoutError: 'Purchase timed out',
start: () async {
final started = await _inAppPurchase.buyNonConsumable( final started = await _inAppPurchase.buyNonConsumable(
purchaseParam: purchaseParam, purchaseParam: PurchaseParam(productDetails: product),
); );
if (!started) { if (!started) {
return PurchaseResult.failed('Could not start purchase'); throw StateError('Could not start purchase');
} }
final completer = Completer<PurchaseResult>();
late StreamSubscription sub;
sub = purchaseStream.timeout(
const Duration(seconds: 60),
onTimeout: (sink) {
if (!completer.isCompleted) {
completer.complete(PurchaseResult.failed('Purchase timed out'));
}
sub.cancel();
}, },
).listen((purchases) { );
for (final p in purchases) {
if (p.productID == BillingService.proProductId &&
p.status == PurchaseStatus.purchased) {
if (!completer.isCompleted) {
completer.complete(PurchaseResult.ok(p.verificationData.serverVerificationData));
}
sub.cancel();
return;
}
if (p.status == PurchaseStatus.error) {
if (!completer.isCompleted) {
completer.complete(PurchaseResult.failed(p.error?.message));
}
sub.cancel();
return;
}
}
});
return completer.future;
} }
@override @override
@@ -105,88 +70,128 @@ class PlayBillingService implements BillingService {
return PurchaseResult.failed('Billing not available'); return PurchaseResult.failed('Billing not available');
} }
await _inAppPurchase.restorePurchases(); return _waitForPurchase(
timeout: const Duration(seconds: 30),
timeoutError: 'No purchases found',
start: _inAppPurchase.restorePurchases,
);
}
@override
Future<PurchaseResult> queryPastPurchase() => restorePurchases();
Future<PurchaseResult> _waitForPurchase({
required Future<void> Function() start,
required Duration timeout,
required String timeoutError,
}) async {
final completer = Completer<PurchaseResult>(); final completer = Completer<PurchaseResult>();
late StreamSubscription sub; var handlingPurchase = false;
sub = purchaseStream.timeout( late final StreamSubscription<List<PurchaseDetails>> subscription;
const Duration(seconds: 15), late final Timer timeoutTimer;
onTimeout: (sink) {
void finish(PurchaseResult result) {
if (!completer.isCompleted) { if (!completer.isCompleted) {
completer.complete(PurchaseResult.failed('Restore timed out')); completer.complete(result);
} }
sub.cancel();
},
).listen((purchases) {
for (final p in purchases) {
if (p.productID == BillingService.proProductId &&
(p.status == PurchaseStatus.restored ||
p.status == PurchaseStatus.purchased)) {
if (!completer.isCompleted) {
completer.complete(PurchaseResult.ok(p.verificationData.serverVerificationData));
} }
sub.cancel();
Future<void> handlePurchase(PurchaseDetails purchase) async {
if (purchase.productID != BillingService.proProductId) return;
switch (purchase.status) {
case PurchaseStatus.pending:
return;
case PurchaseStatus.purchased:
case PurchaseStatus.restored:
if (handlingPurchase) return;
handlingPurchase = true;
try {
final token = purchase.verificationData.serverVerificationData;
if (token.isEmpty) {
finish(PurchaseResult.failed('Purchase verification data is empty'));
return; return;
} }
if (purchase.pendingCompletePurchase) {
await _inAppPurchase.completePurchase(purchase);
}
finish(PurchaseResult.ok(token));
} catch (error) {
finish(PurchaseResult.failed(error.toString()));
} finally {
handlingPurchase = false;
}
case PurchaseStatus.error:
finish(PurchaseResult.failed(purchase.error?.message));
case PurchaseStatus.canceled:
finish(PurchaseResult.cancelled());
}
} }
});
return completer.future; subscription = _inAppPurchase.purchaseStream.listen(
(purchases) {
for (final purchase in purchases) {
unawaited(handlePurchase(purchase));
}
},
onError: (Object error) {
finish(PurchaseResult.failed(error.toString()));
},
);
timeoutTimer = Timer(
timeout,
() => finish(PurchaseResult.failed(timeoutError)),
);
try {
await start();
} catch (error) {
finish(PurchaseResult.failed(error.toString()));
}
final result = await completer.future;
timeoutTimer.cancel();
await subscription.cancel();
return result;
}
@override
Future<void> dispose() async {}
}
class DebugBillingService implements BillingService {
static const _key = 'debug_purchase_token';
final SharedPreferences _prefs;
DebugBillingService(this._prefs);
@override
Future<PurchaseResult> purchasePro() async {
await Future.delayed(const Duration(seconds: 1));
final token = 'debug_token_${DateTime.now().millisecondsSinceEpoch}';
await _prefs.setString(_key, token);
return PurchaseResult.ok(token);
}
@override
Future<PurchaseResult> restorePurchases() async {
await Future.delayed(const Duration(seconds: 1));
final token = _prefs.getString(_key);
if (token != null) {
return PurchaseResult.ok(token);
}
return const PurchaseResult();
} }
@override @override
Future<PurchaseResult> queryPastPurchase() async { Future<PurchaseResult> queryPastPurchase() async {
final available = await _inAppPurchase.isAvailable(); final token = _prefs.getString(_key);
if (!available) { if (token != null) {
return PurchaseResult.ok(token);
}
return const PurchaseResult(); return const PurchaseResult();
} }
final response = await _inAppPurchase.queryProductDetails(
{BillingService.proProductId},
);
if (response.productDetails.isEmpty) {
return const PurchaseResult();
}
final completer = Completer<PurchaseResult>();
late StreamSubscription sub;
sub = purchaseStream.timeout(
const Duration(seconds: 10),
onTimeout: (sink) {
if (!completer.isCompleted) {
completer.complete(const PurchaseResult());
}
sub.cancel();
},
).listen((purchases) {
for (final p in purchases) {
if (p.productID == BillingService.proProductId &&
(p.status == PurchaseStatus.restored ||
p.status == PurchaseStatus.purchased)) {
if (!completer.isCompleted) {
completer.complete(PurchaseResult.ok(p.verificationData.serverVerificationData));
}
sub.cancel();
return;
}
}
});
await _inAppPurchase.restorePurchases();
return completer.future;
}
@override @override
Future<void> completePurchase(String purchaseToken) async { Future<void> dispose() async {}
if (kDebugMode) {
print('completePurchase: $purchaseToken');
}
}
@override
Future<void> dispose() async {
await _sub.cancel();
await _controller.close();
}
} }
+3 -3
View File
@@ -24,10 +24,12 @@ class PremiumManager {
} }
Future<PurchaseResult> purchase() async { Future<PurchaseResult> purchase() async {
if (isPremium) {
return PurchaseResult.ok(purchaseToken ?? 'existing');
}
final result = await _billing.purchasePro(); final result = await _billing.purchasePro();
if (result.success && result.purchaseToken != null) { if (result.success && result.purchaseToken != null) {
await _setPremium(true, result.purchaseToken); await _setPremium(true, result.purchaseToken);
await _billing.completePurchase(result.purchaseToken!);
} }
return result; return result;
} }
@@ -36,7 +38,6 @@ class PremiumManager {
final result = await _billing.restorePurchases(); final result = await _billing.restorePurchases();
if (result.success && result.purchaseToken != null) { if (result.success && result.purchaseToken != null) {
await _setPremium(true, result.purchaseToken); await _setPremium(true, result.purchaseToken);
await _billing.completePurchase(result.purchaseToken!);
} }
return result; return result;
} }
@@ -46,7 +47,6 @@ class PremiumManager {
final result = await _billing.queryPastPurchase(); final result = await _billing.queryPastPurchase();
if (result.success && result.purchaseToken != null) { if (result.success && result.purchaseToken != null) {
await _setPremium(true, result.purchaseToken); await _setPremium(true, result.purchaseToken);
await _billing.completePurchase(result.purchaseToken!);
} }
} }
+125 -144
View File
@@ -5,7 +5,6 @@ import '../../core/l10n/app_strings.dart';
import '../../core/l10n/locale_provider.dart'; import '../../core/l10n/locale_provider.dart';
import '../../core/services/haptic_service.dart'; import '../../core/services/haptic_service.dart';
import '../providers/current_user_provider.dart'; import '../providers/current_user_provider.dart';
import '../providers/google_drive_provider.dart';
import '../providers/premium_provider.dart'; import '../providers/premium_provider.dart';
import 'error_snackbar.dart'; import 'error_snackbar.dart';
@@ -20,14 +19,16 @@ class _ProScreenState extends ConsumerState<ProScreen>
with SingleTickerProviderStateMixin { with SingleTickerProviderStateMixin {
bool _purchasing = false; bool _purchasing = false;
bool _restoring = false; bool _restoring = false;
bool _resetting = false;
bool _showSuccess = false; bool _showSuccess = false;
String _successTitle = '';
late final AnimationController _successController; late final AnimationController _successController;
late final Animation<double> _successScale; late final Animation<double> _successScale;
static const _gradientColors = [ static const _gradientColors = [
Color(0xFF283593), Color(0xFF5B4DCC),
Color(0xFF5E35B1), Color(0xFF7C6DED),
Color(0xFFD81B60), Color(0xFF9D8FF5),
]; ];
@override @override
@@ -51,8 +52,11 @@ class _ProScreenState extends ConsumerState<ProScreen>
super.dispose(); super.dispose();
} }
void _showSuccessOverlay() { void _showSuccessOverlay(String title) {
setState(() => _showSuccess = true); setState(() {
_successTitle = title;
_showSuccess = true;
});
_successController.forward(from: 0.0); _successController.forward(from: 0.0);
} }
@@ -67,8 +71,6 @@ class _ProScreenState extends ConsumerState<ProScreen>
Widget build(BuildContext context) { Widget build(BuildContext context) {
final s = ref.watch(stringsProvider); final s = ref.watch(stringsProvider);
final isPremium = ref.watch(isPremiumProvider); final isPremium = ref.watch(isPremiumProvider);
final driveUserAsync = ref.watch(googleDriveUserProvider);
final driveUser = driveUserAsync.value;
final colorScheme = Theme.of(context).colorScheme; final colorScheme = Theme.of(context).colorScheme;
return Stack( return Stack(
@@ -77,7 +79,7 @@ class _ProScreenState extends ConsumerState<ProScreen>
body: SafeArea( body: SafeArea(
child: Column( child: Column(
children: [ children: [
_buildHeader(context, s, colorScheme), _buildHeader(context),
Expanded( Expanded(
child: SingleChildScrollView( child: SingleChildScrollView(
padding: const EdgeInsets.symmetric(horizontal: 20), padding: const EdgeInsets.symmetric(horizontal: 20),
@@ -85,13 +87,10 @@ class _ProScreenState extends ConsumerState<ProScreen>
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
const SizedBox(height: 4), const SizedBox(height: 4),
_buildHeroBanner(context, s, colorScheme, isPremium), _buildHeroBanner(context, s, isPremium),
const SizedBox(height: 20), const SizedBox(height: 20),
_buildFeatureList(context, s, colorScheme), _buildFeatureList(context, s, colorScheme),
const SizedBox(height: 16), const SizedBox(height: 16),
if (isPremium) ...[
_buildProActiveSection(context, s, colorScheme, driveUser),
],
], ],
), ),
), ),
@@ -106,11 +105,7 @@ class _ProScreenState extends ConsumerState<ProScreen>
); );
} }
Widget _buildHeader( Widget _buildHeader(BuildContext context) {
BuildContext context,
AppStrings s,
ColorScheme colorScheme,
) {
return Padding( return Padding(
padding: const EdgeInsets.fromLTRB(8, 4, 16, 0), padding: const EdgeInsets.fromLTRB(8, 4, 16, 0),
child: Row( child: Row(
@@ -127,12 +122,11 @@ class _ProScreenState extends ConsumerState<ProScreen>
Widget _buildHeroBanner( Widget _buildHeroBanner(
BuildContext context, BuildContext context,
AppStrings s, AppStrings s,
ColorScheme colorScheme,
bool isVip, bool isVip,
) { ) {
return Container( return Container(
width: double.infinity, width: double.infinity,
padding: const EdgeInsets.symmetric(vertical: 24, horizontal: 20), padding: const EdgeInsets.symmetric(vertical: 36, horizontal: 20),
decoration: BoxDecoration( decoration: BoxDecoration(
gradient: const LinearGradient( gradient: const LinearGradient(
begin: Alignment.topLeft, begin: Alignment.topLeft,
@@ -209,7 +203,7 @@ class _ProScreenState extends ConsumerState<ProScreen>
), ),
const SizedBox(height: 20), const SizedBox(height: 20),
Text( Text(
s.proPurchaseSuccess, _successTitle,
style: Theme.of(context).textTheme.titleLarge?.copyWith( style: Theme.of(context).textTheme.titleLarge?.copyWith(
fontWeight: FontWeight.w800, fontWeight: FontWeight.w800,
color: colorScheme.onSurface, color: colorScheme.onSurface,
@@ -240,7 +234,6 @@ class _ProScreenState extends ConsumerState<ProScreen>
ColorScheme colorScheme, ColorScheme colorScheme,
) { ) {
final features = [ final features = [
(Icons.cloud_sync_rounded, s.proFeatureCloudSync, s.proFeatureCloudSyncDesc),
(Icons.analytics_rounded, s.proFeatureAnalytics, s.proFeatureAnalyticsDesc), (Icons.analytics_rounded, s.proFeatureAnalytics, s.proFeatureAnalyticsDesc),
(Icons.palette_rounded, s.proFeatureCustomization, s.proFeatureCustomizationDesc), (Icons.palette_rounded, s.proFeatureCustomization, s.proFeatureCustomizationDesc),
(Icons.fingerprint_rounded, s.proFeatureBiometric, s.proFeatureBiometricDesc), (Icons.fingerprint_rounded, s.proFeatureBiometric, s.proFeatureBiometricDesc),
@@ -295,116 +288,12 @@ class _ProScreenState extends ConsumerState<ProScreen>
); );
} }
Widget _buildProActiveSection(
BuildContext context,
AppStrings s,
ColorScheme colorScheme,
dynamic googleUser,
) {
return Container(
padding: const EdgeInsets.all(16),
decoration: BoxDecoration(
color: colorScheme.surface,
borderRadius: BorderRadius.circular(16),
border: Border.all(
color: colorScheme.primary.withOpacity(0.2),
width: 1,
),
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
if (googleUser != null) ...[
Row(
children: [
Icon(Icons.email_outlined, size: 18, color: colorScheme.onSurface.withOpacity(0.5)),
const SizedBox(width: 8),
Expanded(
child: Text(
googleUser.email,
style: Theme.of(context).textTheme.bodyMedium?.copyWith(
color: colorScheme.onSurface,
),
),
),
],
),
const SizedBox(height: 12),
Row(
children: [
Icon(Icons.sync_rounded, size: 18, color: colorScheme.primary),
const SizedBox(width: 8),
Expanded(
child: Text(
s.proSyncEnabled,
style: Theme.of(context).textTheme.bodyMedium?.copyWith(
color: colorScheme.onSurface,
),
),
),
Icon(Icons.check_circle_rounded, color: colorScheme.primary, size: 20),
],
),
const SizedBox(height: 8),
Row(
children: [
Icon(Icons.backup_outlined, size: 18, color: colorScheme.onSurface.withOpacity(0.5)),
const SizedBox(width: 8),
Text(
'${s.proLastBackup}: —',
style: Theme.of(context).textTheme.bodySmall?.copyWith(
color: colorScheme.onSurface.withOpacity(0.5),
),
),
],
),
const SizedBox(height: 16),
Row(
children: [
Expanded(
child: OutlinedButton.icon(
onPressed: _handleGoogleSignOut,
icon: Icon(Icons.logout_rounded, color: colorScheme.error),
label: Text(s.proSignOut),
style: OutlinedButton.styleFrom(
foregroundColor: colorScheme.error,
),
),
),
],
),
] else ...[
Text(
s.proSignInForSync,
style: Theme.of(context).textTheme.bodyMedium?.copyWith(
color: colorScheme.onSurface.withOpacity(0.7),
),
),
const SizedBox(height: 16),
SizedBox(
width: double.infinity,
child: OutlinedButton.icon(
onPressed: _handleGoogleSignIn,
icon: Icon(Icons.login_rounded, color: colorScheme.primary),
label: Text(s.proSignInGoogle),
),
),
],
],
),
);
}
Widget _buildBottomBar( Widget _buildBottomBar(
BuildContext context, BuildContext context,
AppStrings s, AppStrings s,
ColorScheme colorScheme, ColorScheme colorScheme,
bool isVip, bool isVip,
) { ) {
if (isVip) {
return const SizedBox.shrink();
}
return Container( return Container(
padding: const EdgeInsets.fromLTRB(20, 12, 20, 24), padding: const EdgeInsets.fromLTRB(20, 12, 20, 24),
decoration: BoxDecoration( decoration: BoxDecoration(
@@ -419,6 +308,7 @@ class _ProScreenState extends ConsumerState<ProScreen>
child: Column( child: Column(
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
children: [ children: [
if (!isVip) ...[
SizedBox( SizedBox(
width: double.infinity, width: double.infinity,
child: FilledButton( child: FilledButton(
@@ -464,6 +354,78 @@ class _ProScreenState extends ConsumerState<ProScreen>
: Text(s.proRestorePurchases), : Text(s.proRestorePurchases),
), ),
), ),
] else ...[
Container(
width: double.infinity,
padding: const EdgeInsets.symmetric(vertical: 12, horizontal: 16),
decoration: BoxDecoration(
color: colorScheme.primary.withOpacity(0.08),
borderRadius: BorderRadius.circular(12),
border: Border.all(
color: colorScheme.primary.withOpacity(0.2),
width: 1,
),
),
child: Row(
children: [
Icon(
Icons.verified_rounded,
color: colorScheme.primary,
size: 20,
),
const SizedBox(width: 10),
Expanded(
child: Text(
s.proActive,
style: TextStyle(
color: colorScheme.primary,
fontWeight: FontWeight.w700,
fontSize: 14,
),
),
),
],
),
),
const SizedBox(height: 10),
SizedBox(
width: double.infinity,
child: OutlinedButton.icon(
onPressed: _resetting ? null : _handleResetData,
icon: _resetting
? SizedBox(
width: 16,
height: 16,
child: CircularProgressIndicator(
strokeWidth: 2,
color: colorScheme.onSurface.withOpacity(0.5),
),
)
: Icon(
Icons.restart_alt_rounded,
size: 18,
color: colorScheme.onSurface.withOpacity(0.6),
),
label: Text(
s.proResetData,
style: TextStyle(
fontSize: 13,
fontWeight: FontWeight.w600,
color: colorScheme.onSurface.withOpacity(0.6),
),
),
style: OutlinedButton.styleFrom(
padding: const EdgeInsets.symmetric(vertical: 12),
side: BorderSide(
color: colorScheme.onSurface.withOpacity(0.15),
),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(12),
),
),
),
),
],
], ],
), ),
); );
@@ -478,7 +440,7 @@ class _ProScreenState extends ConsumerState<ProScreen>
if (result.success) { if (result.success) {
await ref.read(currentUserProvider.notifier).refreshFromPremium(); await ref.read(currentUserProvider.notifier).refreshFromPremium();
if (mounted) { if (mounted) {
_showSuccessOverlay(); _showSuccessOverlay(ref.read(stringsProvider).proPurchaseSuccess);
HapticService.medium(); HapticService.medium();
} }
} else { } else {
@@ -504,7 +466,7 @@ class _ProScreenState extends ConsumerState<ProScreen>
if (result.success) { if (result.success) {
await ref.read(currentUserProvider.notifier).refreshFromPremium(); await ref.read(currentUserProvider.notifier).refreshFromPremium();
if (mounted) { if (mounted) {
_showSuccessOverlay(); _showSuccessOverlay(ref.read(stringsProvider).proRestoreSuccessTitle);
HapticService.medium(); HapticService.medium();
} }
} else { } else {
@@ -521,27 +483,46 @@ class _ProScreenState extends ConsumerState<ProScreen>
} }
} }
Future<void> _handleGoogleSignIn() async { Future<void> _handleResetData() async {
final s = ref.read(stringsProvider);
showDialog(
context: context,
builder: (ctx) => AlertDialog(
title: Text(s.proResetData),
content: Text(s.proResetDataConfirm),
actions: [
TextButton(
onPressed: () => Navigator.pop(ctx),
child: Text(s.cancel),
),
TextButton(
onPressed: () async {
Navigator.pop(ctx);
HapticService.light(); HapticService.light();
setState(() => _resetting = true);
try { try {
final service = ref.read(googleDriveServiceProvider); final manager = ref.read(premiumManagerProvider);
await service.signIn(); await manager.clear();
await ref.read(currentUserProvider.notifier).refreshFromPremium();
if (mounted) {
showSuccessSnackbar(context, s.proResetDataSuccess);
HapticService.medium();
}
} catch (e) { } catch (e) {
if (mounted) { if (mounted) {
showErrorSnackbar(context, e.toString()); showErrorSnackbar(context, e.toString());
} }
} } finally {
} if (mounted) setState(() => _resetting = false);
}
Future<void> _handleGoogleSignOut() async { },
HapticService.light(); style: TextButton.styleFrom(
try { foregroundColor: const Color(0xFFE05C6B),
final service = ref.read(googleDriveServiceProvider); ),
await service.signOut(); child: Text(s.proResetData),
} catch (e) { ),
if (mounted) { ],
showErrorSnackbar(context, e.toString()); ),
} );
}
} }
} }
+184 -91
View File
@@ -3,34 +3,60 @@ import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:go_router/go_router.dart'; import 'package:go_router/go_router.dart';
import '../../core/l10n/locale_provider.dart'; import '../../core/l10n/locale_provider.dart';
import '../../core/services/haptic_service.dart'; import '../../core/services/haptic_service.dart';
import '../providers/google_drive_provider.dart';
import '../providers/premium_provider.dart'; import '../providers/premium_provider.dart';
class ProSubscriptionCard extends ConsumerWidget { class ProSubscriptionCard extends StatefulWidget {
const ProSubscriptionCard({super.key}); const ProSubscriptionCard({super.key});
@override
State<ProSubscriptionCard> createState() =>
_ProSubscriptionCardState();
}
class _ProSubscriptionCardState extends State<ProSubscriptionCard>
with SingleTickerProviderStateMixin {
late final AnimationController _shimmerController;
static const _gradientColors = [ static const _gradientColors = [
Color(0xFF283593), Color(0xFF5B4DCC),
Color(0xFF5E35B1), Color(0xFF7C6DED),
Color(0xFFD81B60), Color(0xFF9D8FF5),
]; ];
@override @override
Widget build(BuildContext context, WidgetRef ref) { void initState() {
super.initState();
_shimmerController = AnimationController(
vsync: this,
duration: const Duration(milliseconds: 2800),
)..repeat();
}
@override
void dispose() {
_shimmerController.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
return Consumer(
builder: (context, ref, _) {
final s = ref.watch(stringsProvider); final s = ref.watch(stringsProvider);
final isPremium = ref.watch(isPremiumProvider); final isPremium = ref.watch(isPremiumProvider);
final driveUserAsync = ref.watch(googleDriveUserProvider);
final driveUser = driveUserAsync.value;
return Container( return ClipRRect(
padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 24), borderRadius: BorderRadius.circular(20),
decoration: BoxDecoration( child: Stack(
gradient: const LinearGradient( children: [
Container(
padding: const EdgeInsets.fromLTRB(20, 22, 20, 18),
decoration: const BoxDecoration(
gradient: LinearGradient(
begin: Alignment.topLeft, begin: Alignment.topLeft,
end: Alignment.bottomRight, end: Alignment.bottomRight,
colors: _gradientColors, colors: _gradientColors,
), ),
borderRadius: BorderRadius.circular(16),
), ),
child: Column( child: Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
@@ -38,17 +64,21 @@ class ProSubscriptionCard extends ConsumerWidget {
Row( Row(
children: [ children: [
Container( Container(
padding: const EdgeInsets.all(12), padding: const EdgeInsets.all(10),
decoration: BoxDecoration( decoration: BoxDecoration(
color: Colors.white.withOpacity(0.15), color: Colors.white.withOpacity(0.18),
borderRadius: BorderRadius.circular(12), borderRadius: BorderRadius.circular(12),
border: Border.all(
color: Colors.white.withOpacity(0.25),
width: 1,
),
), ),
child: Icon( child: Icon(
isPremium isPremium
? Icons.verified_rounded ? Icons.verified_rounded
: Icons.workspace_premium_rounded, : Icons.workspace_premium_rounded,
color: Colors.white, color: Colors.white,
size: 28, size: 26,
), ),
), ),
const SizedBox(width: 14), const SizedBox(width: 14),
@@ -58,114 +88,177 @@ class ProSubscriptionCard extends ConsumerWidget {
children: [ children: [
Text( Text(
s.proTitle, s.proTitle,
style: style: Theme.of(context)
Theme.of(context).textTheme.titleLarge?.copyWith( .textTheme
fontWeight: FontWeight.w900, .titleLarge
?.copyWith(
fontWeight: FontWeight.w800,
color: Colors.white, color: Colors.white,
letterSpacing: -0.3,
), ),
), ),
const SizedBox(height: 4), const SizedBox(height: 3),
Text( Text(
isPremium ? s.proActive : s.proSubtitle, isPremium ? s.proActive : s.proSubtitle,
style: isPremium style: isPremium
? Theme.of(context).textTheme.bodyMedium?.copyWith( ? Theme.of(context)
color: Colors.white.withOpacity(0.9), .textTheme
.bodyMedium
?.copyWith(
color: Colors.white.withOpacity(0.95),
fontWeight: FontWeight.w600, fontWeight: FontWeight.w600,
) )
: Theme.of(context).textTheme.bodySmall?.copyWith( : Theme.of(context)
color: Colors.white.withOpacity(0.7), .textTheme
.bodySmall
?.copyWith(
color: Colors.white.withOpacity(0.75),
), ),
), ),
], ],
), ),
), ),
], if (isPremium)
Container(
padding: const EdgeInsets.symmetric(
horizontal: 10,
vertical: 5,
), ),
const SizedBox(height: 16), decoration: BoxDecoration(
if (!isPremium) ...[ color: Colors.white.withOpacity(0.2),
Row( borderRadius: BorderRadius.circular(20),
border: Border.all(
color: Colors.white.withOpacity(0.3),
width: 1,
),
),
child: Row(
mainAxisSize: MainAxisSize.min,
children: [ children: [
Expanded( Icon(
child: OutlinedButton( Icons.check_circle_rounded,
onPressed: () { color: Colors.white.withOpacity(0.95),
size: 14,
),
const SizedBox(width: 4),
Text(
'Pro',
style: TextStyle(
color: Colors.white.withOpacity(0.95),
fontSize: 11,
fontWeight: FontWeight.w700,
),
),
],
),
),
],
),
const SizedBox(height: 18),
SizedBox(
width: double.infinity,
child: _GlassButton(
label: s.proAboutPro,
icon: Icons.arrow_forward_rounded,
onTap: () {
HapticService.light(); HapticService.light();
context.push('/pro'); context.push('/pro');
}, },
style: OutlinedButton.styleFrom(
foregroundColor: Colors.white,
side: BorderSide(
color: Colors.white.withOpacity(0.4), width: 1.5),
padding: const EdgeInsets.symmetric(vertical: 12),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(12),
), ),
), ),
child: Text( ],
s.proAboutPro, ),
style: const TextStyle( ),
fontWeight: FontWeight.w700, fontSize: 15), Positioned.fill(
child: IgnorePointer(
child: AnimatedBuilder(
animation: _shimmerController,
builder: (context, _) {
final t = _shimmerController.value;
final startX = -1.5;
final endX = 2.5;
final x = startX + (endX - startX) * t;
return ShaderMask(
blendMode: BlendMode.srcOver,
shaderCallback: (Rect bounds) {
return LinearGradient(
begin: Alignment(x, 0),
end: Alignment(x + 0.5, 0),
colors: [
Colors.white.withOpacity(0),
Colors.white.withOpacity(0.12),
Colors.white.withOpacity(0),
],
stops: const [0.0, 0.5, 1.0],
).createShader(bounds);
},
child: Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(20),
border: Border.all(
color: Colors.white.withOpacity(0.15),
width: 1,
),
),
),
);
},
), ),
), ),
), ),
], ],
), ),
] else ...[ );
Row( },
);
}
}
class _GlassButton extends StatelessWidget {
final String label;
final IconData icon;
final VoidCallback onTap;
const _GlassButton({
required this.label,
required this.icon,
required this.onTap,
});
@override
Widget build(BuildContext context) {
return Material(
color: Colors.white.withOpacity(0.15),
borderRadius: BorderRadius.circular(12),
child: InkWell(
onTap: onTap,
borderRadius: BorderRadius.circular(12),
child: Container(
padding: const EdgeInsets.symmetric(vertical: 12, horizontal: 16),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(12),
border: Border.all(
color: Colors.white.withOpacity(0.25),
width: 1,
),
),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [ children: [
Expanded( Text(
child: OutlinedButton.icon( label,
onPressed: () { style: const TextStyle(
HapticService.light();
context.push('/backup');
},
icon: Icon(
driveUser != null
? Icons.cloud_done_rounded
: Icons.cloud_sync_rounded,
color: Colors.white, color: Colors.white,
size: 20, fontWeight: FontWeight.w700,
), fontSize: 14,
label: Text(s.backupSyncWithDrive),
style: OutlinedButton.styleFrom(
foregroundColor: Colors.white,
side: BorderSide(
color: Colors.white.withOpacity(0.4), width: 1.5),
padding: const EdgeInsets.symmetric(vertical: 12),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(12),
),
),
), ),
), ),
const SizedBox(width: 6),
Icon(icon, color: Colors.white, size: 18),
], ],
), ),
if (driveUser == null) ...[
const SizedBox(height: 10),
SizedBox(
width: double.infinity,
child: OutlinedButton.icon(
onPressed: () {
HapticService.light();
ref.read(googleDriveServiceProvider).signIn();
},
icon: const Icon(Icons.login_rounded,
color: Colors.white, size: 18),
label: Text(s.proSignInGoogle),
style: OutlinedButton.styleFrom(
foregroundColor: Colors.white,
side: BorderSide(
color: Colors.white.withOpacity(0.3), width: 1),
padding: const EdgeInsets.symmetric(vertical: 10),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(12),
), ),
), ),
),
),
],
],
],
),
); );
} }
} }