mirror of
https://github.com/koloideal/Casha.git
synced 2026-08-08 17:51:14 +03:00
Compare commits
13 Commits
4727835402
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
| c4ac692019 | |||
| 861a9abd02 | |||
| e3c60c4775 | |||
| 64a3f4e34e | |||
| 19db4fe688 | |||
| 00bdd63ea6 | |||
| 7b9bf6d060 | |||
| 4f56e4983c | |||
| 58bfc6b12c | |||
| 4b548adb9a | |||
| 4b5c6be212 | |||
| 186cec8e2a | |||
| cd6113f3c6 |
@@ -7,14 +7,30 @@ import '../features/add_transaction/screen.dart';
|
|||||||
import '../features/categories/screen.dart';
|
import '../features/categories/screen.dart';
|
||||||
import '../features/settings/screen.dart';
|
import '../features/settings/screen.dart';
|
||||||
import '../features/settings/categories/category_manager_screen.dart';
|
import '../features/settings/categories/category_manager_screen.dart';
|
||||||
|
import '../features/onboarding/screen.dart';
|
||||||
import '../shared/models/transaction.dart';
|
import '../shared/models/transaction.dart';
|
||||||
import '../shared/paywall/paywall_screen.dart';
|
import '../shared/paywall/paywall_screen.dart';
|
||||||
|
import '../shared/services/onboarding_service.dart';
|
||||||
|
import '../shared/widgets/pro_screen.dart';
|
||||||
|
import '../shared/widgets/backup_screen.dart';
|
||||||
|
import '../shared/providers/premium_provider.dart';
|
||||||
|
|
||||||
final _shellKey = GlobalKey<NavigatorState>();
|
final _shellKey = GlobalKey<NavigatorState>();
|
||||||
|
|
||||||
final appRouter = GoRouter(
|
final appRouter = GoRouter(
|
||||||
initialLocation: '/dashboard',
|
initialLocation: '/dashboard',
|
||||||
|
redirect: (context, state) {
|
||||||
|
final location = state.uri.toString();
|
||||||
|
if (OnboardingService.shouldShowOnboarding && location != '/onboarding') {
|
||||||
|
return '/onboarding';
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
},
|
||||||
routes: [
|
routes: [
|
||||||
|
GoRoute(
|
||||||
|
path: '/onboarding',
|
||||||
|
builder: (context, state) => const OnboardingScreen(),
|
||||||
|
),
|
||||||
ShellRoute(
|
ShellRoute(
|
||||||
navigatorKey: _shellKey,
|
navigatorKey: _shellKey,
|
||||||
builder: (context, state, child) => AppShell(child: child),
|
builder: (context, state, child) => AppShell(child: child),
|
||||||
@@ -54,6 +70,19 @@ final appRouter = GoRouter(
|
|||||||
path: '/paywall',
|
path: '/paywall',
|
||||||
builder: (context, state) => const PaywallScreen(),
|
builder: (context, state) => const PaywallScreen(),
|
||||||
),
|
),
|
||||||
|
GoRoute(
|
||||||
|
path: '/pro',
|
||||||
|
builder: (context, state) => const ProScreen(),
|
||||||
|
),
|
||||||
|
GoRoute(
|
||||||
|
path: '/backup',
|
||||||
|
redirect: (context, state) {
|
||||||
|
final container = ProviderScope.containerOf(context);
|
||||||
|
final isPremium = container.read(isPremiumProvider);
|
||||||
|
return isPremium ? null : '/pro';
|
||||||
|
},
|
||||||
|
builder: (context, state) => const BackupScreen(),
|
||||||
|
),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
+21
-19
@@ -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(
|
||||||
@@ -132,10 +132,12 @@ class AppTheme {
|
|||||||
|
|
||||||
static ThemeData get lightTheme {
|
static ThemeData get lightTheme {
|
||||||
final base = ThemeData.light(useMaterial3: true);
|
final base = ThemeData.light(useMaterial3: true);
|
||||||
final textTheme = GoogleFonts.poppinsTextTheme(base.textTheme).apply(
|
final textTheme = _withCyrillicFallback(
|
||||||
|
base.textTheme.apply(
|
||||||
|
fontFamily: 'Poppins',
|
||||||
bodyColor: const Color(0xFF1A1A2E),
|
bodyColor: const Color(0xFF1A1A2E),
|
||||||
displayColor: const Color(0xFF1A1A2E),
|
displayColor: const Color(0xFF1A1A2E),
|
||||||
fontFamilyFallback: ['Roboto'],
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
return base.copyWith(
|
return base.copyWith(
|
||||||
@@ -143,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),
|
||||||
),
|
),
|
||||||
@@ -166,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,
|
||||||
);
|
);
|
||||||
@@ -186,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));
|
||||||
}),
|
}),
|
||||||
@@ -204,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(
|
||||||
@@ -227,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),
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -261,4 +261,125 @@ class AppStrings {
|
|||||||
_ru ? 'Изменение высоты карточки' : 'Resizable card height';
|
_ru ? 'Изменение высоты карточки' : 'Resizable card height';
|
||||||
String get premiumFeatureAccounts =>
|
String get premiumFeatureAccounts =>
|
||||||
_ru ? 'До 8 счетов' : 'Up to 8 accounts';
|
_ru ? 'До 8 счетов' : 'Up to 8 accounts';
|
||||||
|
|
||||||
|
String get onboardingWelcome => _ru ? 'Добро пожаловать в' : 'Welcome to';
|
||||||
|
String get onboardingMultiCurrencyTitle =>
|
||||||
|
_ru ? 'Все деньги\nна одном экране' : 'All Your Money,\nOne View';
|
||||||
|
String get onboardingMultiCurrencyBody => _ru
|
||||||
|
? 'Счета в разных валютах с автоматической конвертацией по актуальным курсам'
|
||||||
|
: 'Accounts in different currencies, automatically converted at live exchange rates';
|
||||||
|
String get onboardingCardsTitle =>
|
||||||
|
_ru ? 'Живые карточки' : 'Cards That Come Alive';
|
||||||
|
String get onboardingCardsBody => _ru
|
||||||
|
? 'Наклоните телефон — и карточка оживает. Градиенты, цвета и высота — всё настраивается под вас'
|
||||||
|
: 'Tilt your phone and watch them respond. Customize gradients, colors and height to make them yours';
|
||||||
|
String get onboardingReadyTitle => _ru ? 'Всё готово' : "You're All Set";
|
||||||
|
String get onboardingReadyBody => _ru
|
||||||
|
? 'Если готовы — свайпните вправо, чтобы открыть приложение'
|
||||||
|
: "If you're ready — swipe right to open the app";
|
||||||
|
String get onboardingSwipeRight => _ru ? 'Свайп вправо' : 'Swipe Right';
|
||||||
|
|
||||||
|
String get proTitle => _ru ? 'Casha Pro' : 'Casha Pro';
|
||||||
|
String get proAboutPro => _ru ? 'Подробнее' : 'About Pro';
|
||||||
|
String get proSubtitle => _ru
|
||||||
|
? 'Раскройте весь потенциал Casha'
|
||||||
|
: 'Unlock the full power of Casha';
|
||||||
|
String get proBuy => _ru ? 'Купить Pro' : 'Buy Pro';
|
||||||
|
String get proFeatureCloudSync =>
|
||||||
|
_ru ? 'Облачная синхронизация' : 'Cloud Sync';
|
||||||
|
String get proFeatureCloudSyncDesc => _ru
|
||||||
|
? 'Синхронизация между всеми вашими устройствами'
|
||||||
|
: 'Sync across all your devices';
|
||||||
|
String get proFeatureBiometric =>
|
||||||
|
_ru ? 'Биометрическая защита' : 'Biometric Protection';
|
||||||
|
String get proFeatureBiometricDesc => _ru
|
||||||
|
? 'Защитите свои данные отпечатком пальца или Face ID'
|
||||||
|
: 'Secure your data with fingerprint or Face ID';
|
||||||
|
String get proFeatureAnalytics =>
|
||||||
|
_ru ? 'Детальная аналитика' : 'Detailed Analytics';
|
||||||
|
String get proFeatureAnalyticsDesc => _ru
|
||||||
|
? 'Графики и статистика по расходам и доходам'
|
||||||
|
: 'Charts and stats for income and spending';
|
||||||
|
String get proFeatureCustomization =>
|
||||||
|
_ru ? 'Кастомизация карточек' : 'Card Customization';
|
||||||
|
String get proFeatureCustomizationDesc => _ru
|
||||||
|
? 'Цвета, градиенты, высота — всё под вашим контролем'
|
||||||
|
: 'Colors, gradients, height — all under your control';
|
||||||
|
String get proFeatureAccounts =>
|
||||||
|
_ru ? 'До 8 счетов' : 'Up to 8 Accounts';
|
||||||
|
String get proFeatureAccountsDesc => _ru
|
||||||
|
? 'Создавайте больше счетов для разных целей'
|
||||||
|
: 'Create more accounts for different goals';
|
||||||
|
String get proTryPro => _ru ? 'Попробовать Pro' : 'Try Pro';
|
||||||
|
String get proRestorePurchases =>
|
||||||
|
_ru ? 'Восстановить покупки' : 'Restore Purchases';
|
||||||
|
String get proActive => _ru ? 'Pro активна' : 'Pro Active';
|
||||||
|
String get proSignInForSync =>
|
||||||
|
_ru ? 'Войдите, чтобы включить синхронизацию' : 'Sign in to enable sync';
|
||||||
|
String get proSignInGoogle =>
|
||||||
|
_ru ? 'Войти через Google' : 'Sign in with Google';
|
||||||
|
String get proSyncEnabled =>
|
||||||
|
_ru ? 'Синхронизация включена' : 'Sync enabled';
|
||||||
|
String get proLastBackup => _ru ? 'Последняя резервная копия' : 'Last backup';
|
||||||
|
String get proSignOut => _ru ? 'Выйти' : 'Sign Out';
|
||||||
|
String get proPurchaseSuccess =>
|
||||||
|
_ru ? 'Pro успешно активирована!' : 'Pro successfully activated!';
|
||||||
|
String get proPurchaseFailed =>
|
||||||
|
_ru ? 'Не удалось оформить подписку' : 'Purchase failed';
|
||||||
|
String get proRestoreSuccess =>
|
||||||
|
_ru ? 'Покупки восстановлены!' : 'Purchases restored!';
|
||||||
|
String get proRestoreNotFound =>
|
||||||
|
_ru ? 'Предыдущие покупки не найдены' : 'No previous purchases found';
|
||||||
|
String get proTapToClose =>
|
||||||
|
_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 backupCreate => _ru ? 'Создать резервную копию' : 'Create Backup';
|
||||||
|
String get backupRestore => _ru ? 'Восстановить из копии' : 'Restore Backup';
|
||||||
|
String get backupCreating => _ru ? 'Создание копии...' : 'Creating backup...';
|
||||||
|
String get backupRestoring => _ru ? 'Восстановление...' : 'Restoring...';
|
||||||
|
String get backupSuccess =>
|
||||||
|
_ru ? 'Резервная копия успешно создана!' : 'Backup created successfully!';
|
||||||
|
String get backupRestoreSuccess =>
|
||||||
|
_ru ? 'Данные успешно восстановлены!' : 'Data restored successfully!';
|
||||||
|
String get backupRestoreFailed =>
|
||||||
|
_ru ? 'Не удалось восстановить данные' : 'Failed to restore data';
|
||||||
|
String get backupNoFileFound =>
|
||||||
|
_ru ? 'Резервная копия не найдена' : 'No backup file found';
|
||||||
|
String get backupTokenMismatch =>
|
||||||
|
_ru
|
||||||
|
? 'Этот файл резервной копии принадлежит другому покупателю Premium'
|
||||||
|
: 'This backup file belongs to another Premium purchaser';
|
||||||
|
String get backupInvalidFormat =>
|
||||||
|
_ru ? 'Неверный формат файла резервной копии' : 'Invalid backup file format';
|
||||||
|
String get backupNoToken =>
|
||||||
|
_ru
|
||||||
|
? 'Файл резервной копии не содержит токен покупки'
|
||||||
|
: 'Backup file does not contain a purchase token';
|
||||||
|
String get backupRequiresPremium =>
|
||||||
|
_ru ? 'Резервная копия доступна только для Pro' : 'Backup is a Pro-only feature';
|
||||||
|
String get backupRequiresSignIn =>
|
||||||
|
_ru
|
||||||
|
? 'Войдите в Google аккаунт для работы с резервными копиями'
|
||||||
|
: 'Sign in to Google to manage backups';
|
||||||
|
String get backupLastBackup => _ru ? 'Последняя копия' : 'Last backup';
|
||||||
|
String get backupNever => _ru ? 'Никогда' : 'Never';
|
||||||
|
String get backupSyncWithDrive =>
|
||||||
|
_ru ? 'Синхронизация с Google Диском' : 'Google Drive Sync';
|
||||||
|
String get backupSyncDesc =>
|
||||||
|
_ru
|
||||||
|
? 'Резервное копирование данных на ваш Google Диск'
|
||||||
|
: 'Back up your data to your Google Drive';
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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,
|
||||||
|
|||||||
@@ -13,9 +13,9 @@ class FeatureLimitException implements Exception {
|
|||||||
|
|
||||||
class AccountRepository {
|
class AccountRepository {
|
||||||
final AppDatabase _db;
|
final AppDatabase _db;
|
||||||
final FeatureFlags _featureFlags;
|
final FeatureFlags Function() _getFeatureFlags;
|
||||||
|
|
||||||
AccountRepository(this._db, this._featureFlags);
|
AccountRepository(this._db, this._getFeatureFlags);
|
||||||
|
|
||||||
Stream<List<model.Account>> watchAll() {
|
Stream<List<model.Account>> watchAll() {
|
||||||
return (_db.select(_db.accounts)
|
return (_db.select(_db.accounts)
|
||||||
@@ -167,8 +167,9 @@ class AccountRepository {
|
|||||||
Future<int> add(model.Account account) async {
|
Future<int> add(model.Account account) async {
|
||||||
final existing = await getAll();
|
final existing = await getAll();
|
||||||
final nonMainCount = existing.where((a) => !a.isMain).length;
|
final nonMainCount = existing.where((a) => !a.isMain).length;
|
||||||
if (nonMainCount >= _featureFlags.maxAccounts) {
|
final flags = _getFeatureFlags();
|
||||||
throw FeatureLimitException('Account limit reached (${_featureFlags.maxAccounts})');
|
if (flags.maxAccounts != -1 && nonMainCount >= flags.maxAccounts) {
|
||||||
|
throw FeatureLimitException('Account limit reached (${flags.maxAccounts})');
|
||||||
}
|
}
|
||||||
return await _db.into(_db.accounts).insert(
|
return await _db.into(_db.accounts).insert(
|
||||||
AccountsCompanion.insert(
|
AccountsCompanion.insert(
|
||||||
|
|||||||
@@ -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,
|
||||||
|
|||||||
@@ -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++;
|
||||||
@@ -128,22 +136,34 @@ final statsExpenseTotalProvider = Provider<double>((ref) {
|
|||||||
averageIncome: incomeCount == 0 ? 0 : income / incomeCount,
|
averageIncome: incomeCount == 0 ? 0 : income / incomeCount,
|
||||||
averageExpense: expenseCount == 0 ? 0 : expense / expenseCount,
|
averageExpense: expenseCount == 0 ? 0 : expense / expenseCount,
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
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>[];
|
||||||
|
|
||||||
|
|||||||
@@ -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),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -28,8 +28,7 @@ final transactionRepositoryProvider = Provider<TransactionRepository>((ref) {
|
|||||||
|
|
||||||
final accountRepositoryProvider = Provider<AccountRepository>((ref) {
|
final accountRepositoryProvider = Provider<AccountRepository>((ref) {
|
||||||
final db = ref.watch(appDatabaseProvider);
|
final db = ref.watch(appDatabaseProvider);
|
||||||
final flags = ref.watch(featureFlagsProvider);
|
return AccountRepository(db, () => ref.read(featureFlagsProvider));
|
||||||
return AccountRepository(db, flags);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
final storageServiceProvider = Provider<StorageService>((ref) {
|
final storageServiceProvider = Provider<StorageService>((ref) {
|
||||||
|
|||||||
@@ -303,7 +303,10 @@ class _DashboardScreenState extends ConsumerState<DashboardScreen> {
|
|||||||
elevation: 0,
|
elevation: 0,
|
||||||
scrolledUnderElevation: 0,
|
scrolledUnderElevation: 0,
|
||||||
titleSpacing: 20,
|
titleSpacing: 20,
|
||||||
title: Text(
|
title: Row(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
'Casha',
|
'Casha',
|
||||||
style: Theme.of(context).textTheme.headlineMedium?.copyWith(
|
style: Theme.of(context).textTheme.headlineMedium?.copyWith(
|
||||||
fontWeight: FontWeight.w800,
|
fontWeight: FontWeight.w800,
|
||||||
@@ -311,6 +314,22 @@ class _DashboardScreenState extends ConsumerState<DashboardScreen> {
|
|||||||
letterSpacing: -0.5,
|
letterSpacing: -0.5,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
if (ref.watch(featureFlagsProvider).canEditCardColors) ...[
|
||||||
|
const SizedBox(width: 6),
|
||||||
|
Text(
|
||||||
|
'Pro',
|
||||||
|
style: Theme.of(context).textTheme.headlineMedium?.copyWith(
|
||||||
|
fontWeight: FontWeight.w500,
|
||||||
|
color: Theme.of(context)
|
||||||
|
.colorScheme
|
||||||
|
.onSurface
|
||||||
|
.withOpacity(0.4),
|
||||||
|
letterSpacing: -0.5,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
],
|
||||||
|
),
|
||||||
actions: [
|
actions: [
|
||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.only(right: 20),
|
padding: const EdgeInsets.only(right: 20),
|
||||||
@@ -468,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(
|
||||||
|
|||||||
@@ -2,6 +2,9 @@ import 'dart:ui';
|
|||||||
import 'package:flutter/material.dart';
|
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/app_strings.dart';
|
||||||
|
import '../../../../core/l10n/locale_provider.dart';
|
||||||
|
import '../../../../core/services/haptic_service.dart';
|
||||||
import '../../../../core/utils/card_layout.dart';
|
import '../../../../core/utils/card_layout.dart';
|
||||||
import '../../../../shared/models/account.dart';
|
import '../../../../shared/models/account.dart';
|
||||||
import '../../../../shared/models/transaction.dart';
|
import '../../../../shared/models/transaction.dart';
|
||||||
@@ -60,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();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -282,6 +283,104 @@ class _AccountEditorOverlayState extends State<AccountEditorOverlay> {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
] else ...[
|
||||||
|
Positioned(
|
||||||
|
top: editorPanelTop + editorPanelHeight + layout.sectionGap,
|
||||||
|
left: 20,
|
||||||
|
right: 20,
|
||||||
|
child: GestureDetector(
|
||||||
|
onTap: () {
|
||||||
|
if (_showCurrencyDropdown) {
|
||||||
|
setState(() {
|
||||||
|
_showCurrencyDropdown = false;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
behavior: HitTestBehavior.opaque,
|
||||||
|
child: Container(
|
||||||
|
padding: EdgeInsets.symmetric(
|
||||||
|
horizontal: 16,
|
||||||
|
vertical: layout.buttonVerticalPadding,
|
||||||
|
),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: Theme.of(widget.context).colorScheme.surface,
|
||||||
|
borderRadius: BorderRadius.circular(20),
|
||||||
|
border: Border.all(
|
||||||
|
color: Theme.of(
|
||||||
|
widget.context,
|
||||||
|
).colorScheme.onSurface.withOpacity(0.1),
|
||||||
|
width: 1.5,
|
||||||
|
),
|
||||||
|
boxShadow: [
|
||||||
|
BoxShadow(
|
||||||
|
color: Colors.black.withOpacity(0.3),
|
||||||
|
blurRadius: 24,
|
||||||
|
offset: const Offset(0, 8),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
child: SizedBox(
|
||||||
|
width: double.infinity,
|
||||||
|
child: ElevatedButton(
|
||||||
|
onPressed:
|
||||||
|
dash.tempAccountName.trim().isEmpty
|
||||||
|
? null
|
||||||
|
: () {
|
||||||
|
final accounts =
|
||||||
|
ref.read(accountsProvider).value ?? [];
|
||||||
|
if (_isDuplicateName(
|
||||||
|
accounts,
|
||||||
|
dash.tempAccountName,
|
||||||
|
)) {
|
||||||
|
setState(() => _showDuplicateError = true);
|
||||||
|
Future.delayed(
|
||||||
|
const Duration(seconds: 3),
|
||||||
|
() {
|
||||||
|
if (mounted) {
|
||||||
|
setState(() =>
|
||||||
|
_showDuplicateError = false);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
HapticService.light();
|
||||||
|
dash.closeAccountOverlay(apply: true);
|
||||||
|
},
|
||||||
|
style: ElevatedButton.styleFrom(
|
||||||
|
backgroundColor: const Color(0xFF7C6DED),
|
||||||
|
foregroundColor: Colors.white,
|
||||||
|
disabledBackgroundColor: Theme.of(
|
||||||
|
widget.context,
|
||||||
|
).colorScheme.onSurface.withOpacity(0.12),
|
||||||
|
disabledForegroundColor: Theme.of(
|
||||||
|
widget.context,
|
||||||
|
).colorScheme.onSurface.withOpacity(0.38),
|
||||||
|
padding: EdgeInsets.symmetric(
|
||||||
|
vertical: layout.buttonVerticalPadding,
|
||||||
|
),
|
||||||
|
shape: RoundedRectangleBorder(
|
||||||
|
borderRadius: BorderRadius.circular(12),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
child: Text(
|
||||||
|
dash.isAddingAccount
|
||||||
|
? AppStrings(
|
||||||
|
ref.read(localeProvider),
|
||||||
|
).addAccount
|
||||||
|
: AppStrings(
|
||||||
|
ref.read(localeProvider),
|
||||||
|
).apply,
|
||||||
|
style: TextStyle(
|
||||||
|
fontWeight: FontWeight.w700,
|
||||||
|
fontSize: layout.compact ? 13 : 14,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
],
|
],
|
||||||
if (_showCurrencyDropdown)
|
if (_showCurrencyDropdown)
|
||||||
Positioned(
|
Positioned(
|
||||||
@@ -310,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;
|
||||||
});
|
});
|
||||||
@@ -366,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,
|
||||||
|
|||||||
@@ -0,0 +1,18 @@
|
|||||||
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||||
|
import '../../shared/providers/onboarding_provider.dart';
|
||||||
|
|
||||||
|
class OnboardingNotifier extends Notifier<int> {
|
||||||
|
@override
|
||||||
|
int build() => 0;
|
||||||
|
|
||||||
|
void setPage(int page) => state = page;
|
||||||
|
|
||||||
|
Future<void> complete() async {
|
||||||
|
final service = ref.read(onboardingServiceProvider);
|
||||||
|
await service.completeOnboarding();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
final onboardingProvider = NotifierProvider<OnboardingNotifier, int>(
|
||||||
|
OnboardingNotifier.new,
|
||||||
|
);
|
||||||
@@ -0,0 +1,164 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||||
|
import 'package:go_router/go_router.dart';
|
||||||
|
import '../../core/l10n/locale_provider.dart';
|
||||||
|
import '../../core/services/haptic_service.dart';
|
||||||
|
import 'provider.dart';
|
||||||
|
import 'widgets/fade_slide_in.dart';
|
||||||
|
import 'widgets/onboarding_page.dart';
|
||||||
|
import 'widgets/onboarding_page_indicator.dart';
|
||||||
|
|
||||||
|
class OnboardingScreen extends ConsumerStatefulWidget {
|
||||||
|
const OnboardingScreen({super.key});
|
||||||
|
|
||||||
|
@override
|
||||||
|
ConsumerState<OnboardingScreen> createState() => _OnboardingScreenState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _OnboardingScreenState extends ConsumerState<OnboardingScreen> {
|
||||||
|
final _controller = PageController();
|
||||||
|
|
||||||
|
@override
|
||||||
|
void dispose() {
|
||||||
|
_controller.dispose();
|
||||||
|
super.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
void _onPageChanged(int page) {
|
||||||
|
ref.read(onboardingProvider.notifier).setPage(page);
|
||||||
|
HapticService.light();
|
||||||
|
if (page == 4) {
|
||||||
|
HapticService.medium();
|
||||||
|
ref.read(onboardingProvider.notifier).complete();
|
||||||
|
Future.delayed(const Duration(milliseconds: 150), () {
|
||||||
|
if (mounted) context.go('/dashboard');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
final s = ref.watch(stringsProvider);
|
||||||
|
final currentPage = ref.watch(onboardingProvider);
|
||||||
|
|
||||||
|
return Scaffold(
|
||||||
|
body: SafeArea(
|
||||||
|
child: Column(
|
||||||
|
children: [
|
||||||
|
Expanded(
|
||||||
|
child: PageView(
|
||||||
|
controller: _controller,
|
||||||
|
onPageChanged: _onPageChanged,
|
||||||
|
children: [
|
||||||
|
OnboardingPage.welcome(
|
||||||
|
welcomeText: s.onboardingWelcome,
|
||||||
|
isActive: currentPage == 0,
|
||||||
|
),
|
||||||
|
OnboardingPage.content(
|
||||||
|
icon: Icons.currency_exchange_rounded,
|
||||||
|
headline: s.onboardingMultiCurrencyTitle,
|
||||||
|
description: s.onboardingMultiCurrencyBody,
|
||||||
|
isActive: currentPage == 1,
|
||||||
|
),
|
||||||
|
OnboardingPage.content(
|
||||||
|
icon: Icons.credit_card_rounded,
|
||||||
|
headline: s.onboardingCardsTitle,
|
||||||
|
description: s.onboardingCardsBody,
|
||||||
|
isActive: currentPage == 2,
|
||||||
|
),
|
||||||
|
_ReadyPage(isActive: currentPage == 3),
|
||||||
|
const SizedBox.shrink(),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.only(bottom: 48),
|
||||||
|
child: OnboardingPageIndicator(
|
||||||
|
current: currentPage,
|
||||||
|
count: 5,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class _ReadyPage extends ConsumerWidget {
|
||||||
|
final bool isActive;
|
||||||
|
|
||||||
|
const _ReadyPage({required this.isActive});
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context, WidgetRef ref) {
|
||||||
|
final s = ref.watch(stringsProvider);
|
||||||
|
final colorScheme = Theme.of(context).colorScheme;
|
||||||
|
|
||||||
|
return Center(
|
||||||
|
child: Padding(
|
||||||
|
padding: const EdgeInsets.symmetric(horizontal: 32),
|
||||||
|
child: Column(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
children: [
|
||||||
|
FadeSlideIn(
|
||||||
|
active: isActive,
|
||||||
|
child: Icon(
|
||||||
|
Icons.waving_hand_rounded,
|
||||||
|
size: 72,
|
||||||
|
color: colorScheme.primary,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 28),
|
||||||
|
FadeSlideIn(
|
||||||
|
active: isActive,
|
||||||
|
delay: const Duration(milliseconds: 150),
|
||||||
|
child: Text(
|
||||||
|
s.onboardingReadyTitle,
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
style: Theme.of(context).textTheme.headlineMedium?.copyWith(
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
color: colorScheme.onSurface,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 12),
|
||||||
|
FadeSlideIn(
|
||||||
|
active: isActive,
|
||||||
|
delay: const Duration(milliseconds: 300),
|
||||||
|
child: Text(
|
||||||
|
s.onboardingReadyBody,
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
style: Theme.of(context).textTheme.bodyLarge?.copyWith(
|
||||||
|
color: colorScheme.onSurface.withOpacity(0.5),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 24),
|
||||||
|
FadeSlideIn(
|
||||||
|
active: isActive,
|
||||||
|
delay: const Duration(milliseconds: 450),
|
||||||
|
child: Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
s.onboardingSwipeRight,
|
||||||
|
style: Theme.of(context).textTheme.titleMedium?.copyWith(
|
||||||
|
color: colorScheme.primary,
|
||||||
|
fontWeight: FontWeight.w600,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(width: 8),
|
||||||
|
Icon(
|
||||||
|
Icons.arrow_forward_rounded,
|
||||||
|
color: colorScheme.primary,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,101 @@
|
|||||||
|
import 'dart:async';
|
||||||
|
import 'dart:math';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:sensors_plus/sensors_plus.dart';
|
||||||
|
|
||||||
|
class CashaShimmerText extends StatefulWidget {
|
||||||
|
final String text;
|
||||||
|
final TextStyle? style;
|
||||||
|
|
||||||
|
const CashaShimmerText({
|
||||||
|
required this.text,
|
||||||
|
this.style,
|
||||||
|
super.key,
|
||||||
|
});
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<CashaShimmerText> createState() => _CashaShimmerTextState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _CashaShimmerTextState extends State<CashaShimmerText>
|
||||||
|
with SingleTickerProviderStateMixin {
|
||||||
|
late final AnimationController _controller;
|
||||||
|
double _tiltX = 0.0, _tiltY = 0.0;
|
||||||
|
double _targetTiltX = 0.0, _targetTiltY = 0.0;
|
||||||
|
StreamSubscription<AccelerometerEvent>? _sub;
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
_controller = AnimationController(
|
||||||
|
vsync: this,
|
||||||
|
duration: const Duration(seconds: 5),
|
||||||
|
)..repeat();
|
||||||
|
|
||||||
|
_sub = accelerometerEventStream(
|
||||||
|
samplingPeriod: const Duration(milliseconds: 50),
|
||||||
|
).listen((e) {
|
||||||
|
_targetTiltY = (e.x / 9.8).clamp(-1.0, 1.0);
|
||||||
|
_targetTiltX = ((e.y / 9.8) - 1.0).clamp(-1.0, 1.0);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void dispose() {
|
||||||
|
_controller.dispose();
|
||||||
|
_sub?.cancel();
|
||||||
|
super.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
final primary = Theme.of(context).colorScheme.primary;
|
||||||
|
final secondary = Theme.of(context).colorScheme.secondary;
|
||||||
|
|
||||||
|
return AnimatedBuilder(
|
||||||
|
animation: _controller,
|
||||||
|
builder: (context, child) {
|
||||||
|
_tiltX += (_targetTiltX - _tiltX) * 0.15;
|
||||||
|
_tiltY += (_targetTiltY - _tiltY) * 0.15;
|
||||||
|
|
||||||
|
final t = _controller.value;
|
||||||
|
final shimmer = sin(t * 2 * pi) * 0.08;
|
||||||
|
|
||||||
|
final gx = (_tiltY + shimmer).clamp(-1.0, 1.0);
|
||||||
|
final gy = (_tiltX + shimmer * 0.3).clamp(-1.0, 1.0);
|
||||||
|
|
||||||
|
return Transform(
|
||||||
|
alignment: Alignment.center,
|
||||||
|
transform: Matrix4.identity()
|
||||||
|
..setEntry(3, 2, 0.001)
|
||||||
|
..rotateX(_tiltX * 0.85)
|
||||||
|
..rotateY(_tiltY * 0.85),
|
||||||
|
child: ShaderMask(
|
||||||
|
shaderCallback: (bounds) {
|
||||||
|
return LinearGradient(
|
||||||
|
begin: Alignment(gx - 0.8, gy - 0.4),
|
||||||
|
end: Alignment(gx + 0.8, gy + 0.4),
|
||||||
|
colors: [
|
||||||
|
primary.withOpacity(0.7),
|
||||||
|
primary,
|
||||||
|
secondary,
|
||||||
|
Colors.white,
|
||||||
|
secondary,
|
||||||
|
primary,
|
||||||
|
primary.withOpacity(0.7),
|
||||||
|
],
|
||||||
|
stops: [0.0, 0.15, 0.35, 0.5, 0.65, 0.85, 1.0],
|
||||||
|
).createShader(bounds);
|
||||||
|
},
|
||||||
|
blendMode: BlendMode.srcIn,
|
||||||
|
child: child,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
child: Text(
|
||||||
|
widget.text,
|
||||||
|
style: widget.style?.copyWith(color: Colors.white),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,78 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
class FadeSlideIn extends StatefulWidget {
|
||||||
|
final bool active;
|
||||||
|
final Duration delay;
|
||||||
|
final Duration duration;
|
||||||
|
final Widget child;
|
||||||
|
|
||||||
|
const FadeSlideIn({
|
||||||
|
required this.active,
|
||||||
|
required this.child,
|
||||||
|
this.delay = Duration.zero,
|
||||||
|
this.duration = const Duration(milliseconds: 500),
|
||||||
|
super.key,
|
||||||
|
});
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<FadeSlideIn> createState() => _FadeSlideInState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _FadeSlideInState extends State<FadeSlideIn>
|
||||||
|
with SingleTickerProviderStateMixin {
|
||||||
|
late final AnimationController _controller;
|
||||||
|
late final Animation<double> _opacity;
|
||||||
|
late final Animation<Offset> _offset;
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
_controller = AnimationController(
|
||||||
|
vsync: this,
|
||||||
|
duration: widget.duration,
|
||||||
|
);
|
||||||
|
_opacity = Tween<double>(begin: 0.0, end: 1.0).animate(
|
||||||
|
CurvedAnimation(parent: _controller, curve: Curves.easeOut),
|
||||||
|
);
|
||||||
|
_offset = Tween<Offset>(
|
||||||
|
begin: const Offset(0, 0.15),
|
||||||
|
end: Offset.zero,
|
||||||
|
).animate(CurvedAnimation(parent: _controller, curve: Curves.easeOut));
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void didUpdateWidget(covariant FadeSlideIn oldWidget) {
|
||||||
|
super.didUpdateWidget(oldWidget);
|
||||||
|
if (widget.active && !oldWidget.active) {
|
||||||
|
_controller.reset();
|
||||||
|
Future.delayed(widget.delay, () {
|
||||||
|
if (mounted) _controller.forward();
|
||||||
|
});
|
||||||
|
} else if (!widget.active && oldWidget.active) {
|
||||||
|
_controller.reset();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void dispose() {
|
||||||
|
_controller.dispose();
|
||||||
|
super.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return AnimatedBuilder(
|
||||||
|
animation: _controller,
|
||||||
|
builder: (context, child) {
|
||||||
|
return Opacity(
|
||||||
|
opacity: _opacity.value,
|
||||||
|
child: FractionalTranslation(
|
||||||
|
translation: _offset.value,
|
||||||
|
child: child,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
child: widget.child,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,113 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'casha_shimmer_text.dart';
|
||||||
|
import 'fade_slide_in.dart';
|
||||||
|
|
||||||
|
class OnboardingPage extends StatelessWidget {
|
||||||
|
final IconData? icon;
|
||||||
|
final String? headline;
|
||||||
|
final String? description;
|
||||||
|
final String? welcomeText;
|
||||||
|
final bool isWelcomePage;
|
||||||
|
final bool isActive;
|
||||||
|
|
||||||
|
const OnboardingPage.welcome({
|
||||||
|
required this.welcomeText,
|
||||||
|
this.isActive = false,
|
||||||
|
super.key,
|
||||||
|
}) : icon = null,
|
||||||
|
headline = null,
|
||||||
|
description = null,
|
||||||
|
isWelcomePage = true;
|
||||||
|
|
||||||
|
const OnboardingPage.content({
|
||||||
|
required this.icon,
|
||||||
|
required this.headline,
|
||||||
|
required this.description,
|
||||||
|
this.isActive = false,
|
||||||
|
super.key,
|
||||||
|
}) : welcomeText = null,
|
||||||
|
isWelcomePage = false;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
if (isWelcomePage) {
|
||||||
|
final colorScheme = Theme.of(context).colorScheme;
|
||||||
|
return Center(
|
||||||
|
child: Column(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
welcomeText!,
|
||||||
|
style: Theme.of(context).textTheme.titleMedium?.copyWith(
|
||||||
|
fontWeight: FontWeight.w300,
|
||||||
|
color: colorScheme.onSurface.withOpacity(0.4),
|
||||||
|
letterSpacing: 2,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 12),
|
||||||
|
CashaShimmerText(
|
||||||
|
text: 'Casha',
|
||||||
|
style: Theme.of(context).textTheme.displayLarge?.copyWith(
|
||||||
|
fontSize: 72,
|
||||||
|
fontWeight: FontWeight.w900,
|
||||||
|
letterSpacing: -1,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
final colorScheme = Theme.of(context).colorScheme;
|
||||||
|
return Center(
|
||||||
|
child: Padding(
|
||||||
|
padding: const EdgeInsets.symmetric(horizontal: 32),
|
||||||
|
child: Column(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
children: [
|
||||||
|
FadeSlideIn(
|
||||||
|
active: isActive,
|
||||||
|
child: Container(
|
||||||
|
padding: const EdgeInsets.all(24),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: colorScheme.primary.withOpacity(0.12),
|
||||||
|
shape: BoxShape.circle,
|
||||||
|
),
|
||||||
|
child: Icon(
|
||||||
|
icon,
|
||||||
|
size: 64,
|
||||||
|
color: colorScheme.primary,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 32),
|
||||||
|
FadeSlideIn(
|
||||||
|
active: isActive,
|
||||||
|
delay: const Duration(milliseconds: 150),
|
||||||
|
child: Text(
|
||||||
|
headline!,
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
style: Theme.of(context).textTheme.headlineSmall?.copyWith(
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
color: colorScheme.onSurface,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 12),
|
||||||
|
FadeSlideIn(
|
||||||
|
active: isActive,
|
||||||
|
delay: const Duration(milliseconds: 300),
|
||||||
|
child: Text(
|
||||||
|
description!,
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
style: Theme.of(context).textTheme.bodyMedium?.copyWith(
|
||||||
|
color: colorScheme.onSurface.withOpacity(0.6),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,38 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
class OnboardingPageIndicator extends StatelessWidget {
|
||||||
|
final int current;
|
||||||
|
final int count;
|
||||||
|
|
||||||
|
const OnboardingPageIndicator({
|
||||||
|
required this.current,
|
||||||
|
required this.count,
|
||||||
|
super.key,
|
||||||
|
});
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
final color = Theme.of(context).colorScheme.primary;
|
||||||
|
final outlineColor = Theme.of(context).colorScheme.secondary;
|
||||||
|
return Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
children: List.generate(count, (i) {
|
||||||
|
final isActive = i == current;
|
||||||
|
final isLast = i == count - 1;
|
||||||
|
return AnimatedContainer(
|
||||||
|
duration: const Duration(milliseconds: 200),
|
||||||
|
margin: const EdgeInsets.symmetric(horizontal: 4),
|
||||||
|
width: isActive ? 24 : 8,
|
||||||
|
height: 8,
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: isActive ? color : color.withOpacity(0.3),
|
||||||
|
borderRadius: BorderRadius.circular(4),
|
||||||
|
border: isLast && !isActive
|
||||||
|
? Border.all(color: outlineColor, width: 1.5)
|
||||||
|
: null,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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(
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ import '../../core/l10n/locale_provider.dart';
|
|||||||
import '../../core/services/biometric_service.dart';
|
import '../../core/services/biometric_service.dart';
|
||||||
import '../../core/services/haptic_service.dart';
|
import '../../core/services/haptic_service.dart';
|
||||||
import '../dashboard/provider.dart';
|
import '../dashboard/provider.dart';
|
||||||
import 'provider.dart';
|
|
||||||
import 'widgets/theme_section.dart';
|
import 'widgets/theme_section.dart';
|
||||||
import 'widgets/card_text_color_section.dart';
|
import 'widgets/card_text_color_section.dart';
|
||||||
import 'widgets/haptic_section.dart';
|
import 'widgets/haptic_section.dart';
|
||||||
@@ -14,7 +13,7 @@ import 'widgets/language_section.dart';
|
|||||||
import 'widgets/currency_section.dart';
|
import 'widgets/currency_section.dart';
|
||||||
import 'widgets/amount_format_section.dart';
|
import 'widgets/amount_format_section.dart';
|
||||||
import 'widgets/categories_section.dart';
|
import 'widgets/categories_section.dart';
|
||||||
import 'widgets/premium_section.dart';
|
import '../../shared/widgets/pro_subscription_card.dart';
|
||||||
|
|
||||||
class SettingsScreen extends ConsumerWidget {
|
class SettingsScreen extends ConsumerWidget {
|
||||||
const SettingsScreen({super.key});
|
const SettingsScreen({super.key});
|
||||||
@@ -117,23 +116,24 @@ class SettingsScreen extends ConsumerWidget {
|
|||||||
physics: const ClampingScrollPhysics(),
|
physics: const ClampingScrollPhysics(),
|
||||||
padding: const EdgeInsets.fromLTRB(20, 16, 20, 40),
|
padding: const EdgeInsets.fromLTRB(20, 16, 20, 40),
|
||||||
children: [
|
children: [
|
||||||
const PremiumSection(),
|
const ProSubscriptionCard(),
|
||||||
const SizedBox(height: 16),
|
const SizedBox(height: 12),
|
||||||
const ThemeSection(),
|
|
||||||
const SizedBox(height: 16),
|
|
||||||
const CardTextColorSection(),
|
|
||||||
const SizedBox(height: 16),
|
|
||||||
const HapticSection(),
|
|
||||||
const SizedBox(height: 16),
|
|
||||||
const CurrencyConversionsSection(),
|
|
||||||
const SizedBox(height: 16),
|
|
||||||
const _BiometricSection(),
|
|
||||||
const LanguageSection(),
|
|
||||||
const SizedBox(height: 16),
|
|
||||||
const CurrencySection(),
|
const CurrencySection(),
|
||||||
const SizedBox(height: 16),
|
const SizedBox(height: 12),
|
||||||
|
const ThemeSection(),
|
||||||
|
const SizedBox(height: 12),
|
||||||
|
const LanguageSection(),
|
||||||
|
const SizedBox(height: 12),
|
||||||
|
const _BiometricSection(),
|
||||||
|
const SizedBox(height: 12),
|
||||||
|
const CardTextColorSection(),
|
||||||
|
const SizedBox(height: 12),
|
||||||
|
const HapticSection(),
|
||||||
|
const SizedBox(height: 12),
|
||||||
const AmountFormatSection(),
|
const AmountFormatSection(),
|
||||||
const SizedBox(height: 16),
|
const SizedBox(height: 12),
|
||||||
|
const CurrencyConversionsSection(),
|
||||||
|
const SizedBox(height: 12),
|
||||||
const CategoriesSection(),
|
const CategoriesSection(),
|
||||||
const SizedBox(height: 24),
|
const SizedBox(height: 24),
|
||||||
Text(
|
Text(
|
||||||
@@ -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
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ class CardTextColorSection extends ConsumerWidget {
|
|||||||
final isDark = Theme.of(context).brightness == Brightness.dark;
|
final isDark = Theme.of(context).brightness == Brightness.dark;
|
||||||
|
|
||||||
return Container(
|
return Container(
|
||||||
padding: const EdgeInsets.all(20),
|
padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 14),
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: Theme.of(context).colorScheme.surface,
|
color: Theme.of(context).colorScheme.surface,
|
||||||
borderRadius: BorderRadius.circular(16),
|
borderRadius: BorderRadius.circular(16),
|
||||||
@@ -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,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -49,7 +49,7 @@ class CardTextColorSection extends ConsumerWidget {
|
|||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
const SizedBox(height: 16),
|
const SizedBox(height: 12),
|
||||||
Row(
|
Row(
|
||||||
children: [
|
children: [
|
||||||
Expanded(
|
Expanded(
|
||||||
@@ -113,17 +113,17 @@ class _CardTextColorOption extends StatelessWidget {
|
|||||||
onTap: onTap,
|
onTap: onTap,
|
||||||
child: AnimatedContainer(
|
child: AnimatedContainer(
|
||||||
duration: const Duration(milliseconds: 200),
|
duration: const Duration(milliseconds: 200),
|
||||||
padding: const EdgeInsets.symmetric(vertical: 12),
|
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,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ class CurrencySection extends ConsumerWidget {
|
|||||||
final isDark = Theme.of(context).brightness == Brightness.dark;
|
final isDark = Theme.of(context).brightness == Brightness.dark;
|
||||||
|
|
||||||
return Container(
|
return Container(
|
||||||
padding: const EdgeInsets.all(20),
|
padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 14),
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: Theme.of(context).colorScheme.surface,
|
color: Theme.of(context).colorScheme.surface,
|
||||||
borderRadius: BorderRadius.circular(16),
|
borderRadius: BorderRadius.circular(16),
|
||||||
@@ -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,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -52,7 +52,7 @@ class CurrencySection extends ConsumerWidget {
|
|||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
const SizedBox(height: 16),
|
const SizedBox(height: 12),
|
||||||
Row(
|
Row(
|
||||||
children: ['USD', 'EUR', 'BYN', 'RUB'].map((code) {
|
children: ['USD', 'EUR', 'BYN', 'RUB'].map((code) {
|
||||||
final info = currencyMap[code]!;
|
final info = currencyMap[code]!;
|
||||||
@@ -65,14 +65,14 @@ class CurrencySection extends ConsumerWidget {
|
|||||||
ref.read(currencyProvider.notifier).setCurrency(code);
|
ref.read(currencyProvider.notifier).setCurrency(code);
|
||||||
},
|
},
|
||||||
child: Container(
|
child: Container(
|
||||||
padding: const EdgeInsets.symmetric(vertical: 12),
|
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(
|
||||||
@@ -83,19 +83,25 @@ class CurrencySection extends ConsumerWidget {
|
|||||||
child: Column(
|
child: Column(
|
||||||
children: [
|
children: [
|
||||||
code == 'BYN'
|
code == 'BYN'
|
||||||
? BynSign(
|
? SizedBox(
|
||||||
fontSize: 28,
|
height: 28,
|
||||||
|
child: Align(
|
||||||
|
alignment: Alignment.center,
|
||||||
|
child: BynSign(
|
||||||
|
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),
|
||||||
|
),
|
||||||
|
),
|
||||||
)
|
)
|
||||||
: Text(
|
: Text(
|
||||||
info.symbol,
|
info.symbol,
|
||||||
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
|
||||||
@@ -111,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),
|
|
||||||
),
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ class ThemeSection extends ConsumerWidget {
|
|||||||
final isDark = Theme.of(context).brightness == Brightness.dark;
|
final isDark = Theme.of(context).brightness == Brightness.dark;
|
||||||
|
|
||||||
return Container(
|
return Container(
|
||||||
padding: const EdgeInsets.all(20),
|
padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 14),
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: Theme.of(context).colorScheme.surface,
|
color: Theme.of(context).colorScheme.surface,
|
||||||
borderRadius: BorderRadius.circular(16),
|
borderRadius: BorderRadius.circular(16),
|
||||||
@@ -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,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -51,7 +51,7 @@ class ThemeSection extends ConsumerWidget {
|
|||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
const SizedBox(height: 16),
|
const SizedBox(height: 12),
|
||||||
Row(
|
Row(
|
||||||
children: [
|
children: [
|
||||||
Expanded(
|
Expanded(
|
||||||
@@ -109,15 +109,15 @@ class _ThemeOption extends StatelessWidget {
|
|||||||
onTap: onTap,
|
onTap: onTap,
|
||||||
child: AnimatedContainer(
|
child: AnimatedContainer(
|
||||||
duration: const Duration(milliseconds: 200),
|
duration: const Duration(milliseconds: 200),
|
||||||
padding: const EdgeInsets.symmetric(vertical: 12),
|
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,
|
||||||
|
|||||||
@@ -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';
|
||||||
@@ -6,6 +7,10 @@ import 'app/app.dart';
|
|||||||
import 'core/services/haptic_service.dart';
|
import 'core/services/haptic_service.dart';
|
||||||
import 'data/database/app_database.dart';
|
import 'data/database/app_database.dart';
|
||||||
import 'features/dashboard/provider.dart';
|
import 'features/dashboard/provider.dart';
|
||||||
|
import 'shared/services/onboarding_service.dart';
|
||||||
|
import 'shared/services/billing_service.dart';
|
||||||
|
import 'shared/services/premium_manager.dart';
|
||||||
|
import 'shared/providers/billing_provider.dart';
|
||||||
|
|
||||||
void main() async {
|
void main() async {
|
||||||
WidgetsFlutterBinding.ensureInitialized();
|
WidgetsFlutterBinding.ensureInitialized();
|
||||||
@@ -17,14 +22,22 @@ void main() async {
|
|||||||
|
|
||||||
final prefs = await SharedPreferences.getInstance();
|
final prefs = await SharedPreferences.getInstance();
|
||||||
await HapticService.init();
|
await HapticService.init();
|
||||||
|
OnboardingService(prefs);
|
||||||
|
|
||||||
final database = AppDatabase();
|
final database = AppDatabase();
|
||||||
|
|
||||||
|
final billing = kDebugMode
|
||||||
|
? DebugBillingService(prefs)
|
||||||
|
: PlayBillingService();
|
||||||
|
final premiumManager = PremiumManager(prefs, billing);
|
||||||
|
await premiumManager.autoRestore();
|
||||||
|
|
||||||
runApp(
|
runApp(
|
||||||
ProviderScope(
|
ProviderScope(
|
||||||
overrides: [
|
overrides: [
|
||||||
sharedPreferencesProvider.overrideWithValue(prefs),
|
sharedPreferencesProvider.overrideWithValue(prefs),
|
||||||
appDatabaseProvider.overrideWithValue(database),
|
appDatabaseProvider.overrideWithValue(database),
|
||||||
|
billingServiceProvider.overrideWithValue(billing),
|
||||||
],
|
],
|
||||||
child: const App(),
|
child: const App(),
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -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),
|
||||||
|
|||||||
@@ -0,0 +1,8 @@
|
|||||||
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||||
|
import '../services/backup_service.dart';
|
||||||
|
import 'premium_provider.dart';
|
||||||
|
|
||||||
|
final backupServiceProvider = Provider<BackupService>((ref) {
|
||||||
|
final token = ref.watch(purchaseTokenProvider) ?? '';
|
||||||
|
return BackupService(token);
|
||||||
|
});
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
import 'package:flutter/foundation.dart';
|
||||||
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||||
|
import '../../features/dashboard/provider.dart';
|
||||||
|
import '../services/billing_service.dart';
|
||||||
|
|
||||||
|
final billingServiceProvider = Provider<BillingService>((ref) {
|
||||||
|
if (kDebugMode) {
|
||||||
|
final prefs = ref.watch(sharedPreferencesProvider);
|
||||||
|
return DebugBillingService(prefs);
|
||||||
|
}
|
||||||
|
return PlayBillingService();
|
||||||
|
});
|
||||||
@@ -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,
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,29 +1,27 @@
|
|||||||
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 '../models/user_model.dart';
|
||||||
|
import '../services/premium_manager.dart';
|
||||||
|
import 'billing_provider.dart';
|
||||||
|
|
||||||
class CurrentUserNotifier extends Notifier<UserModel> {
|
class CurrentUserNotifier extends Notifier<UserModel> {
|
||||||
static const _key = 'user_plan';
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
UserModel build() {
|
UserModel build() {
|
||||||
final prefs = ref.watch(sharedPreferencesProvider);
|
final prefs = ref.watch(sharedPreferencesProvider);
|
||||||
final planName = prefs.getString(_key);
|
final billing = ref.watch(billingServiceProvider);
|
||||||
final plan = UserPlan.values.firstWhere(
|
final manager = PremiumManager(prefs, billing);
|
||||||
(e) => e.name == planName,
|
return UserModel(plan: manager.currentPlan);
|
||||||
orElse: () => UserPlan.free,
|
|
||||||
);
|
|
||||||
return UserModel(plan: plan);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> setPlan(UserPlan plan) async {
|
Future<void> setPlan(UserPlan plan) async {
|
||||||
final prefs = ref.read(sharedPreferencesProvider);
|
|
||||||
state = UserModel(plan: plan);
|
state = UserModel(plan: plan);
|
||||||
await prefs.setString(_key, plan.name);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> toggleVip() async {
|
Future<void> refreshFromPremium() async {
|
||||||
await setPlan(state.isVip ? UserPlan.free : UserPlan.vip);
|
final prefs = ref.read(sharedPreferencesProvider);
|
||||||
|
final billing = ref.read(billingServiceProvider);
|
||||||
|
final manager = PremiumManager(prefs, billing);
|
||||||
|
state = UserModel(plan: manager.currentPlan);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,12 @@
|
|||||||
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||||
|
import 'package:google_sign_in/google_sign_in.dart';
|
||||||
|
import '../services/google_auth_service.dart';
|
||||||
|
|
||||||
|
final googleAuthProvider = Provider<GoogleAuthService>((ref) {
|
||||||
|
return GoogleAuthService();
|
||||||
|
});
|
||||||
|
|
||||||
|
final googleCurrentUserProvider = StreamProvider<GoogleSignInAccount?>((ref) {
|
||||||
|
final service = ref.watch(googleAuthProvider);
|
||||||
|
return service.onCurrentUserChanged;
|
||||||
|
});
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||||
|
import 'package:google_sign_in/google_sign_in.dart';
|
||||||
|
import '../services/google_drive_service.dart';
|
||||||
|
|
||||||
|
final googleDriveServiceProvider = Provider<GoogleDriveService>((ref) {
|
||||||
|
final signIn = GoogleSignIn(
|
||||||
|
scopes: [
|
||||||
|
'email',
|
||||||
|
'https://www.googleapis.com/auth/drive.appdata',
|
||||||
|
],
|
||||||
|
);
|
||||||
|
return GoogleDriveService(signIn);
|
||||||
|
});
|
||||||
|
|
||||||
|
final googleDriveUserProvider = StreamProvider<GoogleSignInAccount?>((ref) {
|
||||||
|
final service = ref.watch(googleDriveServiceProvider);
|
||||||
|
return service.onUserChanged;
|
||||||
|
});
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||||
|
import '../../features/dashboard/provider.dart';
|
||||||
|
import '../services/onboarding_service.dart';
|
||||||
|
|
||||||
|
final onboardingServiceProvider = Provider<OnboardingService>((ref) {
|
||||||
|
final prefs = ref.watch(sharedPreferencesProvider);
|
||||||
|
return OnboardingService(prefs);
|
||||||
|
});
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||||
|
import '../../features/dashboard/provider.dart';
|
||||||
|
import '../models/user_model.dart';
|
||||||
|
import '../services/premium_manager.dart';
|
||||||
|
import 'billing_provider.dart';
|
||||||
|
import 'current_user_provider.dart';
|
||||||
|
|
||||||
|
final premiumManagerProvider = Provider<PremiumManager>((ref) {
|
||||||
|
final prefs = ref.watch(sharedPreferencesProvider);
|
||||||
|
final billing = ref.watch(billingServiceProvider);
|
||||||
|
return PremiumManager(prefs, billing);
|
||||||
|
});
|
||||||
|
|
||||||
|
final isPremiumProvider = Provider<bool>((ref) {
|
||||||
|
final user = ref.watch(currentUserProvider);
|
||||||
|
return user.plan == UserPlan.vip;
|
||||||
|
});
|
||||||
|
|
||||||
|
final purchaseTokenProvider = Provider<String?>((ref) {
|
||||||
|
final manager = ref.watch(premiumManagerProvider);
|
||||||
|
return manager.purchaseToken;
|
||||||
|
});
|
||||||
@@ -0,0 +1,72 @@
|
|||||||
|
import 'dart:convert';
|
||||||
|
import 'dart:typed_data';
|
||||||
|
|
||||||
|
class BackupData {
|
||||||
|
final String ownerPurchaseToken;
|
||||||
|
final DateTime createdAt;
|
||||||
|
final Map<String, dynamic> payload;
|
||||||
|
|
||||||
|
const BackupData({
|
||||||
|
required this.ownerPurchaseToken,
|
||||||
|
required this.createdAt,
|
||||||
|
required this.payload,
|
||||||
|
});
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() => {
|
||||||
|
'owner_purchase_token': ownerPurchaseToken,
|
||||||
|
'created_at': createdAt.toIso8601String(),
|
||||||
|
'payload': payload,
|
||||||
|
};
|
||||||
|
|
||||||
|
factory BackupData.fromJson(Map<String, dynamic> json) {
|
||||||
|
return BackupData(
|
||||||
|
ownerPurchaseToken: json['owner_purchase_token'] as String? ?? '',
|
||||||
|
createdAt: DateTime.tryParse(json['created_at'] as String? ?? '') ??
|
||||||
|
DateTime.now(),
|
||||||
|
payload: json['payload'] as Map<String, dynamic>? ?? {},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
enum BackupVerifyResult { ok, tokenMismatch, noToken, invalidFormat }
|
||||||
|
|
||||||
|
class BackupService {
|
||||||
|
String _currentPurchaseToken;
|
||||||
|
|
||||||
|
BackupService(this._currentPurchaseToken);
|
||||||
|
|
||||||
|
void updatePurchaseToken(String token) {
|
||||||
|
_currentPurchaseToken = token;
|
||||||
|
}
|
||||||
|
|
||||||
|
String get currentPurchaseToken => _currentPurchaseToken;
|
||||||
|
|
||||||
|
Uint8List createBackup(Map<String, dynamic> payload) {
|
||||||
|
final data = BackupData(
|
||||||
|
ownerPurchaseToken: _currentPurchaseToken,
|
||||||
|
createdAt: DateTime.now(),
|
||||||
|
payload: payload,
|
||||||
|
);
|
||||||
|
final json = jsonEncode(data.toJson());
|
||||||
|
return Uint8List.fromList(utf8.encode(json));
|
||||||
|
}
|
||||||
|
|
||||||
|
(BackupVerifyResult, BackupData?) verifyAndParse(Uint8List raw) {
|
||||||
|
try {
|
||||||
|
final json = jsonDecode(utf8.decode(raw)) as Map<String, dynamic>;
|
||||||
|
final data = BackupData.fromJson(json);
|
||||||
|
|
||||||
|
if (data.ownerPurchaseToken.isEmpty) {
|
||||||
|
return (BackupVerifyResult.noToken, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (data.ownerPurchaseToken != _currentPurchaseToken) {
|
||||||
|
return (BackupVerifyResult.tokenMismatch, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (BackupVerifyResult.ok, data);
|
||||||
|
} catch (e) {
|
||||||
|
return (BackupVerifyResult.invalidFormat, null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,197 @@
|
|||||||
|
import 'dart:async';
|
||||||
|
import 'package:in_app_purchase/in_app_purchase.dart';
|
||||||
|
import 'package:shared_preferences/shared_preferences.dart';
|
||||||
|
|
||||||
|
class PurchaseResult {
|
||||||
|
final bool success;
|
||||||
|
final String? purchaseToken;
|
||||||
|
final String? error;
|
||||||
|
|
||||||
|
const PurchaseResult({this.success = false, this.purchaseToken, this.error});
|
||||||
|
|
||||||
|
factory PurchaseResult.ok(String token) =>
|
||||||
|
PurchaseResult(success: true, purchaseToken: token);
|
||||||
|
|
||||||
|
factory PurchaseResult.failed([String? error]) =>
|
||||||
|
PurchaseResult(success: false, error: error);
|
||||||
|
|
||||||
|
factory PurchaseResult.cancelled() =>
|
||||||
|
const PurchaseResult(success: false);
|
||||||
|
}
|
||||||
|
|
||||||
|
abstract class BillingService {
|
||||||
|
static const proProductId = 'casha_pro_lifetime';
|
||||||
|
|
||||||
|
Future<PurchaseResult> purchasePro();
|
||||||
|
Future<PurchaseResult> restorePurchases();
|
||||||
|
Future<PurchaseResult> queryPastPurchase();
|
||||||
|
Future<void> dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
class PlayBillingService implements BillingService {
|
||||||
|
final InAppPurchase _inAppPurchase = InAppPurchase.instance;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<PurchaseResult> purchasePro() async {
|
||||||
|
final available = await _inAppPurchase.isAvailable();
|
||||||
|
if (!available) {
|
||||||
|
return PurchaseResult.failed('Billing not available');
|
||||||
|
}
|
||||||
|
|
||||||
|
final response = await _inAppPurchase.queryProductDetails(
|
||||||
|
{BillingService.proProductId},
|
||||||
|
);
|
||||||
|
if (response.error != null) {
|
||||||
|
return PurchaseResult.failed(response.error!.message);
|
||||||
|
}
|
||||||
|
if (response.productDetails.isEmpty) {
|
||||||
|
return PurchaseResult.failed('Product not found');
|
||||||
|
}
|
||||||
|
|
||||||
|
final product = response.productDetails.first;
|
||||||
|
return _waitForPurchase(
|
||||||
|
timeout: const Duration(minutes: 2),
|
||||||
|
timeoutError: 'Purchase timed out',
|
||||||
|
start: () async {
|
||||||
|
final started = await _inAppPurchase.buyNonConsumable(
|
||||||
|
purchaseParam: PurchaseParam(productDetails: product),
|
||||||
|
);
|
||||||
|
if (!started) {
|
||||||
|
throw StateError('Could not start purchase');
|
||||||
|
}
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<PurchaseResult> restorePurchases() async {
|
||||||
|
final available = await _inAppPurchase.isAvailable();
|
||||||
|
if (!available) {
|
||||||
|
return PurchaseResult.failed('Billing not available');
|
||||||
|
}
|
||||||
|
|
||||||
|
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>();
|
||||||
|
var handlingPurchase = false;
|
||||||
|
late final StreamSubscription<List<PurchaseDetails>> subscription;
|
||||||
|
late final Timer timeoutTimer;
|
||||||
|
|
||||||
|
void finish(PurchaseResult result) {
|
||||||
|
if (!completer.isCompleted) {
|
||||||
|
completer.complete(result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
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());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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
|
||||||
|
Future<PurchaseResult> queryPastPurchase() async {
|
||||||
|
final token = _prefs.getString(_key);
|
||||||
|
if (token != null) {
|
||||||
|
return PurchaseResult.ok(token);
|
||||||
|
}
|
||||||
|
return const PurchaseResult();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<void> dispose() async {}
|
||||||
|
}
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
import 'dart:async';
|
||||||
|
import 'package:google_sign_in/google_sign_in.dart';
|
||||||
|
|
||||||
|
class GoogleAuthService {
|
||||||
|
final GoogleSignIn _googleSignIn;
|
||||||
|
|
||||||
|
GoogleAuthService() : _googleSignIn = GoogleSignIn(scopes: [
|
||||||
|
'email',
|
||||||
|
'https://www.googleapis.com/auth/drive.appdata',
|
||||||
|
]);
|
||||||
|
|
||||||
|
GoogleSignInAccount? get currentUser => _googleSignIn.currentUser;
|
||||||
|
|
||||||
|
Stream<GoogleSignInAccount?> get onCurrentUserChanged =>
|
||||||
|
_googleSignIn.onCurrentUserChanged;
|
||||||
|
|
||||||
|
Future<void> signIn() async {
|
||||||
|
await _googleSignIn.signIn();
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> signOut() async {
|
||||||
|
await _googleSignIn.signOut();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,147 @@
|
|||||||
|
import 'dart:typed_data';
|
||||||
|
import 'package:googleapis/drive/v3.dart' as drive;
|
||||||
|
import 'package:google_sign_in/google_sign_in.dart';
|
||||||
|
import 'package:extension_google_sign_in_as_googleapis_auth/extension_google_sign_in_as_googleapis_auth.dart';
|
||||||
|
|
||||||
|
class DriveBackupResult {
|
||||||
|
final bool success;
|
||||||
|
final String? error;
|
||||||
|
final String? fileId;
|
||||||
|
final DateTime? modifiedTime;
|
||||||
|
|
||||||
|
const DriveBackupResult({this.success = false, this.error, this.fileId, this.modifiedTime});
|
||||||
|
|
||||||
|
factory DriveBackupResult.ok(String fileId, DateTime modifiedTime) =>
|
||||||
|
DriveBackupResult(success: true, fileId: fileId, modifiedTime: modifiedTime);
|
||||||
|
|
||||||
|
factory DriveBackupResult.failed(String error) =>
|
||||||
|
DriveBackupResult(success: false, error: error);
|
||||||
|
}
|
||||||
|
|
||||||
|
class GoogleDriveService {
|
||||||
|
static const _fileName = 'casha_backup.json';
|
||||||
|
static const _appDataFolder = 'appDataFolder';
|
||||||
|
|
||||||
|
final GoogleSignIn _googleSignIn;
|
||||||
|
|
||||||
|
GoogleDriveService(this._googleSignIn);
|
||||||
|
|
||||||
|
GoogleSignInAccount? get currentUser => _googleSignIn.currentUser;
|
||||||
|
Stream<GoogleSignInAccount?> get onUserChanged => _googleSignIn.onCurrentUserChanged;
|
||||||
|
|
||||||
|
Future<void> signIn() async {
|
||||||
|
await _googleSignIn.signIn();
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> signOut() async {
|
||||||
|
await _googleSignIn.signOut();
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<drive.DriveApi?> _getDriveApi() async {
|
||||||
|
if (_googleSignIn.currentUser == null) return null;
|
||||||
|
final httpClient = await _googleSignIn.authenticatedClient();
|
||||||
|
if (httpClient == null) return null;
|
||||||
|
return drive.DriveApi(httpClient);
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<String?> _findExistingFile(drive.DriveApi api) async {
|
||||||
|
final list = await api.files.list(
|
||||||
|
spaces: _appDataFolder,
|
||||||
|
q: "name = '$_fileName' and trashed = false",
|
||||||
|
$fields: 'files(id, name, modifiedTime)',
|
||||||
|
);
|
||||||
|
return list.files?.isNotEmpty == true ? list.files!.first.id : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<DriveBackupResult> uploadBackup(Uint8List data) async {
|
||||||
|
final api = await _getDriveApi();
|
||||||
|
if (api == null) {
|
||||||
|
return DriveBackupResult.failed('Not authenticated');
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
final existingId = await _findExistingFile(api);
|
||||||
|
|
||||||
|
final media = drive.Media(
|
||||||
|
Stream<List<int>>.fromIterable([data.toList()]),
|
||||||
|
data.length,
|
||||||
|
);
|
||||||
|
|
||||||
|
if (existingId != null) {
|
||||||
|
final file = drive.File(
|
||||||
|
name: _fileName,
|
||||||
|
modifiedTime: DateTime.now(),
|
||||||
|
);
|
||||||
|
final updated = await api.files.update(
|
||||||
|
file,
|
||||||
|
existingId,
|
||||||
|
uploadMedia: media,
|
||||||
|
$fields: 'id, modifiedTime',
|
||||||
|
);
|
||||||
|
return DriveBackupResult.ok(
|
||||||
|
updated.id!,
|
||||||
|
updated.modifiedTime!,
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
final file = drive.File(
|
||||||
|
name: _fileName,
|
||||||
|
parents: [_appDataFolder],
|
||||||
|
modifiedTime: DateTime.now(),
|
||||||
|
);
|
||||||
|
final created = await api.files.create(
|
||||||
|
file,
|
||||||
|
uploadMedia: media,
|
||||||
|
$fields: 'id, modifiedTime',
|
||||||
|
);
|
||||||
|
return DriveBackupResult.ok(
|
||||||
|
created.id!,
|
||||||
|
created.modifiedTime!,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
return DriveBackupResult.failed(e.toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<Uint8List?> downloadBackup() async {
|
||||||
|
final api = await _getDriveApi();
|
||||||
|
if (api == null) return null;
|
||||||
|
|
||||||
|
try {
|
||||||
|
final fileId = await _findExistingFile(api);
|
||||||
|
if (fileId == null) return null;
|
||||||
|
|
||||||
|
final media = await api.files.get(
|
||||||
|
fileId,
|
||||||
|
downloadOptions: drive.DownloadOptions.fullMedia,
|
||||||
|
) as drive.Media;
|
||||||
|
|
||||||
|
final bytes = <int>[];
|
||||||
|
await for (final chunk in media.stream) {
|
||||||
|
bytes.addAll(chunk);
|
||||||
|
}
|
||||||
|
return Uint8List.fromList(bytes);
|
||||||
|
} catch (e) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<DateTime?> getLastBackupTime() async {
|
||||||
|
final api = await _getDriveApi();
|
||||||
|
if (api == null) return null;
|
||||||
|
|
||||||
|
try {
|
||||||
|
final list = await api.files.list(
|
||||||
|
spaces: _appDataFolder,
|
||||||
|
q: "name = '$_fileName' and trashed = false",
|
||||||
|
$fields: 'files(id, name, modifiedTime)',
|
||||||
|
);
|
||||||
|
if (list.files?.isNotEmpty == true) {
|
||||||
|
return list.files!.first.modifiedTime;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
} catch (e) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
import 'package:flutter/foundation.dart';
|
||||||
|
import 'package:shared_preferences/shared_preferences.dart';
|
||||||
|
|
||||||
|
class OnboardingService {
|
||||||
|
static const _key = 'onboarding_completed';
|
||||||
|
static bool _shownInSession = false;
|
||||||
|
static SharedPreferences? _staticPrefs;
|
||||||
|
|
||||||
|
final SharedPreferences _prefs;
|
||||||
|
|
||||||
|
OnboardingService(this._prefs) {
|
||||||
|
_staticPrefs = _prefs;
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool get shouldShowOnboarding {
|
||||||
|
if (kDebugMode) {
|
||||||
|
return !_shownInSession;
|
||||||
|
}
|
||||||
|
return !(_staticPrefs?.getBool(_key) ?? false);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void markCompleted() {
|
||||||
|
_shownInSession = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool get shouldShowOnboardingInstance => shouldShowOnboarding;
|
||||||
|
|
||||||
|
Future<void> completeOnboarding() async {
|
||||||
|
_shownInSession = true;
|
||||||
|
if (!kDebugMode) {
|
||||||
|
await _prefs.setBool(_key, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,58 @@
|
|||||||
|
import 'package:shared_preferences/shared_preferences.dart';
|
||||||
|
import '../models/user_model.dart';
|
||||||
|
import 'billing_service.dart';
|
||||||
|
|
||||||
|
class PremiumManager {
|
||||||
|
static const _keyIsPremium = 'is_premium';
|
||||||
|
static const _keyPurchaseToken = 'purchase_token';
|
||||||
|
|
||||||
|
final SharedPreferences _prefs;
|
||||||
|
final BillingService _billing;
|
||||||
|
|
||||||
|
PremiumManager(this._prefs, this._billing);
|
||||||
|
|
||||||
|
bool get isPremium => _prefs.getBool(_keyIsPremium) ?? false;
|
||||||
|
String? get purchaseToken => _prefs.getString(_keyPurchaseToken);
|
||||||
|
|
||||||
|
Future<void> _setPremium(bool value, String? token) async {
|
||||||
|
await _prefs.setBool(_keyIsPremium, value);
|
||||||
|
if (token != null) {
|
||||||
|
await _prefs.setString(_keyPurchaseToken, token);
|
||||||
|
} else if (!value) {
|
||||||
|
await _prefs.remove(_keyPurchaseToken);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<PurchaseResult> purchase() async {
|
||||||
|
if (isPremium) {
|
||||||
|
return PurchaseResult.ok(purchaseToken ?? 'existing');
|
||||||
|
}
|
||||||
|
final result = await _billing.purchasePro();
|
||||||
|
if (result.success && result.purchaseToken != null) {
|
||||||
|
await _setPremium(true, result.purchaseToken);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<PurchaseResult> restore() async {
|
||||||
|
final result = await _billing.restorePurchases();
|
||||||
|
if (result.success && result.purchaseToken != null) {
|
||||||
|
await _setPremium(true, result.purchaseToken);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> autoRestore() async {
|
||||||
|
if (isPremium) return;
|
||||||
|
final result = await _billing.queryPastPurchase();
|
||||||
|
if (result.success && result.purchaseToken != null) {
|
||||||
|
await _setPremium(true, result.purchaseToken);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
UserPlan get currentPlan => isPremium ? UserPlan.vip : UserPlan.free;
|
||||||
|
|
||||||
|
Future<void> clear() async {
|
||||||
|
await _setPremium(false, null);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,360 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||||
|
import 'package:go_router/go_router.dart';
|
||||||
|
import '../../core/l10n/app_strings.dart';
|
||||||
|
import '../../core/l10n/locale_provider.dart';
|
||||||
|
import '../../core/services/haptic_service.dart';
|
||||||
|
import '../providers/backup_provider.dart';
|
||||||
|
import '../providers/google_drive_provider.dart';
|
||||||
|
import '../providers/premium_provider.dart';
|
||||||
|
import 'error_snackbar.dart';
|
||||||
|
import '../services/backup_service.dart';
|
||||||
|
|
||||||
|
class BackupScreen extends ConsumerStatefulWidget {
|
||||||
|
const BackupScreen({super.key});
|
||||||
|
|
||||||
|
@override
|
||||||
|
ConsumerState<BackupScreen> createState() => _BackupScreenState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _BackupScreenState extends ConsumerState<BackupScreen> {
|
||||||
|
bool _backingUp = false;
|
||||||
|
bool _restoring = false;
|
||||||
|
DateTime? _lastBackupTime;
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
_loadLastBackupTime();
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> _loadLastBackupTime() async {
|
||||||
|
final service = ref.read(googleDriveServiceProvider);
|
||||||
|
final time = await service.getLastBackupTime();
|
||||||
|
if (mounted) {
|
||||||
|
setState(() => _lastBackupTime = time);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> _handleBackup() async {
|
||||||
|
final s = ref.read(stringsProvider);
|
||||||
|
final driveService = ref.read(googleDriveServiceProvider);
|
||||||
|
|
||||||
|
if (driveService.currentUser == null) {
|
||||||
|
showErrorSnackbar(context, s.backupRequiresSignIn);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
HapticService.light();
|
||||||
|
setState(() => _backingUp = true);
|
||||||
|
|
||||||
|
try {
|
||||||
|
final backupService = ref.read(backupServiceProvider);
|
||||||
|
final payload = <String, dynamic>{
|
||||||
|
'version': 1,
|
||||||
|
'exported_at': DateTime.now().toIso8601String(),
|
||||||
|
};
|
||||||
|
final data = backupService.createBackup(payload);
|
||||||
|
final result = await driveService.uploadBackup(data);
|
||||||
|
|
||||||
|
if (result.success) {
|
||||||
|
setState(() => _lastBackupTime = result.modifiedTime);
|
||||||
|
HapticService.medium();
|
||||||
|
if (mounted) {
|
||||||
|
showSuccessSnackbar(context, s.backupSuccess);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (mounted) {
|
||||||
|
showErrorSnackbar(context, result.error ?? s.backupRestoreFailed);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
if (mounted) {
|
||||||
|
showErrorSnackbar(context, e.toString());
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
if (mounted) setState(() => _backingUp = false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> _handleRestore() async {
|
||||||
|
final s = ref.read(stringsProvider);
|
||||||
|
final driveService = ref.read(googleDriveServiceProvider);
|
||||||
|
|
||||||
|
if (driveService.currentUser == null) {
|
||||||
|
showErrorSnackbar(context, s.backupRequiresSignIn);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
HapticService.light();
|
||||||
|
setState(() => _restoring = true);
|
||||||
|
|
||||||
|
try {
|
||||||
|
final raw = await driveService.downloadBackup();
|
||||||
|
if (raw == null) {
|
||||||
|
if (mounted) {
|
||||||
|
showWarningSnackbar(context, s.backupNoFileFound);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
final backupService = ref.read(backupServiceProvider);
|
||||||
|
final (result, data) = backupService.verifyAndParse(raw);
|
||||||
|
|
||||||
|
switch (result) {
|
||||||
|
case BackupVerifyResult.ok:
|
||||||
|
HapticService.medium();
|
||||||
|
if (mounted) {
|
||||||
|
showSuccessSnackbar(context, s.backupRestoreSuccess);
|
||||||
|
}
|
||||||
|
case BackupVerifyResult.tokenMismatch:
|
||||||
|
if (mounted) {
|
||||||
|
showErrorSnackbar(context, s.backupTokenMismatch);
|
||||||
|
}
|
||||||
|
case BackupVerifyResult.noToken:
|
||||||
|
if (mounted) {
|
||||||
|
showErrorSnackbar(context, s.backupNoToken);
|
||||||
|
}
|
||||||
|
case BackupVerifyResult.invalidFormat:
|
||||||
|
if (mounted) {
|
||||||
|
showErrorSnackbar(context, s.backupInvalidFormat);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
if (mounted) {
|
||||||
|
showErrorSnackbar(context, e.toString());
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
if (mounted) setState(() => _restoring = false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
final s = ref.watch(stringsProvider);
|
||||||
|
final isPremium = ref.watch(isPremiumProvider);
|
||||||
|
final driveUserAsync = ref.watch(googleDriveUserProvider);
|
||||||
|
final driveUser = driveUserAsync.value;
|
||||||
|
final colorScheme = Theme.of(context).colorScheme;
|
||||||
|
|
||||||
|
return Scaffold(
|
||||||
|
body: SafeArea(
|
||||||
|
child: Column(
|
||||||
|
children: [
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.fromLTRB(8, 4, 16, 0),
|
||||||
|
child: Row(
|
||||||
|
children: [
|
||||||
|
IconButton(
|
||||||
|
icon: const Icon(Icons.arrow_back_rounded),
|
||||||
|
onPressed: () => context.pop(),
|
||||||
|
),
|
||||||
|
Text(
|
||||||
|
s.backupTitle,
|
||||||
|
style: Theme.of(context).textTheme.titleLarge?.copyWith(
|
||||||
|
fontWeight: FontWeight.w800,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Expanded(
|
||||||
|
child: SingleChildScrollView(
|
||||||
|
padding: const EdgeInsets.all(20),
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
if (!isPremium) ...[
|
||||||
|
_buildLockedState(context, s, colorScheme),
|
||||||
|
] else ...[
|
||||||
|
_buildSyncStatus(context, s, colorScheme, driveUser),
|
||||||
|
const SizedBox(height: 20),
|
||||||
|
_buildBackupActions(context, s, colorScheme, driveUser),
|
||||||
|
const SizedBox(height: 20),
|
||||||
|
_buildLastBackup(context, s, colorScheme),
|
||||||
|
],
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _buildLockedState(
|
||||||
|
BuildContext context,
|
||||||
|
AppStrings s,
|
||||||
|
ColorScheme colorScheme,
|
||||||
|
) {
|
||||||
|
return Container(
|
||||||
|
width: double.infinity,
|
||||||
|
padding: const EdgeInsets.all(24),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: colorScheme.surface,
|
||||||
|
borderRadius: BorderRadius.circular(16),
|
||||||
|
border: Border.all(color: colorScheme.outlineVariant),
|
||||||
|
),
|
||||||
|
child: Column(
|
||||||
|
children: [
|
||||||
|
Icon(Icons.lock_outline_rounded, size: 48, color: colorScheme.primary),
|
||||||
|
const SizedBox(height: 16),
|
||||||
|
Text(
|
||||||
|
s.backupRequiresPremium,
|
||||||
|
style: Theme.of(context).textTheme.titleMedium?.copyWith(
|
||||||
|
fontWeight: FontWeight.w600,
|
||||||
|
),
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
),
|
||||||
|
const SizedBox(height: 16),
|
||||||
|
FilledButton(
|
||||||
|
onPressed: () => context.push('/pro'),
|
||||||
|
child: Text(s.proBuy),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _buildSyncStatus(
|
||||||
|
BuildContext context,
|
||||||
|
AppStrings s,
|
||||||
|
ColorScheme colorScheme,
|
||||||
|
dynamic driveUser,
|
||||||
|
) {
|
||||||
|
return Container(
|
||||||
|
width: double.infinity,
|
||||||
|
padding: const EdgeInsets.all(16),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: colorScheme.surface,
|
||||||
|
borderRadius: BorderRadius.circular(16),
|
||||||
|
border: Border.all(color: colorScheme.outlineVariant),
|
||||||
|
),
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Row(
|
||||||
|
children: [
|
||||||
|
Icon(
|
||||||
|
driveUser != null
|
||||||
|
? Icons.cloud_done_rounded
|
||||||
|
: Icons.cloud_off_rounded,
|
||||||
|
color: driveUser != null ? colorScheme.primary : colorScheme.onSurface.withOpacity(0.4),
|
||||||
|
size: 24,
|
||||||
|
),
|
||||||
|
const SizedBox(width: 12),
|
||||||
|
Expanded(
|
||||||
|
child: Text(
|
||||||
|
driveUser != null
|
||||||
|
? s.proSyncEnabled
|
||||||
|
: s.backupRequiresSignIn,
|
||||||
|
style: Theme.of(context).textTheme.titleMedium?.copyWith(
|
||||||
|
fontWeight: FontWeight.w600,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
if (driveUser != null) ...[
|
||||||
|
const SizedBox(height: 8),
|
||||||
|
Text(
|
||||||
|
driveUser.email,
|
||||||
|
style: Theme.of(context).textTheme.bodySmall?.copyWith(
|
||||||
|
color: colorScheme.onSurface.withOpacity(0.6),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _buildBackupActions(
|
||||||
|
BuildContext context,
|
||||||
|
AppStrings s,
|
||||||
|
ColorScheme colorScheme,
|
||||||
|
dynamic driveUser,
|
||||||
|
) {
|
||||||
|
final disabled = driveUser == null;
|
||||||
|
return Column(
|
||||||
|
children: [
|
||||||
|
SizedBox(
|
||||||
|
width: double.infinity,
|
||||||
|
child: FilledButton.icon(
|
||||||
|
onPressed: (disabled || _backingUp) ? null : _handleBackup,
|
||||||
|
icon: _backingUp
|
||||||
|
? SizedBox(
|
||||||
|
width: 18,
|
||||||
|
height: 18,
|
||||||
|
child: CircularProgressIndicator(
|
||||||
|
strokeWidth: 2,
|
||||||
|
color: colorScheme.onPrimary,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
: const Icon(Icons.backup_outlined),
|
||||||
|
label: Text(_backingUp ? s.backupCreating : s.backupCreate),
|
||||||
|
style: FilledButton.styleFrom(
|
||||||
|
padding: const EdgeInsets.symmetric(vertical: 14),
|
||||||
|
shape: RoundedRectangleBorder(
|
||||||
|
borderRadius: BorderRadius.circular(12),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 12),
|
||||||
|
SizedBox(
|
||||||
|
width: double.infinity,
|
||||||
|
child: OutlinedButton.icon(
|
||||||
|
onPressed: (disabled || _restoring) ? null : _handleRestore,
|
||||||
|
icon: _restoring
|
||||||
|
? SizedBox(
|
||||||
|
width: 18,
|
||||||
|
height: 18,
|
||||||
|
child: CircularProgressIndicator(
|
||||||
|
strokeWidth: 2,
|
||||||
|
color: colorScheme.primary,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
: const Icon(Icons.restore_rounded),
|
||||||
|
label: Text(_restoring ? s.backupRestoring : s.backupRestore),
|
||||||
|
style: OutlinedButton.styleFrom(
|
||||||
|
padding: const EdgeInsets.symmetric(vertical: 14),
|
||||||
|
shape: RoundedRectangleBorder(
|
||||||
|
borderRadius: BorderRadius.circular(12),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _buildLastBackup(
|
||||||
|
BuildContext context,
|
||||||
|
AppStrings s,
|
||||||
|
ColorScheme colorScheme,
|
||||||
|
) {
|
||||||
|
return Row(
|
||||||
|
children: [
|
||||||
|
Icon(
|
||||||
|
Icons.schedule_rounded,
|
||||||
|
size: 18,
|
||||||
|
color: colorScheme.onSurface.withOpacity(0.5),
|
||||||
|
),
|
||||||
|
const SizedBox(width: 8),
|
||||||
|
Text(
|
||||||
|
'${s.backupLastBackup}: ${_lastBackupTime != null ? _formatDate(_lastBackupTime!) : s.backupNever}',
|
||||||
|
style: Theme.of(context).textTheme.bodySmall?.copyWith(
|
||||||
|
color: colorScheme.onSurface.withOpacity(0.5),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
String _formatDate(DateTime dt) {
|
||||||
|
final d = dt.toLocal();
|
||||||
|
return '${d.day.toString().padLeft(2, '0')}.${d.month.toString().padLeft(2, '0')}.${d.year} ${d.hour.toString().padLeft(2, '0')}:${d.minute.toString().padLeft(2, '0')}';
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,528 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||||
|
import 'package:go_router/go_router.dart';
|
||||||
|
import '../../core/l10n/app_strings.dart';
|
||||||
|
import '../../core/l10n/locale_provider.dart';
|
||||||
|
import '../../core/services/haptic_service.dart';
|
||||||
|
import '../providers/current_user_provider.dart';
|
||||||
|
import '../providers/premium_provider.dart';
|
||||||
|
import 'error_snackbar.dart';
|
||||||
|
|
||||||
|
class ProScreen extends ConsumerStatefulWidget {
|
||||||
|
const ProScreen({super.key});
|
||||||
|
|
||||||
|
@override
|
||||||
|
ConsumerState<ProScreen> createState() => _ProScreenState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _ProScreenState extends ConsumerState<ProScreen>
|
||||||
|
with SingleTickerProviderStateMixin {
|
||||||
|
bool _purchasing = false;
|
||||||
|
bool _restoring = false;
|
||||||
|
bool _resetting = false;
|
||||||
|
bool _showSuccess = false;
|
||||||
|
String _successTitle = '';
|
||||||
|
late final AnimationController _successController;
|
||||||
|
late final Animation<double> _successScale;
|
||||||
|
|
||||||
|
static const _gradientColors = [
|
||||||
|
Color(0xFF5B4DCC),
|
||||||
|
Color(0xFF7C6DED),
|
||||||
|
Color(0xFF9D8FF5),
|
||||||
|
];
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
_successController = AnimationController(
|
||||||
|
vsync: this,
|
||||||
|
duration: const Duration(milliseconds: 400),
|
||||||
|
);
|
||||||
|
_successScale = Tween<double>(begin: 0.0, end: 1.0).animate(
|
||||||
|
CurvedAnimation(
|
||||||
|
parent: _successController,
|
||||||
|
curve: Curves.elasticOut,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void dispose() {
|
||||||
|
_successController.dispose();
|
||||||
|
super.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
void _showSuccessOverlay(String title) {
|
||||||
|
setState(() {
|
||||||
|
_successTitle = title;
|
||||||
|
_showSuccess = true;
|
||||||
|
});
|
||||||
|
_successController.forward(from: 0.0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void _dismissSuccessOverlay() {
|
||||||
|
_successController.stop();
|
||||||
|
if (mounted) {
|
||||||
|
setState(() => _showSuccess = false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
final s = ref.watch(stringsProvider);
|
||||||
|
final isPremium = ref.watch(isPremiumProvider);
|
||||||
|
final colorScheme = Theme.of(context).colorScheme;
|
||||||
|
|
||||||
|
return Stack(
|
||||||
|
children: [
|
||||||
|
Scaffold(
|
||||||
|
body: SafeArea(
|
||||||
|
child: Column(
|
||||||
|
children: [
|
||||||
|
_buildHeader(context),
|
||||||
|
Expanded(
|
||||||
|
child: SingleChildScrollView(
|
||||||
|
padding: const EdgeInsets.symmetric(horizontal: 20),
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
const SizedBox(height: 4),
|
||||||
|
_buildHeroBanner(context, s, isPremium),
|
||||||
|
const SizedBox(height: 20),
|
||||||
|
_buildFeatureList(context, s, colorScheme),
|
||||||
|
const SizedBox(height: 16),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
_buildBottomBar(context, s, colorScheme, isPremium),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
if (_showSuccess) _buildSuccessOverlay(context, s, colorScheme),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _buildHeader(BuildContext context) {
|
||||||
|
return Padding(
|
||||||
|
padding: const EdgeInsets.fromLTRB(8, 4, 16, 0),
|
||||||
|
child: Row(
|
||||||
|
children: [
|
||||||
|
IconButton(
|
||||||
|
icon: const Icon(Icons.arrow_back_rounded),
|
||||||
|
onPressed: () => context.pop(),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _buildHeroBanner(
|
||||||
|
BuildContext context,
|
||||||
|
AppStrings s,
|
||||||
|
bool isVip,
|
||||||
|
) {
|
||||||
|
return Container(
|
||||||
|
width: double.infinity,
|
||||||
|
padding: const EdgeInsets.symmetric(vertical: 36, horizontal: 20),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
gradient: const LinearGradient(
|
||||||
|
begin: Alignment.topLeft,
|
||||||
|
end: Alignment.bottomRight,
|
||||||
|
colors: _gradientColors,
|
||||||
|
),
|
||||||
|
borderRadius: BorderRadius.circular(20),
|
||||||
|
),
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
s.proTitle,
|
||||||
|
style: Theme.of(context).textTheme.displaySmall?.copyWith(
|
||||||
|
fontWeight: FontWeight.w900,
|
||||||
|
color: Colors.white,
|
||||||
|
letterSpacing: -0.5,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 6),
|
||||||
|
Text(
|
||||||
|
isVip ? s.proActive : s.proSubtitle,
|
||||||
|
style: Theme.of(context).textTheme.titleMedium?.copyWith(
|
||||||
|
color: Colors.white.withOpacity(0.9),
|
||||||
|
fontWeight: isVip ? FontWeight.w700 : FontWeight.w500,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _buildSuccessOverlay(
|
||||||
|
BuildContext context,
|
||||||
|
AppStrings s,
|
||||||
|
ColorScheme colorScheme,
|
||||||
|
) {
|
||||||
|
return GestureDetector(
|
||||||
|
onTap: _dismissSuccessOverlay,
|
||||||
|
child: Container(
|
||||||
|
color: Colors.black54,
|
||||||
|
child: Center(
|
||||||
|
child: GestureDetector(
|
||||||
|
onTap: _dismissSuccessOverlay,
|
||||||
|
child: AnimatedBuilder(
|
||||||
|
animation: _successController,
|
||||||
|
builder: (context, child) {
|
||||||
|
return Transform.scale(
|
||||||
|
scale: _successScale.value,
|
||||||
|
child: child,
|
||||||
|
);
|
||||||
|
},
|
||||||
|
child: Container(
|
||||||
|
padding: const EdgeInsets.all(32),
|
||||||
|
margin: const EdgeInsets.symmetric(horizontal: 40),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: colorScheme.surface,
|
||||||
|
borderRadius: BorderRadius.circular(24),
|
||||||
|
),
|
||||||
|
child: Column(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
children: [
|
||||||
|
Container(
|
||||||
|
padding: const EdgeInsets.all(16),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: colorScheme.primary.withOpacity(0.15),
|
||||||
|
shape: BoxShape.circle,
|
||||||
|
),
|
||||||
|
child: Icon(
|
||||||
|
Icons.check_circle_rounded,
|
||||||
|
color: colorScheme.primary,
|
||||||
|
size: 64,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 20),
|
||||||
|
Text(
|
||||||
|
_successTitle,
|
||||||
|
style: Theme.of(context).textTheme.titleLarge?.copyWith(
|
||||||
|
fontWeight: FontWeight.w800,
|
||||||
|
color: colorScheme.onSurface,
|
||||||
|
),
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
),
|
||||||
|
const SizedBox(height: 12),
|
||||||
|
Text(
|
||||||
|
s.proTapToClose,
|
||||||
|
style: Theme.of(context).textTheme.bodySmall?.copyWith(
|
||||||
|
color: colorScheme.onSurface.withOpacity(0.5),
|
||||||
|
),
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _buildFeatureList(
|
||||||
|
BuildContext context,
|
||||||
|
AppStrings s,
|
||||||
|
ColorScheme colorScheme,
|
||||||
|
) {
|
||||||
|
final features = [
|
||||||
|
(Icons.analytics_rounded, s.proFeatureAnalytics, s.proFeatureAnalyticsDesc),
|
||||||
|
(Icons.palette_rounded, s.proFeatureCustomization, s.proFeatureCustomizationDesc),
|
||||||
|
(Icons.fingerprint_rounded, s.proFeatureBiometric, s.proFeatureBiometricDesc),
|
||||||
|
(Icons.account_balance_wallet_rounded, s.proFeatureAccounts, s.proFeatureAccountsDesc),
|
||||||
|
];
|
||||||
|
|
||||||
|
return Column(
|
||||||
|
children: features.map((f) {
|
||||||
|
return Padding(
|
||||||
|
padding: const EdgeInsets.only(bottom: 14),
|
||||||
|
child: Row(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Container(
|
||||||
|
padding: const EdgeInsets.all(10),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: colorScheme.primary.withOpacity(0.1),
|
||||||
|
borderRadius: BorderRadius.circular(12),
|
||||||
|
),
|
||||||
|
child: Icon(
|
||||||
|
f.$1,
|
||||||
|
color: colorScheme.primary,
|
||||||
|
size: 22,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(width: 14),
|
||||||
|
Expanded(
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
f.$2,
|
||||||
|
style: Theme.of(context).textTheme.titleSmall?.copyWith(
|
||||||
|
fontWeight: FontWeight.w700,
|
||||||
|
color: colorScheme.onSurface,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 4),
|
||||||
|
Text(
|
||||||
|
f.$3,
|
||||||
|
style: Theme.of(context).textTheme.bodyMedium?.copyWith(
|
||||||
|
color: colorScheme.onSurface.withOpacity(0.6),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}).toList(),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _buildBottomBar(
|
||||||
|
BuildContext context,
|
||||||
|
AppStrings s,
|
||||||
|
ColorScheme colorScheme,
|
||||||
|
bool isVip,
|
||||||
|
) {
|
||||||
|
return Container(
|
||||||
|
padding: const EdgeInsets.fromLTRB(20, 12, 20, 24),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: Theme.of(context).scaffoldBackgroundColor,
|
||||||
|
border: Border(
|
||||||
|
top: BorderSide(
|
||||||
|
color: colorScheme.outlineVariant.withOpacity(0.3),
|
||||||
|
width: 1,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
child: Column(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
children: [
|
||||||
|
if (!isVip) ...[
|
||||||
|
SizedBox(
|
||||||
|
width: double.infinity,
|
||||||
|
child: FilledButton(
|
||||||
|
onPressed: _purchasing ? null : _handlePurchase,
|
||||||
|
style: FilledButton.styleFrom(
|
||||||
|
padding: const EdgeInsets.symmetric(vertical: 16),
|
||||||
|
shape: RoundedRectangleBorder(
|
||||||
|
borderRadius: BorderRadius.circular(12),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
child: _purchasing
|
||||||
|
? SizedBox(
|
||||||
|
width: 20,
|
||||||
|
height: 20,
|
||||||
|
child: CircularProgressIndicator(
|
||||||
|
strokeWidth: 2,
|
||||||
|
color: colorScheme.onPrimary,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
: Text(
|
||||||
|
s.proBuy,
|
||||||
|
style: const TextStyle(
|
||||||
|
fontSize: 16,
|
||||||
|
fontWeight: FontWeight.w700,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 8),
|
||||||
|
SizedBox(
|
||||||
|
width: double.infinity,
|
||||||
|
child: TextButton(
|
||||||
|
onPressed: _restoring ? null : _handleRestore,
|
||||||
|
child: _restoring
|
||||||
|
? SizedBox(
|
||||||
|
width: 16,
|
||||||
|
height: 16,
|
||||||
|
child: CircularProgressIndicator(
|
||||||
|
strokeWidth: 2,
|
||||||
|
color: colorScheme.primary,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
: 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),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> _handlePurchase() async {
|
||||||
|
HapticService.light();
|
||||||
|
setState(() => _purchasing = true);
|
||||||
|
try {
|
||||||
|
final manager = ref.read(premiumManagerProvider);
|
||||||
|
final result = await manager.purchase();
|
||||||
|
if (result.success) {
|
||||||
|
await ref.read(currentUserProvider.notifier).refreshFromPremium();
|
||||||
|
if (mounted) {
|
||||||
|
_showSuccessOverlay(ref.read(stringsProvider).proPurchaseSuccess);
|
||||||
|
HapticService.medium();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (mounted) {
|
||||||
|
showErrorSnackbar(context, result.error ?? ref.read(stringsProvider).proPurchaseFailed);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
if (mounted) {
|
||||||
|
showErrorSnackbar(context, e.toString());
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
if (mounted) setState(() => _purchasing = false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> _handleRestore() async {
|
||||||
|
HapticService.light();
|
||||||
|
setState(() => _restoring = true);
|
||||||
|
try {
|
||||||
|
final manager = ref.read(premiumManagerProvider);
|
||||||
|
final result = await manager.restore();
|
||||||
|
if (result.success) {
|
||||||
|
await ref.read(currentUserProvider.notifier).refreshFromPremium();
|
||||||
|
if (mounted) {
|
||||||
|
_showSuccessOverlay(ref.read(stringsProvider).proRestoreSuccessTitle);
|
||||||
|
HapticService.medium();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (mounted) {
|
||||||
|
showWarningSnackbar(context, ref.read(stringsProvider).proRestoreNotFound);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
if (mounted) {
|
||||||
|
showErrorSnackbar(context, e.toString());
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
if (mounted) setState(() => _restoring = false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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();
|
||||||
|
setState(() => _resetting = true);
|
||||||
|
try {
|
||||||
|
final manager = ref.read(premiumManagerProvider);
|
||||||
|
await manager.clear();
|
||||||
|
await ref.read(currentUserProvider.notifier).refreshFromPremium();
|
||||||
|
if (mounted) {
|
||||||
|
showSuccessSnackbar(context, s.proResetDataSuccess);
|
||||||
|
HapticService.medium();
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
if (mounted) {
|
||||||
|
showErrorSnackbar(context, e.toString());
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
if (mounted) setState(() => _resetting = false);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
style: TextButton.styleFrom(
|
||||||
|
foregroundColor: const Color(0xFFE05C6B),
|
||||||
|
),
|
||||||
|
child: Text(s.proResetData),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,264 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||||
|
import 'package:go_router/go_router.dart';
|
||||||
|
import '../../core/l10n/locale_provider.dart';
|
||||||
|
import '../../core/services/haptic_service.dart';
|
||||||
|
import '../providers/premium_provider.dart';
|
||||||
|
|
||||||
|
class ProSubscriptionCard extends StatefulWidget {
|
||||||
|
const ProSubscriptionCard({super.key});
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<ProSubscriptionCard> createState() =>
|
||||||
|
_ProSubscriptionCardState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _ProSubscriptionCardState extends State<ProSubscriptionCard>
|
||||||
|
with SingleTickerProviderStateMixin {
|
||||||
|
late final AnimationController _shimmerController;
|
||||||
|
|
||||||
|
static const _gradientColors = [
|
||||||
|
Color(0xFF5B4DCC),
|
||||||
|
Color(0xFF7C6DED),
|
||||||
|
Color(0xFF9D8FF5),
|
||||||
|
];
|
||||||
|
|
||||||
|
@override
|
||||||
|
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 isPremium = ref.watch(isPremiumProvider);
|
||||||
|
|
||||||
|
return ClipRRect(
|
||||||
|
borderRadius: BorderRadius.circular(20),
|
||||||
|
child: Stack(
|
||||||
|
children: [
|
||||||
|
Container(
|
||||||
|
padding: const EdgeInsets.fromLTRB(20, 22, 20, 18),
|
||||||
|
decoration: const BoxDecoration(
|
||||||
|
gradient: LinearGradient(
|
||||||
|
begin: Alignment.topLeft,
|
||||||
|
end: Alignment.bottomRight,
|
||||||
|
colors: _gradientColors,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Row(
|
||||||
|
children: [
|
||||||
|
Container(
|
||||||
|
padding: const EdgeInsets.all(10),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: Colors.white.withOpacity(0.18),
|
||||||
|
borderRadius: BorderRadius.circular(12),
|
||||||
|
border: Border.all(
|
||||||
|
color: Colors.white.withOpacity(0.25),
|
||||||
|
width: 1,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
child: Icon(
|
||||||
|
isPremium
|
||||||
|
? Icons.verified_rounded
|
||||||
|
: Icons.workspace_premium_rounded,
|
||||||
|
color: Colors.white,
|
||||||
|
size: 26,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(width: 14),
|
||||||
|
Expanded(
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
s.proTitle,
|
||||||
|
style: Theme.of(context)
|
||||||
|
.textTheme
|
||||||
|
.titleLarge
|
||||||
|
?.copyWith(
|
||||||
|
fontWeight: FontWeight.w800,
|
||||||
|
color: Colors.white,
|
||||||
|
letterSpacing: -0.3,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 3),
|
||||||
|
Text(
|
||||||
|
isPremium ? s.proActive : s.proSubtitle,
|
||||||
|
style: isPremium
|
||||||
|
? Theme.of(context)
|
||||||
|
.textTheme
|
||||||
|
.bodyMedium
|
||||||
|
?.copyWith(
|
||||||
|
color: Colors.white.withOpacity(0.95),
|
||||||
|
fontWeight: FontWeight.w600,
|
||||||
|
)
|
||||||
|
: Theme.of(context)
|
||||||
|
.textTheme
|
||||||
|
.bodySmall
|
||||||
|
?.copyWith(
|
||||||
|
color: Colors.white.withOpacity(0.75),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
if (isPremium)
|
||||||
|
Container(
|
||||||
|
padding: const EdgeInsets.symmetric(
|
||||||
|
horizontal: 10,
|
||||||
|
vertical: 5,
|
||||||
|
),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: Colors.white.withOpacity(0.2),
|
||||||
|
borderRadius: BorderRadius.circular(20),
|
||||||
|
border: Border.all(
|
||||||
|
color: Colors.white.withOpacity(0.3),
|
||||||
|
width: 1,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
child: Row(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
children: [
|
||||||
|
Icon(
|
||||||
|
Icons.check_circle_rounded,
|
||||||
|
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();
|
||||||
|
context.push('/pro');
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
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,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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: [
|
||||||
|
Text(
|
||||||
|
label,
|
||||||
|
style: const TextStyle(
|
||||||
|
color: Colors.white,
|
||||||
|
fontWeight: FontWeight.w700,
|
||||||
|
fontSize: 14,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(width: 6),
|
||||||
|
Icon(icon, color: Colors.white, size: 18),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -5,10 +5,14 @@
|
|||||||
import FlutterMacOS
|
import FlutterMacOS
|
||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
|
import google_sign_in_ios
|
||||||
|
import in_app_purchase_storekit
|
||||||
import local_auth_darwin
|
import local_auth_darwin
|
||||||
import shared_preferences_foundation
|
import shared_preferences_foundation
|
||||||
|
|
||||||
func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
|
func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
|
||||||
|
FLTGoogleSignInPlugin.register(with: registry.registrar(forPlugin: "FLTGoogleSignInPlugin"))
|
||||||
|
InAppPurchasePlugin.register(with: registry.registrar(forPlugin: "InAppPurchasePlugin"))
|
||||||
LocalAuthPlugin.register(with: registry.registrar(forPlugin: "LocalAuthPlugin"))
|
LocalAuthPlugin.register(with: registry.registrar(forPlugin: "LocalAuthPlugin"))
|
||||||
SharedPreferencesPlugin.register(with: registry.registrar(forPlugin: "SharedPreferencesPlugin"))
|
SharedPreferencesPlugin.register(with: registry.registrar(forPlugin: "SharedPreferencesPlugin"))
|
||||||
}
|
}
|
||||||
|
|||||||
+112
@@ -1,6 +1,14 @@
|
|||||||
# Generated by pub
|
# Generated by pub
|
||||||
# See https://dart.dev/tools/pub/glossary#lockfile
|
# See https://dart.dev/tools/pub/glossary#lockfile
|
||||||
packages:
|
packages:
|
||||||
|
_discoveryapis_commons:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: _discoveryapis_commons
|
||||||
|
sha256: "113c4100b90a5b70a983541782431b82168b3cae166ab130649c36eb3559d498"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "1.0.7"
|
||||||
_fe_analyzer_shared:
|
_fe_analyzer_shared:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@@ -241,6 +249,14 @@ packages:
|
|||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.0.8"
|
version: "2.0.8"
|
||||||
|
extension_google_sign_in_as_googleapis_auth:
|
||||||
|
dependency: "direct main"
|
||||||
|
description:
|
||||||
|
name: extension_google_sign_in_as_googleapis_auth
|
||||||
|
sha256: "0dcb17e399f62e897ac78f0a402a3cb6ab9313ced8b2bf131f684d317e05c9ab"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "2.0.13"
|
||||||
fake_async:
|
fake_async:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@@ -376,6 +392,70 @@ packages:
|
|||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "8.1.0"
|
version: "8.1.0"
|
||||||
|
google_identity_services_web:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: google_identity_services_web
|
||||||
|
sha256: "5d187c46dc59e02646e10fe82665fc3884a9b71bc1c90c2b8b749316d33ee454"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "0.3.3+1"
|
||||||
|
google_sign_in:
|
||||||
|
dependency: "direct main"
|
||||||
|
description:
|
||||||
|
name: google_sign_in
|
||||||
|
sha256: d0a2c3bcb06e607bb11e4daca48bd4b6120f0bbc4015ccebbe757d24ea60ed2a
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "6.3.0"
|
||||||
|
google_sign_in_android:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: google_sign_in_android
|
||||||
|
sha256: d5e23c56a4b84b6427552f1cf3f98f716db3b1d1a647f16b96dbb5b93afa2805
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "6.2.1"
|
||||||
|
google_sign_in_ios:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: google_sign_in_ios
|
||||||
|
sha256: "102005f498ce18442e7158f6791033bbc15ad2dcc0afa4cf4752e2722a516c96"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "5.9.0"
|
||||||
|
google_sign_in_platform_interface:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: google_sign_in_platform_interface
|
||||||
|
sha256: "5f6f79cf139c197261adb6ac024577518ae48fdff8e53205c5373b5f6430a8aa"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "2.5.0"
|
||||||
|
google_sign_in_web:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: google_sign_in_web
|
||||||
|
sha256: "460547beb4962b7623ac0fb8122d6b8268c951cf0b646dd150d60498430e4ded"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "0.12.4+4"
|
||||||
|
googleapis:
|
||||||
|
dependency: "direct main"
|
||||||
|
description:
|
||||||
|
name: googleapis
|
||||||
|
sha256: "864f222aed3f2ff00b816c675edf00a39e2aaf373d728d8abec30b37bee1a81c"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "13.2.0"
|
||||||
|
googleapis_auth:
|
||||||
|
dependency: "direct main"
|
||||||
|
description:
|
||||||
|
name: googleapis_auth
|
||||||
|
sha256: befd71383a955535060acde8792e7efc11d2fccd03dd1d3ec434e85b68775938
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "1.6.0"
|
||||||
graphs:
|
graphs:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@@ -432,6 +512,38 @@ packages:
|
|||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "4.9.1"
|
version: "4.9.1"
|
||||||
|
in_app_purchase:
|
||||||
|
dependency: "direct main"
|
||||||
|
description:
|
||||||
|
name: in_app_purchase
|
||||||
|
sha256: "0e9510b80b0074e89ab0a8e0fc901439b779dc9ae575ab8d419253c6e1627716"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "3.3.0"
|
||||||
|
in_app_purchase_android:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: in_app_purchase_android
|
||||||
|
sha256: eb8f551039481d1b265f12fa54f5ab5dd4f13ec5444a468b85a3793517a37fda
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "0.5.1"
|
||||||
|
in_app_purchase_platform_interface:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: in_app_purchase_platform_interface
|
||||||
|
sha256: "0b0076cac8ce4fa7048f01e76af8b123aeb6a7c4e0dea2a5206d6664454f3e36"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "1.4.1"
|
||||||
|
in_app_purchase_storekit:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: in_app_purchase_storekit
|
||||||
|
sha256: "5f9d59c86c15f56429a4fdf09097c99d5b412510e1fcf80cf874fc9638fab369"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "0.4.10"
|
||||||
intl:
|
intl:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
|
|||||||
@@ -25,6 +25,11 @@ dependencies:
|
|||||||
drift: ^2.14.1
|
drift: ^2.14.1
|
||||||
sqlite3_flutter_libs: ^0.6.0+eol
|
sqlite3_flutter_libs: ^0.6.0+eol
|
||||||
path: ^1.8.3
|
path: ^1.8.3
|
||||||
|
google_sign_in: ^6.2.1
|
||||||
|
in_app_purchase: ^3.2.0
|
||||||
|
googleapis: ^13.2.0
|
||||||
|
googleapis_auth: ^1.6.0
|
||||||
|
extension_google_sign_in_as_googleapis_auth: ^2.0.12
|
||||||
|
|
||||||
flutter_launcher_icons:
|
flutter_launcher_icons:
|
||||||
android: true
|
android: true
|
||||||
|
|||||||
Reference in New Issue
Block a user