Compare commits

..

20 Commits

Author SHA1 Message Date
kolo c4ac692019 update 2026-08-06 21:35:22 +03:00
kolo 861a9abd02 first google play release for internal testing 2026-07-10 17:32:02 +03:00
kolo e3c60c4775 step 2026-07-01 16:20:30 +03:00
kolo 64a3f4e34e step 2026-06-29 20:43:13 +03:00
kolo 19db4fe688 step 2026-06-29 19:43:04 +03:00
kolo 00bdd63ea6 step 2026-06-29 19:37:28 +03:00
kolo 7b9bf6d060 step 2026-06-29 16:24:10 +03:00
kolo 4f56e4983c step 2026-06-29 16:04:15 +03:00
kolo 58bfc6b12c step 2026-06-29 14:15:33 +03:00
kolo 4b548adb9a step 2026-06-29 12:20:43 +03:00
kolo 4b5c6be212 step 2026-06-29 11:53:00 +03:00
kolo 186cec8e2a step 2026-06-29 11:18:32 +03:00
kolo cd6113f3c6 step 2026-06-28 19:26:28 +03:00
kolo 4727835402 step 2026-06-28 18:33:46 +03:00
kolo 65ea30339d step 2026-06-28 16:27:59 +03:00
kolo 3adac05cdf step 2026-06-28 16:16:19 +03:00
kolo 5891440a0c step 2026-06-28 16:12:57 +03:00
kolo f2d444cb16 step 2026-06-28 15:10:17 +03:00
kolo 2b89545248 step 2026-06-28 14:55:41 +03:00
kolo 6fdf4eedf1 step
big
2026-06-28 03:16:42 +03:00
74 changed files with 4144 additions and 595 deletions
+60
View File
@@ -20,6 +20,15 @@ lib/
├── data/ # Database schema, repositories ├── data/ # Database schema, repositories
├── features/ # Feature modules (provider + screen + widgets) ├── features/ # Feature modules (provider + screen + widgets)
├── shared/ # Cross-feature models, providers, services, widgets ├── shared/ # Cross-feature models, providers, services, widgets
│ ├── feature_flags/
│ │ ├── feature_flags.dart # abstract class FeatureFlags
│ │ ├── free_feature_flags.dart # FreeFeatureFlags implements FeatureFlags
│ │ ├── vip_feature_flags.dart # VipFeatureFlags implements FeatureFlags
│ │ └── feature_flags_provider.dart # featureFlagsProvider
│ └── paywall/
│ ├── paywall_guard.dart # PaywallGuard widget
│ ├── paywall_banner.dart # inline upsell banner
│ └── paywall_screen.dart # full-screen paywall
└── main.dart └── main.dart
``` ```
@@ -46,6 +55,8 @@ lib/
- `services/``ExchangeRateService`, `StorageService` - `services/``ExchangeRateService`, `StorageService`
- `utils/``CurrencyUtils` - `utils/``CurrencyUtils`
- `widgets/``BynSign`, `ErrorSnackbar` - `widgets/``BynSign`, `ErrorSnackbar`
- `feature_flags/``FeatureFlags` abstraction and plan-specific implementations
- `paywall/``PaywallGuard`, `PaywallBanner`, `PaywallScreen`
## Architecture Rules ## Architecture Rules
@@ -57,6 +68,14 @@ lib/
- Database queries are in repositories only — no raw Drift queries in providers or widgets - Database queries are in repositories only — no raw Drift queries in providers or widgets
- After any changes to Drift tables or DAOs, run `dart run build_runner build --delete-conflicting-outputs` - After any changes to Drift tables or DAOs, run `dart run build_runner build --delete-conflicting-outputs`
### Feature Gating Rules
- Never check `user.isVip` or `plan == UserPlan.vip` directly in widgets or screens
- All access control goes through `featureFlagsProvider` — read the relevant flag, wrap with `PaywallGuard`
- Quantity limits (e.g. max accounts) are enforced inside repositories, not in widgets — throw `FeatureLimitException` on violation
- Routes that are entirely VIP-only use GoRouter `redirect` reading `featureFlagsProvider`
- Adding a new gated feature means: add a getter to `FeatureFlags`, implement in `FreeFeatureFlags` and `VipFeatureFlags`, then use in UI/repo
## Code Style ## Code Style
**No comments anywhere in the codebase.** No `//`, no `/* */`, no `///` doc comments. Code must be self-explanatory through naming. **No comments anywhere in the codebase.** No `//`, no `/* */`, no `///` doc comments. Code must be self-explanatory through naming.
@@ -110,6 +129,44 @@ result.when(
**Colors for accounts** — use `CardColorService`, not hardcoded colors. **Colors for accounts** — use `CardColorService`, not hardcoded colors.
**Feature gating** — wrap gated UI with `PaywallGuard`:
```dart
class ExportScreen extends ConsumerWidget {
@override
Widget build(BuildContext context, WidgetRef ref) {
final flags = ref.watch(featureFlagsProvider);
return PaywallGuard(
canAccess: flags.canExportCsv,
child: ExportContent(),
);
}
}
```
**Quantity limits in repositories**:
```dart
Future<Result<void>> createAccount(Account account) async {
final flags = ref.read(featureFlagsProvider);
final count = await _db.countAccounts();
if (flags.maxAccounts != -1 && count >= flags.maxAccounts) {
return Result.failure(FeatureLimitException());
}
return Result.success(await _db.insertAccount(account));
}
```
**VIP-only routes** — use GoRouter redirect, never guard inside the screen itself:
```dart
GoRoute(
path: '/analytics',
redirect: (context, state) {
final flags = ref.read(featureFlagsProvider);
return flags.canSeeAnalytics ? null : '/paywall';
},
builder: (context, state) => AnalyticsScreen(),
),
```
## Existing Features ## Existing Features
- **dashboard** — main screen with account carousel (`BalanceCard`), transaction list, search, filter chips, budget progress, account editor overlay - **dashboard** — main screen with account carousel (`BalanceCard`), transaction list, search, filter chips, budget progress, account editor overlay
@@ -126,3 +183,6 @@ result.when(
- Do not use `BuildContext` across async gaps without checking `mounted` - Do not use `BuildContext` across async gaps without checking `mounted`
- Do not hardcode user-facing strings — use `AppStrings` - Do not hardcode user-facing strings — use `AppStrings`
- Do not format currency amounts manually — use `CurrencyUtils` - Do not format currency amounts manually — use `CurrencyUtils`
- Do not check `user.isVip` or `plan == UserPlan.vip` in widgets or screens — use `featureFlagsProvider`
- Do not enforce feature limits in widgets — put them in repositories and throw `FeatureLimitException`
- Do not add a new gated feature without adding a corresponding getter to `FeatureFlags` and implementing it in both `FreeFeatureFlags` and `VipFeatureFlags`
+34
View File
@@ -7,13 +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/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),
@@ -49,6 +66,23 @@ final appRouter = GoRouter(
path: '/settings/categories', path: '/settings/categories',
builder: (context, state) => const CategoryManagerScreen(), builder: (context, state) => const CategoryManagerScreen(),
), ),
GoRoute(
path: '/paywall',
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
View File
@@ -44,8 +44,8 @@ class AppTheme {
scaffoldBackgroundColor: AppColors.background, scaffoldBackgroundColor: AppColors.background,
colorScheme: const ColorScheme.dark( colorScheme: const ColorScheme.dark(
surface: AppColors.surface, surface: AppColors.surface,
primary: AppColors.accent, primary: const Color(0xFF7C6DED),
secondary: AppColors.accent, secondary: const Color(0xFF7C6DED),
onPrimary: Colors.white, onPrimary: Colors.white,
onSurface: AppColors.textPrimary, onSurface: AppColors.textPrimary,
), ),
@@ -70,11 +70,11 @@ class AppTheme {
), ),
navigationBarTheme: NavigationBarThemeData( navigationBarTheme: NavigationBarThemeData(
backgroundColor: AppColors.surface, backgroundColor: AppColors.surface,
indicatorColor: AppColors.accent.withOpacity(0.2), indicatorColor: const Color(0xFF7C6DED).withOpacity(0.2),
labelTextStyle: WidgetStateProperty.resolveWith((states) { labelTextStyle: WidgetStateProperty.resolveWith((states) {
if (states.contains(WidgetState.selected)) { if (states.contains(WidgetState.selected)) {
return GoogleFonts.poppins( return GoogleFonts.poppins(
color: AppColors.accent, color: const Color(0xFF7C6DED),
fontSize: 12, fontSize: 12,
fontWeight: FontWeight.w600, fontWeight: FontWeight.w600,
); );
@@ -86,7 +86,7 @@ class AppTheme {
}), }),
iconTheme: WidgetStateProperty.resolveWith((states) { iconTheme: WidgetStateProperty.resolveWith((states) {
if (states.contains(WidgetState.selected)) { if (states.contains(WidgetState.selected)) {
return const IconThemeData(color: AppColors.accent); return const IconThemeData(color: const Color(0xFF7C6DED));
} }
return const IconThemeData(color: AppColors.textSecondary); return const IconThemeData(color: AppColors.textSecondary);
}), }),
@@ -104,14 +104,14 @@ class AppTheme {
), ),
focusedBorder: OutlineInputBorder( focusedBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(12), borderRadius: BorderRadius.circular(12),
borderSide: const BorderSide(color: AppColors.accent, width: 1.5), borderSide: const BorderSide(color: const Color(0xFF7C6DED), width: 1.5),
), ),
labelStyle: const TextStyle(color: AppColors.textSecondary), labelStyle: const TextStyle(color: AppColors.textSecondary),
hintStyle: const TextStyle(color: AppColors.textSecondary), hintStyle: const TextStyle(color: AppColors.textSecondary),
), ),
elevatedButtonTheme: ElevatedButtonThemeData( elevatedButtonTheme: ElevatedButtonThemeData(
style: ElevatedButton.styleFrom( style: ElevatedButton.styleFrom(
backgroundColor: AppColors.accent, backgroundColor: const Color(0xFF7C6DED),
foregroundColor: Colors.white, foregroundColor: Colors.white,
minimumSize: const Size(double.infinity, 52), minimumSize: const Size(double.infinity, 52),
shape: RoundedRectangleBorder( shape: RoundedRectangleBorder(
@@ -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),
), ),
+56
View File
@@ -26,6 +26,14 @@ class AppCategories {
'Shopping', 'Shopping',
'Health', 'Health',
'Entertainment', 'Entertainment',
'Housing',
'Education',
'Travel',
'Utilities',
'Clothing',
'Sports',
'Beauty',
'Pets',
'Other' 'Other'
]; ];
@@ -35,6 +43,8 @@ class AppCategories {
'Gift', 'Gift',
'Investment', 'Investment',
'Refund', 'Refund',
'Business',
'Savings',
'Other' 'Other'
]; ];
@@ -50,11 +60,21 @@ class AppCategories {
'Shopping': Icons.shopping_bag_rounded, 'Shopping': Icons.shopping_bag_rounded,
'Health': Icons.favorite_rounded, 'Health': Icons.favorite_rounded,
'Entertainment': Icons.movie_rounded, 'Entertainment': Icons.movie_rounded,
'Housing': Icons.home_rounded,
'Education': Icons.school_rounded,
'Travel': Icons.flight_rounded,
'Utilities': Icons.bolt_rounded,
'Clothing': Icons.checkroom_rounded,
'Sports': Icons.fitness_center_rounded,
'Beauty': Icons.brush_rounded,
'Pets': Icons.pets_rounded,
'Salary': Icons.work_rounded, 'Salary': Icons.work_rounded,
'Freelance': Icons.laptop_rounded, 'Freelance': Icons.laptop_rounded,
'Gift': Icons.card_giftcard_rounded, 'Gift': Icons.card_giftcard_rounded,
'Investment': Icons.trending_up_rounded, 'Investment': Icons.trending_up_rounded,
'Refund': Icons.money_rounded, 'Refund': Icons.money_rounded,
'Business': Icons.business_center_rounded,
'Savings': Icons.savings_rounded,
'Other': Icons.category_rounded, 'Other': Icons.category_rounded,
}; };
@@ -64,11 +84,21 @@ class AppCategories {
'Shopping': Color(0xFFFFD369), 'Shopping': Color(0xFFFFD369),
'Health': Color(0xFF69FFB4), 'Health': Color(0xFF69FFB4),
'Entertainment': Color(0xFFFF69B4), 'Entertainment': Color(0xFFFF69B4),
'Housing': Color(0xFF69B4FF),
'Education': Color(0xFFFFB469),
'Travel': Color(0xFF69FFB4),
'Utilities': Color(0xFFFFD369),
'Clothing': Color(0xFFFF69B4),
'Sports': Color(0xFF69FFB4),
'Beauty': Color(0xFFFF69B4),
'Pets': Color(0xFFB4FF69),
'Salary': Color(0xFF4CAF8C), 'Salary': Color(0xFF4CAF8C),
'Freelance': Color(0xFF69FFB4), 'Freelance': Color(0xFF69FFB4),
'Gift': Color(0xFFFFB469), 'Gift': Color(0xFFFFB469),
'Investment': Color(0xFF69B4FF), 'Investment': Color(0xFF69B4FF),
'Refund': Color(0xFFB4FF69), 'Refund': Color(0xFFB4FF69),
'Business': Color(0xFFFF8C69),
'Savings': Color(0xFF4CAF8C),
'Other': Color(0xFFB469FF), 'Other': Color(0xFFB469FF),
}; };
@@ -78,11 +108,21 @@ class AppCategories {
'Shopping': 'shopping_bag', 'Shopping': 'shopping_bag',
'Health': 'heart', 'Health': 'heart',
'Entertainment': 'movie', 'Entertainment': 'movie',
'Housing': 'home',
'Education': 'school',
'Travel': 'flight',
'Utilities': 'bolt',
'Clothing': 'checkroom',
'Sports': 'fitness',
'Beauty': 'brush',
'Pets': 'pets',
'Salary': 'work', 'Salary': 'work',
'Freelance': 'laptop', 'Freelance': 'laptop',
'Gift': 'gift', 'Gift': 'gift',
'Investment': 'trending_up', 'Investment': 'trending_up',
'Refund': 'money', 'Refund': 'money',
'Business': 'work',
'Savings': 'savings',
'Other': 'category', 'Other': 'category',
}; };
@@ -108,6 +148,22 @@ class AppCategories {
'Pets': 'Питомцы', 'Pets': 'Питомцы',
'Business': 'Бизнес', 'Business': 'Бизнес',
'Savings': 'Накопления', 'Savings': 'Накопления',
'Dining': 'Ресторан',
'Cafe': 'Кафе',
'Coffee': 'Кофе',
'Restaurant': 'Ресторан',
'Fuel': 'Топливо',
'Taxi': 'Такси',
'Phone': 'Связь',
'Internet': 'Интернет',
'Insurance': 'Страховка',
'Taxes': 'Налоги',
'Medicine': 'Медицина',
'Children': 'Дети',
'Hobby': 'Хобби',
'Music': 'Музыка',
'Games': 'Игры',
'Books': 'Книги',
}; };
} }
+144 -1
View File
@@ -168,7 +168,7 @@ class AppStrings {
} }
String get colorPrimary => _ru ? 'Основной' : 'Primary'; String get colorPrimary => _ru ? 'Основной' : 'Primary';
String get colorSecondary => _ru ? 'Второй' : 'Secondary'; String get colorSecondary => _ru ? 'Второй' : 'Second';
String get colorSecond => _ru ? 'Второй' : 'Second'; String get colorSecond => _ru ? 'Второй' : 'Second';
String get colorSolid => _ru ? 'Однотон' : 'Solid'; String get colorSolid => _ru ? 'Однотон' : 'Solid';
String get gradientLinear => _ru ? 'Линейный' : 'Linear'; String get gradientLinear => _ru ? 'Линейный' : 'Linear';
@@ -239,4 +239,147 @@ class AppStrings {
String get categorySaved => _ru ? 'Категория сохранена' : 'Category saved'; String get categorySaved => _ru ? 'Категория сохранена' : 'Category saved';
String get dateLocale => _ru ? 'ru_RU' : 'en_US'; String get dateLocale => _ru ? 'ru_RU' : 'en_US';
String get premium => _ru ? 'Премиум' : 'Premium';
String get premiumStatus => _ru ? 'Статус премиум' : 'Premium status';
String get premiumDescription => _ru
? 'Разблокируйте цвета карточек, высоту и до 8 счетов'
: 'Unlock card colors, card height and up to 8 accounts';
String get premiumEnabled => _ru ? 'Включён' : 'Enabled';
String get premiumDisabled => _ru ? 'Выключен' : 'Disabled';
String get premiumFeatureLocked =>
_ru ? 'Доступно в премиум' : 'Premium feature';
String get accountLimitReached => _ru
? 'Достигнут лиммт счетов. Обновите до премиум для большего количества.'
: 'Account limit reached. Upgrade to premium for more accounts.';
String accountsLimitLabel(int max) =>
_ru ? 'Максимум $max счетов.' : 'Maximum $max accounts.';
String get premiumFeatureColors =>
_ru ? 'Настройка цветов карточек' : 'Custom card colors';
String get premiumFeatureHeight =>
_ru ? 'Изменение высоты карточки' : 'Resizable card height';
String get premiumFeatureAccounts =>
_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';
} }
+6 -6
View File
@@ -10,14 +10,14 @@ class CardColorService {
static const _keyGradientLight = 'gradient_type_light'; static const _keyGradientLight = 'gradient_type_light';
static const _keyGradientDark = 'gradient_type_dark'; static const _keyGradientDark = 'gradient_type_dark';
static const defaultPrimary = Color(0xFFBEF264); static const defaultPrimary = Color(0xFF4CAF8C);
static const defaultSecondary = Color(0xFF4D7C0F); static const defaultSecondary = Color(0xFF4CAF8C);
static const defaultPrimaryLight = Color(0xFF6A6482); static const defaultPrimaryLight = Color(0xFF4CAF8C);
static const defaultSecondaryLight = Color(0xFF000000); static const defaultSecondaryLight = Color(0xFF4CAF8C);
static const defaultGradientLight = GradientType.sweep; static const defaultGradientLight = GradientType.solid;
static const defaultGradientDark = GradientType.radial; static const defaultGradientDark = GradientType.solid;
static Future<(Color, Color, GradientType, GradientType)> load({ static Future<(Color, Color, GradientType, GradientType)> load({
int? accountId, int? accountId,
+12 -4
View File
@@ -1,19 +1,21 @@
import 'package:drift/drift.dart'; import 'package:drift/drift.dart';
import '../database/app_database.dart'; import '../database/app_database.dart';
import '../../shared/models/account.dart' as model; import '../../shared/models/account.dart' as model;
import '../../shared/feature_flags/feature_flags.dart';
class AccountLimitException implements Exception { class FeatureLimitException implements Exception {
final String message; final String message;
AccountLimitException(this.message); FeatureLimitException(this.message);
@override @override
String toString() => 'AccountLimitException: $message'; String toString() => 'FeatureLimitException: $message';
} }
class AccountRepository { class AccountRepository {
final AppDatabase _db; final AppDatabase _db;
final FeatureFlags Function() _getFeatureFlags;
AccountRepository(this._db); 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)
@@ -163,6 +165,12 @@ class AccountRepository {
} }
Future<int> add(model.Account account) async { Future<int> add(model.Account account) async {
final existing = await getAll();
final nonMainCount = existing.where((a) => !a.isMain).length;
final flags = _getFeatureFlags();
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(
name: account.name, name: account.name,
+4 -4
View File
@@ -391,12 +391,12 @@ 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!,
), ),
); );
if (picked != null) { if (picked != null && mounted) {
setState(() => _selectedDate = picked); setState(() => _selectedDate = picked);
} }
} }
@@ -423,7 +423,7 @@ class _AddTransactionScreenState extends ConsumerState<AddTransactionScreen>
child: child!, child: child!,
), ),
); );
if (picked != null) { if (picked != null && mounted) {
setState(() => _selectedTime = picked); setState(() => _selectedTime = picked);
} }
} }
@@ -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),
), ),
], ],
], ],
@@ -27,6 +27,9 @@ class AccountSelector extends ConsumerWidget {
return accountsAsync.when( return accountsAsync.when(
data: (accounts) { data: (accounts) {
if (accounts.isEmpty) {
return const SizedBox.shrink();
}
final txAccountId = ref final txAccountId = ref
.read(addTransactionProvider(initial)) .read(addTransactionProvider(initial))
.selectedAccountId; .selectedAccountId;
@@ -70,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(
@@ -241,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,
+82 -40
View File
@@ -1,8 +1,23 @@
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';
enum StatsTimeFilter { allTime, month }
final statsTimeFilterProvider =
NotifierProvider<_StatsTimeFilterNotifier, StatsTimeFilter>(
_StatsTimeFilterNotifier.new,
);
class _StatsTimeFilterNotifier extends Notifier<StatsTimeFilter> {
@override
StatsTimeFilter build() => StatsTimeFilter.month;
void set(StatsTimeFilter v) => state = v;
}
class StatsSummary { class StatsSummary {
final double income; final double income;
final double expense; final double expense;
@@ -21,81 +36,88 @@ import '../settings/provider.dart';
}); });
} }
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(timeFilterProvider);
var filtered = txs.where((t) => t.category != 'Transfer'); var filtered = txs.where((t) => t.category != 'Transfer');
if (timeFilter == StatsTimeFilter.month) {
if (timeFilter == TimeFilter.lastMonth) {
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++;
@@ -117,19 +139,31 @@ final statsExpenseTotalProvider = Provider<double>((ref) {
}); });
final categoryExpenseProvider = Provider<Map<String, double>>((ref) { final categoryExpenseProvider = Provider<Map<String, double>>((ref) {
final exchange = ref.watch(exchangeRateServiceProvider);
final index = ref.watch(activeAccountIndexProvider);
final accountsAsync = ref.watch(accountsProvider);
final globalCurrency = ref.watch(currencyProvider).code;
final accounts = accountsAsync.value ?? [];
final target = _resolveTargetCurrency(index, accounts, globalCurrency);
final map = <String, double>{}; final map = <String, double>{};
for (final t in ref.watch(statsScopedTransactionsProvider)) { for (final t in ref.watch(statsScopedTransactionsProvider)) {
if (t.type != TransactionType.expense) continue; if (t.type != TransactionType.expense) continue;
map[t.category] = (map[t.category] ?? 0) + _convertAmount(ref, t); map[t.category] = (map[t.category] ?? 0) + exchange.convert(t.amount, t.currencyCode, target);
} }
return map; return map;
}); });
final categoryIncomeProvider = Provider<Map<String, double>>((ref) { final categoryIncomeProvider = Provider<Map<String, double>>((ref) {
final exchange = ref.watch(exchangeRateServiceProvider);
final index = ref.watch(activeAccountIndexProvider);
final accountsAsync = ref.watch(accountsProvider);
final globalCurrency = ref.watch(currencyProvider).code;
final accounts = accountsAsync.value ?? [];
final target = _resolveTargetCurrency(index, accounts, globalCurrency);
final map = <String, double>{}; final map = <String, double>{};
for (final t in ref.watch(statsScopedTransactionsProvider)) { for (final t in ref.watch(statsScopedTransactionsProvider)) {
if (t.type != TransactionType.income) continue; if (t.type != TransactionType.income) continue;
map[t.category] = (map[t.category] ?? 0) + _convertAmount(ref, t); map[t.category] = (map[t.category] ?? 0) + exchange.convert(t.amount, t.currencyCode, target);
} }
return map; return map;
}); });
@@ -137,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>[];
@@ -163,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>[];
+160 -65
View File
@@ -30,15 +30,13 @@ class _CategoriesScreenState extends ConsumerState<CategoriesScreen> {
final s = ref.watch(stringsProvider); final s = ref.watch(stringsProvider);
final isRu = s.locale == AppLocale.ru; final isRu = s.locale == AppLocale.ru;
final catalog = ref.watch(categoryCatalogProvider); final catalog = ref.watch(categoryCatalogProvider);
final timeFilter = ref.watch(statsTimeFilterProvider);
final summary = ref.watch(statsSummaryProvider); final summary = ref.watch(statsSummaryProvider);
final data = _showIncome final data = _showIncome
? ref.watch(categoryIncomeProvider) ? ref.watch(categoryIncomeProvider)
: ref.watch(categoryExpenseProvider); : ref.watch(categoryExpenseProvider);
final total = data.values.fold(0.0, (a, b) => a + b); final total = data.values.fold(0.0, (a, b) => a + b);
final currencyInfo = ref.watch(statsCurrencyProvider); final currencyInfo = ref.watch(statsCurrencyProvider);
final monthlyData = _showIncome
? ref.watch(monthlyIncomeBreakdownProvider)
: ref.watch(monthlyBreakdownProvider);
final sortedEntries = data.entries.toList() final sortedEntries = data.entries.toList()
..sort((a, b) => b.value.compareTo(a.value)); ..sort((a, b) => b.value.compareTo(a.value));
@@ -47,22 +45,16 @@ class _CategoriesScreenState extends ConsumerState<CategoriesScreen> {
return Scaffold( return Scaffold(
backgroundColor: Theme.of(context).scaffoldBackgroundColor, backgroundColor: Theme.of(context).scaffoldBackgroundColor,
appBar: AppBar(
title: Text(
s.statistics,
style: Theme.of(context).textTheme.titleLarge?.copyWith(
fontWeight: FontWeight.w700,
color: Theme.of(context).colorScheme.onSurface,
),
),
),
body: SafeArea( body: SafeArea(
child: ListView( child: ListView(
padding: const EdgeInsets.fromLTRB(20, 8, 20, 100), padding: const EdgeInsets.fromLTRB(20, 16, 20, 100),
children: [ children: [
const AccountScopeChips(), const AccountScopeChips(),
const SizedBox(height: 16), const SizedBox(height: 16),
_IncomeExpenseToggle( Row(
children: [
Expanded(
child: _IncomeExpenseToggle(
isIncome: _showIncome, isIncome: _showIncome,
onChanged: (val) { onChanged: (val) {
HapticService.selection(); HapticService.selection();
@@ -72,58 +64,37 @@ class _CategoriesScreenState extends ConsumerState<CategoriesScreen> {
}); });
}, },
), ),
const SizedBox(height: 16),
_InsightCard(
title: s.overview,
subtitle: s.analyticsInsight,
child: GridView.count(
crossAxisCount: 2,
shrinkWrap: true,
physics: const NeverScrollableScrollPhysics(),
mainAxisSpacing: 10,
crossAxisSpacing: 10,
childAspectRatio: 1.22,
children: [
_MetricTile(
label: s.income,
value: summary.income,
currencyInfo: currencyInfo,
color: AppColors.income,
icon: Icons.south_west_rounded,
), ),
_MetricTile( const SizedBox(width: 10),
label: s.expenses, Expanded(
value: summary.expense, child: _TimePeriodToggle(
currencyInfo: currencyInfo, filter: timeFilter,
color: AppColors.expense, onChanged: (val) {
icon: Icons.north_east_rounded, HapticService.selection();
ref.read(statsTimeFilterProvider.notifier).set(val);
setState(() => _touchedIndex = -1);
},
), ),
_MetricTile(
label: s.netBalance,
value: summary.balance,
currencyInfo: currencyInfo,
color: summary.balance >= 0 ? AppColors.accent : AppColors.warning,
icon: Icons.account_balance_wallet_rounded,
),
_CountTile(
label: s.transactionsCount,
value: summary.transactionCount,
color: AppColors.accent,
icon: Icons.receipt_long_rounded,
), ),
], ],
), ),
const SizedBox(height: 16),
_OverviewCard(
isIncome: _showIncome,
amount: _showIncome ? summary.income : summary.expense,
transactionCount: summary.transactionCount,
currencyInfo: currencyInfo,
), ),
const SizedBox(height: 16), const SizedBox(height: 16),
_InsightCard( // _InsightCard(
title: s.monthlyTrend, // title: s.monthlyTrend,
subtitle: s.lastSixMonths, // subtitle: s.lastSixMonths,
child: _MonthlyTrendSection( // child: _MonthlyTrendSection(
data: monthlyData, // data: monthlyData,
color: _showIncome ? AppColors.income : AppColors.expense, // color: _showIncome ? AppColors.income : AppColors.expense,
), // ),
), // ),
const SizedBox(height: 16), // const SizedBox(height: 16),
if (data.isEmpty) if (data.isEmpty)
_EmptyState(isIncome: _showIncome) _EmptyState(isIncome: _showIncome)
else ...[ else ...[
@@ -252,6 +223,9 @@ class _PieChartSection extends ConsumerWidget {
final fmt = ref.watch(amountFormatProvider); final fmt = ref.watch(amountFormatProvider);
final entries = data.entries.toList(); final entries = data.entries.toList();
final accent = isIncome ? AppColors.income : AppColors.expense; final accent = isIncome ? AppColors.income : AppColors.expense;
if (entries.isEmpty) {
return const SizedBox.shrink();
}
final selectedIndex = touchedIndex >= 0 ? touchedIndex : 0; final selectedIndex = touchedIndex >= 0 ? touchedIndex : 0;
final selectedEntry = entries[selectedIndex.clamp(0, entries.length - 1)]; final selectedEntry = entries[selectedIndex.clamp(0, entries.length - 1)];
final selectedAmount = selectedEntry.value; final selectedAmount = selectedEntry.value;
@@ -287,7 +261,9 @@ class _PieChartSection extends ConsumerWidget {
color: color, color: color,
value: val, value: val,
title: isTouched title: isTouched
? total > 0
? '${(val / total * 100).toStringAsFixed(0)}%' ? '${(val / total * 100).toStringAsFixed(0)}%'
: '0%'
: '', : '',
radius: isTouched ? 60 : 52, radius: isTouched ? 60 : 52,
titleStyle: const TextStyle( titleStyle: const TextStyle(
@@ -360,7 +336,9 @@ class _PieChartSection extends ConsumerWidget {
), ),
), ),
Text( Text(
'${(selectedAmount / total * 100).toStringAsFixed(1)}%', total > 0
? '${(selectedAmount / total * 100).toStringAsFixed(1)}%'
: '0%',
style: Theme.of(context).textTheme.bodyMedium?.copyWith( style: Theme.of(context).textTheme.bodyMedium?.copyWith(
fontWeight: FontWeight.w700, fontWeight: FontWeight.w700,
color: accent, color: accent,
@@ -478,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;
@@ -593,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),
), ),
), ),
), ),
@@ -867,6 +845,121 @@ class _EmptyState extends ConsumerWidget {
} }
} }
class _TimePeriodToggle extends ConsumerWidget {
final StatsTimeFilter filter;
final ValueChanged<StatsTimeFilter> onChanged;
const _TimePeriodToggle({
required this.filter,
required this.onChanged,
});
@override
Widget build(BuildContext context, WidgetRef ref) {
final s = ref.watch(stringsProvider);
final theme = Theme.of(context);
return Container(
decoration: BoxDecoration(
color: theme.colorScheme.surface,
borderRadius: BorderRadius.circular(12),
border: Border.all(
color: theme.colorScheme.onSurface.withOpacity(0.06),
),
),
padding: const EdgeInsets.all(2),
child: Row(
children: [
Expanded(
child: _ToggleChip(
label: s.filterMonth,
isSelected: filter == StatsTimeFilter.month,
color: const Color(0xFF7C6DED),
onTap: () => onChanged(StatsTimeFilter.month),
),
),
Expanded(
child: _ToggleChip(
label: s.filterAllTime,
isSelected: filter == StatsTimeFilter.allTime,
color: const Color(0xFF7C6DED),
onTap: () => onChanged(StatsTimeFilter.allTime),
),
),
],
),
);
}
}
class _OverviewCard extends ConsumerWidget {
final bool isIncome;
final double amount;
final int transactionCount;
final CurrencyInfo currencyInfo;
const _OverviewCard({
required this.isIncome,
required this.amount,
required this.transactionCount,
required this.currencyInfo,
});
@override
Widget build(BuildContext context, WidgetRef ref) {
final s = ref.watch(stringsProvider);
final fmt = ref.watch(amountFormatProvider);
final theme = Theme.of(context);
final color = isIncome ? AppColors.income : AppColors.expense;
return Container(
width: double.infinity,
padding: const EdgeInsets.symmetric(vertical: 28, horizontal: 20),
decoration: BoxDecoration(
color: theme.colorScheme.surface,
borderRadius: BorderRadius.circular(24),
border: Border.all(
color: theme.colorScheme.onSurface.withOpacity(0.06),
),
),
child: Column(
children: [
Text(
isIncome ? s.income : s.expenses,
style: theme.textTheme.bodySmall?.copyWith(
color: theme.colorScheme.onSurface.withOpacity(0.5),
fontWeight: FontWeight.w600,
fontSize: 13,
letterSpacing: 0.5,
),
),
const SizedBox(height: 12),
FittedBox(
fit: BoxFit.scaleDown,
child: _FormattedAmount(
amount: amount,
currencyInfo: currencyInfo,
color: color,
fontSize: 40,
fontWeight: FontWeight.w800,
format: fmt,
center: true,
),
),
const SizedBox(height: 14),
Text(
'$transactionCount ${s.transactionsCount.toLowerCase()}',
style: theme.textTheme.bodySmall?.copyWith(
color: theme.colorScheme.onSurface.withOpacity(0.4),
fontSize: 13,
),
),
],
),
);
}
}
class _IncomeExpenseToggle extends ConsumerWidget { class _IncomeExpenseToggle extends ConsumerWidget {
final bool isIncome; final bool isIncome;
final ValueChanged<bool> onChanged; final ValueChanged<bool> onChanged;
@@ -889,7 +982,7 @@ class _IncomeExpenseToggle extends ConsumerWidget {
color: theme.colorScheme.onSurface.withOpacity(0.06), color: theme.colorScheme.onSurface.withOpacity(0.06),
), ),
), ),
padding: const EdgeInsets.all(4), padding: const EdgeInsets.all(2),
child: Row( child: Row(
children: [ children: [
Expanded( Expanded(
@@ -933,7 +1026,7 @@ class _ToggleChip 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: 10), padding: const EdgeInsets.symmetric(vertical: 8, horizontal: 4),
decoration: BoxDecoration( decoration: BoxDecoration(
color: isSelected ? color.withOpacity(0.15) : Colors.transparent, color: isSelected ? color.withOpacity(0.15) : Colors.transparent,
borderRadius: BorderRadius.circular(8), borderRadius: BorderRadius.circular(8),
@@ -941,8 +1034,10 @@ class _ToggleChip extends StatelessWidget {
child: Text( child: Text(
label, label,
textAlign: TextAlign.center, textAlign: TextAlign.center,
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: TextStyle( style: TextStyle(
fontSize: 14, fontSize: 13,
fontWeight: isSelected ? FontWeight.w700 : FontWeight.w500, fontWeight: isSelected ? FontWeight.w700 : FontWeight.w500,
color: isSelected color: isSelected
? color ? color
@@ -33,7 +33,15 @@ class AccountScopeChips extends ConsumerWidget {
HapticService.selection(); HapticService.selection();
}, },
), ),
const SizedBox(width: 6), if (accounts.isNotEmpty) ...[
const SizedBox(width: 8),
Container(
width: 1,
height: 16,
color: Theme.of(context).colorScheme.onSurface.withOpacity(0.15),
),
const SizedBox(width: 8),
],
...accounts.asMap().entries.map((entry) { ...accounts.asMap().entries.map((entry) {
final index = entry.key + 1; final index = entry.key + 1;
final account = entry.value; final account = entry.value;
@@ -82,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),
@@ -97,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),
), ),
), ),
+2 -1
View File
@@ -7,6 +7,7 @@ import '../../core/utils/result.dart';
import '../../data/database/app_database.dart' as db; import '../../data/database/app_database.dart' as db;
import '../../data/repositories/transaction_repository.dart'; import '../../data/repositories/transaction_repository.dart';
import '../../data/repositories/account_repository.dart'; import '../../data/repositories/account_repository.dart';
import '../../shared/feature_flags/feature_flags_provider.dart';
import '../../shared/models/transaction.dart'; import '../../shared/models/transaction.dart';
import '../../shared/models/account.dart'; import '../../shared/models/account.dart';
import '../../shared/services/storage_service.dart'; import '../../shared/services/storage_service.dart';
@@ -27,7 +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);
return AccountRepository(db); return AccountRepository(db, () => ref.read(featureFlagsProvider));
}); });
final storageServiceProvider = Provider<StorageService>((ref) { final storageServiceProvider = Provider<StorageService>((ref) {
+39 -4
View File
@@ -5,7 +5,9 @@ import 'package:intl/intl.dart';
import '../../core/l10n/locale_provider.dart'; import '../../core/l10n/locale_provider.dart';
import '../../core/services/card_color_service.dart'; import '../../core/services/card_color_service.dart';
import '../../core/services/haptic_service.dart'; import '../../core/services/haptic_service.dart';
import '../../data/repositories/account_repository.dart';
import '../../shared/models/account.dart'; import '../../shared/models/account.dart';
import '../../shared/feature_flags/feature_flags_provider.dart';
import '../settings/provider.dart'; import '../settings/provider.dart';
import 'provider.dart'; import 'provider.dart';
import 'widgets/account_editor_overlay/account_editor_overlay.dart'; import 'widgets/account_editor_overlay/account_editor_overlay.dart';
@@ -56,6 +58,7 @@ class _DashboardScreenState extends ConsumerState<DashboardScreen> {
bool isAddingAccount = false; bool isAddingAccount = false;
void _onCardLongPress() { void _onCardLongPress() {
if (!ref.read(featureFlagsProvider).canEditCardColors) return;
final colors = ref.read(cardColorsProvider); final colors = ref.read(cardColorsProvider);
savedPrimary = colors.primary; savedPrimary = colors.primary;
savedSecondary = colors.secondary; savedSecondary = colors.secondary;
@@ -179,6 +182,7 @@ class _DashboardScreenState extends ConsumerState<DashboardScreen> {
createdAt: DateTime.now(), createdAt: DateTime.now(),
); );
try {
final newId = await ref.read(accountRepositoryProvider).add(newAccount); final newId = await ref.read(accountRepositoryProvider).add(newAccount);
await CardColorService.save( await CardColorService.save(
@@ -188,6 +192,15 @@ class _DashboardScreenState extends ConsumerState<DashboardScreen> {
tempDarkGradientType, tempDarkGradientType,
accountId: newId, accountId: newId,
); );
} on FeatureLimitException {
if (mounted) {
final s = ref.read(stringsProvider);
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(content: Text(s.accountLimitReached)),
);
}
return;
}
} else if (editingAccount != null) { } else if (editingAccount != null) {
await ref await ref
.read(accountCardColorsProvider(editingAccount!.id).notifier) .read(accountCardColorsProvider(editingAccount!.id).notifier)
@@ -222,6 +235,7 @@ class _DashboardScreenState extends ConsumerState<DashboardScreen> {
}); });
} }
if (!mounted) return;
overlayEntry?.remove(); overlayEntry?.remove();
overlayEntry = null; overlayEntry = null;
setState(() { setState(() {
@@ -278,8 +292,9 @@ class _DashboardScreenState extends ConsumerState<DashboardScreen> {
final activeIndex = ref.watch(activeAccountIndexProvider); final activeIndex = ref.watch(activeAccountIndexProvider);
final accountsAsync = ref.watch(accountsProvider); final accountsAsync = ref.watch(accountsProvider);
final accountCount = accountsAsync.value?.length ?? 0; final accountCount = accountsAsync.value?.length ?? 0;
final maxAccounts = ref.watch(featureFlagsProvider).maxAccounts;
final isOnAddAccountPage = final isOnAddAccountPage =
accountCount < 5 && activeIndex == accountCount + 1; accountCount < maxAccounts && activeIndex == accountCount + 1;
return Scaffold( return Scaffold(
backgroundColor: Theme.of(context).scaffoldBackgroundColor, backgroundColor: Theme.of(context).scaffoldBackgroundColor,
@@ -288,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,
@@ -296,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),
@@ -437,6 +471,7 @@ class _AccountsInfoBlock extends ConsumerWidget {
@override @override
Widget build(BuildContext context, WidgetRef ref) { Widget build(BuildContext context, WidgetRef ref) {
final s = ref.watch(stringsProvider); final s = ref.watch(stringsProvider);
final maxAccounts = ref.watch(featureFlagsProvider).maxAccounts;
final onSurface = Theme.of(context).colorScheme.onSurface; final onSurface = Theme.of(context).colorScheme.onSurface;
return Padding( return Padding(
padding: const EdgeInsets.only(bottom: 60), padding: const EdgeInsets.only(bottom: 60),
@@ -452,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(
@@ -478,7 +513,7 @@ class _AccountsInfoBlock extends ConsumerWidget {
const SizedBox(height: 8), const SizedBox(height: 8),
_InfoRow( _InfoRow(
icon: Icons.lock_outline_rounded, icon: Icons.lock_outline_rounded,
text: s.accountsInfoLimit, text: s.accountsLimitLabel(maxAccounts),
), ),
], ],
), ),
@@ -2,9 +2,13 @@ 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';
import '../../../../shared/feature_flags/feature_flags_provider.dart';
import '../../../../shared/widgets/byn_sign.dart'; import '../../../../shared/widgets/byn_sign.dart';
import '../../../settings/provider.dart'; import '../../../settings/provider.dart';
import '../../provider.dart'; import '../../provider.dart';
@@ -59,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();
}); });
} }
@@ -87,15 +89,16 @@ class _AccountEditorOverlayState extends State<AccountEditorOverlay> {
final mq = MediaQuery.of(widget.context); final mq = MediaQuery.of(widget.context);
final layout = CardOverlayLayout.fromMediaQuery(mq); final layout = CardOverlayLayout.fromMediaQuery(mq);
final cardTop = layout.cardTop; final cardTop = layout.cardTop;
final cardHeight = layout.cardHeight;
final editorPanelHeight = layout.editorPanelHeight; final editorPanelHeight = layout.editorPanelHeight;
final editorPanelTop = cardTop + cardHeight + layout.sectionGap;
final colorPanelTop = editorPanelTop + editorPanelHeight + layout.sectionGap;
final colorPanelHeight = layout.colorPanelHeight(mq, colorPanelTop);
return Consumer( return Consumer(
builder: (context, ref, _) { builder: (context, ref, _) {
final exchangeService = ref.watch(exchangeRateServiceProvider); final exchangeService = ref.watch(exchangeRateServiceProvider);
final cardHeight = ref.watch(cardHeightProvider);
final isPremium = ref.watch(featureFlagsProvider).canEditCardColors;
final editorPanelTop = cardTop + cardHeight + layout.sectionGap;
final colorPanelTop = editorPanelTop + editorPanelHeight + layout.sectionGap;
final colorPanelHeight = isPremium ? layout.colorPanelHeight(mq, colorPanelTop) : 0.0;
double previewBalance = 0.0; double previewBalance = 0.0;
if (!dash.isAddingAccount) { if (!dash.isAddingAccount) {
@@ -220,6 +223,7 @@ class _AccountEditorOverlayState extends State<AccountEditorOverlay> {
Brightness.dark Brightness.dark
? dash.tempDarkGradientType ? dash.tempDarkGradientType
: dash.tempLightGradientType, : dash.tempLightGradientType,
cardHeight: cardHeight,
), ),
), ),
), ),
@@ -248,6 +252,7 @@ class _AccountEditorOverlayState extends State<AccountEditorOverlay> {
), ),
), ),
), ),
if (isPremium) ...[
Positioned( Positioned(
top: colorPanelTop, top: colorPanelTop,
left: 20, left: 20,
@@ -278,6 +283,105 @@ 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(
top: editorPanelTop + 62, top: editorPanelTop + 62,
@@ -305,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;
}); });
@@ -361,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();
}, },
@@ -9,6 +9,7 @@ import '../../../core/utils/card_layout.dart';
import '../../../shared/utils/card_gradient.dart'; import '../../../shared/utils/card_gradient.dart';
import '../../../core/services/haptic_service.dart'; import '../../../core/services/haptic_service.dart';
import '../../../shared/providers/amount_format_provider.dart'; import '../../../shared/providers/amount_format_provider.dart';
import '../../../shared/feature_flags/feature_flags_provider.dart';
import '../../../shared/widgets/byn_sign.dart'; import '../../../shared/widgets/byn_sign.dart';
import '../../settings/provider.dart'; import '../../settings/provider.dart';
import '../provider.dart'; import '../provider.dart';
@@ -28,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;
@@ -37,6 +38,8 @@ class BalanceCard extends ConsumerStatefulWidget {
final GradientType? previewGradientType; final GradientType? previewGradientType;
final String? accountName; final String? accountName;
final CardColors? accountColors; final CardColors? accountColors;
final double? cardHeight;
final Widget? resizeHandle;
const BalanceCard({ const BalanceCard({
super.key, super.key,
@@ -48,13 +51,15 @@ class BalanceCard extends ConsumerStatefulWidget {
this.previewGradientType, this.previewGradientType,
this.accountName, this.accountName,
this.accountColors, this.accountColors,
this.cardHeight,
this.resizeHandle,
}); });
@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;
@@ -87,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);
@@ -106,6 +113,7 @@ class BalanceCardState extends ConsumerState<BalanceCard>
.toList(); .toList();
final textColorMode = ref.watch(cardTextColorProvider); final textColorMode = ref.watch(cardTextColorProvider);
final canEditCardColors = ref.watch(featureFlagsProvider).canEditCardColors;
final Color onCard = switch (textColorMode) { final Color onCard = switch (textColorMode) {
CardTextColorMode.white => Colors.white, CardTextColorMode.white => Colors.white,
CardTextColorMode.black => Colors.black, CardTextColorMode.black => Colors.black,
@@ -130,9 +138,12 @@ class BalanceCardState extends ConsumerState<BalanceCard>
..setEntry(3, 2, 0.001) ..setEntry(3, 2, 0.001)
..rotateX(_tiltX * 0.42) ..rotateX(_tiltX * 0.42)
..rotateY(_tiltY * 0.42), ..rotateY(_tiltY * 0.42),
child: Container( child: Stack(
clipBehavior: Clip.none,
children: [
Container(
width: double.infinity, width: double.infinity,
height: kBalanceCardHeight, height: widget.cardHeight ?? kBalanceCardHeight,
decoration: BoxDecoration( decoration: BoxDecoration(
borderRadius: BorderRadius.circular(20), borderRadius: BorderRadius.circular(20),
gradient: buildCardGradient(primary, secondary, gradientType), gradient: buildCardGradient(primary, secondary, gradientType),
@@ -317,6 +328,7 @@ class BalanceCardState extends ConsumerState<BalanceCard>
], ],
), ),
), ),
if (canEditCardColors)
Positioned( Positioned(
bottom: 8, bottom: 8,
left: 0, left: 0,
@@ -334,10 +346,20 @@ class BalanceCardState extends ConsumerState<BalanceCard>
], ],
), ),
), ),
),
if (widget.resizeHandle != null)
Positioned(
right: 0,
bottom: 0,
child: widget.resizeHandle!,
),
],
), ),
); );
}, },
), ),
); );
},
);
} }
} }
@@ -5,6 +5,7 @@ import '../../../core/utils/card_layout.dart';
import '../../../core/services/haptic_service.dart'; import '../../../core/services/haptic_service.dart';
import '../../../shared/models/account.dart'; import '../../../shared/models/account.dart';
import '../../../shared/models/transaction.dart'; import '../../../shared/models/transaction.dart';
import '../../../shared/feature_flags/feature_flags_provider.dart';
import '../../settings/provider.dart'; import '../../settings/provider.dart';
import '../provider.dart'; import '../provider.dart';
import 'balance_card.dart'; import 'balance_card.dart';
@@ -59,15 +60,17 @@ class _BalanceCardCarouselState extends ConsumerState<BalanceCardCarousel> {
Widget build(BuildContext context) { Widget build(BuildContext context) {
final accountsAsync = ref.watch(accountsProvider); final accountsAsync = ref.watch(accountsProvider);
final activeIndex = ref.watch(activeAccountIndexProvider); final activeIndex = ref.watch(activeAccountIndexProvider);
final cardHeight = ref.watch(cardHeightProvider);
final maxAccounts = ref.watch(featureFlagsProvider).maxAccounts;
return accountsAsync.when( return accountsAsync.when(
data: (accounts) { data: (accounts) {
final totalPages = 1 + accounts.length + (accounts.length < 5 ? 1 : 0); final totalPages = 1 + accounts.length + (accounts.length < maxAccounts ? 1 : 0);
return Column( return Column(
children: [ children: [
SizedBox( SizedBox(
height: kBalanceCardCarouselHeight, height: cardHeight + 10,
child: OverflowBox( child: OverflowBox(
maxWidth: MediaQuery.of(context).size.width, maxWidth: MediaQuery.of(context).size.width,
child: PageView.builder( child: PageView.builder(
@@ -96,6 +99,7 @@ class _BalanceCardCarouselState extends ConsumerState<BalanceCardCarousel> {
previewPrimary: widget.previewPrimary, previewPrimary: widget.previewPrimary,
previewSecondary: widget.previewSecondary, previewSecondary: widget.previewSecondary,
previewGradientType: widget.previewGradientType, previewGradientType: widget.previewGradientType,
cardHeight: cardHeight,
); );
} else if (index <= accounts.length) { } else if (index <= accounts.length) {
final account = accounts[index - 1]; final account = accounts[index - 1];
@@ -134,10 +138,12 @@ class _BalanceCardCarouselState extends ConsumerState<BalanceCardCarousel> {
widget.onAccountLongPress?.call(account), widget.onAccountLongPress?.call(account),
accountName: account.name, accountName: account.name,
accountColors: accountColors, accountColors: accountColors,
cardHeight: cardHeight,
); );
} else { } else {
cardWidget = AddAccountCard( cardWidget = AddAccountCard(
onTap: widget.onAddAccountTap, onTap: widget.onAddAccountTap,
cardHeight: cardHeight,
); );
} }
@@ -154,15 +160,15 @@ class _BalanceCardCarouselState extends ConsumerState<BalanceCardCarousel> {
], ],
); );
}, },
loading: () => const SizedBox( loading: () => SizedBox(
height: kBalanceCardCarouselHeight, height: cardHeight + 10,
child: Center(child: CircularProgressIndicator()), child: const Center(child: CircularProgressIndicator()),
), ),
error: (error, stack) { error: (error, stack) {
return Column( return Column(
children: [ children: [
SizedBox( SizedBox(
height: kBalanceCardCarouselHeight, height: cardHeight + 10,
child: BalanceCard( child: BalanceCard(
balance: widget.balance, balance: widget.balance,
currencyInfo: widget.currencyInfo, currencyInfo: widget.currencyInfo,
@@ -170,6 +176,7 @@ class _BalanceCardCarouselState extends ConsumerState<BalanceCardCarousel> {
previewPrimary: widget.previewPrimary, previewPrimary: widget.previewPrimary,
previewSecondary: widget.previewSecondary, previewSecondary: widget.previewSecondary,
previewGradientType: widget.previewGradientType, previewGradientType: widget.previewGradientType,
cardHeight: cardHeight,
), ),
), ),
const SizedBox(height: 12), const SizedBox(height: 12),
@@ -183,8 +190,9 @@ class _BalanceCardCarouselState extends ConsumerState<BalanceCardCarousel> {
class AddAccountCard extends StatelessWidget { class AddAccountCard extends StatelessWidget {
final VoidCallback? onTap; final VoidCallback? onTap;
final double? cardHeight;
const AddAccountCard({super.key, this.onTap}); const AddAccountCard({super.key, this.onTap, this.cardHeight});
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
@@ -199,7 +207,7 @@ class AddAccountCard extends StatelessWidget {
painter: _DashedBorderPainter(), painter: _DashedBorderPainter(),
child: Container( child: Container(
width: double.infinity, width: double.infinity,
height: kAddAccountCardHeight, height: cardHeight ?? kAddAccountCardHeight,
decoration: BoxDecoration( decoration: BoxDecoration(
color: Theme.of(context).colorScheme.surface.withOpacity(0.4), color: Theme.of(context).colorScheme.surface.withOpacity(0.4),
borderRadius: BorderRadius.circular(20), borderRadius: BorderRadius.circular(20),
@@ -5,7 +5,9 @@ import 'package:flutter_riverpod/flutter_riverpod.dart';
import '../../../core/l10n/app_strings.dart'; import '../../../core/l10n/app_strings.dart';
import '../../../core/l10n/locale_provider.dart'; import '../../../core/l10n/locale_provider.dart';
import '../../../core/services/card_color_service.dart'; import '../../../core/services/card_color_service.dart';
import '../../../core/services/haptic_service.dart';
import '../../../core/utils/card_layout.dart'; import '../../../core/utils/card_layout.dart';
import '../../../shared/feature_flags/feature_flags_provider.dart';
import '../../settings/provider.dart'; import '../../settings/provider.dart';
import '../provider.dart'; import '../provider.dart';
import 'balance_card.dart'; import 'balance_card.dart';
@@ -37,8 +39,14 @@ class _FullScreenBlurOverlayState extends State<FullScreenBlurOverlay> {
final mq = MediaQuery.of(widget.context); final mq = MediaQuery.of(widget.context);
final layout = CardOverlayLayout.fromMediaQuery(mq); final layout = CardOverlayLayout.fromMediaQuery(mq);
final cardTop = layout.cardTop; final cardTop = layout.cardTop;
final cardHeight = layout.cardHeight;
final panelTop = cardTop + cardHeight + layout.cardPreviewGap; return Consumer(
builder: (context, ref, _) {
final cardHeight = ref.watch(cardHeightProvider);
final isPremium = ref.watch(featureFlagsProvider).canEditCardHeight;
final heightDelta = (kBalanceCardHeight - cardHeight) / 2;
final adjustedCardTop = cardTop + heightDelta;
final panelTop = adjustedCardTop + cardHeight + layout.cardPreviewGap;
final panelHeight = layout.colorPanelHeight(mq, panelTop); final panelHeight = layout.colorPanelHeight(mq, panelTop);
return Material( return Material(
@@ -60,7 +68,7 @@ class _FullScreenBlurOverlayState extends State<FullScreenBlurOverlay> {
), ),
), ),
Positioned( Positioned(
top: cardTop, top: adjustedCardTop,
left: 0, left: 0,
right: 0, right: 0,
child: FractionallySizedBox( child: FractionallySizedBox(
@@ -69,7 +77,10 @@ class _FullScreenBlurOverlayState extends State<FullScreenBlurOverlay> {
height: cardHeight, height: cardHeight,
child: Padding( child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 8), padding: const EdgeInsets.symmetric(horizontal: 8),
child: Consumer( child: Stack(
clipBehavior: Clip.none,
children: [
Consumer(
builder: (ctx, ref, _) => BalanceCard( builder: (ctx, ref, _) => BalanceCard(
balance: ref.read(totalBalanceProvider), balance: ref.read(totalBalanceProvider),
currencyInfo: ref.read(currencyProvider), currencyInfo: ref.read(currencyProvider),
@@ -80,8 +91,20 @@ class _FullScreenBlurOverlayState extends State<FullScreenBlurOverlay> {
Theme.of(widget.context).brightness == Brightness.dark Theme.of(widget.context).brightness == Brightness.dark
? dash.tempDarkGradientType ? dash.tempDarkGradientType
: dash.tempLightGradientType, : dash.tempLightGradientType,
cardHeight: cardHeight,
resizeHandle: isPremium ? _CornerResizeHandle(
cardHeight: cardHeight,
onHeightChanged: (newHeight) {
ref.read(cardHeightProvider.notifier).set(newHeight);
if (ref.read(hapticEnabledProvider)) {
HapticService.selection();
}
},
) : null,
), ),
), ),
],
),
), ),
), ),
), ),
@@ -132,6 +155,8 @@ class _FullScreenBlurOverlayState extends State<FullScreenBlurOverlay> {
], ],
), ),
); );
},
);
} }
Widget _buildPanel(double panelHeight, CardOverlayLayout layout) { Widget _buildPanel(double panelHeight, CardOverlayLayout layout) {
@@ -161,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();
@@ -170,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();
} }
@@ -208,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();
}, },
@@ -234,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();
}, },
@@ -266,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 =
@@ -276,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();
}, },
@@ -393,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();
}, },
@@ -446,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();
}, },
@@ -507,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) {
@@ -539,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();
}, },
@@ -610,8 +616,6 @@ class _FullScreenBlurOverlayState extends State<FullScreenBlurOverlay> {
}) })
.toList(), .toList(),
), ),
),
),
SizedBox(height: layout.controlSpacing), SizedBox(height: layout.controlSpacing),
Row( Row(
children: [ children: [
@@ -627,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);
@@ -636,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();
}, },
@@ -784,3 +786,103 @@ class PanelTab extends StatelessWidget {
); );
} }
} }
class _CornerResizeHandle extends StatefulWidget {
final double cardHeight;
final ValueChanged<double> onHeightChanged;
const _CornerResizeHandle({
required this.cardHeight,
required this.onHeightChanged,
});
@override
State<_CornerResizeHandle> createState() => _CornerResizeHandleState();
}
class _CornerResizeHandleState extends State<_CornerResizeHandle> {
bool _dragging = false;
double _lastHeight = 0;
@override
Widget build(BuildContext context) {
final theme = Theme.of(context);
return GestureDetector(
onVerticalDragStart: (_) {
setState(() => _dragging = true);
_lastHeight = widget.cardHeight;
},
onVerticalDragUpdate: (details) {
final newHeight = widget.cardHeight + details.delta.dy * 2;
if ((newHeight - _lastHeight).abs() > 0.5) {
widget.onHeightChanged(newHeight);
_lastHeight = newHeight;
}
},
onVerticalDragEnd: (_) => setState(() => _dragging = false),
behavior: HitTestBehavior.opaque,
child: SizedBox(
width: 48,
height: 48,
child: CustomPaint(
size: const Size(48, 48),
painter: _CornerDashedPainter(
color: theme.colorScheme.onSurface.withOpacity(_dragging ? 0.8 : 0.5),
radius: 20,
),
),
),
);
}
}
class _CornerDashedPainter extends CustomPainter {
final Color color;
final double radius;
const _CornerDashedPainter({
required this.color,
required this.radius,
});
@override
void paint(Canvas canvas, Size size) {
final paint = Paint()
..color = color
..strokeWidth = 2.5
..style = PaintingStyle.stroke
..strokeCap = StrokeCap.round;
const dashLength = 6.0;
const dashSpace = 5.0;
const extraLine = 8.0;
final cornerCenter = Offset(size.width - radius, size.height - radius);
final path = Path()
..moveTo(cornerCenter.dx - extraLine, size.height)
..lineTo(cornerCenter.dx, size.height)
..arcToPoint(
Offset(size.width, cornerCenter.dy),
radius: Radius.circular(radius),
clockwise: false,
)
..lineTo(size.width, cornerCenter.dy - extraLine);
final metrics = path.computeMetrics();
for (final metric in metrics) {
double distance = 0;
while (distance < metric.length) {
final end = (distance + dashLength).clamp(0.0, metric.length);
final extracted = metric.extractPath(distance, end);
canvas.drawPath(extracted, paint);
distance += dashLength + dashSpace;
}
}
}
@override
bool shouldRepaint(covariant _CornerDashedPainter oldDelegate) =>
color != oldDelegate.color;
}
@@ -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,
+18
View File
@@ -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,
);
+164
View File
@@ -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,
),
);
}),
);
}
}
@@ -1,3 +1,5 @@
import 'dart:async';
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';
@@ -44,6 +46,11 @@ class _CategoryEditorSheetState extends ConsumerState<CategoryEditorSheet> {
bool _translatingEn = false; bool _translatingEn = false;
bool _translatingRu = false; bool _translatingRu = false;
bool _saving = false; bool _saving = false;
DateTime? _lastTranslateTime;
bool _enOverflow = false;
bool _ruOverflow = false;
Timer? _enOverflowTimer;
Timer? _ruOverflowTimer;
@override @override
void initState() { void initState() {
@@ -62,6 +69,8 @@ class _CategoryEditorSheetState extends ConsumerState<CategoryEditorSheet> {
@override @override
void dispose() { void dispose() {
_enOverflowTimer?.cancel();
_ruOverflowTimer?.cancel();
_enController.dispose(); _enController.dispose();
_ruController.dispose(); _ruController.dispose();
super.dispose(); super.dispose();
@@ -71,21 +80,50 @@ class _CategoryEditorSheetState extends ConsumerState<CategoryEditorSheet> {
if (_enController.text.trim().isNotEmpty && _enSuggestion != null) { if (_enController.text.trim().isNotEmpty && _enSuggestion != null) {
setState(() => _enSuggestion = null); setState(() => _enSuggestion = null);
} }
if (_enController.text.length >= 20) {
_enOverflowTimer?.cancel();
setState(() => _enOverflow = true);
_enOverflowTimer = Timer(const Duration(seconds: 1), () {
if (mounted) setState(() => _enOverflow = false);
});
}
} }
void _onRuChanged() { void _onRuChanged() {
if (_ruController.text.trim().isNotEmpty && _ruSuggestion != null) { if (_ruController.text.trim().isNotEmpty && _ruSuggestion != null) {
setState(() => _ruSuggestion = null); setState(() => _ruSuggestion = null);
} }
if (_ruController.text.length >= 20) {
_ruOverflowTimer?.cancel();
setState(() => _ruOverflow = true);
_ruOverflowTimer = Timer(const Duration(seconds: 1), () {
if (mounted) setState(() => _ruOverflow = false);
});
}
}
bool _isThrottled() {
final now = DateTime.now();
if (_lastTranslateTime != null &&
now.difference(_lastTranslateTime!) < const Duration(seconds: 2)) {
return true;
}
_lastTranslateTime = now;
return false;
} }
Future<void> _translateToRu() async { Future<void> _translateToRu() async {
final source = _enController.text.trim(); final source = _enController.text.trim();
if (source.isEmpty) return; if (source.isEmpty) return;
setState(() => _translatingRu = true); setState(() => _translatingRu = true);
final result = await ref final service = ref.read(translationServiceProvider);
.read(translationServiceProvider) TranslationResult? result;
.translate(source, TranslateDirection.enToRu); if (_isThrottled()) {
final dict = service.dictionaryLookup(source, TranslateDirection.enToRu);
result = dict != null ? TranslationResult(dict, fromCache: true) : null;
} else {
result = await service.translate(source, TranslateDirection.enToRu);
}
if (!mounted) return; if (!mounted) return;
setState(() { setState(() {
_translatingRu = false; _translatingRu = false;
@@ -100,9 +138,14 @@ class _CategoryEditorSheetState extends ConsumerState<CategoryEditorSheet> {
final source = _ruController.text.trim(); final source = _ruController.text.trim();
if (source.isEmpty) return; if (source.isEmpty) return;
setState(() => _translatingEn = true); setState(() => _translatingEn = true);
final result = await ref final service = ref.read(translationServiceProvider);
.read(translationServiceProvider) TranslationResult? result;
.translate(source, TranslateDirection.ruToEn); if (_isThrottled()) {
final dict = service.dictionaryLookup(source, TranslateDirection.ruToEn);
result = dict != null ? TranslationResult(dict, fromCache: true) : null;
} else {
result = await service.translate(source, TranslateDirection.ruToEn);
}
if (!mounted) return; if (!mounted) return;
setState(() { setState(() {
_translatingEn = false; _translatingEn = false;
@@ -122,21 +165,45 @@ class _CategoryEditorSheetState extends ConsumerState<CategoryEditorSheet> {
} }
setState(() => _saving = true); setState(() => _saving = true);
HapticService.medium(); HapticService.medium();
String labelEn = _enController.text.trim();
String labelRu = _ruController.text.trim();
if (labelEn.isEmpty && labelRu.isNotEmpty) {
final result = await ref
.read(translationServiceProvider)
.translate(labelRu, TranslateDirection.ruToEn);
if (result != null && result.text.isNotEmpty) {
labelEn = result.text;
} else {
labelEn = labelRu;
}
} else if (labelRu.isEmpty && labelEn.isNotEmpty) {
final result = await ref
.read(translationServiceProvider)
.translate(labelEn, TranslateDirection.enToRu);
if (result != null && result.text.isNotEmpty) {
labelRu = result.text;
} else {
labelRu = labelEn;
}
}
final actions = ref.read(categoryActionsProvider); final actions = ref.read(categoryActionsProvider);
final existing = widget.existing; final existing = widget.existing;
final result = existing != null && existing.id != null final result = existing != null && existing.id != null
? await actions.edit( ? await actions.edit(
id: existing.id!, id: existing.id!,
type: _type, type: _type,
labelEn: _enController.text, labelEn: labelEn,
labelRu: _ruController.text, labelRu: labelRu,
iconName: _iconName, iconName: _iconName,
colorValue: _colorValue, colorValue: _colorValue,
) )
: await actions.create( : await actions.create(
type: _type, type: _type,
labelEn: _enController.text, labelEn: labelEn,
labelRu: _ruController.text, labelRu: labelRu,
iconName: _iconName, iconName: _iconName,
colorValue: _colorValue, colorValue: _colorValue,
); );
@@ -180,14 +247,14 @@ class _CategoryEditorSheetState extends ConsumerState<CategoryEditorSheet> {
), ),
), ),
), ),
const SizedBox(height: 16), const SizedBox(height: 28),
Text( Text(
widget.existing != null ? s.editCategory : s.newCategory, widget.existing != null ? s.editCategory : s.newCategory,
style: theme.textTheme.titleLarge?.copyWith( style: theme.textTheme.titleLarge?.copyWith(
fontWeight: FontWeight.w700, fontWeight: FontWeight.w700,
), ),
), ),
const SizedBox(height: 20), const SizedBox(height: 24),
_TypeToggle( _TypeToggle(
type: _type, type: _type,
onChanged: (t) => setState(() => _type = t), onChanged: (t) => setState(() => _type = t),
@@ -201,6 +268,7 @@ class _CategoryEditorSheetState extends ConsumerState<CategoryEditorSheet> {
hint: s.nameEnHint, hint: s.nameEnHint,
suggestion: _enSuggestion, suggestion: _enSuggestion,
isTranslating: _translatingEn, isTranslating: _translatingEn,
isOverflow: _enOverflow,
canTranslate: _ruController.text.trim().isNotEmpty, canTranslate: _ruController.text.trim().isNotEmpty,
translatingLabel: s.translating, translatingLabel: s.translating,
applyLabel: s.applyTranslation, applyLabel: s.applyTranslation,
@@ -217,6 +285,7 @@ class _CategoryEditorSheetState extends ConsumerState<CategoryEditorSheet> {
hint: s.nameRuHint, hint: s.nameRuHint,
suggestion: _ruSuggestion, suggestion: _ruSuggestion,
isTranslating: _translatingRu, isTranslating: _translatingRu,
isOverflow: _ruOverflow,
canTranslate: _enController.text.trim().isNotEmpty, canTranslate: _enController.text.trim().isNotEmpty,
translatingLabel: s.translating, translatingLabel: s.translating,
applyLabel: s.applyTranslation, applyLabel: s.applyTranslation,
@@ -265,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),
@@ -384,6 +453,7 @@ class _TranslatableField extends StatelessWidget {
final bool canTranslate; final bool canTranslate;
final String translatingLabel; final String translatingLabel;
final String applyLabel; final String applyLabel;
final bool isOverflow;
final VoidCallback onTranslate; final VoidCallback onTranslate;
final VoidCallback onApply; final VoidCallback onApply;
@@ -393,6 +463,7 @@ class _TranslatableField extends StatelessWidget {
required this.hint, required this.hint,
required this.suggestion, required this.suggestion,
required this.isTranslating, required this.isTranslating,
required this.isOverflow,
required this.canTranslate, required this.canTranslate,
required this.translatingLabel, required this.translatingLabel,
required this.applyLabel, required this.applyLabel,
@@ -424,7 +495,9 @@ class _TranslatableField extends StatelessWidget {
decoration: BoxDecoration( decoration: BoxDecoration(
color: theme.colorScheme.surface, color: theme.colorScheme.surface,
borderRadius: BorderRadius.circular(14), borderRadius: BorderRadius.circular(14),
border: isDark border: isOverflow
? Border.all(color: AppColors.expense, width: 1.5)
: isDark
? null ? null
: Border.all(color: const Color(0xFFDDDDEE), width: 1), : Border.all(color: const Color(0xFFDDDDEE), width: 1),
), ),
@@ -457,10 +530,14 @@ class _TranslatableField extends StatelessWidget {
TextField( TextField(
controller: controller, controller: controller,
style: theme.textTheme.bodyLarge, style: theme.textTheme.bodyLarge,
maxLength: 20,
decoration: InputDecoration( decoration: InputDecoration(
hintText: showGhost ? '' : hint, hintText: showGhost ? '' : hint,
isDense: true, isDense: true,
filled: false, filled: false,
counterText: '',
enabledBorder: InputBorder.none,
focusedBorder: InputBorder.none,
border: InputBorder.none, border: InputBorder.none,
contentPadding: const EdgeInsets.symmetric( contentPadding: const EdgeInsets.symmetric(
horizontal: 14, horizontal: 14,
@@ -499,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,
@@ -515,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: '',
); );
} }
@@ -537,7 +614,9 @@ class _IconGrid extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final theme = Theme.of(context); final theme = Theme.of(context);
return Wrap( return Center(
child: Wrap(
alignment: WrapAlignment.center,
spacing: 10, spacing: 10,
runSpacing: 10, runSpacing: 10,
children: kCategoryIcons.entries.map((entry) { children: kCategoryIcons.entries.map((entry) {
@@ -567,6 +646,7 @@ class _IconGrid extends StatelessWidget {
), ),
); );
}).toList(), }).toList(),
),
); );
} }
} }
@@ -579,7 +659,9 @@ class _ColorRow extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Wrap( return Center(
child: Wrap(
alignment: WrapAlignment.center,
spacing: 12, spacing: 12,
runSpacing: 12, runSpacing: 12,
children: kCategoryColors.map((color) { children: kCategoryColors.map((color) {
@@ -612,6 +694,7 @@ class _ColorRow extends StatelessWidget {
), ),
); );
}).toList(), }).toList(),
),
); );
} }
} }
@@ -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(
+25
View File
@@ -103,6 +103,31 @@ final exchangeRateServiceProvider = Provider<ExchangeRateService>((ref) {
return ExchangeRateService(prefs); return ExchangeRateService(prefs);
}); });
final cardHeightProvider = NotifierProvider<CardHeightNotifier, double>(
CardHeightNotifier.new,
);
class CardHeightNotifier extends Notifier<double> {
static const _key = 'card_height';
static const minHeight = 140.0;
static const maxHeight = 200.0;
static const _defaultHeight = 200.0;
@override
double build() {
final prefs = ref.watch(sharedPreferencesProvider);
final saved = prefs.getDouble(_key);
if (saved == null) return _defaultHeight;
return saved.clamp(minHeight, maxHeight);
}
void set(double height) {
final clamped = height.clamp(minHeight, maxHeight);
state = clamped;
ref.read(sharedPreferencesProvider).setDouble(_key, clamped);
}
}
final ratesInitProvider = FutureProvider<void>((ref) async { final ratesInitProvider = FutureProvider<void>((ref) async {
await ref.read(exchangeRateServiceProvider).fetchRates(); await ref.read(exchangeRateServiceProvider).fetchRates();
}); });
+22 -31
View File
@@ -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,6 +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 '../../shared/widgets/pro_subscription_card.dart';
class SettingsScreen extends ConsumerWidget { class SettingsScreen extends ConsumerWidget {
const SettingsScreen({super.key}); const SettingsScreen({super.key});
@@ -111,39 +111,29 @@ class SettingsScreen extends ConsumerWidget {
return Scaffold( return Scaffold(
backgroundColor: Theme.of(context).scaffoldBackgroundColor, backgroundColor: Theme.of(context).scaffoldBackgroundColor,
appBar: AppBar( body: SafeArea(
backgroundColor: Theme.of(context).scaffoldBackgroundColor, child: ListView(
elevation: 0,
scrolledUnderElevation: 0,
centerTitle: true,
title: Text(
'Casha',
style: Theme.of(context).textTheme.headlineMedium?.copyWith(
fontWeight: FontWeight.w800,
color: Theme.of(context).colorScheme.onSurface,
letterSpacing: -0.5,
),
),
),
body: ListView(
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 ThemeSection(), const ProSubscriptionCard(),
const SizedBox(height: 16), const SizedBox(height: 12),
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(
@@ -180,6 +170,7 @@ class SettingsScreen extends ConsumerWidget {
const _FooterWidget(), const _FooterWidget(),
], ],
), ),
),
); );
} }
} }
@@ -292,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,
), ),
@@ -0,0 +1,73 @@
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import '../../../core/constants.dart';
import '../../../core/l10n/locale_provider.dart';
import '../../../shared/providers/current_user_provider.dart';
class PremiumSection extends ConsumerWidget {
const PremiumSection({super.key});
@override
Widget build(BuildContext context, WidgetRef ref) {
final s = ref.watch(stringsProvider);
final user = ref.watch(currentUserProvider);
final isDark = Theme.of(context).brightness == Brightness.dark;
return Container(
padding: const EdgeInsets.all(20),
decoration: BoxDecoration(
color: Theme.of(context).colorScheme.surface,
borderRadius: BorderRadius.circular(16),
border: isDark
? null
: Border.all(color: const Color(0xFFDDDDEE), width: 1),
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
children: [
Container(
padding: const EdgeInsets.all(10),
decoration: BoxDecoration(
color: (user.isVip ? const Color(0xFF7C6DED) : AppColors.warning)
.withOpacity(0.15),
borderRadius: BorderRadius.circular(12),
),
child: Icon(
user.isVip ? Icons.workspace_premium_rounded : Icons.lock_outline_rounded,
color: user.isVip ? const Color(0xFF7C6DED) : AppColors.warning,
size: 20,
),
),
const SizedBox(width: 12),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
s.premiumStatus,
style: Theme.of(context).textTheme.titleMedium?.copyWith(
fontWeight: FontWeight.w600,
color: Theme.of(context).colorScheme.onSurface,
),
),
Text(
s.premiumDescription,
style: Theme.of(context).textTheme.bodySmall?.copyWith(
color: Theme.of(context)
.colorScheme
.onSurface
.withOpacity(0.6),
),
),
],
),
),
],
),
],
),
);
}
}
@@ -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,
+13
View File
@@ -1,4 +1,5 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:intl/date_symbol_data_local.dart'; import 'package:intl/date_symbol_data_local.dart';
import 'package:shared_preferences/shared_preferences.dart'; import 'package:shared_preferences/shared_preferences.dart';
@@ -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(),
), ),
@@ -0,0 +1,6 @@
abstract class FeatureFlags {
bool get canEditCardColors;
bool get canEditCardHeight;
bool get canEditCardTextColor;
int get maxAccounts;
}
@@ -0,0 +1,12 @@
import 'package:flutter_riverpod/flutter_riverpod.dart';
import '../providers/current_user_provider.dart';
import 'feature_flags.dart';
import 'free_feature_flags.dart';
import 'vip_feature_flags.dart';
final featureFlagsProvider = Provider<FeatureFlags>((ref) {
final user = ref.watch(currentUserProvider);
return user.isVip
? const VipFeatureFlags()
: const FreeFeatureFlags();
});
@@ -0,0 +1,17 @@
import 'feature_flags.dart';
class FreeFeatureFlags implements FeatureFlags {
const FreeFeatureFlags();
@override
bool get canEditCardColors => false;
@override
bool get canEditCardHeight => false;
@override
bool get canEditCardTextColor => false;
@override
int get maxAccounts => 3;
}
@@ -0,0 +1,17 @@
import 'feature_flags.dart';
class VipFeatureFlags implements FeatureFlags {
const VipFeatureFlags();
@override
bool get canEditCardColors => true;
@override
bool get canEditCardHeight => true;
@override
bool get canEditCardTextColor => true;
@override
int get maxAccounts => 8;
}
+9
View File
@@ -0,0 +1,9 @@
enum UserPlan { free, vip }
class UserModel {
final UserPlan plan;
const UserModel({this.plan = UserPlan.free});
bool get isVip => plan == UserPlan.vip;
}
+55
View File
@@ -0,0 +1,55 @@
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import '../../core/l10n/app_strings.dart';
import '../../core/l10n/locale_provider.dart';
class PaywallBanner extends ConsumerWidget {
final String? message;
final VoidCallback? onTap;
const PaywallBanner({
super.key,
this.message,
this.onTap,
});
@override
Widget build(BuildContext context, WidgetRef ref) {
final s = AppStrings(ref.watch(localeProvider));
return GestureDetector(
onTap: onTap,
child: Container(
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12),
decoration: BoxDecoration(
color: Theme.of(context).colorScheme.surface,
borderRadius: BorderRadius.circular(12),
border: Border.all(
color: Theme.of(context).colorScheme.onSurface.withOpacity(0.15),
width: 1,
),
),
child: Row(
children: [
Icon(
Icons.lock_outline_rounded,
size: 20,
color: Theme.of(context).colorScheme.onSurface.withOpacity(0.5),
),
const SizedBox(width: 12),
Expanded(
child: Text(
message ?? s.premiumFeatureLocked,
style: Theme.of(context).textTheme.bodySmall?.copyWith(
color: Theme.of(context)
.colorScheme
.onSurface
.withOpacity(0.6),
),
),
),
],
),
),
);
}
}
+22
View File
@@ -0,0 +1,22 @@
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'paywall_banner.dart';
class PaywallGuard extends ConsumerWidget {
final bool canAccess;
final Widget child;
final Widget? fallback;
const PaywallGuard({
super.key,
required this.canAccess,
required this.child,
this.fallback,
});
@override
Widget build(BuildContext context, WidgetRef ref) {
if (canAccess) return child;
return fallback ?? PaywallBanner();
}
}
+92
View File
@@ -0,0 +1,92 @@
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';
class PaywallScreen extends ConsumerWidget {
const PaywallScreen({super.key});
@override
Widget build(BuildContext context, WidgetRef ref) {
final s = AppStrings(ref.watch(localeProvider));
return Scaffold(
backgroundColor: Theme.of(context).scaffoldBackgroundColor,
appBar: AppBar(
backgroundColor: Theme.of(context).scaffoldBackgroundColor,
elevation: 0,
scrolledUnderElevation: 0,
leading: IconButton(
icon: const Icon(Icons.arrow_back_rounded),
onPressed: () => context.pop(),
),
),
body: SafeArea(
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 24),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Container(
padding: const EdgeInsets.all(24),
decoration: BoxDecoration(
color: const Color(0xFF7C6DED).withOpacity(0.12),
shape: BoxShape.circle,
),
child: const Icon(
Icons.workspace_premium_rounded,
size: 64,
color: const Color(0xFF7C6DED),
),
),
const SizedBox(height: 24),
Text(
s.premium,
style: Theme.of(context).textTheme.headlineMedium?.copyWith(
fontWeight: FontWeight.w700,
),
),
const SizedBox(height: 12),
Text(
s.premiumDescription,
textAlign: TextAlign.center,
style: Theme.of(context).textTheme.bodyMedium?.copyWith(
color: Theme.of(context)
.colorScheme
.onSurface
.withOpacity(0.6),
),
),
const SizedBox(height: 32),
_FeatureItem(icon: Icons.palette_rounded, label: s.premiumFeatureColors),
_FeatureItem(icon: Icons.height_rounded, label: s.premiumFeatureHeight),
_FeatureItem(icon: Icons.account_balance_wallet_rounded, label: s.premiumFeatureAccounts),
],
),
),
),
);
}
}
class _FeatureItem extends StatelessWidget {
final IconData icon;
final String label;
const _FeatureItem({required this.icon, required this.label});
@override
Widget build(BuildContext context) {
return Padding(
padding: const EdgeInsets.symmetric(vertical: 8),
child: Row(
children: [
Icon(icon, size: 20, color: const Color(0xFF7C6DED)),
const SizedBox(width: 12),
Text(label, style: Theme.of(context).textTheme.bodyMedium),
],
),
);
}
}
@@ -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();
});
+11 -4
View File
@@ -107,10 +107,17 @@ 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) {
byKey(key)?.label(isRu) ?? key; final cat = byKey(key);
if (cat != null) return cat.label(isRu);
if (isRu) {
final ru = AppCategories.ruLabels[key];
if (ru != null) return ru;
}
return key;
}
bool hasKey(String key) => byKey(key) != null; bool hasKey(String key) => byKey(key) != null;
} }
@@ -140,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,
); );
@@ -0,0 +1,30 @@
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';
class CurrentUserNotifier extends Notifier<UserModel> {
@override
UserModel build() {
final prefs = ref.watch(sharedPreferencesProvider);
final billing = ref.watch(billingServiceProvider);
final manager = PremiumManager(prefs, billing);
return UserModel(plan: manager.currentPlan);
}
Future<void> setPlan(UserPlan plan) async {
state = UserModel(plan: plan);
}
Future<void> refreshFromPremium() async {
final prefs = ref.read(sharedPreferencesProvider);
final billing = ref.read(billingServiceProvider);
final manager = PremiumManager(prefs, billing);
state = UserModel(plan: manager.currentPlan);
}
}
final currentUserProvider = NotifierProvider<CurrentUserNotifier, UserModel>(
CurrentUserNotifier.new,
);
@@ -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;
});
+72
View File
@@ -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);
}
}
}
+197
View File
@@ -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 {}
}
@@ -97,6 +97,7 @@ class ExchangeRateService {
final fromRate = currentRates[from] ?? 1.0; final fromRate = currentRates[from] ?? 1.0;
final toRate = currentRates[to] ?? 1.0; final toRate = currentRates[to] ?? 1.0;
if (fromRate == 0) return amount;
final amountInUsd = amount / fromRate; final amountInUsd = amount / fromRate;
return amountInUsd * toRate; return amountInUsd * toRate;
@@ -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);
}
}
}
+58
View File
@@ -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);
}
}
+2 -2
View File
@@ -59,7 +59,7 @@ class TranslationService {
for (final entry in _ruToEn.entries) entry.value.toLowerCase(): entry.key, for (final entry in _ruToEn.entries) entry.value.toLowerCase(): entry.key,
}; };
String? _dictionaryLookup(String input, TranslateDirection direction) { String? dictionaryLookup(String input, TranslateDirection direction) {
final normalized = input.trim().toLowerCase(); final normalized = input.trim().toLowerCase();
if (normalized.isEmpty) return null; if (normalized.isEmpty) return null;
final map = direction == TranslateDirection.ruToEn ? _ruToEn : _enToRu; final map = direction == TranslateDirection.ruToEn ? _ruToEn : _enToRu;
@@ -75,7 +75,7 @@ class TranslationService {
final trimmed = input.trim(); final trimmed = input.trim();
if (trimmed.isEmpty) return null; if (trimmed.isEmpty) return null;
final cached = _dictionaryLookup(trimmed, direction); final cached = dictionaryLookup(trimmed, direction);
if (cached != null) { if (cached != null) {
return TranslationResult(cached, fromCache: true); return TranslationResult(cached, fromCache: true);
} }
+360
View File
@@ -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')}';
}
}
+528
View File
@@ -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
View File
@@ -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:
+5
View File
@@ -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