mirror of
https://github.com/koloideal/Casha.git
synced 2026-08-08 17:51:14 +03:00
Compare commits
27 Commits
2682c92f23
..
master
| Author | SHA1 | Date | |
|---|---|---|---|
| c4ac692019 | |||
| 861a9abd02 | |||
| e3c60c4775 | |||
| 64a3f4e34e | |||
| 19db4fe688 | |||
| 00bdd63ea6 | |||
| 7b9bf6d060 | |||
| 4f56e4983c | |||
| 58bfc6b12c | |||
| 4b548adb9a | |||
| 4b5c6be212 | |||
| 186cec8e2a | |||
| cd6113f3c6 | |||
| 4727835402 | |||
| 65ea30339d | |||
| 3adac05cdf | |||
| 5891440a0c | |||
| f2d444cb16 | |||
| 2b89545248 | |||
| 6fdf4eedf1 | |||
| 1a6ad1fe27 | |||
| bc51609f85 | |||
| ed45748c95 | |||
| 83fd8bdbf1 | |||
| 3961327bdb | |||
| 127a917eac | |||
| 8fb785944c |
@@ -0,0 +1,188 @@
|
||||
# AGENTS.md
|
||||
|
||||
## Project Overview
|
||||
|
||||
Personal finance Flutter app for Android. Tracks accounts, transactions, categories, budgets with multi-currency support, biometric auth, and haptic feedback.
|
||||
|
||||
## Stack
|
||||
|
||||
- **Flutter** — UI framework
|
||||
- **Riverpod** — state management (per-feature `provider.dart` files)
|
||||
- **Drift** — local database (code generation via `.g.dart`)
|
||||
- **Feature-first architecture**
|
||||
|
||||
## Project Structure
|
||||
|
||||
```
|
||||
lib/
|
||||
├── app/ # App root, router, theme
|
||||
├── core/ # Constants, l10n, core services, utils
|
||||
├── data/ # Database schema, repositories
|
||||
├── features/ # Feature modules (provider + screen + 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
|
||||
```
|
||||
|
||||
### Layer Responsibilities
|
||||
|
||||
**`core/`** — app-wide infrastructure. No business logic.
|
||||
- `constants.dart` — global constants
|
||||
- `l10n/` — localization strings and locale provider
|
||||
- `services/` — biometric, haptic, card color services
|
||||
- `utils/result.dart` — `Result<T>` type for error handling
|
||||
|
||||
**`data/`** — persistence only. No UI, no Riverpod providers.
|
||||
- `database/` — Drift tables and generated code. Do not edit `.g.dart` files manually.
|
||||
- `repositories/` — `AccountRepository`, `TransactionRepository`. All DB access goes through repositories.
|
||||
|
||||
**`features/<name>/`** — self-contained feature modules.
|
||||
- `provider.dart` — Riverpod providers scoped to this feature
|
||||
- `screen.dart` — top-level screen widget, minimal logic
|
||||
- `widgets/` — feature-specific widgets
|
||||
|
||||
**`shared/`** — reusable across features.
|
||||
- `models/` — `Account`, `Transaction` data classes
|
||||
- `providers/` — providers used by multiple features
|
||||
- `services/` — `ExchangeRateService`, `StorageService`
|
||||
- `utils/` — `CurrencyUtils`
|
||||
- `widgets/` — `BynSign`, `ErrorSnackbar`
|
||||
- `feature_flags/` — `FeatureFlags` abstraction and plan-specific implementations
|
||||
- `paywall/` — `PaywallGuard`, `PaywallBanner`, `PaywallScreen`
|
||||
|
||||
## Architecture Rules
|
||||
|
||||
- Widgets never access repositories directly — always through providers
|
||||
- Providers in `features/<name>/provider.dart` are local to that feature
|
||||
- Providers in `shared/providers/` are app-wide
|
||||
- Business logic lives in providers or repositories, not in widgets or screens
|
||||
- `Result<T>` from `core/utils/result.dart` is used for fallible operations in repositories
|
||||
- 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`
|
||||
|
||||
### 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
|
||||
|
||||
**No comments anywhere in the codebase.** No `//`, no `/* */`, no `///` doc comments. Code must be self-explanatory through naming.
|
||||
|
||||
- Use descriptive names — no abbreviations unless universally known (`id`, `url`, `db`)
|
||||
- Prefer named constructors and named parameters
|
||||
- Extract widgets aggressively — if a build method exceeds ~40 lines, split it
|
||||
- Widget files: one primary widget per file, name matches filename
|
||||
- Use `final` everywhere possible
|
||||
- No `dynamic` types
|
||||
- Avoid `late` unless genuinely necessary
|
||||
|
||||
## Naming Conventions
|
||||
|
||||
| Element | Convention | Example |
|
||||
|---|---|---|
|
||||
| Files | `snake_case.dart` | `balance_card.dart` |
|
||||
| Classes | `PascalCase` | `BalanceCard` |
|
||||
| Providers | `camelCase` + `Provider` suffix | `transactionListProvider` |
|
||||
| Riverpod notifiers | `PascalCase` + `Notifier` suffix | `AddTransactionNotifier` |
|
||||
| Private members | `_camelCase` | `_handleSubmit` |
|
||||
|
||||
## Feature Structure Template
|
||||
|
||||
When adding a new feature, follow this pattern:
|
||||
|
||||
```
|
||||
features/
|
||||
└── <feature_name>/
|
||||
├── provider.dart # Riverpod providers for this feature
|
||||
├── screen.dart # Top-level screen widget
|
||||
└── widgets/ # Sub-widgets (create only if needed)
|
||||
```
|
||||
|
||||
## Key Patterns
|
||||
|
||||
**Error handling** — use `Result<T>`:
|
||||
```dart
|
||||
final result = await repository.getAccounts();
|
||||
result.when(
|
||||
success: (accounts) => ...,
|
||||
failure: (error) => ...,
|
||||
);
|
||||
```
|
||||
|
||||
**Localization** — use `AppStrings` from `core/l10n/app_strings.dart`, never hardcode strings visible to the user.
|
||||
|
||||
**Currency formatting** — use `CurrencyUtils` and `amountFormatProvider`, never format amounts manually.
|
||||
|
||||
**Haptics** — route all haptic feedback through `HapticService`, never call `HapticFeedback` directly.
|
||||
|
||||
**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
|
||||
|
||||
- **dashboard** — main screen with account carousel (`BalanceCard`), transaction list, search, filter chips, budget progress, account editor overlay
|
||||
- **add_transaction** — form screen: amount input, type toggle (income/expense), category picker, currency picker, account selector, date/time pickers, note field
|
||||
- **categories** — category list management
|
||||
- **settings** — theme, language, currency, budget, amount format, card text color, haptics, currency conversions
|
||||
|
||||
## What NOT to Do
|
||||
|
||||
- Do not add comments
|
||||
- Do not put business logic in screen or widget files
|
||||
- Do not access `AppDatabase` directly from features — use repositories
|
||||
- Do not create new providers in `shared/providers/` unless the provider is needed by 2+ features
|
||||
- Do not use `BuildContext` across async gaps without checking `mounted`
|
||||
- Do not hardcode user-facing strings — use `AppStrings`
|
||||
- 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`
|
||||
@@ -3,7 +3,6 @@ import java.io.FileInputStream
|
||||
|
||||
plugins {
|
||||
id("com.android.application")
|
||||
id("kotlin-android")
|
||||
id("dev.flutter.flutter-gradle-plugin")
|
||||
}
|
||||
|
||||
@@ -24,7 +23,7 @@ android {
|
||||
}
|
||||
|
||||
kotlinOptions {
|
||||
jvmTarget = JavaVersion.VERSION_17.toString()
|
||||
jvmTarget = "17"
|
||||
}
|
||||
|
||||
defaultConfig {
|
||||
@@ -35,18 +34,22 @@ android {
|
||||
versionName = flutter.versionName
|
||||
}
|
||||
|
||||
signingConfigs {
|
||||
create("release") {
|
||||
keyAlias = keyProperties["keyAlias"] as String
|
||||
keyPassword = keyProperties["keyPassword"] as String
|
||||
storeFile = file(keyProperties["storeFile"] as String)
|
||||
storePassword = keyProperties["storePassword"] as String
|
||||
if (keyPropertiesFile.exists()) {
|
||||
signingConfigs {
|
||||
create("release") {
|
||||
keyAlias = keyProperties["keyAlias"] as String
|
||||
keyPassword = keyProperties["keyPassword"] as String
|
||||
storeFile = file(keyProperties["storeFile"] as String)
|
||||
storePassword = keyProperties["storePassword"] as String
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
buildTypes {
|
||||
release {
|
||||
signingConfig = signingConfigs.getByName("release")
|
||||
if (keyPropertiesFile.exists()) {
|
||||
signingConfig = signingConfigs.getByName("release")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,2 +1,6 @@
|
||||
org.gradle.jvmargs=-Xmx8G -XX:MaxMetaspaceSize=4G -XX:ReservedCodeCacheSize=512m -XX:+HeapDumpOnOutOfMemoryError
|
||||
android.useAndroidX=true
|
||||
# This builtInKotlin flag was added automatically by Flutter migrator
|
||||
android.builtInKotlin=false
|
||||
# This newDsl flag was added automatically by Flutter migrator
|
||||
android.newDsl=false
|
||||
|
||||
@@ -6,13 +6,31 @@ import '../features/dashboard/screen.dart';
|
||||
import '../features/add_transaction/screen.dart';
|
||||
import '../features/categories/screen.dart';
|
||||
import '../features/settings/screen.dart';
|
||||
import '../features/settings/categories/category_manager_screen.dart';
|
||||
import '../features/onboarding/screen.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 appRouter = GoRouter(
|
||||
initialLocation: '/dashboard',
|
||||
redirect: (context, state) {
|
||||
final location = state.uri.toString();
|
||||
if (OnboardingService.shouldShowOnboarding && location != '/onboarding') {
|
||||
return '/onboarding';
|
||||
}
|
||||
return null;
|
||||
},
|
||||
routes: [
|
||||
GoRoute(
|
||||
path: '/onboarding',
|
||||
builder: (context, state) => const OnboardingScreen(),
|
||||
),
|
||||
ShellRoute(
|
||||
navigatorKey: _shellKey,
|
||||
builder: (context, state, child) => AppShell(child: child),
|
||||
@@ -44,6 +62,27 @@ final appRouter = GoRouter(
|
||||
return AddTransactionScreen(initial: transaction);
|
||||
},
|
||||
),
|
||||
GoRoute(
|
||||
path: '/settings/categories',
|
||||
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(),
|
||||
),
|
||||
],
|
||||
);
|
||||
|
||||
|
||||
+23
-21
@@ -44,8 +44,8 @@ class AppTheme {
|
||||
scaffoldBackgroundColor: AppColors.background,
|
||||
colorScheme: const ColorScheme.dark(
|
||||
surface: AppColors.surface,
|
||||
primary: AppColors.accent,
|
||||
secondary: AppColors.accent,
|
||||
primary: const Color(0xFF7C6DED),
|
||||
secondary: const Color(0xFF7C6DED),
|
||||
onPrimary: Colors.white,
|
||||
onSurface: AppColors.textPrimary,
|
||||
),
|
||||
@@ -70,11 +70,11 @@ class AppTheme {
|
||||
),
|
||||
navigationBarTheme: NavigationBarThemeData(
|
||||
backgroundColor: AppColors.surface,
|
||||
indicatorColor: AppColors.accent.withOpacity(0.2),
|
||||
indicatorColor: const Color(0xFF7C6DED).withOpacity(0.2),
|
||||
labelTextStyle: WidgetStateProperty.resolveWith((states) {
|
||||
if (states.contains(WidgetState.selected)) {
|
||||
return GoogleFonts.poppins(
|
||||
color: AppColors.accent,
|
||||
color: const Color(0xFF7C6DED),
|
||||
fontSize: 12,
|
||||
fontWeight: FontWeight.w600,
|
||||
);
|
||||
@@ -86,7 +86,7 @@ class AppTheme {
|
||||
}),
|
||||
iconTheme: WidgetStateProperty.resolveWith((states) {
|
||||
if (states.contains(WidgetState.selected)) {
|
||||
return const IconThemeData(color: AppColors.accent);
|
||||
return const IconThemeData(color: const Color(0xFF7C6DED));
|
||||
}
|
||||
return const IconThemeData(color: AppColors.textSecondary);
|
||||
}),
|
||||
@@ -104,14 +104,14 @@ class AppTheme {
|
||||
),
|
||||
focusedBorder: OutlineInputBorder(
|
||||
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),
|
||||
hintStyle: const TextStyle(color: AppColors.textSecondary),
|
||||
),
|
||||
elevatedButtonTheme: ElevatedButtonThemeData(
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: AppColors.accent,
|
||||
backgroundColor: const Color(0xFF7C6DED),
|
||||
foregroundColor: Colors.white,
|
||||
minimumSize: const Size(double.infinity, 52),
|
||||
shape: RoundedRectangleBorder(
|
||||
@@ -132,10 +132,12 @@ class AppTheme {
|
||||
|
||||
static ThemeData get lightTheme {
|
||||
final base = ThemeData.light(useMaterial3: true);
|
||||
final textTheme = GoogleFonts.poppinsTextTheme(base.textTheme).apply(
|
||||
bodyColor: const Color(0xFF1A1A2E),
|
||||
displayColor: const Color(0xFF1A1A2E),
|
||||
fontFamilyFallback: ['Roboto'],
|
||||
final textTheme = _withCyrillicFallback(
|
||||
base.textTheme.apply(
|
||||
fontFamily: 'Poppins',
|
||||
bodyColor: const Color(0xFF1A1A2E),
|
||||
displayColor: const Color(0xFF1A1A2E),
|
||||
),
|
||||
);
|
||||
|
||||
return base.copyWith(
|
||||
@@ -143,8 +145,8 @@ class AppTheme {
|
||||
scaffoldBackgroundColor: const Color(0xFFF0F0F7),
|
||||
colorScheme: const ColorScheme.light(
|
||||
surface: Colors.white,
|
||||
primary: AppColors.accent,
|
||||
secondary: AppColors.accent,
|
||||
primary: const Color(0xFF7C6DED),
|
||||
secondary: const Color(0xFF7C6DED),
|
||||
onPrimary: Colors.white,
|
||||
onSurface: Color(0xFF1A1A2E),
|
||||
),
|
||||
@@ -166,15 +168,15 @@ class AppTheme {
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
iconTheme: const IconThemeData(color: AppColors.accent),
|
||||
iconTheme: const IconThemeData(color: const Color(0xFF7C6DED)),
|
||||
),
|
||||
navigationBarTheme: NavigationBarThemeData(
|
||||
backgroundColor: Colors.white,
|
||||
indicatorColor: AppColors.accent.withOpacity(0.2),
|
||||
indicatorColor: const Color(0xFF7C6DED).withOpacity(0.2),
|
||||
labelTextStyle: WidgetStateProperty.resolveWith((states) {
|
||||
if (states.contains(WidgetState.selected)) {
|
||||
return GoogleFonts.poppins(
|
||||
color: AppColors.accent,
|
||||
color: const Color(0xFF7C6DED),
|
||||
fontSize: 12,
|
||||
fontWeight: FontWeight.w600,
|
||||
);
|
||||
@@ -186,7 +188,7 @@ class AppTheme {
|
||||
}),
|
||||
iconTheme: WidgetStateProperty.resolveWith((states) {
|
||||
if (states.contains(WidgetState.selected)) {
|
||||
return const IconThemeData(color: AppColors.accent);
|
||||
return const IconThemeData(color: const Color(0xFF7C6DED));
|
||||
}
|
||||
return const IconThemeData(color: Color(0xFF9999BB));
|
||||
}),
|
||||
@@ -204,14 +206,14 @@ class AppTheme {
|
||||
),
|
||||
focusedBorder: OutlineInputBorder(
|
||||
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)),
|
||||
hintStyle: const TextStyle(color: Color(0xFF9999BB)),
|
||||
),
|
||||
elevatedButtonTheme: ElevatedButtonThemeData(
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: AppColors.accent,
|
||||
backgroundColor: const Color(0xFF7C6DED),
|
||||
foregroundColor: Colors.white,
|
||||
minimumSize: const Size(double.infinity, 52),
|
||||
shape: RoundedRectangleBorder(
|
||||
@@ -227,10 +229,10 @@ class AppTheme {
|
||||
color: Color(0xFFDDDDEE),
|
||||
thickness: 1,
|
||||
),
|
||||
iconTheme: const IconThemeData(color: AppColors.accent),
|
||||
iconTheme: const IconThemeData(color: const Color(0xFF7C6DED)),
|
||||
chipTheme: ChipThemeData(
|
||||
backgroundColor: const Color(0xFFEEEEF8),
|
||||
selectedColor: AppColors.accent,
|
||||
selectedColor: const Color(0xFF7C6DED),
|
||||
labelStyle: GoogleFonts.poppins(
|
||||
color: const Color(0xFF1A1A2E),
|
||||
),
|
||||
|
||||
@@ -26,6 +26,14 @@ class AppCategories {
|
||||
'Shopping',
|
||||
'Health',
|
||||
'Entertainment',
|
||||
'Housing',
|
||||
'Education',
|
||||
'Travel',
|
||||
'Utilities',
|
||||
'Clothing',
|
||||
'Sports',
|
||||
'Beauty',
|
||||
'Pets',
|
||||
'Other'
|
||||
];
|
||||
|
||||
@@ -35,6 +43,8 @@ class AppCategories {
|
||||
'Gift',
|
||||
'Investment',
|
||||
'Refund',
|
||||
'Business',
|
||||
'Savings',
|
||||
'Other'
|
||||
];
|
||||
|
||||
@@ -50,11 +60,21 @@ class AppCategories {
|
||||
'Shopping': Icons.shopping_bag_rounded,
|
||||
'Health': Icons.favorite_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,
|
||||
'Freelance': Icons.laptop_rounded,
|
||||
'Gift': Icons.card_giftcard_rounded,
|
||||
'Investment': Icons.trending_up_rounded,
|
||||
'Refund': Icons.money_rounded,
|
||||
'Business': Icons.business_center_rounded,
|
||||
'Savings': Icons.savings_rounded,
|
||||
'Other': Icons.category_rounded,
|
||||
};
|
||||
|
||||
@@ -64,15 +84,141 @@ class AppCategories {
|
||||
'Shopping': Color(0xFFFFD369),
|
||||
'Health': Color(0xFF69FFB4),
|
||||
'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),
|
||||
'Freelance': Color(0xFF69FFB4),
|
||||
'Gift': Color(0xFFFFB469),
|
||||
'Investment': Color(0xFF69B4FF),
|
||||
'Refund': Color(0xFFB4FF69),
|
||||
'Business': Color(0xFFFF8C69),
|
||||
'Savings': Color(0xFF4CAF8C),
|
||||
'Other': Color(0xFFB469FF),
|
||||
};
|
||||
|
||||
static const iconNames = {
|
||||
'Food': 'restaurant',
|
||||
'Transport': 'car',
|
||||
'Shopping': 'shopping_bag',
|
||||
'Health': 'heart',
|
||||
'Entertainment': 'movie',
|
||||
'Housing': 'home',
|
||||
'Education': 'school',
|
||||
'Travel': 'flight',
|
||||
'Utilities': 'bolt',
|
||||
'Clothing': 'checkroom',
|
||||
'Sports': 'fitness',
|
||||
'Beauty': 'brush',
|
||||
'Pets': 'pets',
|
||||
'Salary': 'work',
|
||||
'Freelance': 'laptop',
|
||||
'Gift': 'gift',
|
||||
'Investment': 'trending_up',
|
||||
'Refund': 'money',
|
||||
'Business': 'work',
|
||||
'Savings': 'savings',
|
||||
'Other': 'category',
|
||||
};
|
||||
|
||||
static const ruLabels = {
|
||||
'Food': 'Еда',
|
||||
'Transport': 'Транспорт',
|
||||
'Shopping': 'Покупки',
|
||||
'Entertainment': 'Развлечения',
|
||||
'Health': 'Здоровье',
|
||||
'Housing': 'Жильё',
|
||||
'Education': 'Образование',
|
||||
'Travel': 'Путешествия',
|
||||
'Salary': 'Зарплата',
|
||||
'Freelance': 'Фриланс',
|
||||
'Investment': 'Инвестиции',
|
||||
'Gift': 'Подарок',
|
||||
'Refund': 'Возврат',
|
||||
'Other': 'Другое',
|
||||
'Utilities': 'Коммунальные',
|
||||
'Clothing': 'Одежда',
|
||||
'Sports': 'Спорт',
|
||||
'Beauty': 'Красота',
|
||||
'Pets': 'Питомцы',
|
||||
'Business': 'Бизнес',
|
||||
'Savings': 'Накопления',
|
||||
'Dining': 'Ресторан',
|
||||
'Cafe': 'Кафе',
|
||||
'Coffee': 'Кофе',
|
||||
'Restaurant': 'Ресторан',
|
||||
'Fuel': 'Топливо',
|
||||
'Taxi': 'Такси',
|
||||
'Phone': 'Связь',
|
||||
'Internet': 'Интернет',
|
||||
'Insurance': 'Страховка',
|
||||
'Taxes': 'Налоги',
|
||||
'Medicine': 'Медицина',
|
||||
'Children': 'Дети',
|
||||
'Hobby': 'Хобби',
|
||||
'Music': 'Музыка',
|
||||
'Games': 'Игры',
|
||||
'Books': 'Книги',
|
||||
};
|
||||
}
|
||||
|
||||
const Map<String, IconData> kCategoryIcons = {
|
||||
'restaurant': Icons.restaurant_rounded,
|
||||
'car': Icons.directions_car_rounded,
|
||||
'shopping_bag': Icons.shopping_bag_rounded,
|
||||
'heart': Icons.favorite_rounded,
|
||||
'movie': Icons.movie_rounded,
|
||||
'work': Icons.work_rounded,
|
||||
'laptop': Icons.laptop_rounded,
|
||||
'gift': Icons.card_giftcard_rounded,
|
||||
'trending_up': Icons.trending_up_rounded,
|
||||
'money': Icons.payments_rounded,
|
||||
'category': Icons.category_rounded,
|
||||
'home': Icons.home_rounded,
|
||||
'school': Icons.school_rounded,
|
||||
'flight': Icons.flight_rounded,
|
||||
'fitness': Icons.fitness_center_rounded,
|
||||
'pets': Icons.pets_rounded,
|
||||
'coffee': Icons.local_cafe_rounded,
|
||||
'grocery': Icons.local_grocery_store_rounded,
|
||||
'phone': Icons.smartphone_rounded,
|
||||
'bolt': Icons.bolt_rounded,
|
||||
'water': Icons.water_drop_rounded,
|
||||
'savings': Icons.savings_rounded,
|
||||
'card': Icons.credit_card_rounded,
|
||||
'games': Icons.sports_esports_rounded,
|
||||
'music': Icons.music_note_rounded,
|
||||
'book': Icons.menu_book_rounded,
|
||||
'medical': Icons.medical_services_rounded,
|
||||
'child': Icons.child_care_rounded,
|
||||
'build': Icons.build_rounded,
|
||||
'beauty': Icons.spa_rounded,
|
||||
};
|
||||
|
||||
IconData categoryIconByName(String? name) {
|
||||
return kCategoryIcons[name] ?? Icons.category_rounded;
|
||||
}
|
||||
|
||||
const List<Color> kCategoryColors = [
|
||||
Color(0xFFFF8C69),
|
||||
Color(0xFF69B4FF),
|
||||
Color(0xFFFFD369),
|
||||
Color(0xFF69FFB4),
|
||||
Color(0xFFFF69B4),
|
||||
Color(0xFF4CAF8C),
|
||||
Color(0xFFFFB469),
|
||||
Color(0xFFB4FF69),
|
||||
Color(0xFFB469FF),
|
||||
Color(0xFF7C6DED),
|
||||
Color(0xFFE05C6B),
|
||||
Color(0xFF4DD0E1),
|
||||
];
|
||||
|
||||
enum AmountFormat { commasDot, spacesDot, plain }
|
||||
|
||||
extension AmountFormatExt on AmountFormat {
|
||||
|
||||
+195
-17
@@ -24,9 +24,6 @@ class AppStrings {
|
||||
String get filterMonth => _ru ? 'Месяц' : 'Month';
|
||||
String get income => _ru ? 'Доход' : 'Income';
|
||||
String get expenses => _ru ? 'Расходы' : 'Expenses';
|
||||
String get monthlyBudget => _ru ? 'Бюджет на месяц' : 'Monthly Budget';
|
||||
String get spent => _ru ? 'Потрачено' : 'Spent';
|
||||
String get limit => _ru ? 'Лимит' : 'Limit';
|
||||
String get noTransactions =>
|
||||
_ru ? 'Транзакции не найдены' : 'No transactions found';
|
||||
String get addFirstTx => _ru
|
||||
@@ -80,18 +77,6 @@ class AppStrings {
|
||||
String get language => _ru ? 'Язык' : 'Language';
|
||||
String get langRu => _ru ? 'Русский' : 'Russian';
|
||||
String get langEn => _ru ? 'Английский' : 'English';
|
||||
String get budget => _ru ? 'Бюджет' : 'Budget';
|
||||
String get budgetHint => _ru ? 'Месячный лимит' : 'Monthly limit';
|
||||
String get budgetNone => _ru ? 'Не установлен' : 'Not set';
|
||||
String get monthlyBudgetSetting => _ru ? 'Месячный бюджет' : 'Monthly Budget';
|
||||
String get yourMonthlySpendingLimit =>
|
||||
_ru ? 'Ваш лимит расходов на месяц' : 'Your monthly spending limit';
|
||||
String get setMonthlySpendingLimit => _ru
|
||||
? 'Контролируйте свои расходы за месяц'
|
||||
: 'Track your monthly spending';
|
||||
String get leaveEmptyToRemove => _ru
|
||||
? 'Оставьте пустым для удаления лимита'
|
||||
: 'Leave empty to remove budget limit';
|
||||
String get data => _ru ? 'Данные' : 'Data';
|
||||
String get exportData => _ru ? 'Экспорт данных' : 'Export data';
|
||||
String get clearData => _ru ? 'Очистить данные' : 'Clear all data';
|
||||
@@ -115,11 +100,27 @@ class AppStrings {
|
||||
String get dangerZone => _ru ? 'Опасная зона' : 'Danger Zone';
|
||||
|
||||
String get navDashboard => _ru ? 'Главная' : 'Dashboard';
|
||||
String get navCategories => _ru ? 'Категории' : 'Categories';
|
||||
String get navCategories => _ru ? 'Статистика' : 'Statistics';
|
||||
String get navSettings => _ru ? 'Настройки' : 'Settings';
|
||||
|
||||
String get statistics => _ru ? 'Статистика' : 'Statistics';
|
||||
String get allAccounts => _ru ? 'Все счета' : 'All accounts';
|
||||
String get categories => _ru ? 'Категории' : 'Categories';
|
||||
String get rankedByAmount => _ru ? 'По сумме' : 'Ranked by Amount';
|
||||
String get overview => _ru ? 'Обзор' : 'Overview';
|
||||
String get netBalance => _ru ? 'Чистый баланс' : 'Net Balance';
|
||||
String get averageIncome => _ru ? 'Средний доход' : 'Average Income';
|
||||
String get averageExpense => _ru ? 'Средний расход' : 'Average Expense';
|
||||
String get transactionsCount => _ru ? 'Транзакции' : 'Transactions';
|
||||
String get expenseStructure => _ru ? 'Структура категорий' : 'Category Structure';
|
||||
String get topCategories => _ru ? 'Топ категорий' : 'Top Categories';
|
||||
String get monthlyTrend => _ru ? 'Тренд по месяцам' : 'Monthly Trend';
|
||||
String get topCategory => _ru ? 'Лидер категории' : 'Top Category';
|
||||
String get shareOfTotal => _ru ? 'Доля от общего' : 'Share of Total';
|
||||
String get thisPeriod => _ru ? 'За период' : 'This Period';
|
||||
String get analyticsInsight => _ru ? 'Финансовый срез по выбранному диапазону и счёту' : 'Financial snapshot for the selected range and account';
|
||||
String get noStatisticsYet => _ru ? 'Пока недостаточно данных' : 'Not enough data yet';
|
||||
String get statisticsWillAppear => _ru ? 'Когда появятся операции, здесь будет красивый аналитический обзор' : 'Once you add transactions, a beautiful analytics overview will appear here';
|
||||
String get addCategory => _ru ? 'Добавить категорию' : 'Add Category';
|
||||
String get editCategory => _ru ? 'Редактировать' : 'Edit Category';
|
||||
String get categoryName => _ru ? 'Название' : 'Name';
|
||||
@@ -153,6 +154,7 @@ class AppStrings {
|
||||
'Freelance': 'Фриланс',
|
||||
'Investment': 'Инвестиции',
|
||||
'Gift': 'Подарок',
|
||||
'Refund': 'Возврат',
|
||||
'Other': 'Другое',
|
||||
'Utilities': 'Коммунальные',
|
||||
'Clothing': 'Одежда',
|
||||
@@ -166,7 +168,8 @@ class AppStrings {
|
||||
}
|
||||
|
||||
String get colorPrimary => _ru ? 'Основной' : 'Primary';
|
||||
String get colorSecondary => _ru ? 'Второй' : 'Secondary';
|
||||
String get colorSecondary => _ru ? 'Второй' : 'Second';
|
||||
String get colorSecond => _ru ? 'Второй' : 'Second';
|
||||
String get colorSolid => _ru ? 'Однотон' : 'Solid';
|
||||
String get gradientLinear => _ru ? 'Линейный' : 'Linear';
|
||||
String get gradientReverse => _ru ? 'Обратный' : 'Reverse';
|
||||
@@ -203,5 +206,180 @@ class AppStrings {
|
||||
String get accountPlaceholder => _ru ? 'Счёт' : 'Account';
|
||||
String get saveError => _ru ? 'Ошибка сохранения' : 'Save error';
|
||||
|
||||
String get manageCategories => _ru ? 'Категории' : 'Categories';
|
||||
String get manageCategoriesSubtitle => _ru
|
||||
? 'Создавайте и редактируйте свои категории'
|
||||
: 'Create and edit your own categories';
|
||||
String get customCategories => _ru ? 'Свои категории' : 'Custom categories';
|
||||
String get defaultCategories =>
|
||||
_ru ? 'Стандартные категории' : 'Default categories';
|
||||
String get newCategory => _ru ? 'Новая категория' : 'New category';
|
||||
String get nameEn => _ru ? 'Название (EN)' : 'Name (EN)';
|
||||
String get nameRu => _ru ? 'Название (RU)' : 'Name (RU)';
|
||||
String get nameEnHint => _ru ? 'Например, Coffee' : 'e.g. Coffee';
|
||||
String get nameRuHint => _ru ? 'Например, Кофе' : 'e.g. Кофе';
|
||||
String get autoTranslate => _ru ? 'Автоперевод' : 'Auto-translate';
|
||||
String get applyTranslation => _ru ? 'Применить' : 'Apply';
|
||||
String get translating => _ru ? 'Перевод...' : 'Translating...';
|
||||
String get translationFailed =>
|
||||
_ru ? 'Не удалось перевести' : 'Translation failed';
|
||||
String get categoryNameRequired =>
|
||||
_ru ? 'Введите название' : 'Enter a name';
|
||||
String get deleteCategoryConfirm =>
|
||||
_ru ? 'Удалить эту категорию?' : 'Delete this category?';
|
||||
String get deleteCategoryWarning => _ru
|
||||
? 'Категория будет удалена. Прошлые транзакции сохранятся.'
|
||||
: 'The category will be removed. Past transactions are kept.';
|
||||
String get noCustomCategories =>
|
||||
_ru ? 'Вы ещё не добавили категории' : 'No custom categories yet';
|
||||
String get noCustomCategoriesHint => _ru
|
||||
? 'Нажмите +, чтобы создать свою категорию'
|
||||
: 'Tap + to create your own category';
|
||||
String get categoryType => _ru ? 'Тип' : 'Type';
|
||||
String get categorySaved => _ru ? 'Категория сохранена' : 'Category saved';
|
||||
|
||||
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';
|
||||
}
|
||||
|
||||
@@ -25,10 +25,6 @@ class BiometricService {
|
||||
try {
|
||||
return await _auth.authenticate(
|
||||
localizedReason: 'Confirm your identity to open Casha',
|
||||
options: const AuthenticationOptions(
|
||||
biometricOnly: false,
|
||||
stickyAuth: true,
|
||||
),
|
||||
);
|
||||
} catch (_) {
|
||||
return false;
|
||||
|
||||
@@ -10,14 +10,14 @@ class CardColorService {
|
||||
static const _keyGradientLight = 'gradient_type_light';
|
||||
static const _keyGradientDark = 'gradient_type_dark';
|
||||
|
||||
static const defaultPrimary = Color(0xFFBEF264);
|
||||
static const defaultSecondary = Color(0xFF4D7C0F);
|
||||
static const defaultPrimary = Color(0xFF4CAF8C);
|
||||
static const defaultSecondary = Color(0xFF4CAF8C);
|
||||
|
||||
static const defaultPrimaryLight = Color(0xFF6A6482);
|
||||
static const defaultSecondaryLight = Color(0xFF000000);
|
||||
static const defaultPrimaryLight = Color(0xFF4CAF8C);
|
||||
static const defaultSecondaryLight = Color(0xFF4CAF8C);
|
||||
|
||||
static const defaultGradientLight = GradientType.sweep;
|
||||
static const defaultGradientDark = GradientType.radial;
|
||||
static const defaultGradientLight = GradientType.solid;
|
||||
static const defaultGradientDark = GradientType.solid;
|
||||
|
||||
static Future<(Color, Color, GradientType, GradientType)> load({
|
||||
int? accountId,
|
||||
|
||||
@@ -0,0 +1,64 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
const kBalanceCardHeight = 200.0;
|
||||
const kBalanceCardCarouselHeight = 210.0;
|
||||
const kAddAccountCardHeight = 200.0;
|
||||
|
||||
class CardOverlayLayout {
|
||||
final bool compact;
|
||||
final double cardHeight;
|
||||
final double cardTop;
|
||||
final double cardPreviewGap;
|
||||
final double editorPanelHeight;
|
||||
final double sectionGap;
|
||||
final double panelPaddingTop;
|
||||
final double panelPaddingBottom;
|
||||
final double reservedBelowControls;
|
||||
final double hueSliderHeight;
|
||||
final double hexRowHeight;
|
||||
final double tabSpacing;
|
||||
final double controlSpacing;
|
||||
final double buttonVerticalPadding;
|
||||
|
||||
const CardOverlayLayout._({
|
||||
required this.compact,
|
||||
required this.cardHeight,
|
||||
required this.cardTop,
|
||||
required this.cardPreviewGap,
|
||||
required this.editorPanelHeight,
|
||||
required this.sectionGap,
|
||||
required this.panelPaddingTop,
|
||||
required this.panelPaddingBottom,
|
||||
required this.reservedBelowControls,
|
||||
required this.hueSliderHeight,
|
||||
required this.hexRowHeight,
|
||||
required this.tabSpacing,
|
||||
required this.controlSpacing,
|
||||
required this.buttonVerticalPadding,
|
||||
});
|
||||
|
||||
factory CardOverlayLayout.fromMediaQuery(MediaQueryData mq) {
|
||||
final compact = mq.size.height < 780;
|
||||
return CardOverlayLayout._(
|
||||
compact: compact,
|
||||
cardHeight: kBalanceCardHeight,
|
||||
cardTop: mq.padding.top + kToolbarHeight + (compact ? 8 : 16),
|
||||
cardPreviewGap: compact ? 12 : 32,
|
||||
editorPanelHeight: compact ? 88 : 96,
|
||||
sectionGap: compact ? 8 : 12,
|
||||
panelPaddingTop: compact ? 10 : 14,
|
||||
panelPaddingBottom: compact ? 14 : 22,
|
||||
reservedBelowControls: compact ? 62 : 78,
|
||||
hueSliderHeight: compact ? 28 : 36,
|
||||
hexRowHeight: compact ? 22 : 26,
|
||||
tabSpacing: compact ? 6 : 10,
|
||||
controlSpacing: compact ? 5 : 8,
|
||||
buttonVerticalPadding: compact ? 8 : 10,
|
||||
);
|
||||
}
|
||||
|
||||
double colorPanelHeight(MediaQueryData mq, double panelTop) {
|
||||
final available = mq.size.height - panelTop - mq.padding.bottom - 8;
|
||||
return available.clamp(compact ? 250 : 320, 410);
|
||||
}
|
||||
}
|
||||
@@ -8,12 +8,12 @@ import 'tables.dart';
|
||||
|
||||
part 'app_database.g.dart';
|
||||
|
||||
@DriftDatabase(tables: [Transactions, Categories, Budgets, ExchangeRates, Accounts])
|
||||
@DriftDatabase(tables: [Transactions, Categories, ExchangeRates, Accounts])
|
||||
class AppDatabase extends _$AppDatabase {
|
||||
AppDatabase() : super(_openConnection());
|
||||
|
||||
@override
|
||||
int get schemaVersion => 5;
|
||||
int get schemaVersion => 6;
|
||||
|
||||
@override
|
||||
MigrationStrategy get migration => MigrationStrategy(
|
||||
@@ -50,6 +50,28 @@ class AppDatabase extends _$AppDatabase {
|
||||
print('Migration: Error adding account_id column: $e');
|
||||
}
|
||||
}
|
||||
|
||||
if (from < 6) {
|
||||
await customStatement('DROP TABLE IF EXISTS budgets');
|
||||
try {
|
||||
final columns = await customSelect(
|
||||
'PRAGMA table_info(categories)',
|
||||
).get();
|
||||
final names = columns.map((row) => row.data['name']).toSet();
|
||||
if (!names.contains('label_en')) {
|
||||
await customStatement(
|
||||
'ALTER TABLE categories ADD COLUMN label_en TEXT',
|
||||
);
|
||||
}
|
||||
if (!names.contains('label_ru')) {
|
||||
await customStatement(
|
||||
'ALTER TABLE categories ADD COLUMN label_ru TEXT',
|
||||
);
|
||||
}
|
||||
} catch (e) {
|
||||
print('Migration: Error updating categories table: $e');
|
||||
}
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
@@ -149,6 +171,12 @@ class AppDatabase extends _$AppDatabase {
|
||||
return select(categories).get();
|
||||
}
|
||||
|
||||
Stream<List<Category>> watchAllCategories() {
|
||||
return (select(categories)
|
||||
..orderBy([(c) => OrderingTerm.asc(c.createdAt)]))
|
||||
.watch();
|
||||
}
|
||||
|
||||
Future<List<Category>> getCategoriesByType(String type) {
|
||||
return (select(categories)..where((c) => c.type.equals(type))).get();
|
||||
}
|
||||
@@ -165,20 +193,6 @@ class AppDatabase extends _$AppDatabase {
|
||||
return (delete(categories)..where((c) => c.id.equals(id))).go();
|
||||
}
|
||||
|
||||
Future<Budget?> getBudget(int month, int year) {
|
||||
return (select(budgets)
|
||||
..where((b) => b.month.equals(month) & b.year.equals(year)))
|
||||
.getSingleOrNull();
|
||||
}
|
||||
|
||||
Future<void> upsertBudget(BudgetsCompanion budget) {
|
||||
return into(budgets).insertOnConflictUpdate(budget);
|
||||
}
|
||||
|
||||
Future<int> deleteBudget(int id) {
|
||||
return (delete(budgets)..where((b) => b.id.equals(id))).go();
|
||||
}
|
||||
|
||||
Future<ExchangeRate?> getExchangeRate(String from, String to) {
|
||||
return (select(exchangeRates)
|
||||
..where((r) => r.fromCurrency.equals(from) & r.toCurrency.equals(to)))
|
||||
|
||||
@@ -745,6 +745,28 @@ class $CategoriesTable extends Categories
|
||||
type: DriftSqlType.string,
|
||||
requiredDuringInsert: true,
|
||||
);
|
||||
static const VerificationMeta _labelEnMeta = const VerificationMeta(
|
||||
'labelEn',
|
||||
);
|
||||
@override
|
||||
late final GeneratedColumn<String> labelEn = GeneratedColumn<String>(
|
||||
'label_en',
|
||||
aliasedName,
|
||||
true,
|
||||
type: DriftSqlType.string,
|
||||
requiredDuringInsert: false,
|
||||
);
|
||||
static const VerificationMeta _labelRuMeta = const VerificationMeta(
|
||||
'labelRu',
|
||||
);
|
||||
@override
|
||||
late final GeneratedColumn<String> labelRu = GeneratedColumn<String>(
|
||||
'label_ru',
|
||||
aliasedName,
|
||||
true,
|
||||
type: DriftSqlType.string,
|
||||
requiredDuringInsert: false,
|
||||
);
|
||||
static const VerificationMeta _iconMeta = const VerificationMeta('icon');
|
||||
@override
|
||||
late final GeneratedColumn<String> icon = GeneratedColumn<String>(
|
||||
@@ -795,6 +817,8 @@ class $CategoriesTable extends Categories
|
||||
id,
|
||||
name,
|
||||
type,
|
||||
labelEn,
|
||||
labelRu,
|
||||
icon,
|
||||
color,
|
||||
isDefault,
|
||||
@@ -831,6 +855,18 @@ class $CategoriesTable extends Categories
|
||||
} else if (isInserting) {
|
||||
context.missing(_typeMeta);
|
||||
}
|
||||
if (data.containsKey('label_en')) {
|
||||
context.handle(
|
||||
_labelEnMeta,
|
||||
labelEn.isAcceptableOrUnknown(data['label_en']!, _labelEnMeta),
|
||||
);
|
||||
}
|
||||
if (data.containsKey('label_ru')) {
|
||||
context.handle(
|
||||
_labelRuMeta,
|
||||
labelRu.isAcceptableOrUnknown(data['label_ru']!, _labelRuMeta),
|
||||
);
|
||||
}
|
||||
if (data.containsKey('icon')) {
|
||||
context.handle(
|
||||
_iconMeta,
|
||||
@@ -876,6 +912,14 @@ class $CategoriesTable extends Categories
|
||||
DriftSqlType.string,
|
||||
data['${effectivePrefix}type'],
|
||||
)!,
|
||||
labelEn: attachedDatabase.typeMapping.read(
|
||||
DriftSqlType.string,
|
||||
data['${effectivePrefix}label_en'],
|
||||
),
|
||||
labelRu: attachedDatabase.typeMapping.read(
|
||||
DriftSqlType.string,
|
||||
data['${effectivePrefix}label_ru'],
|
||||
),
|
||||
icon: attachedDatabase.typeMapping.read(
|
||||
DriftSqlType.string,
|
||||
data['${effectivePrefix}icon'],
|
||||
@@ -905,6 +949,8 @@ class Category extends DataClass implements Insertable<Category> {
|
||||
final int id;
|
||||
final String name;
|
||||
final String type;
|
||||
final String? labelEn;
|
||||
final String? labelRu;
|
||||
final String? icon;
|
||||
final String? color;
|
||||
final bool isDefault;
|
||||
@@ -913,6 +959,8 @@ class Category extends DataClass implements Insertable<Category> {
|
||||
required this.id,
|
||||
required this.name,
|
||||
required this.type,
|
||||
this.labelEn,
|
||||
this.labelRu,
|
||||
this.icon,
|
||||
this.color,
|
||||
required this.isDefault,
|
||||
@@ -924,6 +972,12 @@ class Category extends DataClass implements Insertable<Category> {
|
||||
map['id'] = Variable<int>(id);
|
||||
map['name'] = Variable<String>(name);
|
||||
map['type'] = Variable<String>(type);
|
||||
if (!nullToAbsent || labelEn != null) {
|
||||
map['label_en'] = Variable<String>(labelEn);
|
||||
}
|
||||
if (!nullToAbsent || labelRu != null) {
|
||||
map['label_ru'] = Variable<String>(labelRu);
|
||||
}
|
||||
if (!nullToAbsent || icon != null) {
|
||||
map['icon'] = Variable<String>(icon);
|
||||
}
|
||||
@@ -940,6 +994,12 @@ class Category extends DataClass implements Insertable<Category> {
|
||||
id: Value(id),
|
||||
name: Value(name),
|
||||
type: Value(type),
|
||||
labelEn: labelEn == null && nullToAbsent
|
||||
? const Value.absent()
|
||||
: Value(labelEn),
|
||||
labelRu: labelRu == null && nullToAbsent
|
||||
? const Value.absent()
|
||||
: Value(labelRu),
|
||||
icon: icon == null && nullToAbsent ? const Value.absent() : Value(icon),
|
||||
color: color == null && nullToAbsent
|
||||
? const Value.absent()
|
||||
@@ -958,6 +1018,8 @@ class Category extends DataClass implements Insertable<Category> {
|
||||
id: serializer.fromJson<int>(json['id']),
|
||||
name: serializer.fromJson<String>(json['name']),
|
||||
type: serializer.fromJson<String>(json['type']),
|
||||
labelEn: serializer.fromJson<String?>(json['labelEn']),
|
||||
labelRu: serializer.fromJson<String?>(json['labelRu']),
|
||||
icon: serializer.fromJson<String?>(json['icon']),
|
||||
color: serializer.fromJson<String?>(json['color']),
|
||||
isDefault: serializer.fromJson<bool>(json['isDefault']),
|
||||
@@ -971,6 +1033,8 @@ class Category extends DataClass implements Insertable<Category> {
|
||||
'id': serializer.toJson<int>(id),
|
||||
'name': serializer.toJson<String>(name),
|
||||
'type': serializer.toJson<String>(type),
|
||||
'labelEn': serializer.toJson<String?>(labelEn),
|
||||
'labelRu': serializer.toJson<String?>(labelRu),
|
||||
'icon': serializer.toJson<String?>(icon),
|
||||
'color': serializer.toJson<String?>(color),
|
||||
'isDefault': serializer.toJson<bool>(isDefault),
|
||||
@@ -982,6 +1046,8 @@ class Category extends DataClass implements Insertable<Category> {
|
||||
int? id,
|
||||
String? name,
|
||||
String? type,
|
||||
Value<String?> labelEn = const Value.absent(),
|
||||
Value<String?> labelRu = const Value.absent(),
|
||||
Value<String?> icon = const Value.absent(),
|
||||
Value<String?> color = const Value.absent(),
|
||||
bool? isDefault,
|
||||
@@ -990,6 +1056,8 @@ class Category extends DataClass implements Insertable<Category> {
|
||||
id: id ?? this.id,
|
||||
name: name ?? this.name,
|
||||
type: type ?? this.type,
|
||||
labelEn: labelEn.present ? labelEn.value : this.labelEn,
|
||||
labelRu: labelRu.present ? labelRu.value : this.labelRu,
|
||||
icon: icon.present ? icon.value : this.icon,
|
||||
color: color.present ? color.value : this.color,
|
||||
isDefault: isDefault ?? this.isDefault,
|
||||
@@ -1000,6 +1068,8 @@ class Category extends DataClass implements Insertable<Category> {
|
||||
id: data.id.present ? data.id.value : this.id,
|
||||
name: data.name.present ? data.name.value : this.name,
|
||||
type: data.type.present ? data.type.value : this.type,
|
||||
labelEn: data.labelEn.present ? data.labelEn.value : this.labelEn,
|
||||
labelRu: data.labelRu.present ? data.labelRu.value : this.labelRu,
|
||||
icon: data.icon.present ? data.icon.value : this.icon,
|
||||
color: data.color.present ? data.color.value : this.color,
|
||||
isDefault: data.isDefault.present ? data.isDefault.value : this.isDefault,
|
||||
@@ -1013,6 +1083,8 @@ class Category extends DataClass implements Insertable<Category> {
|
||||
..write('id: $id, ')
|
||||
..write('name: $name, ')
|
||||
..write('type: $type, ')
|
||||
..write('labelEn: $labelEn, ')
|
||||
..write('labelRu: $labelRu, ')
|
||||
..write('icon: $icon, ')
|
||||
..write('color: $color, ')
|
||||
..write('isDefault: $isDefault, ')
|
||||
@@ -1022,8 +1094,17 @@ class Category extends DataClass implements Insertable<Category> {
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode =>
|
||||
Object.hash(id, name, type, icon, color, isDefault, createdAt);
|
||||
int get hashCode => Object.hash(
|
||||
id,
|
||||
name,
|
||||
type,
|
||||
labelEn,
|
||||
labelRu,
|
||||
icon,
|
||||
color,
|
||||
isDefault,
|
||||
createdAt,
|
||||
);
|
||||
@override
|
||||
bool operator ==(Object other) =>
|
||||
identical(this, other) ||
|
||||
@@ -1031,6 +1112,8 @@ class Category extends DataClass implements Insertable<Category> {
|
||||
other.id == this.id &&
|
||||
other.name == this.name &&
|
||||
other.type == this.type &&
|
||||
other.labelEn == this.labelEn &&
|
||||
other.labelRu == this.labelRu &&
|
||||
other.icon == this.icon &&
|
||||
other.color == this.color &&
|
||||
other.isDefault == this.isDefault &&
|
||||
@@ -1041,6 +1124,8 @@ class CategoriesCompanion extends UpdateCompanion<Category> {
|
||||
final Value<int> id;
|
||||
final Value<String> name;
|
||||
final Value<String> type;
|
||||
final Value<String?> labelEn;
|
||||
final Value<String?> labelRu;
|
||||
final Value<String?> icon;
|
||||
final Value<String?> color;
|
||||
final Value<bool> isDefault;
|
||||
@@ -1049,6 +1134,8 @@ class CategoriesCompanion extends UpdateCompanion<Category> {
|
||||
this.id = const Value.absent(),
|
||||
this.name = const Value.absent(),
|
||||
this.type = const Value.absent(),
|
||||
this.labelEn = const Value.absent(),
|
||||
this.labelRu = const Value.absent(),
|
||||
this.icon = const Value.absent(),
|
||||
this.color = const Value.absent(),
|
||||
this.isDefault = const Value.absent(),
|
||||
@@ -1058,6 +1145,8 @@ class CategoriesCompanion extends UpdateCompanion<Category> {
|
||||
this.id = const Value.absent(),
|
||||
required String name,
|
||||
required String type,
|
||||
this.labelEn = const Value.absent(),
|
||||
this.labelRu = const Value.absent(),
|
||||
this.icon = const Value.absent(),
|
||||
this.color = const Value.absent(),
|
||||
this.isDefault = const Value.absent(),
|
||||
@@ -1068,6 +1157,8 @@ class CategoriesCompanion extends UpdateCompanion<Category> {
|
||||
Expression<int>? id,
|
||||
Expression<String>? name,
|
||||
Expression<String>? type,
|
||||
Expression<String>? labelEn,
|
||||
Expression<String>? labelRu,
|
||||
Expression<String>? icon,
|
||||
Expression<String>? color,
|
||||
Expression<bool>? isDefault,
|
||||
@@ -1077,6 +1168,8 @@ class CategoriesCompanion extends UpdateCompanion<Category> {
|
||||
if (id != null) 'id': id,
|
||||
if (name != null) 'name': name,
|
||||
if (type != null) 'type': type,
|
||||
if (labelEn != null) 'label_en': labelEn,
|
||||
if (labelRu != null) 'label_ru': labelRu,
|
||||
if (icon != null) 'icon': icon,
|
||||
if (color != null) 'color': color,
|
||||
if (isDefault != null) 'is_default': isDefault,
|
||||
@@ -1088,6 +1181,8 @@ class CategoriesCompanion extends UpdateCompanion<Category> {
|
||||
Value<int>? id,
|
||||
Value<String>? name,
|
||||
Value<String>? type,
|
||||
Value<String?>? labelEn,
|
||||
Value<String?>? labelRu,
|
||||
Value<String?>? icon,
|
||||
Value<String?>? color,
|
||||
Value<bool>? isDefault,
|
||||
@@ -1097,6 +1192,8 @@ class CategoriesCompanion extends UpdateCompanion<Category> {
|
||||
id: id ?? this.id,
|
||||
name: name ?? this.name,
|
||||
type: type ?? this.type,
|
||||
labelEn: labelEn ?? this.labelEn,
|
||||
labelRu: labelRu ?? this.labelRu,
|
||||
icon: icon ?? this.icon,
|
||||
color: color ?? this.color,
|
||||
isDefault: isDefault ?? this.isDefault,
|
||||
@@ -1116,6 +1213,12 @@ class CategoriesCompanion extends UpdateCompanion<Category> {
|
||||
if (type.present) {
|
||||
map['type'] = Variable<String>(type.value);
|
||||
}
|
||||
if (labelEn.present) {
|
||||
map['label_en'] = Variable<String>(labelEn.value);
|
||||
}
|
||||
if (labelRu.present) {
|
||||
map['label_ru'] = Variable<String>(labelRu.value);
|
||||
}
|
||||
if (icon.present) {
|
||||
map['icon'] = Variable<String>(icon.value);
|
||||
}
|
||||
@@ -1137,6 +1240,8 @@ class CategoriesCompanion extends UpdateCompanion<Category> {
|
||||
..write('id: $id, ')
|
||||
..write('name: $name, ')
|
||||
..write('type: $type, ')
|
||||
..write('labelEn: $labelEn, ')
|
||||
..write('labelRu: $labelRu, ')
|
||||
..write('icon: $icon, ')
|
||||
..write('color: $color, ')
|
||||
..write('isDefault: $isDefault, ')
|
||||
@@ -1146,400 +1251,6 @@ class CategoriesCompanion extends UpdateCompanion<Category> {
|
||||
}
|
||||
}
|
||||
|
||||
class $BudgetsTable extends Budgets with TableInfo<$BudgetsTable, Budget> {
|
||||
@override
|
||||
final GeneratedDatabase attachedDatabase;
|
||||
final String? _alias;
|
||||
$BudgetsTable(this.attachedDatabase, [this._alias]);
|
||||
static const VerificationMeta _idMeta = const VerificationMeta('id');
|
||||
@override
|
||||
late final GeneratedColumn<int> id = GeneratedColumn<int>(
|
||||
'id',
|
||||
aliasedName,
|
||||
false,
|
||||
hasAutoIncrement: true,
|
||||
type: DriftSqlType.int,
|
||||
requiredDuringInsert: false,
|
||||
defaultConstraints: GeneratedColumn.constraintIsAlways(
|
||||
'PRIMARY KEY AUTOINCREMENT',
|
||||
),
|
||||
);
|
||||
static const VerificationMeta _amountMeta = const VerificationMeta('amount');
|
||||
@override
|
||||
late final GeneratedColumn<double> amount = GeneratedColumn<double>(
|
||||
'amount',
|
||||
aliasedName,
|
||||
false,
|
||||
type: DriftSqlType.double,
|
||||
requiredDuringInsert: true,
|
||||
);
|
||||
static const VerificationMeta _categoryIdMeta = const VerificationMeta(
|
||||
'categoryId',
|
||||
);
|
||||
@override
|
||||
late final GeneratedColumn<String> categoryId = GeneratedColumn<String>(
|
||||
'category_id',
|
||||
aliasedName,
|
||||
true,
|
||||
type: DriftSqlType.string,
|
||||
requiredDuringInsert: false,
|
||||
);
|
||||
static const VerificationMeta _monthMeta = const VerificationMeta('month');
|
||||
@override
|
||||
late final GeneratedColumn<int> month = GeneratedColumn<int>(
|
||||
'month',
|
||||
aliasedName,
|
||||
false,
|
||||
type: DriftSqlType.int,
|
||||
requiredDuringInsert: true,
|
||||
);
|
||||
static const VerificationMeta _yearMeta = const VerificationMeta('year');
|
||||
@override
|
||||
late final GeneratedColumn<int> year = GeneratedColumn<int>(
|
||||
'year',
|
||||
aliasedName,
|
||||
false,
|
||||
type: DriftSqlType.int,
|
||||
requiredDuringInsert: true,
|
||||
);
|
||||
static const VerificationMeta _createdAtMeta = const VerificationMeta(
|
||||
'createdAt',
|
||||
);
|
||||
@override
|
||||
late final GeneratedColumn<DateTime> createdAt = GeneratedColumn<DateTime>(
|
||||
'created_at',
|
||||
aliasedName,
|
||||
false,
|
||||
type: DriftSqlType.dateTime,
|
||||
requiredDuringInsert: false,
|
||||
defaultValue: currentDateAndTime,
|
||||
);
|
||||
@override
|
||||
List<GeneratedColumn> get $columns => [
|
||||
id,
|
||||
amount,
|
||||
categoryId,
|
||||
month,
|
||||
year,
|
||||
createdAt,
|
||||
];
|
||||
@override
|
||||
String get aliasedName => _alias ?? actualTableName;
|
||||
@override
|
||||
String get actualTableName => $name;
|
||||
static const String $name = 'budgets';
|
||||
@override
|
||||
VerificationContext validateIntegrity(
|
||||
Insertable<Budget> instance, {
|
||||
bool isInserting = false,
|
||||
}) {
|
||||
final context = VerificationContext();
|
||||
final data = instance.toColumns(true);
|
||||
if (data.containsKey('id')) {
|
||||
context.handle(_idMeta, id.isAcceptableOrUnknown(data['id']!, _idMeta));
|
||||
}
|
||||
if (data.containsKey('amount')) {
|
||||
context.handle(
|
||||
_amountMeta,
|
||||
amount.isAcceptableOrUnknown(data['amount']!, _amountMeta),
|
||||
);
|
||||
} else if (isInserting) {
|
||||
context.missing(_amountMeta);
|
||||
}
|
||||
if (data.containsKey('category_id')) {
|
||||
context.handle(
|
||||
_categoryIdMeta,
|
||||
categoryId.isAcceptableOrUnknown(data['category_id']!, _categoryIdMeta),
|
||||
);
|
||||
}
|
||||
if (data.containsKey('month')) {
|
||||
context.handle(
|
||||
_monthMeta,
|
||||
month.isAcceptableOrUnknown(data['month']!, _monthMeta),
|
||||
);
|
||||
} else if (isInserting) {
|
||||
context.missing(_monthMeta);
|
||||
}
|
||||
if (data.containsKey('year')) {
|
||||
context.handle(
|
||||
_yearMeta,
|
||||
year.isAcceptableOrUnknown(data['year']!, _yearMeta),
|
||||
);
|
||||
} else if (isInserting) {
|
||||
context.missing(_yearMeta);
|
||||
}
|
||||
if (data.containsKey('created_at')) {
|
||||
context.handle(
|
||||
_createdAtMeta,
|
||||
createdAt.isAcceptableOrUnknown(data['created_at']!, _createdAtMeta),
|
||||
);
|
||||
}
|
||||
return context;
|
||||
}
|
||||
|
||||
@override
|
||||
Set<GeneratedColumn> get $primaryKey => {id};
|
||||
@override
|
||||
Budget map(Map<String, dynamic> data, {String? tablePrefix}) {
|
||||
final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : '';
|
||||
return Budget(
|
||||
id: attachedDatabase.typeMapping.read(
|
||||
DriftSqlType.int,
|
||||
data['${effectivePrefix}id'],
|
||||
)!,
|
||||
amount: attachedDatabase.typeMapping.read(
|
||||
DriftSqlType.double,
|
||||
data['${effectivePrefix}amount'],
|
||||
)!,
|
||||
categoryId: attachedDatabase.typeMapping.read(
|
||||
DriftSqlType.string,
|
||||
data['${effectivePrefix}category_id'],
|
||||
),
|
||||
month: attachedDatabase.typeMapping.read(
|
||||
DriftSqlType.int,
|
||||
data['${effectivePrefix}month'],
|
||||
)!,
|
||||
year: attachedDatabase.typeMapping.read(
|
||||
DriftSqlType.int,
|
||||
data['${effectivePrefix}year'],
|
||||
)!,
|
||||
createdAt: attachedDatabase.typeMapping.read(
|
||||
DriftSqlType.dateTime,
|
||||
data['${effectivePrefix}created_at'],
|
||||
)!,
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
$BudgetsTable createAlias(String alias) {
|
||||
return $BudgetsTable(attachedDatabase, alias);
|
||||
}
|
||||
}
|
||||
|
||||
class Budget extends DataClass implements Insertable<Budget> {
|
||||
final int id;
|
||||
final double amount;
|
||||
final String? categoryId;
|
||||
final int month;
|
||||
final int year;
|
||||
final DateTime createdAt;
|
||||
const Budget({
|
||||
required this.id,
|
||||
required this.amount,
|
||||
this.categoryId,
|
||||
required this.month,
|
||||
required this.year,
|
||||
required this.createdAt,
|
||||
});
|
||||
@override
|
||||
Map<String, Expression> toColumns(bool nullToAbsent) {
|
||||
final map = <String, Expression>{};
|
||||
map['id'] = Variable<int>(id);
|
||||
map['amount'] = Variable<double>(amount);
|
||||
if (!nullToAbsent || categoryId != null) {
|
||||
map['category_id'] = Variable<String>(categoryId);
|
||||
}
|
||||
map['month'] = Variable<int>(month);
|
||||
map['year'] = Variable<int>(year);
|
||||
map['created_at'] = Variable<DateTime>(createdAt);
|
||||
return map;
|
||||
}
|
||||
|
||||
BudgetsCompanion toCompanion(bool nullToAbsent) {
|
||||
return BudgetsCompanion(
|
||||
id: Value(id),
|
||||
amount: Value(amount),
|
||||
categoryId: categoryId == null && nullToAbsent
|
||||
? const Value.absent()
|
||||
: Value(categoryId),
|
||||
month: Value(month),
|
||||
year: Value(year),
|
||||
createdAt: Value(createdAt),
|
||||
);
|
||||
}
|
||||
|
||||
factory Budget.fromJson(
|
||||
Map<String, dynamic> json, {
|
||||
ValueSerializer? serializer,
|
||||
}) {
|
||||
serializer ??= driftRuntimeOptions.defaultSerializer;
|
||||
return Budget(
|
||||
id: serializer.fromJson<int>(json['id']),
|
||||
amount: serializer.fromJson<double>(json['amount']),
|
||||
categoryId: serializer.fromJson<String?>(json['categoryId']),
|
||||
month: serializer.fromJson<int>(json['month']),
|
||||
year: serializer.fromJson<int>(json['year']),
|
||||
createdAt: serializer.fromJson<DateTime>(json['createdAt']),
|
||||
);
|
||||
}
|
||||
@override
|
||||
Map<String, dynamic> toJson({ValueSerializer? serializer}) {
|
||||
serializer ??= driftRuntimeOptions.defaultSerializer;
|
||||
return <String, dynamic>{
|
||||
'id': serializer.toJson<int>(id),
|
||||
'amount': serializer.toJson<double>(amount),
|
||||
'categoryId': serializer.toJson<String?>(categoryId),
|
||||
'month': serializer.toJson<int>(month),
|
||||
'year': serializer.toJson<int>(year),
|
||||
'createdAt': serializer.toJson<DateTime>(createdAt),
|
||||
};
|
||||
}
|
||||
|
||||
Budget copyWith({
|
||||
int? id,
|
||||
double? amount,
|
||||
Value<String?> categoryId = const Value.absent(),
|
||||
int? month,
|
||||
int? year,
|
||||
DateTime? createdAt,
|
||||
}) => Budget(
|
||||
id: id ?? this.id,
|
||||
amount: amount ?? this.amount,
|
||||
categoryId: categoryId.present ? categoryId.value : this.categoryId,
|
||||
month: month ?? this.month,
|
||||
year: year ?? this.year,
|
||||
createdAt: createdAt ?? this.createdAt,
|
||||
);
|
||||
Budget copyWithCompanion(BudgetsCompanion data) {
|
||||
return Budget(
|
||||
id: data.id.present ? data.id.value : this.id,
|
||||
amount: data.amount.present ? data.amount.value : this.amount,
|
||||
categoryId: data.categoryId.present
|
||||
? data.categoryId.value
|
||||
: this.categoryId,
|
||||
month: data.month.present ? data.month.value : this.month,
|
||||
year: data.year.present ? data.year.value : this.year,
|
||||
createdAt: data.createdAt.present ? data.createdAt.value : this.createdAt,
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return (StringBuffer('Budget(')
|
||||
..write('id: $id, ')
|
||||
..write('amount: $amount, ')
|
||||
..write('categoryId: $categoryId, ')
|
||||
..write('month: $month, ')
|
||||
..write('year: $year, ')
|
||||
..write('createdAt: $createdAt')
|
||||
..write(')'))
|
||||
.toString();
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode =>
|
||||
Object.hash(id, amount, categoryId, month, year, createdAt);
|
||||
@override
|
||||
bool operator ==(Object other) =>
|
||||
identical(this, other) ||
|
||||
(other is Budget &&
|
||||
other.id == this.id &&
|
||||
other.amount == this.amount &&
|
||||
other.categoryId == this.categoryId &&
|
||||
other.month == this.month &&
|
||||
other.year == this.year &&
|
||||
other.createdAt == this.createdAt);
|
||||
}
|
||||
|
||||
class BudgetsCompanion extends UpdateCompanion<Budget> {
|
||||
final Value<int> id;
|
||||
final Value<double> amount;
|
||||
final Value<String?> categoryId;
|
||||
final Value<int> month;
|
||||
final Value<int> year;
|
||||
final Value<DateTime> createdAt;
|
||||
const BudgetsCompanion({
|
||||
this.id = const Value.absent(),
|
||||
this.amount = const Value.absent(),
|
||||
this.categoryId = const Value.absent(),
|
||||
this.month = const Value.absent(),
|
||||
this.year = const Value.absent(),
|
||||
this.createdAt = const Value.absent(),
|
||||
});
|
||||
BudgetsCompanion.insert({
|
||||
this.id = const Value.absent(),
|
||||
required double amount,
|
||||
this.categoryId = const Value.absent(),
|
||||
required int month,
|
||||
required int year,
|
||||
this.createdAt = const Value.absent(),
|
||||
}) : amount = Value(amount),
|
||||
month = Value(month),
|
||||
year = Value(year);
|
||||
static Insertable<Budget> custom({
|
||||
Expression<int>? id,
|
||||
Expression<double>? amount,
|
||||
Expression<String>? categoryId,
|
||||
Expression<int>? month,
|
||||
Expression<int>? year,
|
||||
Expression<DateTime>? createdAt,
|
||||
}) {
|
||||
return RawValuesInsertable({
|
||||
if (id != null) 'id': id,
|
||||
if (amount != null) 'amount': amount,
|
||||
if (categoryId != null) 'category_id': categoryId,
|
||||
if (month != null) 'month': month,
|
||||
if (year != null) 'year': year,
|
||||
if (createdAt != null) 'created_at': createdAt,
|
||||
});
|
||||
}
|
||||
|
||||
BudgetsCompanion copyWith({
|
||||
Value<int>? id,
|
||||
Value<double>? amount,
|
||||
Value<String?>? categoryId,
|
||||
Value<int>? month,
|
||||
Value<int>? year,
|
||||
Value<DateTime>? createdAt,
|
||||
}) {
|
||||
return BudgetsCompanion(
|
||||
id: id ?? this.id,
|
||||
amount: amount ?? this.amount,
|
||||
categoryId: categoryId ?? this.categoryId,
|
||||
month: month ?? this.month,
|
||||
year: year ?? this.year,
|
||||
createdAt: createdAt ?? this.createdAt,
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Map<String, Expression> toColumns(bool nullToAbsent) {
|
||||
final map = <String, Expression>{};
|
||||
if (id.present) {
|
||||
map['id'] = Variable<int>(id.value);
|
||||
}
|
||||
if (amount.present) {
|
||||
map['amount'] = Variable<double>(amount.value);
|
||||
}
|
||||
if (categoryId.present) {
|
||||
map['category_id'] = Variable<String>(categoryId.value);
|
||||
}
|
||||
if (month.present) {
|
||||
map['month'] = Variable<int>(month.value);
|
||||
}
|
||||
if (year.present) {
|
||||
map['year'] = Variable<int>(year.value);
|
||||
}
|
||||
if (createdAt.present) {
|
||||
map['created_at'] = Variable<DateTime>(createdAt.value);
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return (StringBuffer('BudgetsCompanion(')
|
||||
..write('id: $id, ')
|
||||
..write('amount: $amount, ')
|
||||
..write('categoryId: $categoryId, ')
|
||||
..write('month: $month, ')
|
||||
..write('year: $year, ')
|
||||
..write('createdAt: $createdAt')
|
||||
..write(')'))
|
||||
.toString();
|
||||
}
|
||||
}
|
||||
|
||||
class $ExchangeRatesTable extends ExchangeRates
|
||||
with TableInfo<$ExchangeRatesTable, ExchangeRate> {
|
||||
@override
|
||||
@@ -2291,7 +2002,6 @@ abstract class _$AppDatabase extends GeneratedDatabase {
|
||||
$AppDatabaseManager get managers => $AppDatabaseManager(this);
|
||||
late final $TransactionsTable transactions = $TransactionsTable(this);
|
||||
late final $CategoriesTable categories = $CategoriesTable(this);
|
||||
late final $BudgetsTable budgets = $BudgetsTable(this);
|
||||
late final $ExchangeRatesTable exchangeRates = $ExchangeRatesTable(this);
|
||||
late final $AccountsTable accounts = $AccountsTable(this);
|
||||
@override
|
||||
@@ -2301,7 +2011,6 @@ abstract class _$AppDatabase extends GeneratedDatabase {
|
||||
List<DatabaseSchemaEntity> get allSchemaEntities => [
|
||||
transactions,
|
||||
categories,
|
||||
budgets,
|
||||
exchangeRates,
|
||||
accounts,
|
||||
];
|
||||
@@ -2654,6 +2363,8 @@ typedef $$CategoriesTableCreateCompanionBuilder =
|
||||
Value<int> id,
|
||||
required String name,
|
||||
required String type,
|
||||
Value<String?> labelEn,
|
||||
Value<String?> labelRu,
|
||||
Value<String?> icon,
|
||||
Value<String?> color,
|
||||
Value<bool> isDefault,
|
||||
@@ -2664,6 +2375,8 @@ typedef $$CategoriesTableUpdateCompanionBuilder =
|
||||
Value<int> id,
|
||||
Value<String> name,
|
||||
Value<String> type,
|
||||
Value<String?> labelEn,
|
||||
Value<String?> labelRu,
|
||||
Value<String?> icon,
|
||||
Value<String?> color,
|
||||
Value<bool> isDefault,
|
||||
@@ -2694,6 +2407,16 @@ class $$CategoriesTableFilterComposer
|
||||
builder: (column) => ColumnFilters(column),
|
||||
);
|
||||
|
||||
ColumnFilters<String> get labelEn => $composableBuilder(
|
||||
column: $table.labelEn,
|
||||
builder: (column) => ColumnFilters(column),
|
||||
);
|
||||
|
||||
ColumnFilters<String> get labelRu => $composableBuilder(
|
||||
column: $table.labelRu,
|
||||
builder: (column) => ColumnFilters(column),
|
||||
);
|
||||
|
||||
ColumnFilters<String> get icon => $composableBuilder(
|
||||
column: $table.icon,
|
||||
builder: (column) => ColumnFilters(column),
|
||||
@@ -2739,6 +2462,16 @@ class $$CategoriesTableOrderingComposer
|
||||
builder: (column) => ColumnOrderings(column),
|
||||
);
|
||||
|
||||
ColumnOrderings<String> get labelEn => $composableBuilder(
|
||||
column: $table.labelEn,
|
||||
builder: (column) => ColumnOrderings(column),
|
||||
);
|
||||
|
||||
ColumnOrderings<String> get labelRu => $composableBuilder(
|
||||
column: $table.labelRu,
|
||||
builder: (column) => ColumnOrderings(column),
|
||||
);
|
||||
|
||||
ColumnOrderings<String> get icon => $composableBuilder(
|
||||
column: $table.icon,
|
||||
builder: (column) => ColumnOrderings(column),
|
||||
@@ -2778,6 +2511,12 @@ class $$CategoriesTableAnnotationComposer
|
||||
GeneratedColumn<String> get type =>
|
||||
$composableBuilder(column: $table.type, builder: (column) => column);
|
||||
|
||||
GeneratedColumn<String> get labelEn =>
|
||||
$composableBuilder(column: $table.labelEn, builder: (column) => column);
|
||||
|
||||
GeneratedColumn<String> get labelRu =>
|
||||
$composableBuilder(column: $table.labelRu, builder: (column) => column);
|
||||
|
||||
GeneratedColumn<String> get icon =>
|
||||
$composableBuilder(column: $table.icon, builder: (column) => column);
|
||||
|
||||
@@ -2822,6 +2561,8 @@ class $$CategoriesTableTableManager
|
||||
Value<int> id = const Value.absent(),
|
||||
Value<String> name = const Value.absent(),
|
||||
Value<String> type = const Value.absent(),
|
||||
Value<String?> labelEn = const Value.absent(),
|
||||
Value<String?> labelRu = const Value.absent(),
|
||||
Value<String?> icon = const Value.absent(),
|
||||
Value<String?> color = const Value.absent(),
|
||||
Value<bool> isDefault = const Value.absent(),
|
||||
@@ -2830,6 +2571,8 @@ class $$CategoriesTableTableManager
|
||||
id: id,
|
||||
name: name,
|
||||
type: type,
|
||||
labelEn: labelEn,
|
||||
labelRu: labelRu,
|
||||
icon: icon,
|
||||
color: color,
|
||||
isDefault: isDefault,
|
||||
@@ -2840,6 +2583,8 @@ class $$CategoriesTableTableManager
|
||||
Value<int> id = const Value.absent(),
|
||||
required String name,
|
||||
required String type,
|
||||
Value<String?> labelEn = const Value.absent(),
|
||||
Value<String?> labelRu = const Value.absent(),
|
||||
Value<String?> icon = const Value.absent(),
|
||||
Value<String?> color = const Value.absent(),
|
||||
Value<bool> isDefault = const Value.absent(),
|
||||
@@ -2848,6 +2593,8 @@ class $$CategoriesTableTableManager
|
||||
id: id,
|
||||
name: name,
|
||||
type: type,
|
||||
labelEn: labelEn,
|
||||
labelRu: labelRu,
|
||||
icon: icon,
|
||||
color: color,
|
||||
isDefault: isDefault,
|
||||
@@ -2875,215 +2622,6 @@ typedef $$CategoriesTableProcessedTableManager =
|
||||
Category,
|
||||
PrefetchHooks Function()
|
||||
>;
|
||||
typedef $$BudgetsTableCreateCompanionBuilder =
|
||||
BudgetsCompanion Function({
|
||||
Value<int> id,
|
||||
required double amount,
|
||||
Value<String?> categoryId,
|
||||
required int month,
|
||||
required int year,
|
||||
Value<DateTime> createdAt,
|
||||
});
|
||||
typedef $$BudgetsTableUpdateCompanionBuilder =
|
||||
BudgetsCompanion Function({
|
||||
Value<int> id,
|
||||
Value<double> amount,
|
||||
Value<String?> categoryId,
|
||||
Value<int> month,
|
||||
Value<int> year,
|
||||
Value<DateTime> createdAt,
|
||||
});
|
||||
|
||||
class $$BudgetsTableFilterComposer
|
||||
extends Composer<_$AppDatabase, $BudgetsTable> {
|
||||
$$BudgetsTableFilterComposer({
|
||||
required super.$db,
|
||||
required super.$table,
|
||||
super.joinBuilder,
|
||||
super.$addJoinBuilderToRootComposer,
|
||||
super.$removeJoinBuilderFromRootComposer,
|
||||
});
|
||||
ColumnFilters<int> get id => $composableBuilder(
|
||||
column: $table.id,
|
||||
builder: (column) => ColumnFilters(column),
|
||||
);
|
||||
|
||||
ColumnFilters<double> get amount => $composableBuilder(
|
||||
column: $table.amount,
|
||||
builder: (column) => ColumnFilters(column),
|
||||
);
|
||||
|
||||
ColumnFilters<String> get categoryId => $composableBuilder(
|
||||
column: $table.categoryId,
|
||||
builder: (column) => ColumnFilters(column),
|
||||
);
|
||||
|
||||
ColumnFilters<int> get month => $composableBuilder(
|
||||
column: $table.month,
|
||||
builder: (column) => ColumnFilters(column),
|
||||
);
|
||||
|
||||
ColumnFilters<int> get year => $composableBuilder(
|
||||
column: $table.year,
|
||||
builder: (column) => ColumnFilters(column),
|
||||
);
|
||||
|
||||
ColumnFilters<DateTime> get createdAt => $composableBuilder(
|
||||
column: $table.createdAt,
|
||||
builder: (column) => ColumnFilters(column),
|
||||
);
|
||||
}
|
||||
|
||||
class $$BudgetsTableOrderingComposer
|
||||
extends Composer<_$AppDatabase, $BudgetsTable> {
|
||||
$$BudgetsTableOrderingComposer({
|
||||
required super.$db,
|
||||
required super.$table,
|
||||
super.joinBuilder,
|
||||
super.$addJoinBuilderToRootComposer,
|
||||
super.$removeJoinBuilderFromRootComposer,
|
||||
});
|
||||
ColumnOrderings<int> get id => $composableBuilder(
|
||||
column: $table.id,
|
||||
builder: (column) => ColumnOrderings(column),
|
||||
);
|
||||
|
||||
ColumnOrderings<double> get amount => $composableBuilder(
|
||||
column: $table.amount,
|
||||
builder: (column) => ColumnOrderings(column),
|
||||
);
|
||||
|
||||
ColumnOrderings<String> get categoryId => $composableBuilder(
|
||||
column: $table.categoryId,
|
||||
builder: (column) => ColumnOrderings(column),
|
||||
);
|
||||
|
||||
ColumnOrderings<int> get month => $composableBuilder(
|
||||
column: $table.month,
|
||||
builder: (column) => ColumnOrderings(column),
|
||||
);
|
||||
|
||||
ColumnOrderings<int> get year => $composableBuilder(
|
||||
column: $table.year,
|
||||
builder: (column) => ColumnOrderings(column),
|
||||
);
|
||||
|
||||
ColumnOrderings<DateTime> get createdAt => $composableBuilder(
|
||||
column: $table.createdAt,
|
||||
builder: (column) => ColumnOrderings(column),
|
||||
);
|
||||
}
|
||||
|
||||
class $$BudgetsTableAnnotationComposer
|
||||
extends Composer<_$AppDatabase, $BudgetsTable> {
|
||||
$$BudgetsTableAnnotationComposer({
|
||||
required super.$db,
|
||||
required super.$table,
|
||||
super.joinBuilder,
|
||||
super.$addJoinBuilderToRootComposer,
|
||||
super.$removeJoinBuilderFromRootComposer,
|
||||
});
|
||||
GeneratedColumn<int> get id =>
|
||||
$composableBuilder(column: $table.id, builder: (column) => column);
|
||||
|
||||
GeneratedColumn<double> get amount =>
|
||||
$composableBuilder(column: $table.amount, builder: (column) => column);
|
||||
|
||||
GeneratedColumn<String> get categoryId => $composableBuilder(
|
||||
column: $table.categoryId,
|
||||
builder: (column) => column,
|
||||
);
|
||||
|
||||
GeneratedColumn<int> get month =>
|
||||
$composableBuilder(column: $table.month, builder: (column) => column);
|
||||
|
||||
GeneratedColumn<int> get year =>
|
||||
$composableBuilder(column: $table.year, builder: (column) => column);
|
||||
|
||||
GeneratedColumn<DateTime> get createdAt =>
|
||||
$composableBuilder(column: $table.createdAt, builder: (column) => column);
|
||||
}
|
||||
|
||||
class $$BudgetsTableTableManager
|
||||
extends
|
||||
RootTableManager<
|
||||
_$AppDatabase,
|
||||
$BudgetsTable,
|
||||
Budget,
|
||||
$$BudgetsTableFilterComposer,
|
||||
$$BudgetsTableOrderingComposer,
|
||||
$$BudgetsTableAnnotationComposer,
|
||||
$$BudgetsTableCreateCompanionBuilder,
|
||||
$$BudgetsTableUpdateCompanionBuilder,
|
||||
(Budget, BaseReferences<_$AppDatabase, $BudgetsTable, Budget>),
|
||||
Budget,
|
||||
PrefetchHooks Function()
|
||||
> {
|
||||
$$BudgetsTableTableManager(_$AppDatabase db, $BudgetsTable table)
|
||||
: super(
|
||||
TableManagerState(
|
||||
db: db,
|
||||
table: table,
|
||||
createFilteringComposer: () =>
|
||||
$$BudgetsTableFilterComposer($db: db, $table: table),
|
||||
createOrderingComposer: () =>
|
||||
$$BudgetsTableOrderingComposer($db: db, $table: table),
|
||||
createComputedFieldComposer: () =>
|
||||
$$BudgetsTableAnnotationComposer($db: db, $table: table),
|
||||
updateCompanionCallback:
|
||||
({
|
||||
Value<int> id = const Value.absent(),
|
||||
Value<double> amount = const Value.absent(),
|
||||
Value<String?> categoryId = const Value.absent(),
|
||||
Value<int> month = const Value.absent(),
|
||||
Value<int> year = const Value.absent(),
|
||||
Value<DateTime> createdAt = const Value.absent(),
|
||||
}) => BudgetsCompanion(
|
||||
id: id,
|
||||
amount: amount,
|
||||
categoryId: categoryId,
|
||||
month: month,
|
||||
year: year,
|
||||
createdAt: createdAt,
|
||||
),
|
||||
createCompanionCallback:
|
||||
({
|
||||
Value<int> id = const Value.absent(),
|
||||
required double amount,
|
||||
Value<String?> categoryId = const Value.absent(),
|
||||
required int month,
|
||||
required int year,
|
||||
Value<DateTime> createdAt = const Value.absent(),
|
||||
}) => BudgetsCompanion.insert(
|
||||
id: id,
|
||||
amount: amount,
|
||||
categoryId: categoryId,
|
||||
month: month,
|
||||
year: year,
|
||||
createdAt: createdAt,
|
||||
),
|
||||
withReferenceMapper: (p0) => p0
|
||||
.map((e) => (e.readTable(table), BaseReferences(db, table, e)))
|
||||
.toList(),
|
||||
prefetchHooksCallback: null,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
typedef $$BudgetsTableProcessedTableManager =
|
||||
ProcessedTableManager<
|
||||
_$AppDatabase,
|
||||
$BudgetsTable,
|
||||
Budget,
|
||||
$$BudgetsTableFilterComposer,
|
||||
$$BudgetsTableOrderingComposer,
|
||||
$$BudgetsTableAnnotationComposer,
|
||||
$$BudgetsTableCreateCompanionBuilder,
|
||||
$$BudgetsTableUpdateCompanionBuilder,
|
||||
(Budget, BaseReferences<_$AppDatabase, $BudgetsTable, Budget>),
|
||||
Budget,
|
||||
PrefetchHooks Function()
|
||||
>;
|
||||
typedef $$ExchangeRatesTableCreateCompanionBuilder =
|
||||
ExchangeRatesCompanion Function({
|
||||
Value<int> id,
|
||||
@@ -3497,8 +3035,6 @@ class $AppDatabaseManager {
|
||||
$$TransactionsTableTableManager(_db, _db.transactions);
|
||||
$$CategoriesTableTableManager get categories =>
|
||||
$$CategoriesTableTableManager(_db, _db.categories);
|
||||
$$BudgetsTableTableManager get budgets =>
|
||||
$$BudgetsTableTableManager(_db, _db.budgets);
|
||||
$$ExchangeRatesTableTableManager get exchangeRates =>
|
||||
$$ExchangeRatesTableTableManager(_db, _db.exchangeRates);
|
||||
$$AccountsTableTableManager get accounts =>
|
||||
|
||||
@@ -22,21 +22,14 @@ class Categories extends Table {
|
||||
IntColumn get id => integer().autoIncrement()();
|
||||
TextColumn get name => text().withLength(min: 1, max: 50)();
|
||||
TextColumn get type => text()();
|
||||
TextColumn get labelEn => text().nullable()();
|
||||
TextColumn get labelRu => text().nullable()();
|
||||
TextColumn get icon => text().nullable()();
|
||||
TextColumn get color => text().nullable()();
|
||||
BoolColumn get isDefault => boolean().withDefault(const Constant(false))();
|
||||
DateTimeColumn get createdAt => dateTime().withDefault(currentDateAndTime)();
|
||||
}
|
||||
|
||||
class Budgets extends Table {
|
||||
IntColumn get id => integer().autoIncrement()();
|
||||
RealColumn get amount => real()();
|
||||
TextColumn get categoryId => text().nullable()();
|
||||
IntColumn get month => integer()();
|
||||
IntColumn get year => integer()();
|
||||
DateTimeColumn get createdAt => dateTime().withDefault(currentDateAndTime)();
|
||||
}
|
||||
|
||||
class ExchangeRates extends Table {
|
||||
IntColumn get id => integer().autoIncrement()();
|
||||
TextColumn get fromCurrency => text()();
|
||||
|
||||
@@ -1,19 +1,21 @@
|
||||
import 'package:drift/drift.dart';
|
||||
import '../database/app_database.dart';
|
||||
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;
|
||||
AccountLimitException(this.message);
|
||||
FeatureLimitException(this.message);
|
||||
|
||||
@override
|
||||
String toString() => 'AccountLimitException: $message';
|
||||
String toString() => 'FeatureLimitException: $message';
|
||||
}
|
||||
|
||||
class AccountRepository {
|
||||
final AppDatabase _db;
|
||||
final FeatureFlags Function() _getFeatureFlags;
|
||||
|
||||
AccountRepository(this._db);
|
||||
AccountRepository(this._db, this._getFeatureFlags);
|
||||
|
||||
Stream<List<model.Account>> watchAll() {
|
||||
return (_db.select(_db.accounts)
|
||||
@@ -163,6 +165,12 @@ class AccountRepository {
|
||||
}
|
||||
|
||||
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(
|
||||
AccountsCompanion.insert(
|
||||
name: account.name,
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
import 'package:drift/drift.dart';
|
||||
import '../database/app_database.dart';
|
||||
|
||||
class CategoryRepository {
|
||||
final AppDatabase _db;
|
||||
|
||||
CategoryRepository(this._db);
|
||||
|
||||
Stream<List<Category>> watchAll() {
|
||||
return _db.watchAllCategories();
|
||||
}
|
||||
|
||||
Future<List<Category>> getAll() {
|
||||
return _db.getAllCategories();
|
||||
}
|
||||
|
||||
Future<int> add({
|
||||
required String name,
|
||||
required String type,
|
||||
required String labelEn,
|
||||
required String labelRu,
|
||||
required String iconName,
|
||||
required int colorValue,
|
||||
}) {
|
||||
return _db.insertCategory(
|
||||
CategoriesCompanion.insert(
|
||||
name: name,
|
||||
type: type,
|
||||
labelEn: Value(labelEn),
|
||||
labelRu: Value(labelRu),
|
||||
icon: Value(iconName),
|
||||
color: Value(colorValue.toString()),
|
||||
isDefault: const Value(false),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> updateFields(
|
||||
int id, {
|
||||
required String type,
|
||||
required String labelEn,
|
||||
required String labelRu,
|
||||
required String iconName,
|
||||
required int colorValue,
|
||||
}) {
|
||||
return (_db.update(_db.categories)..where((c) => c.id.equals(id))).write(
|
||||
CategoriesCompanion(
|
||||
type: Value(type),
|
||||
labelEn: Value(labelEn),
|
||||
labelRu: Value(labelRu),
|
||||
icon: Value(iconName),
|
||||
color: Value(colorValue.toString()),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Future<int> delete(int id) {
|
||||
return _db.deleteCategory(id);
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,8 @@
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import '../../core/constants.dart';
|
||||
import '../../shared/models/app_category.dart';
|
||||
import '../../shared/models/transaction.dart';
|
||||
import '../../shared/providers/category_provider.dart';
|
||||
|
||||
class AddTransactionState {
|
||||
final double? amount;
|
||||
@@ -80,13 +82,22 @@ class AddTransactionState {
|
||||
bool get isEditing => editingId != null;
|
||||
}
|
||||
|
||||
class AddTransactionNotifier extends StateNotifier<AddTransactionState> {
|
||||
AddTransactionNotifier(Transaction? initial)
|
||||
: super(
|
||||
initial != null
|
||||
? AddTransactionState.fromTransaction(initial)
|
||||
: AddTransactionState.empty(),
|
||||
);
|
||||
final addTransactionProvider = NotifierProvider.autoDispose
|
||||
.family<AddTransactionNotifier, AddTransactionState, Transaction?>(
|
||||
(initial) => AddTransactionNotifier(initial),
|
||||
);
|
||||
|
||||
class AddTransactionNotifier extends Notifier<AddTransactionState> {
|
||||
AddTransactionNotifier(this._initial);
|
||||
|
||||
final Transaction? _initial;
|
||||
|
||||
@override
|
||||
AddTransactionState build() {
|
||||
return _initial != null
|
||||
? AddTransactionState.fromTransaction(_initial!)
|
||||
: AddTransactionState.empty();
|
||||
}
|
||||
|
||||
void setAmount(double? v) => state = state.copyWith(amount: v);
|
||||
|
||||
@@ -123,15 +134,12 @@ class AddTransactionNotifier extends StateNotifier<AddTransactionState> {
|
||||
void reset() => state = AddTransactionState.empty();
|
||||
}
|
||||
|
||||
final addTransactionProvider = StateNotifierProvider.autoDispose
|
||||
.family<AddTransactionNotifier, AddTransactionState, Transaction?>(
|
||||
(ref, initial) => AddTransactionNotifier(initial),
|
||||
);
|
||||
|
||||
final availableCategoriesProvider = Provider.autoDispose
|
||||
.family<List<String>, Transaction?>((ref, initial) {
|
||||
.family<List<AppCategory>, Transaction?>((ref, initial) {
|
||||
final type = ref.watch(
|
||||
addTransactionProvider(initial).select((s) => s.type),
|
||||
);
|
||||
return AppCategories.forType(type);
|
||||
if (type == TransactionType.transfer) return const [];
|
||||
return ref.watch(categoryCatalogProvider).forType(type);
|
||||
});
|
||||
|
||||
|
||||
@@ -82,7 +82,7 @@ class _AddTransactionScreenState extends ConsumerState<AddTransactionScreen>
|
||||
|
||||
if (widget.initial!.category == 'Transfer') {
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
final allTxs = ref.read(transactionsProvider).valueOrNull ?? [];
|
||||
final allTxs = ref.read(transactionsProvider).value ?? [];
|
||||
|
||||
if (widget.initial!.type == TransactionType.expense) {
|
||||
final counterpart = allTxs.firstWhereOrNull(
|
||||
@@ -271,7 +271,7 @@ class _AddTransactionScreenState extends ConsumerState<AddTransactionScreen>
|
||||
currencyCode: currencyCode,
|
||||
accountId: state.selectedAccountId!,
|
||||
);
|
||||
await ref.read(transactionsProvider.notifier).update(updatedExpense);
|
||||
await ref.read(transactionsProvider.notifier).updateTransaction(updatedExpense);
|
||||
|
||||
if (_transferIncomeRecordId != null) {
|
||||
final updatedIncome = Transaction(
|
||||
@@ -285,7 +285,7 @@ class _AddTransactionScreenState extends ConsumerState<AddTransactionScreen>
|
||||
currencyCode: currencyCode,
|
||||
accountId: state.toAccountId!,
|
||||
);
|
||||
await ref.read(transactionsProvider.notifier).update(updatedIncome);
|
||||
await ref.read(transactionsProvider.notifier).updateTransaction(updatedIncome);
|
||||
}
|
||||
|
||||
if (mounted) context.pop();
|
||||
@@ -349,7 +349,7 @@ class _AddTransactionScreenState extends ConsumerState<AddTransactionScreen>
|
||||
);
|
||||
|
||||
if (state.isEditing) {
|
||||
await ref.read(transactionsProvider.notifier).update(tx);
|
||||
await ref.read(transactionsProvider.notifier).updateTransaction(tx);
|
||||
} else {
|
||||
final res = await ref.read(transactionsProvider.notifier).add(tx);
|
||||
|
||||
@@ -391,12 +391,12 @@ class _AddTransactionScreenState extends ConsumerState<AddTransactionScreen>
|
||||
data: Theme.of(context).copyWith(
|
||||
colorScheme: Theme.of(
|
||||
context,
|
||||
).colorScheme.copyWith(primary: AppColors.accent),
|
||||
).colorScheme.copyWith(primary: const Color(0xFF7C6DED)),
|
||||
),
|
||||
child: child!,
|
||||
),
|
||||
);
|
||||
if (picked != null) {
|
||||
if (picked != null && mounted) {
|
||||
setState(() => _selectedDate = picked);
|
||||
}
|
||||
}
|
||||
@@ -423,7 +423,7 @@ class _AddTransactionScreenState extends ConsumerState<AddTransactionScreen>
|
||||
child: child!,
|
||||
),
|
||||
);
|
||||
if (picked != null) {
|
||||
if (picked != null && mounted) {
|
||||
setState(() => _selectedTime = picked);
|
||||
}
|
||||
}
|
||||
@@ -486,7 +486,7 @@ class _AddTransactionScreenState extends ConsumerState<AddTransactionScreen>
|
||||
.delete(counterpartId);
|
||||
} else {
|
||||
final allTxs =
|
||||
ref.read(transactionsProvider).valueOrNull ??
|
||||
ref.read(transactionsProvider).value ??
|
||||
[];
|
||||
final oppositeType =
|
||||
widget.initial!.type ==
|
||||
@@ -995,7 +995,7 @@ class _ToAccountDropdownOverlay extends ConsumerWidget {
|
||||
const Icon(
|
||||
Icons.check_rounded,
|
||||
size: 16,
|
||||
color: Color(0xFF7C6DED),
|
||||
color: const Color(0xFF7C6DED),
|
||||
),
|
||||
],
|
||||
],
|
||||
|
||||
@@ -41,7 +41,7 @@ class AccountRow extends ConsumerWidget {
|
||||
final s = ref.watch(stringsProvider);
|
||||
final state = ref.watch(addTransactionProvider(initial));
|
||||
final accountsAsync = ref.watch(accountsProvider);
|
||||
final accounts = accountsAsync.valueOrNull ?? [];
|
||||
final accounts = accountsAsync.value ?? [];
|
||||
final isTransfer = state.type == TransactionType.transfer;
|
||||
|
||||
if (isTransfer && accounts.length == 2 && state.selectedAccountId != null) {
|
||||
|
||||
@@ -27,6 +27,9 @@ class AccountSelector extends ConsumerWidget {
|
||||
|
||||
return accountsAsync.when(
|
||||
data: (accounts) {
|
||||
if (accounts.isEmpty) {
|
||||
return const SizedBox.shrink();
|
||||
}
|
||||
final txAccountId = ref
|
||||
.read(addTransactionProvider(initial))
|
||||
.selectedAccountId;
|
||||
@@ -70,7 +73,7 @@ class AccountSelector extends ConsumerWidget {
|
||||
const Icon(
|
||||
Icons.account_balance_wallet_rounded,
|
||||
size: 18,
|
||||
color: Color(0xFF7C6DED),
|
||||
color: const Color(0xFF7C6DED),
|
||||
),
|
||||
const SizedBox(width: 10),
|
||||
Flexible(
|
||||
@@ -241,7 +244,7 @@ class AccountDropdownOverlay extends ConsumerWidget {
|
||||
const Icon(
|
||||
Icons.check_rounded,
|
||||
size: 16,
|
||||
color: Color(0xFF7C6DED),
|
||||
color: const Color(0xFF7C6DED),
|
||||
),
|
||||
],
|
||||
],
|
||||
|
||||
@@ -1,10 +1,14 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import '../../../core/constants.dart';
|
||||
import '../../../core/l10n/app_strings.dart';
|
||||
import '../../../core/l10n/locale_provider.dart';
|
||||
import '../../../core/services/haptic_service.dart';
|
||||
import '../../../shared/models/app_category.dart';
|
||||
|
||||
class CategoryPicker extends ConsumerWidget {
|
||||
final List<String> categories;
|
||||
final List<AppCategory> categories;
|
||||
final String selected;
|
||||
final ValueChanged<String> onChanged;
|
||||
|
||||
@@ -18,61 +22,111 @@ class CategoryPicker extends ConsumerWidget {
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final s = ref.watch(stringsProvider);
|
||||
final isRu = s.locale == AppLocale.ru;
|
||||
final isDark = Theme.of(context).brightness == Brightness.dark;
|
||||
return Wrap(
|
||||
spacing: 8,
|
||||
runSpacing: 8,
|
||||
children: categories.map((cat) {
|
||||
final isSelected = cat == selected;
|
||||
final color = AppCategories.colors[cat] ?? AppColors.accent;
|
||||
final icon = AppCategories.icons[cat] ?? Icons.category_rounded;
|
||||
return GestureDetector(
|
||||
onTap: () => onChanged(cat),
|
||||
child: AnimatedContainer(
|
||||
duration: const Duration(milliseconds: 200),
|
||||
padding: const EdgeInsets.symmetric(horizontal: 14, vertical: 10),
|
||||
decoration: BoxDecoration(
|
||||
color: isSelected
|
||||
? color.withOpacity(0.2)
|
||||
: Theme.of(context).colorScheme.surface,
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
border: isSelected
|
||||
? Border.all(color: color, width: 1.5)
|
||||
: (isDark
|
||||
? null
|
||||
: Border.all(color: const Color(0xFFDDDDEE), width: 1)),
|
||||
),
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Icon(
|
||||
icon,
|
||||
color: isSelected
|
||||
? color
|
||||
: Theme.of(
|
||||
context,
|
||||
).colorScheme.onSurface.withOpacity(0.6),
|
||||
size: 16,
|
||||
),
|
||||
const SizedBox(width: 6),
|
||||
Text(
|
||||
s.categoryLabel(cat),
|
||||
style: Theme.of(context).textTheme.bodySmall?.copyWith(
|
||||
children: [
|
||||
...categories.map((cat) {
|
||||
final isSelected = cat.key == selected;
|
||||
final color = cat.color;
|
||||
return GestureDetector(
|
||||
onTap: () {
|
||||
HapticService.light();
|
||||
onChanged(cat.key);
|
||||
},
|
||||
child: AnimatedContainer(
|
||||
duration: const Duration(milliseconds: 200),
|
||||
padding: const EdgeInsets.symmetric(horizontal: 14, vertical: 10),
|
||||
decoration: BoxDecoration(
|
||||
color: isSelected
|
||||
? color.withOpacity(0.2)
|
||||
: Theme.of(context).colorScheme.surface,
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
border: isSelected
|
||||
? Border.all(color: color, width: 1.5)
|
||||
: (isDark
|
||||
? null
|
||||
: Border.all(
|
||||
color: const Color(0xFFDDDDEE), width: 1)),
|
||||
),
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Icon(
|
||||
cat.icon,
|
||||
color: isSelected
|
||||
? color
|
||||
: Theme.of(
|
||||
context,
|
||||
).colorScheme.onSurface.withOpacity(0.6),
|
||||
fontWeight: isSelected
|
||||
? FontWeight.w600
|
||||
: FontWeight.normal,
|
||||
size: 16,
|
||||
),
|
||||
),
|
||||
],
|
||||
const SizedBox(width: 6),
|
||||
Flexible(
|
||||
child: Text(
|
||||
cat.label(isRu),
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: Theme.of(context).textTheme.bodySmall?.copyWith(
|
||||
color: isSelected
|
||||
? color
|
||||
: Theme.of(context).colorScheme.onSurface.withOpacity(0.6),
|
||||
fontWeight: isSelected
|
||||
? FontWeight.w600
|
||||
: FontWeight.normal,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}).toList(),
|
||||
);
|
||||
}),
|
||||
_AddCategoryChip(label: s.addCategory),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _AddCategoryChip extends StatelessWidget {
|
||||
final String label;
|
||||
|
||||
const _AddCategoryChip({required this.label});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return GestureDetector(
|
||||
onTap: () {
|
||||
HapticService.light();
|
||||
context.push('/settings/categories');
|
||||
},
|
||||
child: Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 14, vertical: 10),
|
||||
decoration: BoxDecoration(
|
||||
color: const Color(0xFF7C6DED).withOpacity(0.12),
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
border: Border.all(
|
||||
color: const Color(0xFF7C6DED).withOpacity(0.5),
|
||||
width: 1,
|
||||
),
|
||||
),
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
const Icon(Icons.add_rounded, color: const Color(0xFF7C6DED), size: 16),
|
||||
const SizedBox(width: 6),
|
||||
Text(
|
||||
label,
|
||||
style: Theme.of(context).textTheme.bodySmall?.copyWith(
|
||||
color: const Color(0xFF7C6DED),
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,7 +43,7 @@ class NoteField extends StatelessWidget {
|
||||
),
|
||||
focusedBorder: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
borderSide: const BorderSide(color: Color(0xFF7C6DED), width: 1.5),
|
||||
borderSide: BorderSide(color: const Color(0xFF7C6DED), width: 1.5),
|
||||
),
|
||||
),
|
||||
onChanged: onChanged,
|
||||
|
||||
@@ -21,7 +21,7 @@ class TypeToggle extends ConsumerWidget {
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final accountsAsync = ref.watch(accountsProvider);
|
||||
final accounts = accountsAsync.valueOrNull ?? [];
|
||||
final accounts = accountsAsync.value ?? [];
|
||||
final transferDisabled = accounts.length <= 1;
|
||||
|
||||
return Container(
|
||||
|
||||
@@ -1,44 +1,227 @@
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import '../../shared/models/account.dart';
|
||||
import '../../shared/models/transaction.dart';
|
||||
import '../dashboard/provider.dart';
|
||||
import '../settings/provider.dart';
|
||||
|
||||
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 {
|
||||
final double income;
|
||||
final double expense;
|
||||
final double balance;
|
||||
final int transactionCount;
|
||||
final double averageIncome;
|
||||
final double averageExpense;
|
||||
|
||||
const StatsSummary({
|
||||
required this.income,
|
||||
required this.expense,
|
||||
required this.balance,
|
||||
required this.transactionCount,
|
||||
required this.averageIncome,
|
||||
required this.averageExpense,
|
||||
});
|
||||
}
|
||||
|
||||
String _resolveTargetCurrency(
|
||||
int activeIndex,
|
||||
List<Account> accounts,
|
||||
String globalCurrency,
|
||||
) {
|
||||
if (activeIndex > 0 && activeIndex <= accounts.length) {
|
||||
return accounts[activeIndex - 1].currency;
|
||||
}
|
||||
return globalCurrency;
|
||||
}
|
||||
|
||||
List<Transaction> _filterScopedTransactions(
|
||||
List<Transaction> txs,
|
||||
StatsTimeFilter timeFilter,
|
||||
) {
|
||||
var filtered = txs.where((t) => t.category != 'Transfer');
|
||||
if (timeFilter == StatsTimeFilter.month) {
|
||||
final now = DateTime.now();
|
||||
filtered = filtered.where(
|
||||
(t) => t.date.year == now.year && t.date.month == now.month,
|
||||
);
|
||||
}
|
||||
return filtered.toList();
|
||||
}
|
||||
|
||||
final statsCurrencyProvider = Provider<CurrencyInfo>((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 txs = ref.watch(accountFilteredTransactionsProvider);
|
||||
final timeFilter = ref.watch(statsTimeFilterProvider);
|
||||
return _filterScopedTransactions(txs, timeFilter);
|
||||
});
|
||||
|
||||
final statsIncomeTotalProvider = Provider<double>((ref) {
|
||||
final exchange = ref.watch(exchangeRateServiceProvider);
|
||||
final index = ref.watch(activeAccountIndexProvider);
|
||||
final accountsAsync = ref.watch(accountsProvider);
|
||||
final globalCurrency = ref.watch(currencyProvider).code;
|
||||
final accounts = accountsAsync.value ?? [];
|
||||
final target = _resolveTargetCurrency(index, accounts, globalCurrency);
|
||||
return ref
|
||||
.watch(statsScopedTransactionsProvider)
|
||||
.where((t) => t.type == TransactionType.income)
|
||||
.fold(0.0, (sum, t) => sum + exchange.convert(t.amount, t.currencyCode, target));
|
||||
});
|
||||
|
||||
final statsExpenseTotalProvider = Provider<double>((ref) {
|
||||
final exchange = ref.watch(exchangeRateServiceProvider);
|
||||
final index = ref.watch(activeAccountIndexProvider);
|
||||
final accountsAsync = ref.watch(accountsProvider);
|
||||
final globalCurrency = ref.watch(currencyProvider).code;
|
||||
final accounts = accountsAsync.value ?? [];
|
||||
final target = _resolveTargetCurrency(index, accounts, globalCurrency);
|
||||
return ref
|
||||
.watch(statsScopedTransactionsProvider)
|
||||
.where((t) => t.type == TransactionType.expense)
|
||||
.fold(0.0, (sum, t) => sum + exchange.convert(t.amount, t.currencyCode, target));
|
||||
});
|
||||
|
||||
final statsSummaryProvider = Provider<StatsSummary>((ref) {
|
||||
final exchange = ref.watch(exchangeRateServiceProvider);
|
||||
final index = ref.watch(activeAccountIndexProvider);
|
||||
final accountsAsync = ref.watch(accountsProvider);
|
||||
final globalCurrency = ref.watch(currencyProvider).code;
|
||||
final accounts = accountsAsync.value ?? [];
|
||||
final target = _resolveTargetCurrency(index, accounts, globalCurrency);
|
||||
final transactions = ref.watch(statsScopedTransactionsProvider);
|
||||
|
||||
var income = 0.0;
|
||||
var expense = 0.0;
|
||||
var incomeCount = 0;
|
||||
var expenseCount = 0;
|
||||
|
||||
for (final transaction in transactions) {
|
||||
final amount = exchange.convert(transaction.amount, transaction.currencyCode, target);
|
||||
if (transaction.type == TransactionType.income) {
|
||||
income += amount;
|
||||
incomeCount++;
|
||||
}
|
||||
if (transaction.type == TransactionType.expense) {
|
||||
expense += amount;
|
||||
expenseCount++;
|
||||
}
|
||||
}
|
||||
|
||||
return StatsSummary(
|
||||
income: income,
|
||||
expense: expense,
|
||||
balance: income - expense,
|
||||
transactionCount: transactions.length,
|
||||
averageIncome: incomeCount == 0 ? 0 : income / incomeCount,
|
||||
averageExpense: expenseCount == 0 ? 0 : expense / expenseCount,
|
||||
);
|
||||
});
|
||||
|
||||
final categoryExpenseProvider = Provider<Map<String, double>>((ref) {
|
||||
final txsAsync = ref.watch(transactionsProvider);
|
||||
final txs = txsAsync.valueOrNull ?? [];
|
||||
final filtered = txs.where((t) => t.type == TransactionType.expense);
|
||||
|
||||
final exchange = ref.watch(exchangeRateServiceProvider);
|
||||
final index = ref.watch(activeAccountIndexProvider);
|
||||
final accountsAsync = ref.watch(accountsProvider);
|
||||
final globalCurrency = ref.watch(currencyProvider).code;
|
||||
final accounts = accountsAsync.value ?? [];
|
||||
final target = _resolveTargetCurrency(index, accounts, globalCurrency);
|
||||
final map = <String, double>{};
|
||||
for (final t in filtered) {
|
||||
map[t.category] = (map[t.category] ?? 0) + t.amount;
|
||||
for (final t in ref.watch(statsScopedTransactionsProvider)) {
|
||||
if (t.type != TransactionType.expense) continue;
|
||||
map[t.category] = (map[t.category] ?? 0) + exchange.convert(t.amount, t.currencyCode, target);
|
||||
}
|
||||
return map;
|
||||
});
|
||||
|
||||
final categoryIncomeProvider = Provider<Map<String, double>>((ref) {
|
||||
final txsAsync = ref.watch(transactionsProvider);
|
||||
final txs = txsAsync.valueOrNull ?? [];
|
||||
final filtered = txs.where((t) => t.type == TransactionType.income);
|
||||
|
||||
final exchange = ref.watch(exchangeRateServiceProvider);
|
||||
final index = ref.watch(activeAccountIndexProvider);
|
||||
final accountsAsync = ref.watch(accountsProvider);
|
||||
final globalCurrency = ref.watch(currencyProvider).code;
|
||||
final accounts = accountsAsync.value ?? [];
|
||||
final target = _resolveTargetCurrency(index, accounts, globalCurrency);
|
||||
final map = <String, double>{};
|
||||
for (final t in filtered) {
|
||||
map[t.category] = (map[t.category] ?? 0) + t.amount;
|
||||
for (final t in ref.watch(statsScopedTransactionsProvider)) {
|
||||
if (t.type != TransactionType.income) continue;
|
||||
map[t.category] = (map[t.category] ?? 0) + exchange.convert(t.amount, t.currencyCode, target);
|
||||
}
|
||||
return map;
|
||||
});
|
||||
|
||||
final monthlyBreakdownProvider = Provider<List<MonthlyData>>((ref) {
|
||||
final txsAsync = ref.watch(transactionsProvider);
|
||||
final txs = txsAsync.valueOrNull ?? [];
|
||||
final filtered = txs.where((t) => t.type == TransactionType.expense);
|
||||
|
||||
final txs = ref.watch(accountFilteredTransactionsProvider);
|
||||
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 now = DateTime.now();
|
||||
final months = <MonthlyData>[];
|
||||
|
||||
for (var i = 5; i >= 0; i--) {
|
||||
final month = DateTime(now.year, now.month - i, 1);
|
||||
final total = filtered
|
||||
.where((t) => t.date.year == month.year && t.date.month == month.month)
|
||||
.fold(0.0, (sum, t) => sum + t.amount);
|
||||
final total = txs
|
||||
.where(
|
||||
(t) =>
|
||||
t.type == TransactionType.expense &&
|
||||
t.category != 'Transfer' &&
|
||||
t.date.year == month.year &&
|
||||
t.date.month == month.month,
|
||||
)
|
||||
.fold(0.0, (sum, t) {
|
||||
return sum + exchange.convert(t.amount, t.currencyCode, target);
|
||||
});
|
||||
months.add(MonthlyData(month: month, amount: total));
|
||||
}
|
||||
|
||||
return months;
|
||||
});
|
||||
|
||||
final monthlyIncomeBreakdownProvider = Provider<List<MonthlyData>>((ref) {
|
||||
final txs = ref.watch(accountFilteredTransactionsProvider);
|
||||
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 now = DateTime.now();
|
||||
final months = <MonthlyData>[];
|
||||
|
||||
for (var i = 5; i >= 0; i--) {
|
||||
final month = DateTime(now.year, now.month - i, 1);
|
||||
final total = txs
|
||||
.where(
|
||||
(t) =>
|
||||
t.type == TransactionType.income &&
|
||||
t.category != 'Transfer' &&
|
||||
t.date.year == month.year &&
|
||||
t.date.month == month.month,
|
||||
)
|
||||
.fold(0.0, (sum, t) {
|
||||
return sum + exchange.convert(t.amount, t.currencyCode, target);
|
||||
});
|
||||
months.add(MonthlyData(month: month, amount: total));
|
||||
}
|
||||
|
||||
|
||||
+912
-507
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,115 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import '../../../core/constants.dart';
|
||||
import '../../../core/l10n/locale_provider.dart';
|
||||
import '../../../core/services/haptic_service.dart';
|
||||
import '../../dashboard/provider.dart';
|
||||
|
||||
class AccountScopeChips extends ConsumerWidget {
|
||||
const AccountScopeChips({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final s = ref.watch(stringsProvider);
|
||||
final accountsAsync = ref.watch(accountsProvider);
|
||||
final activeIndex = ref.watch(activeAccountIndexProvider);
|
||||
final isDark = Theme.of(context).brightness == Brightness.dark;
|
||||
|
||||
return accountsAsync.when(
|
||||
data: (accounts) {
|
||||
if (accounts.isEmpty) return const SizedBox.shrink();
|
||||
|
||||
return SingleChildScrollView(
|
||||
scrollDirection: Axis.horizontal,
|
||||
clipBehavior: Clip.none,
|
||||
child: Row(
|
||||
children: [
|
||||
_ScopeChip(
|
||||
label: s.allAccounts,
|
||||
isSelected: activeIndex == 0,
|
||||
isDark: isDark,
|
||||
onTap: () {
|
||||
ref.read(activeAccountIndexProvider.notifier).set(0);
|
||||
HapticService.selection();
|
||||
},
|
||||
),
|
||||
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) {
|
||||
final index = entry.key + 1;
|
||||
final account = entry.value;
|
||||
return Padding(
|
||||
padding: const EdgeInsets.only(right: 6),
|
||||
child: _ScopeChip(
|
||||
label: account.name,
|
||||
isSelected: activeIndex == index,
|
||||
isDark: isDark,
|
||||
onTap: () {
|
||||
ref.read(activeAccountIndexProvider.notifier).set(index);
|
||||
HapticService.selection();
|
||||
},
|
||||
),
|
||||
);
|
||||
}),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
loading: () => const SizedBox.shrink(),
|
||||
error: (_, __) => const SizedBox.shrink(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _ScopeChip extends StatelessWidget {
|
||||
final String label;
|
||||
final bool isSelected;
|
||||
final bool isDark;
|
||||
final VoidCallback onTap;
|
||||
|
||||
const _ScopeChip({
|
||||
required this.label,
|
||||
required this.isSelected,
|
||||
required this.isDark,
|
||||
required this.onTap,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return GestureDetector(
|
||||
onTap: onTap,
|
||||
child: AnimatedContainer(
|
||||
duration: const Duration(milliseconds: 200),
|
||||
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 6),
|
||||
decoration: BoxDecoration(
|
||||
color: isSelected
|
||||
? const Color(0xFF7C6DED).withOpacity(0.2)
|
||||
: Theme.of(context).colorScheme.surface,
|
||||
borderRadius: BorderRadius.circular(20),
|
||||
border: isSelected
|
||||
? Border.all(color: const Color(0xFF7C6DED), width: 1.5)
|
||||
: isDark
|
||||
? null
|
||||
: Border.all(color: const Color(0xFFDDDDEE), width: 1),
|
||||
),
|
||||
child: Text(
|
||||
label,
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
fontWeight: isSelected ? FontWeight.w600 : FontWeight.normal,
|
||||
color: isSelected
|
||||
? const Color(0xFF7C6DED)
|
||||
: Theme.of(context).colorScheme.onSurface.withOpacity(0.6),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -7,6 +7,7 @@ import '../../core/utils/result.dart';
|
||||
import '../../data/database/app_database.dart' as db;
|
||||
import '../../data/repositories/transaction_repository.dart';
|
||||
import '../../data/repositories/account_repository.dart';
|
||||
import '../../shared/feature_flags/feature_flags_provider.dart';
|
||||
import '../../shared/models/transaction.dart';
|
||||
import '../../shared/models/account.dart';
|
||||
import '../../shared/services/storage_service.dart';
|
||||
@@ -27,7 +28,7 @@ final transactionRepositoryProvider = Provider<TransactionRepository>((ref) {
|
||||
|
||||
final accountRepositoryProvider = Provider<AccountRepository>((ref) {
|
||||
final db = ref.watch(appDatabaseProvider);
|
||||
return AccountRepository(db);
|
||||
return AccountRepository(db, () => ref.read(featureFlagsProvider));
|
||||
});
|
||||
|
||||
final storageServiceProvider = Provider<StorageService>((ref) {
|
||||
@@ -35,77 +36,76 @@ final storageServiceProvider = Provider<StorageService>((ref) {
|
||||
});
|
||||
|
||||
final transactionsProvider =
|
||||
StateNotifierProvider<TransactionsNotifier, AsyncValue<List<Transaction>>>((
|
||||
ref,
|
||||
) {
|
||||
final repository = ref.watch(transactionRepositoryProvider);
|
||||
return TransactionsNotifier(repository);
|
||||
});
|
||||
AsyncNotifierProvider<TransactionsNotifier, List<Transaction>>(
|
||||
TransactionsNotifier.new,
|
||||
);
|
||||
|
||||
class TransactionsNotifier
|
||||
extends StateNotifier<AsyncValue<List<Transaction>>> {
|
||||
final TransactionRepository _repository;
|
||||
class TransactionsNotifier extends AsyncNotifier<List<Transaction>> {
|
||||
@override
|
||||
Future<List<Transaction>> build() async {
|
||||
final repository = ref.watch(transactionRepositoryProvider);
|
||||
final result = await repository.getAll();
|
||||
|
||||
TransactionsNotifier(this._repository) : super(const AsyncValue.loading()) {
|
||||
_load();
|
||||
}
|
||||
|
||||
Future<void> _load() async {
|
||||
state = const AsyncValue.loading();
|
||||
final result = await _repository.getAll();
|
||||
|
||||
state = result.isSuccess
|
||||
? AsyncValue.data(result.dataOrNull!)
|
||||
: AsyncValue.error(result.errorOrNull!, StackTrace.current);
|
||||
if (result.isSuccess) {
|
||||
return result.dataOrNull!;
|
||||
} else {
|
||||
throw result.errorOrNull!;
|
||||
}
|
||||
}
|
||||
|
||||
Future<Result<void>> add(Transaction transaction) async {
|
||||
final result = await _repository.add(transaction);
|
||||
final repository = ref.read(transactionRepositoryProvider);
|
||||
final result = await repository.add(transaction);
|
||||
|
||||
if (result.isSuccess) {
|
||||
await _load();
|
||||
ref.invalidateSelf();
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
Future<Result<void>> update(Transaction transaction) async {
|
||||
final result = await _repository.update(transaction);
|
||||
Future<Result<void>> updateTransaction(Transaction transaction) async {
|
||||
final repository = ref.read(transactionRepositoryProvider);
|
||||
final result = await repository.update(transaction);
|
||||
|
||||
if (result.isSuccess) {
|
||||
await _load();
|
||||
ref.invalidateSelf();
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
Future<Result<void>> delete(String id) async {
|
||||
final result = await _repository.delete(id);
|
||||
final repository = ref.read(transactionRepositoryProvider);
|
||||
final result = await repository.delete(id);
|
||||
|
||||
if (result.isSuccess) {
|
||||
await _load();
|
||||
ref.invalidateSelf();
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
Future<void> restore(Transaction transaction) async {
|
||||
await _repository.add(transaction);
|
||||
await _load();
|
||||
final repository = ref.read(transactionRepositoryProvider);
|
||||
await repository.add(transaction);
|
||||
ref.invalidateSelf();
|
||||
}
|
||||
|
||||
Future<void> clearAll() async {
|
||||
await _repository.deleteAll();
|
||||
final repository = ref.read(transactionRepositoryProvider);
|
||||
await repository.deleteAll();
|
||||
state = const AsyncValue.data([]);
|
||||
}
|
||||
|
||||
Future<void> refresh() async {
|
||||
await _load();
|
||||
ref.invalidateSelf();
|
||||
}
|
||||
}
|
||||
|
||||
final transferPairsProvider = Provider<Map<String, Transaction>>((ref) {
|
||||
final txs = ref.watch(transactionsProvider).valueOrNull ?? [];
|
||||
final txsAsync = ref.watch(transactionsProvider);
|
||||
final txs = txsAsync.value ?? [];
|
||||
final transfers = txs.where((t) => t.category == 'Transfer').toList();
|
||||
final Map<String, Transaction> pairs = {};
|
||||
|
||||
@@ -131,24 +131,47 @@ final transferPairsProvider = Provider<Map<String, Transaction>>((ref) {
|
||||
return pairs;
|
||||
});
|
||||
|
||||
final searchQueryProvider = StateProvider<String>((ref) => '');
|
||||
final searchQueryProvider = NotifierProvider<_SearchQueryNotifier, String>(
|
||||
_SearchQueryNotifier.new,
|
||||
);
|
||||
|
||||
class _SearchQueryNotifier extends Notifier<String> {
|
||||
@override
|
||||
String build() => '';
|
||||
|
||||
void set(String v) => state = v;
|
||||
}
|
||||
|
||||
enum TransactionFilter { all, income, expense, transfer }
|
||||
|
||||
enum TimeFilter { allTime, lastMonth }
|
||||
|
||||
final transactionFilterProvider = StateProvider<TransactionFilter>(
|
||||
(ref) => TransactionFilter.all,
|
||||
final transactionFilterProvider = NotifierProvider<_TransactionFilterNotifier, TransactionFilter>(
|
||||
_TransactionFilterNotifier.new,
|
||||
);
|
||||
|
||||
final timeFilterProvider = StateProvider<TimeFilter>(
|
||||
(ref) => TimeFilter.lastMonth,
|
||||
class _TransactionFilterNotifier extends Notifier<TransactionFilter> {
|
||||
@override
|
||||
TransactionFilter build() => TransactionFilter.all;
|
||||
|
||||
void set(TransactionFilter v) => state = v;
|
||||
}
|
||||
|
||||
final timeFilterProvider = NotifierProvider<_TimeFilterNotifier, TimeFilter>(
|
||||
_TimeFilterNotifier.new,
|
||||
);
|
||||
|
||||
class _TimeFilterNotifier extends Notifier<TimeFilter> {
|
||||
@override
|
||||
TimeFilter build() => TimeFilter.lastMonth;
|
||||
|
||||
void set(TimeFilter v) => state = v;
|
||||
}
|
||||
|
||||
final accountFilteredTransactionsProvider = Provider<List<Transaction>>((ref) {
|
||||
final txsAsync = ref.watch(transactionsProvider);
|
||||
final txs = txsAsync.valueOrNull ?? [];
|
||||
final activeAccount = ref.watch(activeAccountProvider);
|
||||
final txsAsync = ref.watch(transactionsProvider);
|
||||
final txs = txsAsync.value ?? [];
|
||||
|
||||
if (activeAccount == null) {
|
||||
return txs;
|
||||
@@ -158,7 +181,7 @@ final accountFilteredTransactionsProvider = Provider<List<Transaction>>((ref) {
|
||||
});
|
||||
|
||||
final globalTotalBalanceProvider = Provider<double>((ref) {
|
||||
final txs = ref.watch(transactionsProvider).valueOrNull ?? [];
|
||||
final txs = ref.watch(transactionsProvider).value ?? [];
|
||||
final exchangeService = ref.watch(exchangeRateServiceProvider);
|
||||
final targetCurrency = ref.watch(currencyProvider).code;
|
||||
|
||||
@@ -181,7 +204,7 @@ final totalBalanceProvider = Provider<double>((ref) {
|
||||
|
||||
String targetCurrency = globalCurrency;
|
||||
if (index > 0) {
|
||||
final accounts = accountsAsync.valueOrNull ?? [];
|
||||
final accounts = accountsAsync.value ?? [];
|
||||
if (index <= accounts.length) {
|
||||
targetCurrency = accounts[index - 1].currency;
|
||||
}
|
||||
@@ -211,7 +234,7 @@ final totalIncomeProvider = Provider<double>((ref) {
|
||||
|
||||
String targetCurrency = globalCurrency;
|
||||
if (index > 0) {
|
||||
final accounts = accountsAsync.valueOrNull ?? [];
|
||||
final accounts = accountsAsync.value ?? [];
|
||||
if (index <= accounts.length) {
|
||||
targetCurrency = accounts[index - 1].currency;
|
||||
}
|
||||
@@ -237,37 +260,7 @@ final totalExpenseProvider = Provider<double>((ref) {
|
||||
|
||||
String targetCurrency = globalCurrency;
|
||||
if (index > 0) {
|
||||
final accounts = accountsAsync.valueOrNull ?? [];
|
||||
if (index <= accounts.length) {
|
||||
targetCurrency = accounts[index - 1].currency;
|
||||
}
|
||||
}
|
||||
|
||||
final exchangeService = ref.watch(exchangeRateServiceProvider);
|
||||
|
||||
return filtered.fold(0.0, (sum, t) {
|
||||
return sum +
|
||||
exchangeService.convert(t.amount, t.currencyCode, targetCurrency);
|
||||
});
|
||||
});
|
||||
|
||||
final currentMonthExpenseProvider = Provider<double>((ref) {
|
||||
final now = DateTime.now();
|
||||
final txs = ref.watch(accountFilteredTransactionsProvider);
|
||||
final filtered = txs.where(
|
||||
(t) =>
|
||||
t.type == TransactionType.expense &&
|
||||
t.date.year == now.year &&
|
||||
t.date.month == now.month,
|
||||
);
|
||||
|
||||
final index = ref.watch(activeAccountIndexProvider);
|
||||
final accountsAsync = ref.watch(accountsProvider);
|
||||
final globalCurrency = ref.watch(currencyProvider).code;
|
||||
|
||||
String targetCurrency = globalCurrency;
|
||||
if (index > 0) {
|
||||
final accounts = accountsAsync.valueOrNull ?? [];
|
||||
final accounts = accountsAsync.value ?? [];
|
||||
if (index <= accounts.length) {
|
||||
targetCurrency = accounts[index - 1].currency;
|
||||
}
|
||||
@@ -341,15 +334,21 @@ final recentTransactionsProvider = Provider<List<Transaction>>((ref) {
|
||||
return ref.watch(filteredTransactionsProvider).take(20).toList();
|
||||
});
|
||||
|
||||
final accountsProvider = StreamProvider<List<Account>>((ref) async* {
|
||||
final accountsProvider = StreamProvider<List<Account>>((ref) {
|
||||
final repository = ref.watch(accountRepositoryProvider);
|
||||
while (true) {
|
||||
yield await repository.getAll();
|
||||
await Future.delayed(const Duration(milliseconds: 100));
|
||||
}
|
||||
return repository.watchAll();
|
||||
});
|
||||
|
||||
final activeAccountIndexProvider = StateProvider<int>((ref) => 0);
|
||||
final activeAccountIndexProvider = NotifierProvider<_ActiveAccountIndexNotifier, int>(
|
||||
_ActiveAccountIndexNotifier.new,
|
||||
);
|
||||
|
||||
class _ActiveAccountIndexNotifier extends Notifier<int> {
|
||||
@override
|
||||
int build() => 0;
|
||||
|
||||
void set(int v) => state = v;
|
||||
}
|
||||
|
||||
final activeAccountProvider = Provider<Account?>((ref) {
|
||||
final index = ref.watch(activeAccountIndexProvider);
|
||||
@@ -387,52 +386,37 @@ class CardColors {
|
||||
}
|
||||
|
||||
final cardColorsProvider =
|
||||
StateNotifierProvider<CardColorsNotifier, CardColors>((ref) {
|
||||
final notifier = CardColorsNotifier();
|
||||
notifier.setupThemeListener(ref);
|
||||
return notifier;
|
||||
});
|
||||
NotifierProvider<CardColorsNotifier, CardColors>(
|
||||
CardColorsNotifier.new,
|
||||
);
|
||||
|
||||
final accountCardColorsProvider =
|
||||
StateNotifierProvider.family<CardColorsNotifier, CardColors, int>((
|
||||
ref,
|
||||
accountId,
|
||||
) {
|
||||
final notifier = CardColorsNotifier(accountId: accountId);
|
||||
notifier.setupThemeListener(ref);
|
||||
return notifier;
|
||||
});
|
||||
|
||||
class CardColorsNotifier extends StateNotifier<CardColors> {
|
||||
final int? accountId;
|
||||
|
||||
CardColorsNotifier({this.accountId})
|
||||
: super(
|
||||
const CardColors(
|
||||
CardColorService.defaultPrimary,
|
||||
CardColorService.defaultSecondary,
|
||||
CardColorService.defaultGradientLight,
|
||||
CardColorService.defaultGradientDark,
|
||||
),
|
||||
) {
|
||||
_load();
|
||||
}
|
||||
NotifierProvider.family<AccountCardColorsNotifier, CardColors, int>(
|
||||
(accountId) => AccountCardColorsNotifier(accountId),
|
||||
);
|
||||
|
||||
class CardColorsNotifier extends Notifier<CardColors> {
|
||||
int _loadGeneration = 0;
|
||||
|
||||
void setupThemeListener(Ref ref) {
|
||||
@override
|
||||
CardColors build() {
|
||||
ref.listen<ThemeMode>(themeProvider, (previous, next) {
|
||||
if (previous != null) {
|
||||
_onThemeChanged(previous, next);
|
||||
}
|
||||
});
|
||||
_load();
|
||||
return const CardColors(
|
||||
CardColorService.defaultPrimary,
|
||||
CardColorService.defaultSecondary,
|
||||
CardColorService.defaultGradientLight,
|
||||
CardColorService.defaultGradientDark,
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> _load() async {
|
||||
final currentGeneration = ++_loadGeneration;
|
||||
final (c1, c2, lightG, darkG) = await CardColorService.load(
|
||||
accountId: accountId,
|
||||
);
|
||||
final (c1, c2, lightG, darkG) = await CardColorService.load();
|
||||
if (currentGeneration != _loadGeneration) return;
|
||||
state = CardColors(c1, c2, lightG, darkG);
|
||||
}
|
||||
@@ -450,7 +434,6 @@ class CardColorsNotifier extends StateNotifier<CardColors> {
|
||||
secondary,
|
||||
lightGradient,
|
||||
darkGradient,
|
||||
accountId: accountId,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -473,7 +456,127 @@ class CardColorsNotifier extends StateNotifier<CardColors> {
|
||||
secondary,
|
||||
CardColorService.defaultGradientLight,
|
||||
CardColorService.defaultGradientDark,
|
||||
accountId: accountId,
|
||||
);
|
||||
}
|
||||
|
||||
void _onThemeChanged(ThemeMode previous, ThemeMode next) {
|
||||
final previousBrightness = _resolve(previous);
|
||||
final nextBrightness = _resolve(next);
|
||||
|
||||
if (previousBrightness == nextBrightness) return;
|
||||
|
||||
final oldDefaults = _defaultsFor(previousBrightness);
|
||||
final newDefaults = _defaultsFor(nextBrightness);
|
||||
|
||||
final isUsingOldDefaults =
|
||||
state.primary == oldDefaults.primary &&
|
||||
state.secondary == oldDefaults.secondary &&
|
||||
state.gradientTypeForBrightness(previousBrightness) ==
|
||||
oldDefaults.gradient;
|
||||
|
||||
if (isUsingOldDefaults) {
|
||||
_loadGeneration++;
|
||||
state = CardColors(
|
||||
newDefaults.primary,
|
||||
newDefaults.secondary,
|
||||
state.lightGradientType,
|
||||
state.darkGradientType,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Brightness _resolve(ThemeMode mode) {
|
||||
if (mode == ThemeMode.system) {
|
||||
return WidgetsBinding.instance.platformDispatcher.platformBrightness;
|
||||
}
|
||||
return mode == ThemeMode.dark ? Brightness.dark : Brightness.light;
|
||||
}
|
||||
|
||||
({Color primary, Color secondary, GradientType gradient}) _defaultsFor(
|
||||
Brightness brightness,
|
||||
) {
|
||||
return brightness == Brightness.dark
|
||||
? (
|
||||
primary: CardColorService.defaultPrimary,
|
||||
secondary: CardColorService.defaultSecondary,
|
||||
gradient: CardColorService.defaultGradientDark,
|
||||
)
|
||||
: (
|
||||
primary: CardColorService.defaultPrimaryLight,
|
||||
secondary: CardColorService.defaultSecondaryLight,
|
||||
gradient: CardColorService.defaultGradientLight,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class AccountCardColorsNotifier extends Notifier<CardColors> {
|
||||
AccountCardColorsNotifier(this._accountId);
|
||||
|
||||
final int _accountId;
|
||||
int _loadGeneration = 0;
|
||||
|
||||
@override
|
||||
CardColors build() {
|
||||
ref.listen<ThemeMode>(themeProvider, (previous, next) {
|
||||
if (previous != null) {
|
||||
_onThemeChanged(previous, next);
|
||||
}
|
||||
});
|
||||
_load(_accountId);
|
||||
return const CardColors(
|
||||
CardColorService.defaultPrimary,
|
||||
CardColorService.defaultSecondary,
|
||||
CardColorService.defaultGradientLight,
|
||||
CardColorService.defaultGradientDark,
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> _load(int accountId) async {
|
||||
final currentGeneration = ++_loadGeneration;
|
||||
final (c1, c2, lightG, darkG) = await CardColorService.load(
|
||||
accountId: accountId,
|
||||
);
|
||||
if (currentGeneration != _loadGeneration) return;
|
||||
state = CardColors(c1, c2, lightG, darkG);
|
||||
}
|
||||
|
||||
Future<void> save(
|
||||
Color primary,
|
||||
Color secondary,
|
||||
GradientType lightGradient,
|
||||
GradientType darkGradient,
|
||||
) async {
|
||||
_loadGeneration++;
|
||||
state = CardColors(primary, secondary, lightGradient, darkGradient);
|
||||
await CardColorService.save(
|
||||
primary,
|
||||
secondary,
|
||||
lightGradient,
|
||||
darkGradient,
|
||||
accountId: _accountId,
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> reset(bool isDark) async {
|
||||
final primary = isDark
|
||||
? CardColorService.defaultPrimary
|
||||
: CardColorService.defaultPrimaryLight;
|
||||
final secondary = isDark
|
||||
? CardColorService.defaultSecondary
|
||||
: CardColorService.defaultSecondaryLight;
|
||||
_loadGeneration++;
|
||||
state = CardColors(
|
||||
primary,
|
||||
secondary,
|
||||
CardColorService.defaultGradientLight,
|
||||
CardColorService.defaultGradientDark,
|
||||
);
|
||||
await CardColorService.save(
|
||||
primary,
|
||||
secondary,
|
||||
CardColorService.defaultGradientLight,
|
||||
CardColorService.defaultGradientDark,
|
||||
accountId: _accountId,
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -5,12 +5,13 @@ import 'package:intl/intl.dart';
|
||||
import '../../core/l10n/locale_provider.dart';
|
||||
import '../../core/services/card_color_service.dart';
|
||||
import '../../core/services/haptic_service.dart';
|
||||
import '../../data/repositories/account_repository.dart';
|
||||
import '../../shared/models/account.dart';
|
||||
import '../../shared/feature_flags/feature_flags_provider.dart';
|
||||
import '../settings/provider.dart';
|
||||
import 'provider.dart';
|
||||
import 'widgets/account_editor_overlay/account_editor_overlay.dart';
|
||||
import 'widgets/balance_card_carousel.dart';
|
||||
import 'widgets/budget_progress.dart';
|
||||
import 'widgets/color_editor_overlay.dart';
|
||||
import 'widgets/filter_chips.dart';
|
||||
import 'widgets/search_bar.dart' as custom;
|
||||
@@ -57,6 +58,7 @@ class _DashboardScreenState extends ConsumerState<DashboardScreen> {
|
||||
bool isAddingAccount = false;
|
||||
|
||||
void _onCardLongPress() {
|
||||
if (!ref.read(featureFlagsProvider).canEditCardColors) return;
|
||||
final colors = ref.read(cardColorsProvider);
|
||||
savedPrimary = colors.primary;
|
||||
savedSecondary = colors.secondary;
|
||||
@@ -180,15 +182,25 @@ class _DashboardScreenState extends ConsumerState<DashboardScreen> {
|
||||
createdAt: DateTime.now(),
|
||||
);
|
||||
|
||||
final newId = await ref.read(accountRepositoryProvider).add(newAccount);
|
||||
try {
|
||||
final newId = await ref.read(accountRepositoryProvider).add(newAccount);
|
||||
|
||||
await CardColorService.save(
|
||||
tempPrimary,
|
||||
tempSecondary,
|
||||
tempLightGradientType,
|
||||
tempDarkGradientType,
|
||||
accountId: newId,
|
||||
);
|
||||
await CardColorService.save(
|
||||
tempPrimary,
|
||||
tempSecondary,
|
||||
tempLightGradientType,
|
||||
tempDarkGradientType,
|
||||
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) {
|
||||
await ref
|
||||
.read(accountCardColorsProvider(editingAccount!.id).notifier)
|
||||
@@ -223,6 +235,7 @@ class _DashboardScreenState extends ConsumerState<DashboardScreen> {
|
||||
});
|
||||
}
|
||||
|
||||
if (!mounted) return;
|
||||
overlayEntry?.remove();
|
||||
overlayEntry = null;
|
||||
setState(() {
|
||||
@@ -266,8 +279,6 @@ class _DashboardScreenState extends ConsumerState<DashboardScreen> {
|
||||
final balance = ref.watch(totalBalanceProvider);
|
||||
final income = ref.watch(totalIncomeProvider);
|
||||
final expense = ref.watch(totalExpenseProvider);
|
||||
final monthExpense = ref.watch(currentMonthExpenseProvider);
|
||||
final budget = ref.watch(budgetProvider);
|
||||
final recent = ref.watch(recentTransactionsProvider);
|
||||
final activeAccount = ref.watch(activeAccountProvider);
|
||||
final globalCurrencyInfo = ref.watch(currencyProvider);
|
||||
@@ -280,9 +291,10 @@ class _DashboardScreenState extends ConsumerState<DashboardScreen> {
|
||||
|
||||
final activeIndex = ref.watch(activeAccountIndexProvider);
|
||||
final accountsAsync = ref.watch(accountsProvider);
|
||||
final accountCount = accountsAsync.valueOrNull?.length ?? 0;
|
||||
final accountCount = accountsAsync.value?.length ?? 0;
|
||||
final maxAccounts = ref.watch(featureFlagsProvider).maxAccounts;
|
||||
final isOnAddAccountPage =
|
||||
accountCount < 5 && activeIndex == accountCount + 1;
|
||||
accountCount < maxAccounts && activeIndex == accountCount + 1;
|
||||
|
||||
return Scaffold(
|
||||
backgroundColor: Theme.of(context).scaffoldBackgroundColor,
|
||||
@@ -291,13 +303,32 @@ class _DashboardScreenState extends ConsumerState<DashboardScreen> {
|
||||
elevation: 0,
|
||||
scrolledUnderElevation: 0,
|
||||
titleSpacing: 20,
|
||||
title: Text(
|
||||
'Casha',
|
||||
style: Theme.of(context).textTheme.headlineMedium?.copyWith(
|
||||
fontWeight: FontWeight.w800,
|
||||
color: Theme.of(context).colorScheme.onSurface,
|
||||
letterSpacing: -0.5,
|
||||
),
|
||||
title: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Text(
|
||||
'Casha',
|
||||
style: Theme.of(context).textTheme.headlineMedium?.copyWith(
|
||||
fontWeight: FontWeight.w800,
|
||||
color: Theme.of(context).colorScheme.onSurface,
|
||||
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: [
|
||||
Padding(
|
||||
@@ -376,15 +407,6 @@ class _DashboardScreenState extends ConsumerState<DashboardScreen> {
|
||||
currencyInfo: currencyInfo,
|
||||
strings: s,
|
||||
),
|
||||
if (budget != null) ...[
|
||||
const SizedBox(height: 16),
|
||||
BudgetProgress(
|
||||
spent: monthExpense,
|
||||
budget: budget,
|
||||
currencyInfo: currencyInfo,
|
||||
strings: s,
|
||||
),
|
||||
],
|
||||
const SizedBox(height: 24),
|
||||
custom.SearchBar(
|
||||
controller: _searchController,
|
||||
@@ -449,6 +471,7 @@ class _AccountsInfoBlock extends ConsumerWidget {
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final s = ref.watch(stringsProvider);
|
||||
final maxAccounts = ref.watch(featureFlagsProvider).maxAccounts;
|
||||
final onSurface = Theme.of(context).colorScheme.onSurface;
|
||||
return Padding(
|
||||
padding: const EdgeInsets.only(bottom: 60),
|
||||
@@ -464,7 +487,7 @@ class _AccountsInfoBlock extends ConsumerWidget {
|
||||
const Icon(
|
||||
Icons.account_balance_wallet_rounded,
|
||||
size: 18,
|
||||
color: Color(0xFF7C6DED),
|
||||
color: const Color(0xFF7C6DED),
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
Text(
|
||||
@@ -490,7 +513,7 @@ class _AccountsInfoBlock extends ConsumerWidget {
|
||||
const SizedBox(height: 8),
|
||||
_InfoRow(
|
||||
icon: Icons.lock_outline_rounded,
|
||||
text: s.accountsInfoLimit,
|
||||
text: s.accountsLimitLabel(maxAccounts),
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
+145
-40
@@ -2,8 +2,13 @@ import 'dart:ui';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.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 '../../../../shared/models/account.dart';
|
||||
import '../../../../shared/models/transaction.dart';
|
||||
import '../../../../shared/feature_flags/feature_flags_provider.dart';
|
||||
import '../../../../shared/widgets/byn_sign.dart';
|
||||
import '../../../settings/provider.dart';
|
||||
import '../../provider.dart';
|
||||
@@ -58,9 +63,7 @@ class _AccountEditorOverlayState extends State<AccountEditorOverlay> {
|
||||
return;
|
||||
}
|
||||
|
||||
dash.setState(() {
|
||||
dash.tempAccountName = _nameController.text;
|
||||
});
|
||||
dash.tempAccountName = _nameController.text;
|
||||
dash.overlayEntry?.markNeedsBuild();
|
||||
});
|
||||
}
|
||||
@@ -84,16 +87,18 @@ class _AccountEditorOverlayState extends State<AccountEditorOverlay> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final mq = MediaQuery.of(widget.context);
|
||||
final cardTop = mq.padding.top + kToolbarHeight + 16;
|
||||
const cardHeight = 230.0;
|
||||
const editorPanelHeight = 102.0;
|
||||
final editorPanelTop = cardTop + cardHeight + 20;
|
||||
final colorPanelTop = editorPanelTop + editorPanelHeight + 12;
|
||||
const colorPanelHeight = 410.0;
|
||||
final layout = CardOverlayLayout.fromMediaQuery(mq);
|
||||
final cardTop = layout.cardTop;
|
||||
final editorPanelHeight = layout.editorPanelHeight;
|
||||
|
||||
return Consumer(
|
||||
builder: (context, ref, _) {
|
||||
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;
|
||||
if (!dash.isAddingAccount) {
|
||||
@@ -218,6 +223,7 @@ class _AccountEditorOverlayState extends State<AccountEditorOverlay> {
|
||||
Brightness.dark
|
||||
? dash.tempDarkGradientType
|
||||
: dash.tempLightGradientType,
|
||||
cardHeight: cardHeight,
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -246,35 +252,136 @@ class _AccountEditorOverlayState extends State<AccountEditorOverlay> {
|
||||
),
|
||||
),
|
||||
),
|
||||
Positioned(
|
||||
top: colorPanelTop,
|
||||
left: 20,
|
||||
right: 20,
|
||||
child: GestureDetector(
|
||||
onTap: () {
|
||||
if (_showCurrencyDropdown) {
|
||||
setState(() {
|
||||
_showCurrencyDropdown = false;
|
||||
});
|
||||
}
|
||||
},
|
||||
behavior: HitTestBehavior.opaque,
|
||||
child: AccountColorPanel(
|
||||
dashboardState: dash,
|
||||
dashboardContext: widget.context,
|
||||
panelHeight: colorPanelHeight,
|
||||
isDuplicateName: _isDuplicateName,
|
||||
onDuplicateError: () {
|
||||
setState(() => _showDuplicateError = true);
|
||||
Future.delayed(const Duration(seconds: 3), () {
|
||||
if (mounted) {
|
||||
setState(() => _showDuplicateError = false);
|
||||
}
|
||||
});
|
||||
if (isPremium) ...[
|
||||
Positioned(
|
||||
top: colorPanelTop,
|
||||
left: 20,
|
||||
right: 20,
|
||||
child: GestureDetector(
|
||||
onTap: () {
|
||||
if (_showCurrencyDropdown) {
|
||||
setState(() {
|
||||
_showCurrencyDropdown = false;
|
||||
});
|
||||
}
|
||||
},
|
||||
behavior: HitTestBehavior.opaque,
|
||||
child: AccountColorPanel(
|
||||
dashboardState: dash,
|
||||
dashboardContext: widget.context,
|
||||
panelHeight: colorPanelHeight,
|
||||
layout: layout,
|
||||
isDuplicateName: _isDuplicateName,
|
||||
onDuplicateError: () {
|
||||
setState(() => _showDuplicateError = true);
|
||||
Future.delayed(const Duration(seconds: 3), () {
|
||||
if (mounted) {
|
||||
setState(() => _showDuplicateError = false);
|
||||
}
|
||||
});
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
] 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)
|
||||
Positioned(
|
||||
top: editorPanelTop + 62,
|
||||
@@ -302,9 +409,7 @@ class _AccountEditorOverlayState extends State<AccountEditorOverlay> {
|
||||
onTap: () {
|
||||
setState(() {
|
||||
_selectedCurrency = entry.$1;
|
||||
dash.setState(() {
|
||||
dash.tempAccountCurrency = entry.$1;
|
||||
});
|
||||
dash.tempAccountCurrency = entry.$1;
|
||||
dash.overlayEntry?.markNeedsBuild();
|
||||
_showCurrencyDropdown = false;
|
||||
});
|
||||
@@ -358,7 +463,7 @@ class _AccountEditorOverlayState extends State<AccountEditorOverlay> {
|
||||
const Icon(
|
||||
Icons.check_rounded,
|
||||
size: 14,
|
||||
color: Color(0xFF7C6DED),
|
||||
color: const Color(0xFF7C6DED),
|
||||
),
|
||||
],
|
||||
],
|
||||
@@ -377,7 +482,7 @@ class _AccountEditorOverlayState extends State<AccountEditorOverlay> {
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
if (!dash.isAddingAccount &&
|
||||
(ref.watch(accountsProvider).valueOrNull?.length ?? 0) >
|
||||
(ref.watch(accountsProvider).value?.length ?? 0) >
|
||||
1) ...[
|
||||
GestureDetector(
|
||||
onTap: () => setState(() => _showDeleteDialog = true),
|
||||
|
||||
@@ -5,6 +5,7 @@ import '../../../../core/l10n/app_strings.dart';
|
||||
import '../../../../core/l10n/locale_provider.dart';
|
||||
import '../../../../core/services/card_color_service.dart';
|
||||
import '../../../../core/services/haptic_service.dart';
|
||||
import '../../../../core/utils/card_layout.dart';
|
||||
import '../../../../shared/models/account.dart';
|
||||
import '../../provider.dart';
|
||||
import './panel_tab.dart';
|
||||
@@ -14,6 +15,7 @@ class AccountColorPanel extends StatelessWidget {
|
||||
final dynamic dashboardState;
|
||||
final BuildContext dashboardContext;
|
||||
final double panelHeight;
|
||||
final CardOverlayLayout layout;
|
||||
final bool Function(List<Account>, String) isDuplicateName;
|
||||
final VoidCallback onDuplicateError;
|
||||
|
||||
@@ -22,6 +24,7 @@ class AccountColorPanel extends StatelessWidget {
|
||||
required this.dashboardState,
|
||||
required this.dashboardContext,
|
||||
required this.panelHeight,
|
||||
required this.layout,
|
||||
required this.isDuplicateName,
|
||||
required this.onDuplicateError,
|
||||
});
|
||||
@@ -54,16 +57,14 @@ class AccountColorPanel extends StatelessWidget {
|
||||
);
|
||||
|
||||
void onHSVChanged(HSVColor hsv) {
|
||||
if (dashboardState.editingPrimary) {
|
||||
dashboardState.tempPrimaryHSV = hsv;
|
||||
dashboardState.tempPrimary = hsv.toColor();
|
||||
} else {
|
||||
dashboardState.tempSecondaryHSV = hsv;
|
||||
dashboardState.tempSecondary = hsv.toColor();
|
||||
}
|
||||
setPanelState(() {});
|
||||
dashboardState.setState(() {
|
||||
if (dashboardState.editingPrimary) {
|
||||
dashboardState.tempPrimaryHSV = hsv;
|
||||
dashboardState.tempPrimary = hsv.toColor();
|
||||
} else {
|
||||
dashboardState.tempSecondaryHSV = hsv;
|
||||
dashboardState.tempSecondary = hsv.toColor();
|
||||
}
|
||||
});
|
||||
dashboardState.overlayEntry?.markNeedsBuild();
|
||||
}
|
||||
|
||||
@@ -77,7 +78,12 @@ class AccountColorPanel extends StatelessWidget {
|
||||
: dashboardState.tempSecondaryHSV;
|
||||
|
||||
return Padding(
|
||||
padding: const EdgeInsets.fromLTRB(16, 14, 16, 22),
|
||||
padding: EdgeInsets.fromLTRB(
|
||||
16,
|
||||
layout.panelPaddingTop,
|
||||
16,
|
||||
layout.panelPaddingBottom,
|
||||
),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.max,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
@@ -98,18 +104,16 @@ class AccountColorPanel extends StatelessWidget {
|
||||
: dashboardState.tempPrimary,
|
||||
isDimmed: isSolid,
|
||||
onTap: () {
|
||||
dashboardState.setState(() {
|
||||
if (isSolid)
|
||||
if (Theme.of(dashboardContext).brightness ==
|
||||
Brightness.dark) {
|
||||
dashboardState.tempDarkGradientType =
|
||||
CardColorService.defaultGradientDark;
|
||||
} else {
|
||||
dashboardState.tempLightGradientType =
|
||||
CardColorService.defaultGradientLight;
|
||||
}
|
||||
dashboardState.editingPrimary = true;
|
||||
});
|
||||
if (isSolid)
|
||||
if (Theme.of(dashboardContext).brightness ==
|
||||
Brightness.dark) {
|
||||
dashboardState.tempDarkGradientType =
|
||||
GradientType.linear;
|
||||
} else {
|
||||
dashboardState.tempLightGradientType =
|
||||
GradientType.linear;
|
||||
}
|
||||
dashboardState.editingPrimary = true;
|
||||
setPanelState(() {});
|
||||
dashboardState.overlayEntry?.markNeedsBuild();
|
||||
},
|
||||
@@ -124,18 +128,16 @@ class AccountColorPanel extends StatelessWidget {
|
||||
color: dashboardState.tempSecondary,
|
||||
isDimmed: isSolid,
|
||||
onTap: () {
|
||||
dashboardState.setState(() {
|
||||
if (isSolid)
|
||||
if (Theme.of(dashboardContext).brightness ==
|
||||
Brightness.dark) {
|
||||
dashboardState.tempDarkGradientType =
|
||||
CardColorService.defaultGradientDark;
|
||||
} else {
|
||||
dashboardState.tempLightGradientType =
|
||||
CardColorService.defaultGradientLight;
|
||||
}
|
||||
dashboardState.editingPrimary = false;
|
||||
});
|
||||
if (isSolid)
|
||||
if (Theme.of(dashboardContext).brightness ==
|
||||
Brightness.dark) {
|
||||
dashboardState.tempDarkGradientType =
|
||||
GradientType.linear;
|
||||
} else {
|
||||
dashboardState.tempLightGradientType =
|
||||
GradientType.linear;
|
||||
}
|
||||
dashboardState.editingPrimary = false;
|
||||
setPanelState(() {});
|
||||
dashboardState.overlayEntry?.markNeedsBuild();
|
||||
},
|
||||
@@ -156,17 +158,15 @@ class AccountColorPanel extends StatelessWidget {
|
||||
onTap: isSolid
|
||||
? null
|
||||
: () {
|
||||
dashboardState.setState(() {
|
||||
if (Theme.of(dashboardContext).brightness ==
|
||||
Brightness.dark) {
|
||||
dashboardState.tempDarkGradientType =
|
||||
GradientType.solid;
|
||||
} else {
|
||||
dashboardState.tempLightGradientType =
|
||||
GradientType.solid;
|
||||
}
|
||||
dashboardState.editingPrimary = true;
|
||||
});
|
||||
if (Theme.of(dashboardContext).brightness ==
|
||||
Brightness.dark) {
|
||||
dashboardState.tempDarkGradientType =
|
||||
GradientType.solid;
|
||||
} else {
|
||||
dashboardState.tempLightGradientType =
|
||||
GradientType.solid;
|
||||
}
|
||||
dashboardState.editingPrimary = true;
|
||||
setPanelState(() {});
|
||||
dashboardState.overlayEntry?.markNeedsBuild();
|
||||
},
|
||||
@@ -239,12 +239,12 @@ class AccountColorPanel extends StatelessWidget {
|
||||
],
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
SizedBox(height: layout.tabSpacing),
|
||||
Expanded(
|
||||
child: LayoutBuilder(
|
||||
builder: (lbCtx, constraints) {
|
||||
const reservedBelow = 78.0;
|
||||
final spectrumH = (constraints.maxHeight - reservedBelow)
|
||||
final spectrumH = (constraints.maxHeight -
|
||||
layout.reservedBelowControls)
|
||||
.clamp(40.0, double.infinity);
|
||||
|
||||
return Column(
|
||||
@@ -262,9 +262,9 @@ class AccountColorPanel extends StatelessWidget {
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
SizedBox(height: layout.controlSpacing),
|
||||
SizedBox(
|
||||
height: 36,
|
||||
height: layout.hueSliderHeight,
|
||||
child: ColorPickerSlider(
|
||||
TrackType.hue,
|
||||
currentHSV,
|
||||
@@ -272,22 +272,19 @@ class AccountColorPanel extends StatelessWidget {
|
||||
displayThumbColor: true,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
SizedBox(height: layout.controlSpacing),
|
||||
IgnorePointer(
|
||||
ignoring: isSolid,
|
||||
child: AnimatedOpacity(
|
||||
duration: const Duration(milliseconds: 200),
|
||||
opacity: isSolid ? 0.4 : 1.0,
|
||||
child: SizedBox(
|
||||
height: 26,
|
||||
height: layout.hexRowHeight,
|
||||
child: Row(
|
||||
children: [
|
||||
GestureDetector(
|
||||
onTap: () {
|
||||
dashboardState.setState(
|
||||
() => dashboardState.editingPrimary =
|
||||
true,
|
||||
);
|
||||
dashboardState.editingPrimary = true;
|
||||
setPanelState(() {});
|
||||
dashboardState.overlayEntry
|
||||
?.markNeedsBuild();
|
||||
@@ -342,11 +339,7 @@ class AccountColorPanel extends StatelessWidget {
|
||||
if (!isSolid)
|
||||
GestureDetector(
|
||||
onTap: () {
|
||||
dashboardState.setState(
|
||||
() =>
|
||||
dashboardState.editingPrimary =
|
||||
false,
|
||||
);
|
||||
dashboardState.editingPrimary = false;
|
||||
setPanelState(() {});
|
||||
dashboardState.overlayEntry
|
||||
?.markNeedsBuild();
|
||||
@@ -411,14 +404,9 @@ class AccountColorPanel extends StatelessWidget {
|
||||
},
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
IgnorePointer(
|
||||
ignoring: isSolid,
|
||||
child: AnimatedOpacity(
|
||||
duration: const Duration(milliseconds: 200),
|
||||
opacity: isSolid ? 0.3 : 1.0,
|
||||
child: Row(
|
||||
children: GradientType.values
|
||||
SizedBox(height: layout.controlSpacing),
|
||||
Row(
|
||||
children: GradientType.values
|
||||
.where((t) => t != GradientType.solid)
|
||||
.map((type) {
|
||||
final isSelected = activeGradientType == type;
|
||||
@@ -444,27 +432,23 @@ class AccountColorPanel extends StatelessWidget {
|
||||
padding: const EdgeInsets.only(right: 6),
|
||||
child: GestureDetector(
|
||||
onTap: () {
|
||||
dashboardState.setState(
|
||||
() {
|
||||
if (Theme.of(dashboardContext)
|
||||
.brightness ==
|
||||
Brightness.dark) {
|
||||
dashboardState.tempDarkGradientType =
|
||||
type;
|
||||
} else {
|
||||
dashboardState.tempLightGradientType =
|
||||
type;
|
||||
}
|
||||
},
|
||||
);
|
||||
if (Theme.of(dashboardContext)
|
||||
.brightness ==
|
||||
Brightness.dark) {
|
||||
dashboardState.tempDarkGradientType =
|
||||
type;
|
||||
} else {
|
||||
dashboardState.tempLightGradientType =
|
||||
type;
|
||||
}
|
||||
setPanelState(() {});
|
||||
dashboardState.overlayEntry
|
||||
?.markNeedsBuild();
|
||||
},
|
||||
child: AnimatedContainer(
|
||||
duration: const Duration(milliseconds: 150),
|
||||
padding: const EdgeInsets.symmetric(
|
||||
vertical: 5,
|
||||
padding: EdgeInsets.symmetric(
|
||||
vertical: layout.compact ? 3 : 5,
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
color: isSelected
|
||||
@@ -518,12 +502,10 @@ class AccountColorPanel extends StatelessWidget {
|
||||
),
|
||||
),
|
||||
);
|
||||
})
|
||||
.toList(),
|
||||
),
|
||||
),
|
||||
})
|
||||
.toList(),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
SizedBox(height: layout.controlSpacing),
|
||||
Row(
|
||||
children: [
|
||||
Expanded(
|
||||
@@ -538,26 +520,27 @@ class AccountColorPanel extends StatelessWidget {
|
||||
final defS = isDarkTheme
|
||||
? CardColorService.defaultSecondary
|
||||
: CardColorService.defaultSecondaryLight;
|
||||
dashboardState.setState(() {
|
||||
dashboardState.tempPrimary = defP;
|
||||
dashboardState.tempSecondary = defS;
|
||||
dashboardState.tempPrimaryHSV = HSVColor.fromColor(
|
||||
defP,
|
||||
);
|
||||
dashboardState.tempSecondaryHSV =
|
||||
HSVColor.fromColor(defS);
|
||||
dashboardState.tempPrimary = defP;
|
||||
dashboardState.tempSecondary = defS;
|
||||
dashboardState.tempPrimaryHSV = HSVColor.fromColor(
|
||||
defP,
|
||||
);
|
||||
dashboardState.tempSecondaryHSV =
|
||||
HSVColor.fromColor(defS);
|
||||
dashboardState.tempLightGradientType =
|
||||
CardColorService.defaultGradientLight;
|
||||
dashboardState.tempDarkGradientType =
|
||||
CardColorService.defaultGradientDark;
|
||||
});
|
||||
setPanelState(() {});
|
||||
dashboardState.overlayEntry?.markNeedsBuild();
|
||||
},
|
||||
icon: const Icon(Icons.restart_alt_rounded, size: 15),
|
||||
icon: Icon(
|
||||
Icons.restart_alt_rounded,
|
||||
size: layout.compact ? 14 : 15,
|
||||
),
|
||||
label: Text(
|
||||
s.reset,
|
||||
style: const TextStyle(fontSize: 13),
|
||||
style: TextStyle(fontSize: layout.compact ? 12 : 13),
|
||||
),
|
||||
style: OutlinedButton.styleFrom(
|
||||
foregroundColor: Theme.of(
|
||||
@@ -568,7 +551,9 @@ class AccountColorPanel extends StatelessWidget {
|
||||
dashboardContext,
|
||||
).colorScheme.onSurface.withOpacity(0.2),
|
||||
),
|
||||
padding: const EdgeInsets.symmetric(vertical: 10),
|
||||
padding: EdgeInsets.symmetric(
|
||||
vertical: layout.buttonVerticalPadding,
|
||||
),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
),
|
||||
@@ -588,7 +573,7 @@ class AccountColorPanel extends StatelessWidget {
|
||||
final accounts =
|
||||
ProviderScope.containerOf(
|
||||
dashboardContext,
|
||||
).read(accountsProvider).valueOrNull ??
|
||||
).read(accountsProvider).value ??
|
||||
[];
|
||||
|
||||
if (isDuplicateName(
|
||||
@@ -613,7 +598,9 @@ class AccountColorPanel extends StatelessWidget {
|
||||
disabledForegroundColor: Theme.of(
|
||||
dashboardContext,
|
||||
).colorScheme.onSurface.withOpacity(0.38),
|
||||
padding: const EdgeInsets.symmetric(vertical: 10),
|
||||
padding: EdgeInsets.symmetric(
|
||||
vertical: layout.buttonVerticalPadding,
|
||||
),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
),
|
||||
@@ -622,9 +609,9 @@ class AccountColorPanel extends StatelessWidget {
|
||||
dashboardState.isAddingAccount
|
||||
? s.addAccount
|
||||
: s.apply,
|
||||
style: const TextStyle(
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.w700,
|
||||
fontSize: 14,
|
||||
fontSize: layout.compact ? 13 : 14,
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
@@ -56,7 +56,7 @@ class AccountDeleteDialog extends ConsumerWidget {
|
||||
|
||||
onConfirm();
|
||||
|
||||
final txs = ref.read(transactionsProvider).valueOrNull ?? [];
|
||||
final txs = ref.read(transactionsProvider).value ?? [];
|
||||
final accountTxs = txs
|
||||
.where((t) => t.accountId == accountId)
|
||||
.toList();
|
||||
|
||||
@@ -3,7 +3,7 @@ import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import '../../../../core/constants.dart';
|
||||
import '../../../../shared/widgets/byn_sign.dart';
|
||||
|
||||
class AccountEditorPanel extends ConsumerWidget {
|
||||
class AccountEditorPanel extends ConsumerStatefulWidget {
|
||||
final TextEditingController nameController;
|
||||
final String selectedCurrency;
|
||||
final bool showCurrencyDropdown;
|
||||
@@ -26,15 +26,29 @@ class AccountEditorPanel extends ConsumerWidget {
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
ConsumerState<AccountEditorPanel> createState() => _AccountEditorPanelState();
|
||||
}
|
||||
|
||||
class _AccountEditorPanelState extends ConsumerState<AccountEditorPanel> {
|
||||
bool _showNameError = false;
|
||||
|
||||
void _triggerNameError() {
|
||||
setState(() => _showNameError = true);
|
||||
Future.delayed(const Duration(seconds: 2), () {
|
||||
if (mounted) setState(() => _showNameError = false);
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
height: panelHeight,
|
||||
height: widget.panelHeight,
|
||||
decoration: BoxDecoration(
|
||||
color: Theme.of(dashboardContext).colorScheme.surface,
|
||||
color: Theme.of(widget.dashboardContext).colorScheme.surface,
|
||||
borderRadius: BorderRadius.circular(20),
|
||||
border: Border.all(
|
||||
color: Theme.of(
|
||||
dashboardContext,
|
||||
widget.dashboardContext,
|
||||
).colorScheme.onSurface.withOpacity(0.1),
|
||||
width: 1.5,
|
||||
),
|
||||
@@ -47,7 +61,7 @@ class AccountEditorPanel extends ConsumerWidget {
|
||||
],
|
||||
),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 14, vertical: 12),
|
||||
padding: const EdgeInsets.symmetric(horizontal: 14, vertical: 10),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
@@ -58,11 +72,11 @@ class AccountEditorPanel extends ConsumerWidget {
|
||||
fontSize: 11,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: Theme.of(
|
||||
dashboardContext,
|
||||
widget.dashboardContext,
|
||||
).colorScheme.onSurface.withOpacity(0.6),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
const SizedBox(height: 6),
|
||||
IntrinsicHeight(
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
@@ -70,7 +84,7 @@ class AccountEditorPanel extends ConsumerWidget {
|
||||
Expanded(
|
||||
flex: 3,
|
||||
child: TextField(
|
||||
controller: nameController,
|
||||
controller: widget.nameController,
|
||||
buildCounter:
|
||||
(
|
||||
context, {
|
||||
@@ -84,23 +98,23 @@ class AccountEditorPanel extends ConsumerWidget {
|
||||
hintStyle: TextStyle(
|
||||
fontSize: 13,
|
||||
color: Theme.of(
|
||||
dashboardContext,
|
||||
widget.dashboardContext,
|
||||
).colorScheme.onSurface.withOpacity(0.4),
|
||||
),
|
||||
filled: true,
|
||||
fillColor: Theme.of(
|
||||
dashboardContext,
|
||||
widget.dashboardContext,
|
||||
).colorScheme.onSurface.withOpacity(0.05),
|
||||
border: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
borderSide: BorderSide(
|
||||
color:
|
||||
(showLimitError ||
|
||||
showDuplicateError ||
|
||||
nameController.text.trim().isEmpty)
|
||||
(widget.showLimitError ||
|
||||
widget.showDuplicateError ||
|
||||
_showNameError)
|
||||
? Colors.red
|
||||
: Theme.of(
|
||||
dashboardContext,
|
||||
widget.dashboardContext,
|
||||
).colorScheme.onSurface.withOpacity(0.15),
|
||||
width: 1.5,
|
||||
),
|
||||
@@ -109,12 +123,12 @@ class AccountEditorPanel extends ConsumerWidget {
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
borderSide: BorderSide(
|
||||
color:
|
||||
(showLimitError ||
|
||||
showDuplicateError ||
|
||||
nameController.text.trim().isEmpty)
|
||||
(widget.showLimitError ||
|
||||
widget.showDuplicateError ||
|
||||
_showNameError)
|
||||
? Colors.red
|
||||
: Theme.of(
|
||||
dashboardContext,
|
||||
widget.dashboardContext,
|
||||
).colorScheme.onSurface.withOpacity(0.15),
|
||||
width: 1.5,
|
||||
),
|
||||
@@ -123,9 +137,9 @@ class AccountEditorPanel extends ConsumerWidget {
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
borderSide: BorderSide(
|
||||
color:
|
||||
(showLimitError ||
|
||||
showDuplicateError ||
|
||||
nameController.text.trim().isEmpty)
|
||||
(widget.showLimitError ||
|
||||
widget.showDuplicateError ||
|
||||
_showNameError)
|
||||
? Colors.red
|
||||
: const Color(0xFF7C6DED),
|
||||
width: 1.5,
|
||||
@@ -141,19 +155,19 @@ class AccountEditorPanel extends ConsumerWidget {
|
||||
const SizedBox(width: 8),
|
||||
Expanded(
|
||||
child: GestureDetector(
|
||||
onTap: onCurrencyDropdownToggle,
|
||||
onTap: widget.onCurrencyDropdownToggle,
|
||||
child: Container(
|
||||
height: double.infinity,
|
||||
decoration: BoxDecoration(
|
||||
color: Theme.of(
|
||||
dashboardContext,
|
||||
widget.dashboardContext,
|
||||
).colorScheme.onSurface.withOpacity(0.05),
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
border: Border.all(
|
||||
color: showCurrencyDropdown
|
||||
color: widget.showCurrencyDropdown
|
||||
? const Color(0xFF7C6DED)
|
||||
: Theme.of(
|
||||
dashboardContext,
|
||||
widget.dashboardContext,
|
||||
).colorScheme.onSurface.withOpacity(0.15),
|
||||
width: 1.5,
|
||||
),
|
||||
@@ -162,17 +176,17 @@ class AccountEditorPanel extends ConsumerWidget {
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
selectedCurrency == 'BYN'
|
||||
widget.selectedCurrency == 'BYN'
|
||||
? BynSign(
|
||||
fontSize: 15,
|
||||
color: Theme.of(
|
||||
dashboardContext,
|
||||
widget.dashboardContext,
|
||||
).colorScheme.onSurface,
|
||||
)
|
||||
: Text(
|
||||
kDisplayCurrencies
|
||||
.firstWhere(
|
||||
(c) => c.$1 == selectedCurrency,
|
||||
(c) => c.$1 == widget.selectedCurrency,
|
||||
)
|
||||
.$2,
|
||||
style: const TextStyle(
|
||||
@@ -182,12 +196,12 @@ class AccountEditorPanel extends ConsumerWidget {
|
||||
),
|
||||
const SizedBox(width: 4),
|
||||
Icon(
|
||||
showCurrencyDropdown
|
||||
widget.showCurrencyDropdown
|
||||
? Icons.arrow_drop_up
|
||||
: Icons.arrow_drop_down,
|
||||
size: 20,
|
||||
color: Theme.of(
|
||||
dashboardContext,
|
||||
widget.dashboardContext,
|
||||
).colorScheme.onSurface.withOpacity(0.6),
|
||||
),
|
||||
],
|
||||
|
||||
@@ -5,8 +5,11 @@ import 'package:sensors_plus/sensors_plus.dart';
|
||||
import '../../../core/constants.dart';
|
||||
import '../../../core/l10n/locale_provider.dart';
|
||||
import '../../../core/services/card_color_service.dart';
|
||||
import '../../../core/utils/card_layout.dart';
|
||||
import '../../../shared/utils/card_gradient.dart';
|
||||
import '../../../core/services/haptic_service.dart';
|
||||
import '../../../shared/providers/amount_format_provider.dart';
|
||||
import '../../../shared/feature_flags/feature_flags_provider.dart';
|
||||
import '../../../shared/widgets/byn_sign.dart';
|
||||
import '../../settings/provider.dart';
|
||||
import '../provider.dart';
|
||||
@@ -26,7 +29,7 @@ String _smartBalance(double amount, AmountFormat fmt, String symbol) {
|
||||
return symbol.isEmpty ? formatted : '$symbol$formatted';
|
||||
}
|
||||
|
||||
class BalanceCard extends ConsumerStatefulWidget {
|
||||
class BalanceCard extends StatefulWidget {
|
||||
final double balance;
|
||||
final CurrencyInfo currencyInfo;
|
||||
final VoidCallback? onLongPress;
|
||||
@@ -35,6 +38,8 @@ class BalanceCard extends ConsumerStatefulWidget {
|
||||
final GradientType? previewGradientType;
|
||||
final String? accountName;
|
||||
final CardColors? accountColors;
|
||||
final double? cardHeight;
|
||||
final Widget? resizeHandle;
|
||||
|
||||
const BalanceCard({
|
||||
super.key,
|
||||
@@ -46,13 +51,15 @@ class BalanceCard extends ConsumerStatefulWidget {
|
||||
this.previewGradientType,
|
||||
this.accountName,
|
||||
this.accountColors,
|
||||
this.cardHeight,
|
||||
this.resizeHandle,
|
||||
});
|
||||
|
||||
@override
|
||||
ConsumerState<BalanceCard> createState() => BalanceCardState();
|
||||
State<BalanceCard> createState() => BalanceCardState();
|
||||
}
|
||||
|
||||
class BalanceCardState extends ConsumerState<BalanceCard>
|
||||
class BalanceCardState extends State<BalanceCard>
|
||||
with SingleTickerProviderStateMixin {
|
||||
late final AnimationController _controller;
|
||||
double _tiltX = 0.0, _tiltY = 0.0;
|
||||
@@ -83,49 +90,10 @@ class BalanceCardState extends ConsumerState<BalanceCard>
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
Gradient _buildGradient(Color primary, Color secondary, GradientType type) {
|
||||
final colorDark = Color.lerp(secondary, Colors.black, 0.3)!;
|
||||
|
||||
switch (type) {
|
||||
case GradientType.linear:
|
||||
return LinearGradient(
|
||||
begin: Alignment.topLeft,
|
||||
end: Alignment.bottomRight,
|
||||
colors: [primary, secondary, colorDark],
|
||||
stops: const [0.0, 0.6, 1.0],
|
||||
);
|
||||
case GradientType.linearReverse:
|
||||
return LinearGradient(
|
||||
begin: Alignment.topRight,
|
||||
end: Alignment.bottomLeft,
|
||||
colors: [primary, secondary, colorDark],
|
||||
stops: const [0.0, 0.6, 1.0],
|
||||
);
|
||||
case GradientType.radial:
|
||||
return RadialGradient(
|
||||
center: Alignment.center,
|
||||
radius: 1.4,
|
||||
colors: [primary, secondary, colorDark],
|
||||
stops: const [0.0, 0.6, 1.0],
|
||||
);
|
||||
case GradientType.sweep:
|
||||
return SweepGradient(
|
||||
center: Alignment.center,
|
||||
startAngle: 0.0,
|
||||
endAngle: 3.14159 * 2,
|
||||
colors: [primary, secondary, colorDark, secondary, primary],
|
||||
stops: const [0.0, 0.25, 0.5, 0.75, 1.0],
|
||||
);
|
||||
case GradientType.solid:
|
||||
return LinearGradient(
|
||||
colors: [primary, primary, primary],
|
||||
stops: const [0.0, 0.5, 1.0],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Consumer(
|
||||
builder: (context, ref, _) {
|
||||
final s = ref.watch(stringsProvider);
|
||||
final rates = ref.read(exchangeRateServiceProvider);
|
||||
final fmt = ref.watch(amountFormatProvider);
|
||||
@@ -145,15 +113,13 @@ class BalanceCardState extends ConsumerState<BalanceCard>
|
||||
.toList();
|
||||
|
||||
final textColorMode = ref.watch(cardTextColorProvider);
|
||||
final Color onCard;
|
||||
switch (textColorMode) {
|
||||
case CardTextColorMode.white:
|
||||
onCard = Colors.white;
|
||||
case CardTextColorMode.black:
|
||||
onCard = Colors.black;
|
||||
case CardTextColorMode.adaptive:
|
||||
onCard = primary.computeLuminance() > 0.3 ? Colors.black : Colors.white;
|
||||
}
|
||||
final canEditCardColors = ref.watch(featureFlagsProvider).canEditCardColors;
|
||||
final Color onCard = switch (textColorMode) {
|
||||
CardTextColorMode.white => Colors.white,
|
||||
CardTextColorMode.black => Colors.black,
|
||||
CardTextColorMode.adaptive => primary.computeLuminance() > 0.3 ? Colors.black : Colors.white,
|
||||
_ => Colors.white,
|
||||
};
|
||||
|
||||
return GestureDetector(
|
||||
onLongPress: () {
|
||||
@@ -172,24 +138,27 @@ class BalanceCardState extends ConsumerState<BalanceCard>
|
||||
..setEntry(3, 2, 0.001)
|
||||
..rotateX(_tiltX * 0.42)
|
||||
..rotateY(_tiltY * 0.42),
|
||||
child: Container(
|
||||
width: double.infinity,
|
||||
height: 220,
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(20),
|
||||
gradient: _buildGradient(primary, secondary, gradientType),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.black.withOpacity(0.4),
|
||||
blurRadius: 20,
|
||||
offset: const Offset(0, 8),
|
||||
child: Stack(
|
||||
clipBehavior: Clip.none,
|
||||
children: [
|
||||
Container(
|
||||
width: double.infinity,
|
||||
height: widget.cardHeight ?? kBalanceCardHeight,
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(20),
|
||||
gradient: buildCardGradient(primary, secondary, gradientType),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.black.withOpacity(0.4),
|
||||
blurRadius: 20,
|
||||
offset: const Offset(0, 8),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
child: ClipRRect(
|
||||
borderRadius: BorderRadius.circular(20),
|
||||
child: Stack(
|
||||
children: [
|
||||
child: ClipRRect(
|
||||
borderRadius: BorderRadius.circular(20),
|
||||
child: Stack(
|
||||
children: [
|
||||
if (widget.accountName != null)
|
||||
Positioned(
|
||||
top: 20,
|
||||
@@ -359,12 +328,13 @@ class BalanceCardState extends ConsumerState<BalanceCard>
|
||||
],
|
||||
),
|
||||
),
|
||||
Positioned(
|
||||
bottom: 8,
|
||||
left: 0,
|
||||
right: 0,
|
||||
child: Text(
|
||||
s.tapAndHoldToEdit,
|
||||
if (canEditCardColors)
|
||||
Positioned(
|
||||
bottom: 8,
|
||||
left: 0,
|
||||
right: 0,
|
||||
child: Text(
|
||||
s.tapAndHoldToEdit,
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
fontSize: 9,
|
||||
@@ -376,10 +346,20 @@ class BalanceCardState extends ConsumerState<BalanceCard>
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
if (widget.resizeHandle != null)
|
||||
Positioned(
|
||||
right: 0,
|
||||
bottom: 0,
|
||||
child: widget.resizeHandle!,
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import '../../../core/services/card_color_service.dart';
|
||||
import '../../../core/utils/card_layout.dart';
|
||||
import '../../../core/services/haptic_service.dart';
|
||||
import '../../../shared/models/account.dart';
|
||||
import '../../../shared/models/transaction.dart';
|
||||
import '../../../shared/feature_flags/feature_flags_provider.dart';
|
||||
import '../../settings/provider.dart';
|
||||
import '../provider.dart';
|
||||
import 'balance_card.dart';
|
||||
@@ -58,15 +60,17 @@ class _BalanceCardCarouselState extends ConsumerState<BalanceCardCarousel> {
|
||||
Widget build(BuildContext context) {
|
||||
final accountsAsync = ref.watch(accountsProvider);
|
||||
final activeIndex = ref.watch(activeAccountIndexProvider);
|
||||
final cardHeight = ref.watch(cardHeightProvider);
|
||||
final maxAccounts = ref.watch(featureFlagsProvider).maxAccounts;
|
||||
|
||||
return accountsAsync.when(
|
||||
data: (accounts) {
|
||||
final totalPages = 1 + accounts.length + (accounts.length < 5 ? 1 : 0);
|
||||
final totalPages = 1 + accounts.length + (accounts.length < maxAccounts ? 1 : 0);
|
||||
|
||||
return Column(
|
||||
children: [
|
||||
SizedBox(
|
||||
height: 230,
|
||||
height: cardHeight + 10,
|
||||
child: OverflowBox(
|
||||
maxWidth: MediaQuery.of(context).size.width,
|
||||
child: PageView.builder(
|
||||
@@ -75,7 +79,7 @@ class _BalanceCardCarouselState extends ConsumerState<BalanceCardCarousel> {
|
||||
Clip.none,
|
||||
itemCount: totalPages,
|
||||
onPageChanged: (index) {
|
||||
ref.read(activeAccountIndexProvider.notifier).state = index;
|
||||
ref.read(activeAccountIndexProvider.notifier).set(index);
|
||||
if (ref.read(hapticEnabledProvider)) {
|
||||
HapticService.light();
|
||||
}
|
||||
@@ -95,6 +99,7 @@ class _BalanceCardCarouselState extends ConsumerState<BalanceCardCarousel> {
|
||||
previewPrimary: widget.previewPrimary,
|
||||
previewSecondary: widget.previewSecondary,
|
||||
previewGradientType: widget.previewGradientType,
|
||||
cardHeight: cardHeight,
|
||||
);
|
||||
} else if (index <= accounts.length) {
|
||||
final account = accounts[index - 1];
|
||||
@@ -103,7 +108,7 @@ class _BalanceCardCarouselState extends ConsumerState<BalanceCardCarousel> {
|
||||
);
|
||||
|
||||
final txs =
|
||||
ref.watch(transactionsProvider).valueOrNull ?? [];
|
||||
ref.watch(transactionsProvider).value ?? [];
|
||||
final accountTxs = txs
|
||||
.where((t) => t.accountId == account.id)
|
||||
.toList();
|
||||
@@ -133,10 +138,12 @@ class _BalanceCardCarouselState extends ConsumerState<BalanceCardCarousel> {
|
||||
widget.onAccountLongPress?.call(account),
|
||||
accountName: account.name,
|
||||
accountColors: accountColors,
|
||||
cardHeight: cardHeight,
|
||||
);
|
||||
} else {
|
||||
cardWidget = AddAccountCard(
|
||||
onTap: widget.onAddAccountTap,
|
||||
cardHeight: cardHeight,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -153,15 +160,15 @@ class _BalanceCardCarouselState extends ConsumerState<BalanceCardCarousel> {
|
||||
],
|
||||
);
|
||||
},
|
||||
loading: () => const SizedBox(
|
||||
height: 220,
|
||||
child: Center(child: CircularProgressIndicator()),
|
||||
loading: () => SizedBox(
|
||||
height: cardHeight + 10,
|
||||
child: const Center(child: CircularProgressIndicator()),
|
||||
),
|
||||
error: (error, stack) {
|
||||
return Column(
|
||||
children: [
|
||||
SizedBox(
|
||||
height: 220,
|
||||
height: cardHeight + 10,
|
||||
child: BalanceCard(
|
||||
balance: widget.balance,
|
||||
currencyInfo: widget.currencyInfo,
|
||||
@@ -169,6 +176,7 @@ class _BalanceCardCarouselState extends ConsumerState<BalanceCardCarousel> {
|
||||
previewPrimary: widget.previewPrimary,
|
||||
previewSecondary: widget.previewSecondary,
|
||||
previewGradientType: widget.previewGradientType,
|
||||
cardHeight: cardHeight,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
@@ -182,8 +190,9 @@ class _BalanceCardCarouselState extends ConsumerState<BalanceCardCarousel> {
|
||||
|
||||
class AddAccountCard extends StatelessWidget {
|
||||
final VoidCallback? onTap;
|
||||
final double? cardHeight;
|
||||
|
||||
const AddAccountCard({super.key, this.onTap});
|
||||
const AddAccountCard({super.key, this.onTap, this.cardHeight});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@@ -192,13 +201,13 @@ class AddAccountCard extends StatelessWidget {
|
||||
child: Container(
|
||||
margin: const EdgeInsets.symmetric(
|
||||
horizontal: 10,
|
||||
vertical: 10,
|
||||
vertical: 5,
|
||||
),
|
||||
child: CustomPaint(
|
||||
painter: _DashedBorderPainter(),
|
||||
child: Container(
|
||||
width: double.infinity,
|
||||
height: 205,
|
||||
height: cardHeight ?? kAddAccountCardHeight,
|
||||
decoration: BoxDecoration(
|
||||
color: Theme.of(context).colorScheme.surface.withOpacity(0.4),
|
||||
borderRadius: BorderRadius.circular(20),
|
||||
|
||||
@@ -1,187 +0,0 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import '../../../core/l10n/app_strings.dart';
|
||||
import '../../../shared/providers/amount_format_provider.dart';
|
||||
import '../../../shared/utils/currency_utils.dart';
|
||||
import '../../../shared/widgets/byn_sign.dart';
|
||||
import '../../settings/provider.dart';
|
||||
|
||||
class BudgetProgress extends ConsumerWidget {
|
||||
final double spent;
|
||||
final double budget;
|
||||
final CurrencyInfo currencyInfo;
|
||||
final AppStrings strings;
|
||||
const BudgetProgress({
|
||||
super.key,
|
||||
required this.spent,
|
||||
required this.budget,
|
||||
required this.currencyInfo,
|
||||
required this.strings,
|
||||
});
|
||||
|
||||
Border? _themeBorder(BuildContext context) {
|
||||
final isDark = Theme.of(context).brightness == Brightness.dark;
|
||||
return isDark ? null : Border.all(color: const Color(0xFFDDDDEE), width: 1);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final fmt = ref.watch(amountFormatProvider);
|
||||
final progress = budget > 0 ? spent / budget : 0.0;
|
||||
final isOver = progress > 1.0;
|
||||
final displayPercent = (progress * 100).toStringAsFixed(0);
|
||||
|
||||
return ClipRRect(
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
child: Container(
|
||||
padding: const EdgeInsets.all(16),
|
||||
decoration: BoxDecoration(
|
||||
color: Theme.of(context).colorScheme.surface,
|
||||
border: Border(
|
||||
left: BorderSide(
|
||||
color: isOver ? const Color(0xFFE05C6B) : const Color(0xFF7C6DED),
|
||||
width: 3,
|
||||
),
|
||||
top: _themeBorder(context)?.top ?? BorderSide.none,
|
||||
right: _themeBorder(context)?.right ?? BorderSide.none,
|
||||
bottom: _themeBorder(context)?.bottom ?? BorderSide.none,
|
||||
),
|
||||
),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
strings.monthlyBudget,
|
||||
style: Theme.of(context).textTheme.bodyMedium?.copyWith(
|
||||
color: Theme.of(
|
||||
context,
|
||||
).colorScheme.onSurface.withOpacity(0.6),
|
||||
),
|
||||
),
|
||||
Text(
|
||||
'$displayPercent%',
|
||||
style: TextStyle(
|
||||
color: isOver
|
||||
? const Color(0xFFE05C6B)
|
||||
: Theme.of(
|
||||
context,
|
||||
).colorScheme.onSurface.withOpacity(0.7),
|
||||
fontWeight: isOver ? FontWeight.w700 : FontWeight.normal,
|
||||
fontSize: 12,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
ClipRRect(
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
child: LinearProgressIndicator(
|
||||
value: isOver ? 1.0 : progress,
|
||||
backgroundColor: Theme.of(
|
||||
context,
|
||||
).colorScheme.onSurface.withOpacity(0.1),
|
||||
valueColor: AlwaysStoppedAnimation<Color>(
|
||||
isOver
|
||||
? const Color(0xFFE05C6B)
|
||||
: (progress > 0.8
|
||||
? Colors.orange
|
||||
: const Color(0xFF4CAF8C)),
|
||||
),
|
||||
minHeight: 8,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
currencyInfo.code == 'BYN'
|
||||
? Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
Text(
|
||||
'${strings.spent}: ',
|
||||
style: Theme.of(context).textTheme.bodySmall
|
||||
?.copyWith(
|
||||
color: Theme.of(
|
||||
context,
|
||||
).colorScheme.onSurface.withOpacity(0.6),
|
||||
),
|
||||
),
|
||||
BynSign(
|
||||
fontSize: 12,
|
||||
color: Theme.of(
|
||||
context,
|
||||
).colorScheme.onSurface.withOpacity(0.6),
|
||||
),
|
||||
const SizedBox(width: 2),
|
||||
Text(
|
||||
formatAmount('', spent, fmt),
|
||||
style: Theme.of(context).textTheme.bodySmall
|
||||
?.copyWith(
|
||||
color: Theme.of(
|
||||
context,
|
||||
).colorScheme.onSurface.withOpacity(0.6),
|
||||
),
|
||||
),
|
||||
],
|
||||
)
|
||||
: Text(
|
||||
'${strings.spent}: ${formatAmount(currencyInfo.symbol, spent, fmt)}',
|
||||
style: Theme.of(context).textTheme.bodySmall?.copyWith(
|
||||
color: Theme.of(
|
||||
context,
|
||||
).colorScheme.onSurface.withOpacity(0.6),
|
||||
),
|
||||
),
|
||||
currencyInfo.code == 'BYN'
|
||||
? Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
Text(
|
||||
'${strings.limit}: ',
|
||||
style: Theme.of(context).textTheme.bodySmall
|
||||
?.copyWith(
|
||||
color: Theme.of(
|
||||
context,
|
||||
).colorScheme.onSurface.withOpacity(0.6),
|
||||
),
|
||||
),
|
||||
BynSign(
|
||||
fontSize: 12,
|
||||
color: Theme.of(
|
||||
context,
|
||||
).colorScheme.onSurface.withOpacity(0.6),
|
||||
),
|
||||
const SizedBox(width: 2),
|
||||
Text(
|
||||
formatAmount('', budget, fmt),
|
||||
style: Theme.of(context).textTheme.bodySmall
|
||||
?.copyWith(
|
||||
color: Theme.of(
|
||||
context,
|
||||
).colorScheme.onSurface.withOpacity(0.6),
|
||||
),
|
||||
),
|
||||
],
|
||||
)
|
||||
: Text(
|
||||
'${strings.limit}: ${formatAmount(currencyInfo.symbol, budget, fmt)}',
|
||||
style: Theme.of(context).textTheme.bodySmall?.copyWith(
|
||||
color: Theme.of(
|
||||
context,
|
||||
).colorScheme.onSurface.withOpacity(0.6),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -5,6 +5,9 @@ import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import '../../../core/l10n/app_strings.dart';
|
||||
import '../../../core/l10n/locale_provider.dart';
|
||||
import '../../../core/services/card_color_service.dart';
|
||||
import '../../../core/services/haptic_service.dart';
|
||||
import '../../../core/utils/card_layout.dart';
|
||||
import '../../../shared/feature_flags/feature_flags_provider.dart';
|
||||
import '../../settings/provider.dart';
|
||||
import '../provider.dart';
|
||||
import 'balance_card.dart';
|
||||
@@ -34,10 +37,17 @@ class _FullScreenBlurOverlayState extends State<FullScreenBlurOverlay> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final mq = MediaQuery.of(widget.context);
|
||||
final cardTop = mq.padding.top + kToolbarHeight + 16;
|
||||
const cardHeight = 230.0;
|
||||
final panelTop = cardTop + cardHeight + 65;
|
||||
const panelHeight = 410.0;
|
||||
final layout = CardOverlayLayout.fromMediaQuery(mq);
|
||||
final cardTop = layout.cardTop;
|
||||
|
||||
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);
|
||||
|
||||
return Material(
|
||||
color: Colors.transparent,
|
||||
@@ -58,7 +68,7 @@ class _FullScreenBlurOverlayState extends State<FullScreenBlurOverlay> {
|
||||
),
|
||||
),
|
||||
Positioned(
|
||||
top: cardTop,
|
||||
top: adjustedCardTop,
|
||||
left: 0,
|
||||
right: 0,
|
||||
child: FractionallySizedBox(
|
||||
@@ -67,18 +77,33 @@ class _FullScreenBlurOverlayState extends State<FullScreenBlurOverlay> {
|
||||
height: cardHeight,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8),
|
||||
child: Consumer(
|
||||
builder: (ctx, ref, _) => BalanceCard(
|
||||
balance: ref.read(totalBalanceProvider),
|
||||
currencyInfo: ref.read(currencyProvider),
|
||||
onLongPress: null,
|
||||
previewPrimary: dash.tempPrimary,
|
||||
previewSecondary: dash.tempSecondary,
|
||||
previewGradientType:
|
||||
Theme.of(widget.context).brightness == Brightness.dark
|
||||
? dash.tempDarkGradientType
|
||||
: dash.tempLightGradientType,
|
||||
),
|
||||
child: Stack(
|
||||
clipBehavior: Clip.none,
|
||||
children: [
|
||||
Consumer(
|
||||
builder: (ctx, ref, _) => BalanceCard(
|
||||
balance: ref.read(totalBalanceProvider),
|
||||
currencyInfo: ref.read(currencyProvider),
|
||||
onLongPress: null,
|
||||
previewPrimary: dash.tempPrimary,
|
||||
previewSecondary: dash.tempSecondary,
|
||||
previewGradientType:
|
||||
Theme.of(widget.context).brightness == Brightness.dark
|
||||
? dash.tempDarkGradientType
|
||||
: dash.tempLightGradientType,
|
||||
cardHeight: cardHeight,
|
||||
resizeHandle: isPremium ? _CornerResizeHandle(
|
||||
cardHeight: cardHeight,
|
||||
onHeightChanged: (newHeight) {
|
||||
ref.read(cardHeightProvider.notifier).set(newHeight);
|
||||
if (ref.read(hapticEnabledProvider)) {
|
||||
HapticService.selection();
|
||||
}
|
||||
},
|
||||
) : null,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -91,7 +116,7 @@ class _FullScreenBlurOverlayState extends State<FullScreenBlurOverlay> {
|
||||
child: GestureDetector(
|
||||
onTap: () {},
|
||||
behavior: HitTestBehavior.opaque,
|
||||
child: _buildPanel(panelHeight),
|
||||
child: _buildPanel(panelHeight, layout),
|
||||
),
|
||||
),
|
||||
Positioned(
|
||||
@@ -130,9 +155,11 @@ class _FullScreenBlurOverlayState extends State<FullScreenBlurOverlay> {
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildPanel(double panelHeight) {
|
||||
Widget _buildPanel(double panelHeight, CardOverlayLayout layout) {
|
||||
return Container(
|
||||
height: panelHeight,
|
||||
decoration: BoxDecoration(
|
||||
@@ -159,16 +186,14 @@ class _FullScreenBlurOverlayState extends State<FullScreenBlurOverlay> {
|
||||
);
|
||||
|
||||
void onHSVChanged(HSVColor hsv) {
|
||||
if (dash.editingPrimary) {
|
||||
dash.tempPrimaryHSV = hsv;
|
||||
dash.tempPrimary = hsv.toColor();
|
||||
} else {
|
||||
dash.tempSecondaryHSV = hsv;
|
||||
dash.tempSecondary = hsv.toColor();
|
||||
}
|
||||
setPanelState(() {});
|
||||
dash.setState(() {
|
||||
if (dash.editingPrimary) {
|
||||
dash.tempPrimaryHSV = hsv;
|
||||
dash.tempPrimary = hsv.toColor();
|
||||
} else {
|
||||
dash.tempSecondaryHSV = hsv;
|
||||
dash.tempSecondary = hsv.toColor();
|
||||
}
|
||||
});
|
||||
dash.overlayEntry?.markNeedsBuild();
|
||||
}
|
||||
|
||||
@@ -182,7 +207,12 @@ class _FullScreenBlurOverlayState extends State<FullScreenBlurOverlay> {
|
||||
: dash.tempSecondaryHSV;
|
||||
|
||||
return Padding(
|
||||
padding: const EdgeInsets.fromLTRB(16, 14, 16, 22),
|
||||
padding: EdgeInsets.fromLTRB(
|
||||
16,
|
||||
layout.panelPaddingTop,
|
||||
16,
|
||||
layout.panelPaddingBottom,
|
||||
),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.max,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
@@ -201,19 +231,17 @@ class _FullScreenBlurOverlayState extends State<FullScreenBlurOverlay> {
|
||||
: dash.tempPrimary,
|
||||
isDimmed: isSolid,
|
||||
onTap: () {
|
||||
dash.setState(() {
|
||||
if (isSolid) {
|
||||
if (Theme.of(widget.context).brightness ==
|
||||
Brightness.dark) {
|
||||
dash.tempDarkGradientType =
|
||||
CardColorService.defaultGradientDark;
|
||||
} else {
|
||||
dash.tempLightGradientType =
|
||||
CardColorService.defaultGradientLight;
|
||||
}
|
||||
if (isSolid) {
|
||||
if (Theme.of(widget.context).brightness ==
|
||||
Brightness.dark) {
|
||||
dash.tempDarkGradientType =
|
||||
GradientType.linear;
|
||||
} else {
|
||||
dash.tempLightGradientType =
|
||||
GradientType.linear;
|
||||
}
|
||||
dash.editingPrimary = true;
|
||||
});
|
||||
}
|
||||
dash.editingPrimary = true;
|
||||
setPanelState(() {});
|
||||
dash.overlayEntry?.markNeedsBuild();
|
||||
},
|
||||
@@ -227,19 +255,17 @@ class _FullScreenBlurOverlayState extends State<FullScreenBlurOverlay> {
|
||||
color: dash.tempSecondary,
|
||||
isDimmed: isSolid,
|
||||
onTap: () {
|
||||
dash.setState(() {
|
||||
if (isSolid) {
|
||||
if (Theme.of(widget.context).brightness ==
|
||||
Brightness.dark) {
|
||||
dash.tempDarkGradientType =
|
||||
CardColorService.defaultGradientDark;
|
||||
} else {
|
||||
dash.tempLightGradientType =
|
||||
CardColorService.defaultGradientLight;
|
||||
}
|
||||
if (isSolid) {
|
||||
if (Theme.of(widget.context).brightness ==
|
||||
Brightness.dark) {
|
||||
dash.tempDarkGradientType =
|
||||
GradientType.linear;
|
||||
} else {
|
||||
dash.tempLightGradientType =
|
||||
GradientType.linear;
|
||||
}
|
||||
dash.editingPrimary = false;
|
||||
});
|
||||
}
|
||||
dash.editingPrimary = false;
|
||||
setPanelState(() {});
|
||||
dash.overlayEntry?.markNeedsBuild();
|
||||
},
|
||||
@@ -259,17 +285,15 @@ class _FullScreenBlurOverlayState extends State<FullScreenBlurOverlay> {
|
||||
onTap: isSolid
|
||||
? null
|
||||
: () {
|
||||
dash.setState(() {
|
||||
if (Theme.of(widget.context).brightness ==
|
||||
Brightness.dark) {
|
||||
dash.tempDarkGradientType =
|
||||
GradientType.solid;
|
||||
} else {
|
||||
dash.tempLightGradientType =
|
||||
GradientType.solid;
|
||||
}
|
||||
dash.editingPrimary = true;
|
||||
});
|
||||
if (Theme.of(widget.context).brightness ==
|
||||
Brightness.dark) {
|
||||
dash.tempDarkGradientType =
|
||||
GradientType.solid;
|
||||
} else {
|
||||
dash.tempLightGradientType =
|
||||
GradientType.solid;
|
||||
}
|
||||
dash.editingPrimary = true;
|
||||
setPanelState(() {});
|
||||
dash.overlayEntry?.markNeedsBuild();
|
||||
},
|
||||
@@ -341,12 +365,12 @@ class _FullScreenBlurOverlayState extends State<FullScreenBlurOverlay> {
|
||||
],
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
SizedBox(height: layout.tabSpacing),
|
||||
Expanded(
|
||||
child: LayoutBuilder(
|
||||
builder: (lbCtx, constraints) {
|
||||
const reservedBelow = 78.0;
|
||||
final spectrumH = (constraints.maxHeight - reservedBelow)
|
||||
final spectrumH = (constraints.maxHeight -
|
||||
layout.reservedBelowControls)
|
||||
.clamp(40.0, double.infinity);
|
||||
|
||||
return Column(
|
||||
@@ -364,9 +388,9 @@ class _FullScreenBlurOverlayState extends State<FullScreenBlurOverlay> {
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
SizedBox(height: layout.controlSpacing),
|
||||
SizedBox(
|
||||
height: 36,
|
||||
height: layout.hueSliderHeight,
|
||||
child: ColorPickerSlider(
|
||||
TrackType.hue,
|
||||
currentHSV,
|
||||
@@ -374,21 +398,19 @@ class _FullScreenBlurOverlayState extends State<FullScreenBlurOverlay> {
|
||||
displayThumbColor: true,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
SizedBox(height: layout.controlSpacing),
|
||||
IgnorePointer(
|
||||
ignoring: isSolid,
|
||||
child: AnimatedOpacity(
|
||||
duration: const Duration(milliseconds: 200),
|
||||
opacity: isSolid ? 0.4 : 1.0,
|
||||
child: SizedBox(
|
||||
height: 26,
|
||||
height: layout.hexRowHeight,
|
||||
child: Row(
|
||||
children: [
|
||||
GestureDetector(
|
||||
onTap: () {
|
||||
dash.setState(
|
||||
() => dash.editingPrimary = true,
|
||||
);
|
||||
dash.editingPrimary = true;
|
||||
setPanelState(() {});
|
||||
dash.overlayEntry?.markNeedsBuild();
|
||||
},
|
||||
@@ -439,9 +461,7 @@ class _FullScreenBlurOverlayState extends State<FullScreenBlurOverlay> {
|
||||
if (!isSolid)
|
||||
GestureDetector(
|
||||
onTap: () {
|
||||
dash.setState(
|
||||
() => dash.editingPrimary = false,
|
||||
);
|
||||
dash.editingPrimary = false;
|
||||
setPanelState(() {});
|
||||
dash.overlayEntry?.markNeedsBuild();
|
||||
},
|
||||
@@ -499,14 +519,9 @@ class _FullScreenBlurOverlayState extends State<FullScreenBlurOverlay> {
|
||||
},
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
IgnorePointer(
|
||||
ignoring: isSolid,
|
||||
child: AnimatedOpacity(
|
||||
duration: const Duration(milliseconds: 200),
|
||||
opacity: isSolid ? 0.3 : 1.0,
|
||||
child: Row(
|
||||
children: GradientType.values
|
||||
SizedBox(height: layout.controlSpacing),
|
||||
Row(
|
||||
children: GradientType.values
|
||||
.where((t) => t != GradientType.solid)
|
||||
.map((type) {
|
||||
final isSelected = activeGradientType == type;
|
||||
@@ -532,21 +547,19 @@ class _FullScreenBlurOverlayState extends State<FullScreenBlurOverlay> {
|
||||
padding: const EdgeInsets.only(right: 6),
|
||||
child: GestureDetector(
|
||||
onTap: () {
|
||||
dash.setState(() {
|
||||
if (Theme.of(widget.context).brightness ==
|
||||
Brightness.dark) {
|
||||
dash.tempDarkGradientType = type;
|
||||
} else {
|
||||
dash.tempLightGradientType = type;
|
||||
}
|
||||
});
|
||||
if (Theme.of(widget.context).brightness ==
|
||||
Brightness.dark) {
|
||||
dash.tempDarkGradientType = type;
|
||||
} else {
|
||||
dash.tempLightGradientType = type;
|
||||
}
|
||||
setPanelState(() {});
|
||||
dash.overlayEntry?.markNeedsBuild();
|
||||
},
|
||||
child: AnimatedContainer(
|
||||
duration: const Duration(milliseconds: 150),
|
||||
padding: const EdgeInsets.symmetric(
|
||||
vertical: 5,
|
||||
padding: EdgeInsets.symmetric(
|
||||
vertical: layout.compact ? 3 : 5,
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
color: isSelected
|
||||
@@ -600,12 +613,10 @@ class _FullScreenBlurOverlayState extends State<FullScreenBlurOverlay> {
|
||||
),
|
||||
),
|
||||
);
|
||||
})
|
||||
.toList(),
|
||||
),
|
||||
),
|
||||
})
|
||||
.toList(),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
SizedBox(height: layout.controlSpacing),
|
||||
Row(
|
||||
children: [
|
||||
Expanded(
|
||||
@@ -620,23 +631,24 @@ class _FullScreenBlurOverlayState extends State<FullScreenBlurOverlay> {
|
||||
final defS = isDarkTheme
|
||||
? CardColorService.defaultSecondary
|
||||
: CardColorService.defaultSecondaryLight;
|
||||
dash.setState(() {
|
||||
dash.tempPrimary = defP;
|
||||
dash.tempSecondary = defS;
|
||||
dash.tempPrimaryHSV = HSVColor.fromColor(defP);
|
||||
dash.tempSecondaryHSV = HSVColor.fromColor(defS);
|
||||
dash.tempLightGradientType =
|
||||
CardColorService.defaultGradientLight;
|
||||
dash.tempDarkGradientType =
|
||||
CardColorService.defaultGradientDark;
|
||||
});
|
||||
dash.tempPrimary = defP;
|
||||
dash.tempSecondary = defS;
|
||||
dash.tempPrimaryHSV = HSVColor.fromColor(defP);
|
||||
dash.tempSecondaryHSV = HSVColor.fromColor(defS);
|
||||
dash.tempLightGradientType =
|
||||
CardColorService.defaultGradientLight;
|
||||
dash.tempDarkGradientType =
|
||||
CardColorService.defaultGradientDark;
|
||||
setPanelState(() {});
|
||||
dash.overlayEntry?.markNeedsBuild();
|
||||
},
|
||||
icon: const Icon(Icons.restart_alt_rounded, size: 15),
|
||||
icon: Icon(
|
||||
Icons.restart_alt_rounded,
|
||||
size: layout.compact ? 14 : 15,
|
||||
),
|
||||
label: Text(
|
||||
s.reset,
|
||||
style: const TextStyle(fontSize: 13),
|
||||
style: TextStyle(fontSize: layout.compact ? 12 : 13),
|
||||
),
|
||||
style: OutlinedButton.styleFrom(
|
||||
foregroundColor: Theme.of(
|
||||
@@ -647,7 +659,9 @@ class _FullScreenBlurOverlayState extends State<FullScreenBlurOverlay> {
|
||||
widget.context,
|
||||
).colorScheme.onSurface.withOpacity(0.2),
|
||||
),
|
||||
padding: const EdgeInsets.symmetric(vertical: 10),
|
||||
padding: EdgeInsets.symmetric(
|
||||
vertical: layout.buttonVerticalPadding,
|
||||
),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
),
|
||||
@@ -662,16 +676,18 @@ class _FullScreenBlurOverlayState extends State<FullScreenBlurOverlay> {
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: const Color(0xFF7C6DED),
|
||||
foregroundColor: Colors.white,
|
||||
padding: const EdgeInsets.symmetric(vertical: 10),
|
||||
padding: EdgeInsets.symmetric(
|
||||
vertical: layout.buttonVerticalPadding,
|
||||
),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
),
|
||||
),
|
||||
child: Text(
|
||||
s.apply,
|
||||
style: const TextStyle(
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.w700,
|
||||
fontSize: 14,
|
||||
fontSize: layout.compact ? 13 : 14,
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -770,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;
|
||||
}
|
||||
|
||||
@@ -23,15 +23,15 @@ class FilterChips extends ConsumerWidget {
|
||||
_FilterChip(
|
||||
label: strings.filterAllTime,
|
||||
isSelected: timeFilter == TimeFilter.allTime,
|
||||
onTap: () => ref.read(timeFilterProvider.notifier).state =
|
||||
TimeFilter.allTime,
|
||||
onTap: () => ref.read(timeFilterProvider.notifier).set(
|
||||
TimeFilter.allTime),
|
||||
),
|
||||
const SizedBox(width: 6),
|
||||
_FilterChip(
|
||||
label: strings.filterMonth,
|
||||
isSelected: timeFilter == TimeFilter.lastMonth,
|
||||
onTap: () => ref.read(timeFilterProvider.notifier).state =
|
||||
TimeFilter.lastMonth,
|
||||
onTap: () => ref.read(timeFilterProvider.notifier).set(
|
||||
TimeFilter.lastMonth),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8),
|
||||
@@ -46,32 +46,32 @@ class FilterChips extends ConsumerWidget {
|
||||
_FilterChip(
|
||||
label: strings.filterAll,
|
||||
isSelected: typeFilter == TransactionFilter.all,
|
||||
onTap: () => ref.read(transactionFilterProvider.notifier).state =
|
||||
TransactionFilter.all,
|
||||
onTap: () => ref.read(transactionFilterProvider.notifier).set(
|
||||
TransactionFilter.all),
|
||||
),
|
||||
const SizedBox(width: 6),
|
||||
_FilterChip(
|
||||
label: strings.filterIncome,
|
||||
isSelected: typeFilter == TransactionFilter.income,
|
||||
color: AppColors.income,
|
||||
onTap: () => ref.read(transactionFilterProvider.notifier).state =
|
||||
TransactionFilter.income,
|
||||
onTap: () => ref.read(transactionFilterProvider.notifier).set(
|
||||
TransactionFilter.income),
|
||||
),
|
||||
const SizedBox(width: 6),
|
||||
_FilterChip(
|
||||
label: strings.filterExpense,
|
||||
isSelected: typeFilter == TransactionFilter.expense,
|
||||
color: AppColors.expense,
|
||||
onTap: () => ref.read(transactionFilterProvider.notifier).state =
|
||||
TransactionFilter.expense,
|
||||
onTap: () => ref.read(transactionFilterProvider.notifier).set(
|
||||
TransactionFilter.expense),
|
||||
),
|
||||
const SizedBox(width: 6),
|
||||
_FilterChip(
|
||||
label: strings.filterTransfer,
|
||||
isSelected: typeFilter == TransactionFilter.transfer,
|
||||
color: Colors.blueAccent,
|
||||
onTap: () => ref.read(transactionFilterProvider.notifier).state =
|
||||
TransactionFilter.transfer,
|
||||
onTap: () => ref.read(transactionFilterProvider.notifier).set(
|
||||
TransactionFilter.transfer),
|
||||
),
|
||||
],
|
||||
),
|
||||
@@ -94,7 +94,7 @@ class _FilterChip extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final chipColor = color ?? AppColors.accent;
|
||||
final chipColor = color ?? const Color(0xFF7C6DED);
|
||||
final isDark = Theme.of(context).brightness == Brightness.dark;
|
||||
|
||||
return GestureDetector(
|
||||
|
||||
@@ -37,7 +37,7 @@ class SearchBar extends StatelessWidget {
|
||||
color: Theme.of(context).colorScheme.onSurface.withOpacity(0.6),
|
||||
onPressed: () {
|
||||
controller.clear();
|
||||
ref.read(searchQueryProvider.notifier).state = '';
|
||||
ref.read(searchQueryProvider.notifier).set('');
|
||||
},
|
||||
)
|
||||
: null,
|
||||
@@ -52,7 +52,7 @@ class SearchBar extends StatelessWidget {
|
||||
),
|
||||
focusedBorder: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
borderSide: const BorderSide(color: Color(0xFF7C6DED), width: 1.5),
|
||||
borderSide: BorderSide(color: const Color(0xFF7C6DED), width: 1.5),
|
||||
),
|
||||
border: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
@@ -63,7 +63,7 @@ class SearchBar extends StatelessWidget {
|
||||
vertical: 12,
|
||||
),
|
||||
),
|
||||
onChanged: (v) => ref.read(searchQueryProvider.notifier).state = v,
|
||||
onChanged: (v) => ref.read(searchQueryProvider.notifier).set(v),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ import '../../../core/l10n/locale_provider.dart';
|
||||
import '../../../shared/models/transaction.dart';
|
||||
import '../../../shared/models/account.dart';
|
||||
import '../../../shared/providers/amount_format_provider.dart';
|
||||
import '../../../shared/providers/category_provider.dart';
|
||||
import '../../../shared/utils/currency_utils.dart';
|
||||
import '../../../shared/widgets/byn_sign.dart';
|
||||
import '../../settings/provider.dart';
|
||||
@@ -29,7 +30,9 @@ class TransactionTile extends ConsumerWidget {
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final s = ref.watch(stringsProvider);
|
||||
final isRu = s.locale == AppLocale.ru;
|
||||
final fmt = ref.watch(amountFormatProvider);
|
||||
final catalog = ref.watch(categoryCatalogProvider);
|
||||
final isTransfer = transaction.category == 'Transfer';
|
||||
final isIncome = transaction.type == TransactionType.income;
|
||||
final color = isTransfer
|
||||
@@ -37,10 +40,11 @@ class TransactionTile extends ConsumerWidget {
|
||||
: (isIncome ? AppColors.income : AppColors.expense);
|
||||
final catColor = isTransfer
|
||||
? const Color(0xFF7C6DED)
|
||||
: (AppCategories.colors[transaction.category] ?? AppColors.accent);
|
||||
: catalog.colorFor(transaction.category);
|
||||
final catIcon = isTransfer
|
||||
? Icons.swap_horiz_rounded
|
||||
: (AppCategories.icons[transaction.category] ?? Icons.category_rounded);
|
||||
: catalog.iconFor(transaction.category);
|
||||
final catLabel = catalog.labelFor(transaction.category, isRu);
|
||||
|
||||
final activeAccount = ref.watch(activeAccountProvider);
|
||||
final displayCurrency =
|
||||
@@ -56,7 +60,7 @@ class TransactionTile extends ConsumerWidget {
|
||||
: 0.0;
|
||||
final displaySymbol = currencyMap[displayCurrency]?.symbol ?? '';
|
||||
|
||||
final accounts = ref.watch(accountsProvider).valueOrNull ?? [];
|
||||
final accounts = ref.watch(accountsProvider).value ?? [];
|
||||
final txAccount = accounts.firstWhereOrNull(
|
||||
(a) => a.id == transaction.accountId,
|
||||
);
|
||||
@@ -105,7 +109,7 @@ class TransactionTile extends ConsumerWidget {
|
||||
activeAccount,
|
||||
)
|
||||
: Text(
|
||||
s.categoryLabel(transaction.category),
|
||||
catLabel,
|
||||
style: Theme.of(context).textTheme.bodyMedium
|
||||
?.copyWith(
|
||||
fontWeight: FontWeight.w600,
|
||||
@@ -467,7 +471,7 @@ class _TransferChip extends StatelessWidget {
|
||||
label,
|
||||
style: const TextStyle(
|
||||
fontSize: 11,
|
||||
color: Color(0xFF7C6DED),
|
||||
color: const Color(0xFF7C6DED),
|
||||
fontWeight: FontWeight.w500,
|
||||
),
|
||||
overflow: TextOverflow.ellipsis,
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import '../../shared/providers/onboarding_provider.dart';
|
||||
|
||||
class OnboardingNotifier extends Notifier<int> {
|
||||
@override
|
||||
int build() => 0;
|
||||
|
||||
void setPage(int page) => state = page;
|
||||
|
||||
Future<void> complete() async {
|
||||
final service = ref.read(onboardingServiceProvider);
|
||||
await service.completeOnboarding();
|
||||
}
|
||||
}
|
||||
|
||||
final onboardingProvider = NotifierProvider<OnboardingNotifier, int>(
|
||||
OnboardingNotifier.new,
|
||||
);
|
||||
@@ -0,0 +1,164 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import '../../core/l10n/locale_provider.dart';
|
||||
import '../../core/services/haptic_service.dart';
|
||||
import 'provider.dart';
|
||||
import 'widgets/fade_slide_in.dart';
|
||||
import 'widgets/onboarding_page.dart';
|
||||
import 'widgets/onboarding_page_indicator.dart';
|
||||
|
||||
class OnboardingScreen extends ConsumerStatefulWidget {
|
||||
const OnboardingScreen({super.key});
|
||||
|
||||
@override
|
||||
ConsumerState<OnboardingScreen> createState() => _OnboardingScreenState();
|
||||
}
|
||||
|
||||
class _OnboardingScreenState extends ConsumerState<OnboardingScreen> {
|
||||
final _controller = PageController();
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_controller.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
void _onPageChanged(int page) {
|
||||
ref.read(onboardingProvider.notifier).setPage(page);
|
||||
HapticService.light();
|
||||
if (page == 4) {
|
||||
HapticService.medium();
|
||||
ref.read(onboardingProvider.notifier).complete();
|
||||
Future.delayed(const Duration(milliseconds: 150), () {
|
||||
if (mounted) context.go('/dashboard');
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final s = ref.watch(stringsProvider);
|
||||
final currentPage = ref.watch(onboardingProvider);
|
||||
|
||||
return Scaffold(
|
||||
body: SafeArea(
|
||||
child: Column(
|
||||
children: [
|
||||
Expanded(
|
||||
child: PageView(
|
||||
controller: _controller,
|
||||
onPageChanged: _onPageChanged,
|
||||
children: [
|
||||
OnboardingPage.welcome(
|
||||
welcomeText: s.onboardingWelcome,
|
||||
isActive: currentPage == 0,
|
||||
),
|
||||
OnboardingPage.content(
|
||||
icon: Icons.currency_exchange_rounded,
|
||||
headline: s.onboardingMultiCurrencyTitle,
|
||||
description: s.onboardingMultiCurrencyBody,
|
||||
isActive: currentPage == 1,
|
||||
),
|
||||
OnboardingPage.content(
|
||||
icon: Icons.credit_card_rounded,
|
||||
headline: s.onboardingCardsTitle,
|
||||
description: s.onboardingCardsBody,
|
||||
isActive: currentPage == 2,
|
||||
),
|
||||
_ReadyPage(isActive: currentPage == 3),
|
||||
const SizedBox.shrink(),
|
||||
],
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(bottom: 48),
|
||||
child: OnboardingPageIndicator(
|
||||
current: currentPage,
|
||||
count: 5,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _ReadyPage extends ConsumerWidget {
|
||||
final bool isActive;
|
||||
|
||||
const _ReadyPage({required this.isActive});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final s = ref.watch(stringsProvider);
|
||||
final colorScheme = Theme.of(context).colorScheme;
|
||||
|
||||
return Center(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 32),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
FadeSlideIn(
|
||||
active: isActive,
|
||||
child: Icon(
|
||||
Icons.waving_hand_rounded,
|
||||
size: 72,
|
||||
color: colorScheme.primary,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 28),
|
||||
FadeSlideIn(
|
||||
active: isActive,
|
||||
delay: const Duration(milliseconds: 150),
|
||||
child: Text(
|
||||
s.onboardingReadyTitle,
|
||||
textAlign: TextAlign.center,
|
||||
style: Theme.of(context).textTheme.headlineMedium?.copyWith(
|
||||
fontWeight: FontWeight.bold,
|
||||
color: colorScheme.onSurface,
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
FadeSlideIn(
|
||||
active: isActive,
|
||||
delay: const Duration(milliseconds: 300),
|
||||
child: Text(
|
||||
s.onboardingReadyBody,
|
||||
textAlign: TextAlign.center,
|
||||
style: Theme.of(context).textTheme.bodyLarge?.copyWith(
|
||||
color: colorScheme.onSurface.withOpacity(0.5),
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 24),
|
||||
FadeSlideIn(
|
||||
active: isActive,
|
||||
delay: const Duration(milliseconds: 450),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Text(
|
||||
s.onboardingSwipeRight,
|
||||
style: Theme.of(context).textTheme.titleMedium?.copyWith(
|
||||
color: colorScheme.primary,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
Icon(
|
||||
Icons.arrow_forward_rounded,
|
||||
color: colorScheme.primary,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,101 @@
|
||||
import 'dart:async';
|
||||
import 'dart:math';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:sensors_plus/sensors_plus.dart';
|
||||
|
||||
class CashaShimmerText extends StatefulWidget {
|
||||
final String text;
|
||||
final TextStyle? style;
|
||||
|
||||
const CashaShimmerText({
|
||||
required this.text,
|
||||
this.style,
|
||||
super.key,
|
||||
});
|
||||
|
||||
@override
|
||||
State<CashaShimmerText> createState() => _CashaShimmerTextState();
|
||||
}
|
||||
|
||||
class _CashaShimmerTextState extends State<CashaShimmerText>
|
||||
with SingleTickerProviderStateMixin {
|
||||
late final AnimationController _controller;
|
||||
double _tiltX = 0.0, _tiltY = 0.0;
|
||||
double _targetTiltX = 0.0, _targetTiltY = 0.0;
|
||||
StreamSubscription<AccelerometerEvent>? _sub;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_controller = AnimationController(
|
||||
vsync: this,
|
||||
duration: const Duration(seconds: 5),
|
||||
)..repeat();
|
||||
|
||||
_sub = accelerometerEventStream(
|
||||
samplingPeriod: const Duration(milliseconds: 50),
|
||||
).listen((e) {
|
||||
_targetTiltY = (e.x / 9.8).clamp(-1.0, 1.0);
|
||||
_targetTiltX = ((e.y / 9.8) - 1.0).clamp(-1.0, 1.0);
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_controller.dispose();
|
||||
_sub?.cancel();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final primary = Theme.of(context).colorScheme.primary;
|
||||
final secondary = Theme.of(context).colorScheme.secondary;
|
||||
|
||||
return AnimatedBuilder(
|
||||
animation: _controller,
|
||||
builder: (context, child) {
|
||||
_tiltX += (_targetTiltX - _tiltX) * 0.15;
|
||||
_tiltY += (_targetTiltY - _tiltY) * 0.15;
|
||||
|
||||
final t = _controller.value;
|
||||
final shimmer = sin(t * 2 * pi) * 0.08;
|
||||
|
||||
final gx = (_tiltY + shimmer).clamp(-1.0, 1.0);
|
||||
final gy = (_tiltX + shimmer * 0.3).clamp(-1.0, 1.0);
|
||||
|
||||
return Transform(
|
||||
alignment: Alignment.center,
|
||||
transform: Matrix4.identity()
|
||||
..setEntry(3, 2, 0.001)
|
||||
..rotateX(_tiltX * 0.85)
|
||||
..rotateY(_tiltY * 0.85),
|
||||
child: ShaderMask(
|
||||
shaderCallback: (bounds) {
|
||||
return LinearGradient(
|
||||
begin: Alignment(gx - 0.8, gy - 0.4),
|
||||
end: Alignment(gx + 0.8, gy + 0.4),
|
||||
colors: [
|
||||
primary.withOpacity(0.7),
|
||||
primary,
|
||||
secondary,
|
||||
Colors.white,
|
||||
secondary,
|
||||
primary,
|
||||
primary.withOpacity(0.7),
|
||||
],
|
||||
stops: [0.0, 0.15, 0.35, 0.5, 0.65, 0.85, 1.0],
|
||||
).createShader(bounds);
|
||||
},
|
||||
blendMode: BlendMode.srcIn,
|
||||
child: child,
|
||||
),
|
||||
);
|
||||
},
|
||||
child: Text(
|
||||
widget.text,
|
||||
style: widget.style?.copyWith(color: Colors.white),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class FadeSlideIn extends StatefulWidget {
|
||||
final bool active;
|
||||
final Duration delay;
|
||||
final Duration duration;
|
||||
final Widget child;
|
||||
|
||||
const FadeSlideIn({
|
||||
required this.active,
|
||||
required this.child,
|
||||
this.delay = Duration.zero,
|
||||
this.duration = const Duration(milliseconds: 500),
|
||||
super.key,
|
||||
});
|
||||
|
||||
@override
|
||||
State<FadeSlideIn> createState() => _FadeSlideInState();
|
||||
}
|
||||
|
||||
class _FadeSlideInState extends State<FadeSlideIn>
|
||||
with SingleTickerProviderStateMixin {
|
||||
late final AnimationController _controller;
|
||||
late final Animation<double> _opacity;
|
||||
late final Animation<Offset> _offset;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_controller = AnimationController(
|
||||
vsync: this,
|
||||
duration: widget.duration,
|
||||
);
|
||||
_opacity = Tween<double>(begin: 0.0, end: 1.0).animate(
|
||||
CurvedAnimation(parent: _controller, curve: Curves.easeOut),
|
||||
);
|
||||
_offset = Tween<Offset>(
|
||||
begin: const Offset(0, 0.15),
|
||||
end: Offset.zero,
|
||||
).animate(CurvedAnimation(parent: _controller, curve: Curves.easeOut));
|
||||
}
|
||||
|
||||
@override
|
||||
void didUpdateWidget(covariant FadeSlideIn oldWidget) {
|
||||
super.didUpdateWidget(oldWidget);
|
||||
if (widget.active && !oldWidget.active) {
|
||||
_controller.reset();
|
||||
Future.delayed(widget.delay, () {
|
||||
if (mounted) _controller.forward();
|
||||
});
|
||||
} else if (!widget.active && oldWidget.active) {
|
||||
_controller.reset();
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_controller.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return AnimatedBuilder(
|
||||
animation: _controller,
|
||||
builder: (context, child) {
|
||||
return Opacity(
|
||||
opacity: _opacity.value,
|
||||
child: FractionalTranslation(
|
||||
translation: _offset.value,
|
||||
child: child,
|
||||
),
|
||||
);
|
||||
},
|
||||
child: widget.child,
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,113 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'casha_shimmer_text.dart';
|
||||
import 'fade_slide_in.dart';
|
||||
|
||||
class OnboardingPage extends StatelessWidget {
|
||||
final IconData? icon;
|
||||
final String? headline;
|
||||
final String? description;
|
||||
final String? welcomeText;
|
||||
final bool isWelcomePage;
|
||||
final bool isActive;
|
||||
|
||||
const OnboardingPage.welcome({
|
||||
required this.welcomeText,
|
||||
this.isActive = false,
|
||||
super.key,
|
||||
}) : icon = null,
|
||||
headline = null,
|
||||
description = null,
|
||||
isWelcomePage = true;
|
||||
|
||||
const OnboardingPage.content({
|
||||
required this.icon,
|
||||
required this.headline,
|
||||
required this.description,
|
||||
this.isActive = false,
|
||||
super.key,
|
||||
}) : welcomeText = null,
|
||||
isWelcomePage = false;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
if (isWelcomePage) {
|
||||
final colorScheme = Theme.of(context).colorScheme;
|
||||
return Center(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Text(
|
||||
welcomeText!,
|
||||
style: Theme.of(context).textTheme.titleMedium?.copyWith(
|
||||
fontWeight: FontWeight.w300,
|
||||
color: colorScheme.onSurface.withOpacity(0.4),
|
||||
letterSpacing: 2,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
CashaShimmerText(
|
||||
text: 'Casha',
|
||||
style: Theme.of(context).textTheme.displayLarge?.copyWith(
|
||||
fontSize: 72,
|
||||
fontWeight: FontWeight.w900,
|
||||
letterSpacing: -1,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
final colorScheme = Theme.of(context).colorScheme;
|
||||
return Center(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 32),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
FadeSlideIn(
|
||||
active: isActive,
|
||||
child: Container(
|
||||
padding: const EdgeInsets.all(24),
|
||||
decoration: BoxDecoration(
|
||||
color: colorScheme.primary.withOpacity(0.12),
|
||||
shape: BoxShape.circle,
|
||||
),
|
||||
child: Icon(
|
||||
icon,
|
||||
size: 64,
|
||||
color: colorScheme.primary,
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 32),
|
||||
FadeSlideIn(
|
||||
active: isActive,
|
||||
delay: const Duration(milliseconds: 150),
|
||||
child: Text(
|
||||
headline!,
|
||||
textAlign: TextAlign.center,
|
||||
style: Theme.of(context).textTheme.headlineSmall?.copyWith(
|
||||
fontWeight: FontWeight.bold,
|
||||
color: colorScheme.onSurface,
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
FadeSlideIn(
|
||||
active: isActive,
|
||||
delay: const Duration(milliseconds: 300),
|
||||
child: Text(
|
||||
description!,
|
||||
textAlign: TextAlign.center,
|
||||
style: Theme.of(context).textTheme.bodyMedium?.copyWith(
|
||||
color: colorScheme.onSurface.withOpacity(0.6),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class OnboardingPageIndicator extends StatelessWidget {
|
||||
final int current;
|
||||
final int count;
|
||||
|
||||
const OnboardingPageIndicator({
|
||||
required this.current,
|
||||
required this.count,
|
||||
super.key,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final color = Theme.of(context).colorScheme.primary;
|
||||
final outlineColor = Theme.of(context).colorScheme.secondary;
|
||||
return Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: List.generate(count, (i) {
|
||||
final isActive = i == current;
|
||||
final isLast = i == count - 1;
|
||||
return AnimatedContainer(
|
||||
duration: const Duration(milliseconds: 200),
|
||||
margin: const EdgeInsets.symmetric(horizontal: 4),
|
||||
width: isActive ? 24 : 8,
|
||||
height: 8,
|
||||
decoration: BoxDecoration(
|
||||
color: isActive ? color : color.withOpacity(0.3),
|
||||
borderRadius: BorderRadius.circular(4),
|
||||
border: isLast && !isActive
|
||||
? Border.all(color: outlineColor, width: 1.5)
|
||||
: null,
|
||||
),
|
||||
);
|
||||
}),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,700 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import '../../../core/constants.dart';
|
||||
import '../../../core/l10n/locale_provider.dart';
|
||||
import '../../../core/services/haptic_service.dart';
|
||||
import '../../../core/utils/result.dart';
|
||||
import '../../../shared/models/app_category.dart';
|
||||
import '../../../shared/models/transaction.dart';
|
||||
import '../../../shared/providers/category_provider.dart';
|
||||
import '../../../shared/services/translation_service.dart';
|
||||
import '../../../shared/widgets/error_snackbar.dart';
|
||||
|
||||
Future<void> showCategoryEditor(
|
||||
BuildContext context, {
|
||||
AppCategory? existing,
|
||||
}) {
|
||||
return showModalBottomSheet<void>(
|
||||
context: context,
|
||||
isScrollControlled: true,
|
||||
backgroundColor: Colors.transparent,
|
||||
builder: (_) => CategoryEditorSheet(existing: existing),
|
||||
);
|
||||
}
|
||||
|
||||
class CategoryEditorSheet extends ConsumerStatefulWidget {
|
||||
final AppCategory? existing;
|
||||
|
||||
const CategoryEditorSheet({super.key, this.existing});
|
||||
|
||||
@override
|
||||
ConsumerState<CategoryEditorSheet> createState() =>
|
||||
_CategoryEditorSheetState();
|
||||
}
|
||||
|
||||
class _CategoryEditorSheetState extends ConsumerState<CategoryEditorSheet> {
|
||||
late final TextEditingController _enController;
|
||||
late final TextEditingController _ruController;
|
||||
late TransactionType _type;
|
||||
late String _iconName;
|
||||
late int _colorValue;
|
||||
|
||||
String? _enSuggestion;
|
||||
String? _ruSuggestion;
|
||||
bool _translatingEn = false;
|
||||
bool _translatingRu = false;
|
||||
bool _saving = false;
|
||||
DateTime? _lastTranslateTime;
|
||||
bool _enOverflow = false;
|
||||
bool _ruOverflow = false;
|
||||
Timer? _enOverflowTimer;
|
||||
Timer? _ruOverflowTimer;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
final existing = widget.existing;
|
||||
_enController = TextEditingController(text: existing?.labelEn ?? '');
|
||||
_ruController = TextEditingController(text: existing?.labelRu ?? '');
|
||||
_type = existing?.type == TransactionType.income
|
||||
? TransactionType.income
|
||||
: TransactionType.expense;
|
||||
_iconName = existing?.iconName ?? kCategoryIcons.keys.first;
|
||||
_colorValue = existing?.color.value ?? kCategoryColors.first.value;
|
||||
_enController.addListener(_onEnChanged);
|
||||
_ruController.addListener(_onRuChanged);
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_enOverflowTimer?.cancel();
|
||||
_ruOverflowTimer?.cancel();
|
||||
_enController.dispose();
|
||||
_ruController.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
void _onEnChanged() {
|
||||
if (_enController.text.trim().isNotEmpty && _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() {
|
||||
if (_ruController.text.trim().isNotEmpty && _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 {
|
||||
final source = _enController.text.trim();
|
||||
if (source.isEmpty) return;
|
||||
setState(() => _translatingRu = true);
|
||||
final service = ref.read(translationServiceProvider);
|
||||
TranslationResult? result;
|
||||
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;
|
||||
setState(() {
|
||||
_translatingRu = false;
|
||||
_ruSuggestion = result?.text;
|
||||
});
|
||||
if (result == null) {
|
||||
showErrorSnackbar(context, ref.read(stringsProvider).translationFailed);
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _translateToEn() async {
|
||||
final source = _ruController.text.trim();
|
||||
if (source.isEmpty) return;
|
||||
setState(() => _translatingEn = true);
|
||||
final service = ref.read(translationServiceProvider);
|
||||
TranslationResult? result;
|
||||
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;
|
||||
setState(() {
|
||||
_translatingEn = false;
|
||||
_enSuggestion = result?.text;
|
||||
});
|
||||
if (result == null) {
|
||||
showErrorSnackbar(context, ref.read(stringsProvider).translationFailed);
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _save() async {
|
||||
final s = ref.read(stringsProvider);
|
||||
if (_enController.text.trim().isEmpty &&
|
||||
_ruController.text.trim().isEmpty) {
|
||||
showErrorSnackbar(context, s.categoryNameRequired);
|
||||
return;
|
||||
}
|
||||
setState(() => _saving = true);
|
||||
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 existing = widget.existing;
|
||||
final result = existing != null && existing.id != null
|
||||
? await actions.edit(
|
||||
id: existing.id!,
|
||||
type: _type,
|
||||
labelEn: labelEn,
|
||||
labelRu: labelRu,
|
||||
iconName: _iconName,
|
||||
colorValue: _colorValue,
|
||||
)
|
||||
: await actions.create(
|
||||
type: _type,
|
||||
labelEn: labelEn,
|
||||
labelRu: labelRu,
|
||||
iconName: _iconName,
|
||||
colorValue: _colorValue,
|
||||
);
|
||||
if (!mounted) return;
|
||||
setState(() => _saving = false);
|
||||
if (result case Failure(message: final message)) {
|
||||
showErrorSnackbar(context, message);
|
||||
} else {
|
||||
Navigator.of(context).pop();
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final s = ref.watch(stringsProvider);
|
||||
final theme = Theme.of(context);
|
||||
final bottomInset = MediaQuery.of(context).viewInsets.bottom;
|
||||
|
||||
return Padding(
|
||||
padding: EdgeInsets.only(bottom: bottomInset),
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
color: theme.scaffoldBackgroundColor,
|
||||
borderRadius: const BorderRadius.vertical(top: Radius.circular(24)),
|
||||
),
|
||||
child: SafeArea(
|
||||
top: false,
|
||||
child: SingleChildScrollView(
|
||||
padding: const EdgeInsets.fromLTRB(20, 12, 20, 20),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Center(
|
||||
child: Container(
|
||||
width: 40,
|
||||
height: 4,
|
||||
decoration: BoxDecoration(
|
||||
color: theme.colorScheme.onSurface.withOpacity(0.2),
|
||||
borderRadius: BorderRadius.circular(2),
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 28),
|
||||
Text(
|
||||
widget.existing != null ? s.editCategory : s.newCategory,
|
||||
style: theme.textTheme.titleLarge?.copyWith(
|
||||
fontWeight: FontWeight.w700,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 24),
|
||||
_TypeToggle(
|
||||
type: _type,
|
||||
onChanged: (t) => setState(() => _type = t),
|
||||
expenseLabel: s.typeExpense,
|
||||
incomeLabel: s.typeIncome,
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
_TranslatableField(
|
||||
controller: _enController,
|
||||
label: s.nameEn,
|
||||
hint: s.nameEnHint,
|
||||
suggestion: _enSuggestion,
|
||||
isTranslating: _translatingEn,
|
||||
isOverflow: _enOverflow,
|
||||
canTranslate: _ruController.text.trim().isNotEmpty,
|
||||
translatingLabel: s.translating,
|
||||
applyLabel: s.applyTranslation,
|
||||
onTranslate: _translateToEn,
|
||||
onApply: () {
|
||||
_enController.text = _enSuggestion ?? '';
|
||||
setState(() => _enSuggestion = null);
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
_TranslatableField(
|
||||
controller: _ruController,
|
||||
label: s.nameRu,
|
||||
hint: s.nameRuHint,
|
||||
suggestion: _ruSuggestion,
|
||||
isTranslating: _translatingRu,
|
||||
isOverflow: _ruOverflow,
|
||||
canTranslate: _enController.text.trim().isNotEmpty,
|
||||
translatingLabel: s.translating,
|
||||
applyLabel: s.applyTranslation,
|
||||
onTranslate: _translateToRu,
|
||||
onApply: () {
|
||||
_ruController.text = _ruSuggestion ?? '';
|
||||
setState(() => _ruSuggestion = null);
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
Text(
|
||||
s.categoryIcon,
|
||||
style: theme.textTheme.bodyMedium?.copyWith(
|
||||
fontWeight: FontWeight.w600,
|
||||
color: theme.colorScheme.onSurface.withOpacity(0.7),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
_IconGrid(
|
||||
selected: _iconName,
|
||||
color: Color(_colorValue),
|
||||
onSelected: (name) {
|
||||
HapticService.light();
|
||||
setState(() => _iconName = name);
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
Text(
|
||||
s.categoryColor,
|
||||
style: theme.textTheme.bodyMedium?.copyWith(
|
||||
fontWeight: FontWeight.w600,
|
||||
color: theme.colorScheme.onSurface.withOpacity(0.7),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
_ColorRow(
|
||||
selected: _colorValue,
|
||||
onSelected: (value) {
|
||||
HapticService.light();
|
||||
setState(() => _colorValue = value);
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 24),
|
||||
SizedBox(
|
||||
width: double.infinity,
|
||||
child: FilledButton(
|
||||
onPressed: _saving ? null : _save,
|
||||
style: FilledButton.styleFrom(
|
||||
backgroundColor: const Color(0xFF7C6DED),
|
||||
padding: const EdgeInsets.symmetric(vertical: 16),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(14),
|
||||
),
|
||||
),
|
||||
child: _saving
|
||||
? const SizedBox(
|
||||
width: 20,
|
||||
height: 20,
|
||||
child: CircularProgressIndicator(
|
||||
strokeWidth: 2,
|
||||
color: Colors.white,
|
||||
),
|
||||
)
|
||||
: Text(
|
||||
s.save,
|
||||
style: const TextStyle(
|
||||
color: Colors.white,
|
||||
fontWeight: FontWeight.w700,
|
||||
fontSize: 16,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _TypeToggle extends StatelessWidget {
|
||||
final TransactionType type;
|
||||
final ValueChanged<TransactionType> onChanged;
|
||||
final String expenseLabel;
|
||||
final String incomeLabel;
|
||||
|
||||
const _TypeToggle({
|
||||
required this.type,
|
||||
required this.onChanged,
|
||||
required this.expenseLabel,
|
||||
required this.incomeLabel,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final theme = Theme.of(context);
|
||||
return Container(
|
||||
padding: const EdgeInsets.all(4),
|
||||
decoration: BoxDecoration(
|
||||
color: theme.colorScheme.surface,
|
||||
borderRadius: BorderRadius.circular(14),
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
_segment(
|
||||
context,
|
||||
label: expenseLabel,
|
||||
selected: type == TransactionType.expense,
|
||||
color: AppColors.expense,
|
||||
onTap: () => onChanged(TransactionType.expense),
|
||||
),
|
||||
_segment(
|
||||
context,
|
||||
label: incomeLabel,
|
||||
selected: type == TransactionType.income,
|
||||
color: AppColors.income,
|
||||
onTap: () => onChanged(TransactionType.income),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _segment(
|
||||
BuildContext context, {
|
||||
required String label,
|
||||
required bool selected,
|
||||
required Color color,
|
||||
required VoidCallback onTap,
|
||||
}) {
|
||||
return Expanded(
|
||||
child: GestureDetector(
|
||||
onTap: onTap,
|
||||
child: AnimatedContainer(
|
||||
duration: const Duration(milliseconds: 200),
|
||||
padding: const EdgeInsets.symmetric(vertical: 12),
|
||||
decoration: BoxDecoration(
|
||||
color: selected ? color.withOpacity(0.18) : Colors.transparent,
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
),
|
||||
alignment: Alignment.center,
|
||||
child: Text(
|
||||
label,
|
||||
style: TextStyle(
|
||||
color: selected
|
||||
? color
|
||||
: Theme.of(context).colorScheme.onSurface.withOpacity(0.6),
|
||||
fontWeight: selected ? FontWeight.w700 : FontWeight.w500,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _TranslatableField extends StatelessWidget {
|
||||
final TextEditingController controller;
|
||||
final String label;
|
||||
final String hint;
|
||||
final String? suggestion;
|
||||
final bool isTranslating;
|
||||
final bool canTranslate;
|
||||
final String translatingLabel;
|
||||
final String applyLabel;
|
||||
final bool isOverflow;
|
||||
final VoidCallback onTranslate;
|
||||
final VoidCallback onApply;
|
||||
|
||||
const _TranslatableField({
|
||||
required this.controller,
|
||||
required this.label,
|
||||
required this.hint,
|
||||
required this.suggestion,
|
||||
required this.isTranslating,
|
||||
required this.isOverflow,
|
||||
required this.canTranslate,
|
||||
required this.translatingLabel,
|
||||
required this.applyLabel,
|
||||
required this.onTranslate,
|
||||
required this.onApply,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final theme = Theme.of(context);
|
||||
final isDark = theme.brightness == Brightness.dark;
|
||||
return AnimatedBuilder(
|
||||
animation: controller,
|
||||
builder: (context, _) {
|
||||
final isEmpty = controller.text.trim().isEmpty;
|
||||
final showGhost = isEmpty && suggestion != null && !isTranslating;
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
label,
|
||||
style: theme.textTheme.bodySmall?.copyWith(
|
||||
color: theme.colorScheme.onSurface.withOpacity(0.6),
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 6),
|
||||
Container(
|
||||
decoration: BoxDecoration(
|
||||
color: theme.colorScheme.surface,
|
||||
borderRadius: BorderRadius.circular(14),
|
||||
border: isOverflow
|
||||
? Border.all(color: AppColors.expense, width: 1.5)
|
||||
: isDark
|
||||
? null
|
||||
: Border.all(color: const Color(0xFFDDDDEE), width: 1),
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: Stack(
|
||||
children: [
|
||||
if (showGhost)
|
||||
Positioned.fill(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 14,
|
||||
),
|
||||
child: Align(
|
||||
alignment: Alignment.centerLeft,
|
||||
child: Text(
|
||||
suggestion!,
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: theme.textTheme.bodyLarge?.copyWith(
|
||||
color: theme.colorScheme.onSurface
|
||||
.withOpacity(0.28),
|
||||
fontStyle: FontStyle.italic,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
TextField(
|
||||
controller: controller,
|
||||
style: theme.textTheme.bodyLarge,
|
||||
maxLength: 20,
|
||||
decoration: InputDecoration(
|
||||
hintText: showGhost ? '' : hint,
|
||||
isDense: true,
|
||||
filled: false,
|
||||
counterText: '',
|
||||
enabledBorder: InputBorder.none,
|
||||
focusedBorder: InputBorder.none,
|
||||
border: InputBorder.none,
|
||||
contentPadding: const EdgeInsets.symmetric(
|
||||
horizontal: 14,
|
||||
vertical: 14,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
_trailing(context),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Widget _trailing(BuildContext context) {
|
||||
if (isTranslating) {
|
||||
return const Padding(
|
||||
padding: EdgeInsets.symmetric(horizontal: 14),
|
||||
child: SizedBox(
|
||||
width: 18,
|
||||
height: 18,
|
||||
child: CircularProgressIndicator(strokeWidth: 2),
|
||||
),
|
||||
);
|
||||
}
|
||||
final isEmpty = controller.text.trim().isEmpty;
|
||||
if (isEmpty && suggestion != null) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.only(right: 6),
|
||||
child: TextButton(
|
||||
onPressed: onApply,
|
||||
style: TextButton.styleFrom(
|
||||
foregroundColor: const Color(0xFF7C6DED),
|
||||
padding: const EdgeInsets.symmetric(horizontal: 10),
|
||||
minimumSize: const Size(0, 36),
|
||||
tapTargetSize: MaterialTapTargetSize.shrinkWrap,
|
||||
),
|
||||
child: Text(
|
||||
applyLabel,
|
||||
style: const TextStyle(fontWeight: FontWeight.w700),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
if (isEmpty && canTranslate) {
|
||||
return IconButton(
|
||||
onPressed: onTranslate,
|
||||
icon: const Icon(Icons.translate_rounded, size: 20),
|
||||
color: const Color(0xFF7C6DED),
|
||||
tooltip: '',
|
||||
);
|
||||
}
|
||||
return const SizedBox(width: 8);
|
||||
}
|
||||
}
|
||||
|
||||
class _IconGrid extends StatelessWidget {
|
||||
final String selected;
|
||||
final Color color;
|
||||
final ValueChanged<String> onSelected;
|
||||
|
||||
const _IconGrid({
|
||||
required this.selected,
|
||||
required this.color,
|
||||
required this.onSelected,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final theme = Theme.of(context);
|
||||
return Center(
|
||||
child: Wrap(
|
||||
alignment: WrapAlignment.center,
|
||||
spacing: 10,
|
||||
runSpacing: 10,
|
||||
children: kCategoryIcons.entries.map((entry) {
|
||||
final isSelected = entry.key == selected;
|
||||
return GestureDetector(
|
||||
onTap: () => onSelected(entry.key),
|
||||
child: Container(
|
||||
width: 48,
|
||||
height: 48,
|
||||
decoration: BoxDecoration(
|
||||
color: isSelected
|
||||
? color.withOpacity(0.2)
|
||||
: theme.colorScheme.surface,
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
border: Border.all(
|
||||
color: isSelected ? color : Colors.transparent,
|
||||
width: 1.5,
|
||||
),
|
||||
),
|
||||
child: Icon(
|
||||
entry.value,
|
||||
color: isSelected
|
||||
? color
|
||||
: theme.colorScheme.onSurface.withOpacity(0.6),
|
||||
size: 22,
|
||||
),
|
||||
),
|
||||
);
|
||||
}).toList(),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _ColorRow extends StatelessWidget {
|
||||
final int selected;
|
||||
final ValueChanged<int> onSelected;
|
||||
|
||||
const _ColorRow({required this.selected, required this.onSelected});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Center(
|
||||
child: Wrap(
|
||||
alignment: WrapAlignment.center,
|
||||
spacing: 12,
|
||||
runSpacing: 12,
|
||||
children: kCategoryColors.map((color) {
|
||||
final isSelected = color.value == selected;
|
||||
return GestureDetector(
|
||||
onTap: () => onSelected(color.value),
|
||||
child: Container(
|
||||
width: 40,
|
||||
height: 40,
|
||||
decoration: BoxDecoration(
|
||||
color: color,
|
||||
shape: BoxShape.circle,
|
||||
border: Border.all(
|
||||
color: isSelected ? Colors.white : Colors.transparent,
|
||||
width: 3,
|
||||
),
|
||||
boxShadow: isSelected
|
||||
? [
|
||||
BoxShadow(
|
||||
color: color.withOpacity(0.5),
|
||||
blurRadius: 8,
|
||||
spreadRadius: 1,
|
||||
),
|
||||
]
|
||||
: null,
|
||||
),
|
||||
child: isSelected
|
||||
? const Icon(Icons.check_rounded, color: Colors.white, size: 20)
|
||||
: null,
|
||||
),
|
||||
);
|
||||
}).toList(),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,267 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import '../../../core/constants.dart';
|
||||
import '../../../core/l10n/app_strings.dart';
|
||||
import '../../../core/l10n/locale_provider.dart';
|
||||
import '../../../core/services/haptic_service.dart';
|
||||
import '../../../shared/models/app_category.dart';
|
||||
import '../../../shared/models/transaction.dart';
|
||||
import '../../../shared/providers/category_provider.dart';
|
||||
import 'category_editor_sheet.dart';
|
||||
|
||||
class CategoryManagerScreen extends ConsumerWidget {
|
||||
const CategoryManagerScreen({super.key});
|
||||
|
||||
Future<void> _confirmDelete(
|
||||
BuildContext context,
|
||||
WidgetRef ref,
|
||||
AppCategory category,
|
||||
) async {
|
||||
final s = ref.read(stringsProvider);
|
||||
final confirmed = await showDialog<bool>(
|
||||
context: context,
|
||||
builder: (ctx) => AlertDialog(
|
||||
title: Text(s.deleteCategoryConfirm),
|
||||
content: Text(s.deleteCategoryWarning),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => Navigator.pop(ctx, false),
|
||||
child: Text(s.cancel),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () => Navigator.pop(ctx, true),
|
||||
style: TextButton.styleFrom(foregroundColor: AppColors.expense),
|
||||
child: Text(s.delete),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
if (confirmed == true && category.id != null) {
|
||||
HapticService.medium();
|
||||
await ref.read(categoryActionsProvider).remove(category.id!);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final s = ref.watch(stringsProvider);
|
||||
final isRu = s.locale == AppLocale.ru;
|
||||
final catalog = ref.watch(categoryCatalogProvider);
|
||||
final custom = catalog.custom;
|
||||
final defaults = catalog.all.where((c) => !c.isCustom).toList();
|
||||
|
||||
return Scaffold(
|
||||
backgroundColor: Theme.of(context).scaffoldBackgroundColor,
|
||||
appBar: AppBar(
|
||||
backgroundColor: Theme.of(context).scaffoldBackgroundColor,
|
||||
elevation: 0,
|
||||
scrolledUnderElevation: 0,
|
||||
title: Text(
|
||||
s.manageCategories,
|
||||
style: Theme.of(context).textTheme.titleLarge?.copyWith(
|
||||
fontWeight: FontWeight.w700,
|
||||
),
|
||||
),
|
||||
),
|
||||
floatingActionButton: FloatingActionButton.extended(
|
||||
onPressed: () {
|
||||
HapticService.medium();
|
||||
showCategoryEditor(context);
|
||||
},
|
||||
backgroundColor: const Color(0xFF7C6DED),
|
||||
foregroundColor: Colors.white,
|
||||
icon: const Icon(Icons.add),
|
||||
label: Text(
|
||||
s.addCategory,
|
||||
style: const TextStyle(fontWeight: FontWeight.w600),
|
||||
),
|
||||
),
|
||||
body: ListView(
|
||||
physics: const ClampingScrollPhysics(),
|
||||
padding: const EdgeInsets.fromLTRB(20, 8, 20, 100),
|
||||
children: [
|
||||
_SectionLabel(text: s.customCategories),
|
||||
const SizedBox(height: 12),
|
||||
if (custom.isEmpty)
|
||||
_EmptyState(
|
||||
title: s.noCustomCategories,
|
||||
subtitle: s.noCustomCategoriesHint,
|
||||
)
|
||||
else
|
||||
...custom.map(
|
||||
(c) => Padding(
|
||||
padding: const EdgeInsets.only(bottom: 10),
|
||||
child: _CategoryRow(
|
||||
category: c,
|
||||
isRu: isRu,
|
||||
onTap: () => showCategoryEditor(context, existing: c),
|
||||
onDelete: () => _confirmDelete(context, ref, c),
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 28),
|
||||
_SectionLabel(text: s.defaultCategories),
|
||||
const SizedBox(height: 12),
|
||||
...defaults.map(
|
||||
(c) => Padding(
|
||||
padding: const EdgeInsets.only(bottom: 10),
|
||||
child: _CategoryRow(category: c, isRu: isRu),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _SectionLabel extends StatelessWidget {
|
||||
final String text;
|
||||
|
||||
const _SectionLabel({required this.text});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Text(
|
||||
text.toUpperCase(),
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
letterSpacing: 1.1,
|
||||
fontWeight: FontWeight.w700,
|
||||
color: Theme.of(context).colorScheme.onSurface.withOpacity(0.5),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _CategoryRow extends ConsumerWidget {
|
||||
final AppCategory category;
|
||||
final bool isRu;
|
||||
final VoidCallback? onTap;
|
||||
final VoidCallback? onDelete;
|
||||
|
||||
const _CategoryRow({
|
||||
required this.category,
|
||||
required this.isRu,
|
||||
this.onTap,
|
||||
this.onDelete,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final s = ref.watch(stringsProvider);
|
||||
final theme = Theme.of(context);
|
||||
final isDark = theme.brightness == Brightness.dark;
|
||||
final isIncome = category.type == TransactionType.income;
|
||||
return GestureDetector(
|
||||
onTap: onTap,
|
||||
child: Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 14, vertical: 12),
|
||||
decoration: BoxDecoration(
|
||||
color: theme.colorScheme.surface,
|
||||
borderRadius: BorderRadius.circular(14),
|
||||
border: isDark
|
||||
? null
|
||||
: Border.all(color: const Color(0xFFDDDDEE), width: 1),
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
Container(
|
||||
width: 40,
|
||||
height: 40,
|
||||
decoration: BoxDecoration(
|
||||
color: category.color.withOpacity(0.15),
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
),
|
||||
child: Icon(category.icon, color: category.color, size: 20),
|
||||
),
|
||||
const SizedBox(width: 12),
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
category.label(isRu),
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: theme.textTheme.bodyLarge?.copyWith(
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 2),
|
||||
Text(
|
||||
isIncome ? s.income : s.expenses,
|
||||
style: theme.textTheme.bodySmall?.copyWith(
|
||||
color: (isIncome ? AppColors.income : AppColors.expense)
|
||||
.withOpacity(0.9),
|
||||
fontWeight: FontWeight.w500,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
if (onDelete != null)
|
||||
IconButton(
|
||||
onPressed: onDelete,
|
||||
icon: const Icon(Icons.delete_outline_rounded, size: 20),
|
||||
color: theme.colorScheme.onSurface.withOpacity(0.4),
|
||||
)
|
||||
else
|
||||
Icon(
|
||||
Icons.lock_outline_rounded,
|
||||
size: 18,
|
||||
color: theme.colorScheme.onSurface.withOpacity(0.25),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _EmptyState extends StatelessWidget {
|
||||
final String title;
|
||||
final String subtitle;
|
||||
|
||||
const _EmptyState({required this.title, required this.subtitle});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final theme = Theme.of(context);
|
||||
return Container(
|
||||
width: double.infinity,
|
||||
padding: const EdgeInsets.symmetric(vertical: 32, horizontal: 20),
|
||||
decoration: BoxDecoration(
|
||||
color: theme.colorScheme.surface,
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
border: theme.brightness == Brightness.dark
|
||||
? null
|
||||
: Border.all(color: const Color(0xFFDDDDEE), width: 1),
|
||||
),
|
||||
child: Column(
|
||||
children: [
|
||||
Icon(
|
||||
Icons.category_outlined,
|
||||
size: 36,
|
||||
color: theme.colorScheme.onSurface.withOpacity(0.3),
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
Text(
|
||||
title,
|
||||
textAlign: TextAlign.center,
|
||||
style: theme.textTheme.bodyLarge?.copyWith(
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
Text(
|
||||
subtitle,
|
||||
textAlign: TextAlign.center,
|
||||
style: theme.textTheme.bodySmall?.copyWith(
|
||||
color: theme.colorScheme.onSurface.withOpacity(0.6),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -11,32 +11,6 @@ import '../../shared/utils/currency_utils.dart';
|
||||
import '../../shared/providers/amount_format_provider.dart';
|
||||
import '../dashboard/provider.dart';
|
||||
|
||||
final budgetProvider = StateNotifierProvider<BudgetNotifier, double?>((ref) {
|
||||
final storage = ref.watch(storageServiceProvider);
|
||||
return BudgetNotifier(storage.loadBudget(), storage);
|
||||
});
|
||||
|
||||
class BudgetNotifier extends StateNotifier<double?> {
|
||||
final dynamic _storage;
|
||||
|
||||
BudgetNotifier(super.initialBudget, this._storage);
|
||||
|
||||
Future<void> setBudget(double? budget) async {
|
||||
await _storage.saveBudget(budget);
|
||||
state = budget;
|
||||
}
|
||||
|
||||
void onCurrencyChanged(
|
||||
String oldCode,
|
||||
String newCode,
|
||||
ExchangeRateService rates,
|
||||
) {
|
||||
if (state == null) return;
|
||||
final converted = rates.convert(state!, oldCode, newCode);
|
||||
setBudget(converted);
|
||||
}
|
||||
}
|
||||
|
||||
class CurrencyInfo {
|
||||
final String symbol;
|
||||
final String code;
|
||||
@@ -50,70 +24,60 @@ const Map<String, CurrencyInfo> currencyMap = {
|
||||
'RUB': CurrencyInfo('₽', 'RUB'),
|
||||
};
|
||||
|
||||
class CurrencyNotifier extends StateNotifier<CurrencyInfo> {
|
||||
final SharedPreferences _prefs;
|
||||
|
||||
CurrencyNotifier(this._prefs) : super(currencyMap['USD']!) {
|
||||
_load();
|
||||
}
|
||||
|
||||
void _load() {
|
||||
final code = _prefs.getString('currency_code') ?? 'USD';
|
||||
state = currencyMap[code] ?? currencyMap['USD']!;
|
||||
class CurrencyNotifier extends Notifier<CurrencyInfo> {
|
||||
@override
|
||||
CurrencyInfo build() {
|
||||
final prefs = ref.watch(sharedPreferencesProvider);
|
||||
final code = prefs.getString('currency_code') ?? 'USD';
|
||||
return currencyMap[code] ?? currencyMap['USD']!;
|
||||
}
|
||||
|
||||
Future<void> setCurrency(String code) async {
|
||||
final prefs = ref.read(sharedPreferencesProvider);
|
||||
state = currencyMap[code] ?? currencyMap['USD']!;
|
||||
await _prefs.setString('currency_code', code);
|
||||
await prefs.setString('currency_code', code);
|
||||
}
|
||||
}
|
||||
|
||||
final currencyProvider = StateNotifierProvider<CurrencyNotifier, CurrencyInfo>((
|
||||
ref,
|
||||
) {
|
||||
final prefs = ref.watch(sharedPreferencesProvider);
|
||||
return CurrencyNotifier(prefs);
|
||||
});
|
||||
final currencyProvider = NotifierProvider<CurrencyNotifier, CurrencyInfo>(
|
||||
CurrencyNotifier.new,
|
||||
);
|
||||
|
||||
class ThemeModeNotifier extends StateNotifier<ThemeMode> {
|
||||
final SharedPreferences _prefs;
|
||||
|
||||
ThemeModeNotifier(this._prefs) : super(ThemeMode.system) {
|
||||
_load();
|
||||
}
|
||||
|
||||
void _load() {
|
||||
final saved = _prefs.getString('theme_mode');
|
||||
class ThemeModeNotifier extends Notifier<ThemeMode> {
|
||||
@override
|
||||
ThemeMode build() {
|
||||
final prefs = ref.watch(sharedPreferencesProvider);
|
||||
final saved = prefs.getString('theme_mode');
|
||||
if (saved == 'dark') {
|
||||
state = ThemeMode.dark;
|
||||
return ThemeMode.dark;
|
||||
} else if (saved == 'light') {
|
||||
state = ThemeMode.light;
|
||||
return ThemeMode.light;
|
||||
} else {
|
||||
state = ThemeMode.system;
|
||||
return ThemeMode.system;
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> setThemeMode(ThemeMode mode) async {
|
||||
final prefs = ref.read(sharedPreferencesProvider);
|
||||
state = mode;
|
||||
await _prefs.setString('theme_mode', mode.name);
|
||||
await prefs.setString('theme_mode', mode.name);
|
||||
}
|
||||
}
|
||||
|
||||
final themeProvider = StateNotifierProvider<ThemeModeNotifier, ThemeMode>((
|
||||
ref,
|
||||
) {
|
||||
final prefs = ref.watch(sharedPreferencesProvider);
|
||||
return ThemeModeNotifier(prefs);
|
||||
});
|
||||
final themeProvider = NotifierProvider<ThemeModeNotifier, ThemeMode>(
|
||||
ThemeModeNotifier.new,
|
||||
);
|
||||
|
||||
enum CardTextColorMode { white, adaptive, black }
|
||||
|
||||
class CardTextColorNotifier extends StateNotifier<CardTextColorMode> {
|
||||
class CardTextColorNotifier extends Notifier<CardTextColorMode> {
|
||||
static const _key = 'card_text_color';
|
||||
final SharedPreferences _prefs;
|
||||
|
||||
CardTextColorNotifier(this._prefs)
|
||||
: super(_fromString(_prefs.getString(_key)));
|
||||
@override
|
||||
CardTextColorMode build() {
|
||||
final prefs = ref.watch(sharedPreferencesProvider);
|
||||
return _fromString(prefs.getString(_key));
|
||||
}
|
||||
|
||||
static CardTextColorMode _fromString(String? value) {
|
||||
return CardTextColorMode.values.firstWhere(
|
||||
@@ -123,35 +87,60 @@ class CardTextColorNotifier extends StateNotifier<CardTextColorMode> {
|
||||
}
|
||||
|
||||
void set(CardTextColorMode mode) {
|
||||
final prefs = ref.read(sharedPreferencesProvider);
|
||||
state = mode;
|
||||
_prefs.setString(_key, mode.name);
|
||||
prefs.setString(_key, mode.name);
|
||||
}
|
||||
}
|
||||
|
||||
final cardTextColorProvider =
|
||||
StateNotifierProvider<CardTextColorNotifier, CardTextColorMode>((ref) {
|
||||
final prefs = ref.watch(sharedPreferencesProvider);
|
||||
return CardTextColorNotifier(prefs);
|
||||
});
|
||||
NotifierProvider<CardTextColorNotifier, CardTextColorMode>(
|
||||
CardTextColorNotifier.new,
|
||||
);
|
||||
|
||||
final exchangeRateServiceProvider = Provider<ExchangeRateService>((ref) {
|
||||
final prefs = ref.watch(sharedPreferencesProvider);
|
||||
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 {
|
||||
await ref.read(exchangeRateServiceProvider).fetchRates();
|
||||
});
|
||||
|
||||
final hapticEnabledProvider = StateNotifierProvider<HapticNotifier, bool>((
|
||||
ref,
|
||||
) {
|
||||
return HapticNotifier();
|
||||
});
|
||||
final hapticEnabledProvider = NotifierProvider<HapticNotifier, bool>(
|
||||
HapticNotifier.new,
|
||||
);
|
||||
|
||||
class HapticNotifier extends StateNotifier<bool> {
|
||||
HapticNotifier() : super(true) {
|
||||
class HapticNotifier extends Notifier<bool> {
|
||||
@override
|
||||
bool build() {
|
||||
_load();
|
||||
return true;
|
||||
}
|
||||
|
||||
Future<void> _load() async {
|
||||
@@ -166,13 +155,15 @@ class HapticNotifier extends StateNotifier<bool> {
|
||||
}
|
||||
|
||||
final showCurrencyConversionsProvider =
|
||||
StateNotifierProvider<ShowCurrencyConversionsNotifier, bool>((ref) {
|
||||
return ShowCurrencyConversionsNotifier();
|
||||
});
|
||||
NotifierProvider<ShowCurrencyConversionsNotifier, bool>(
|
||||
ShowCurrencyConversionsNotifier.new,
|
||||
);
|
||||
|
||||
class ShowCurrencyConversionsNotifier extends StateNotifier<bool> {
|
||||
ShowCurrencyConversionsNotifier() : super(true) {
|
||||
class ShowCurrencyConversionsNotifier extends Notifier<bool> {
|
||||
@override
|
||||
bool build() {
|
||||
_load();
|
||||
return true;
|
||||
}
|
||||
|
||||
Future<void> _load() async {
|
||||
@@ -198,7 +189,7 @@ class ExportService {
|
||||
|
||||
Future<String> exportToCSV() async {
|
||||
final transactionsAsync = _ref.read(transactionsProvider);
|
||||
final transactions = transactionsAsync.valueOrNull ?? [];
|
||||
final transactions = transactionsAsync.value ?? [];
|
||||
final fmt = _ref.read(amountFormatProvider);
|
||||
|
||||
final buffer = StringBuffer();
|
||||
|
||||
@@ -5,7 +5,6 @@ import '../../core/l10n/locale_provider.dart';
|
||||
import '../../core/services/biometric_service.dart';
|
||||
import '../../core/services/haptic_service.dart';
|
||||
import '../dashboard/provider.dart';
|
||||
import 'provider.dart';
|
||||
import 'widgets/theme_section.dart';
|
||||
import 'widgets/card_text_color_section.dart';
|
||||
import 'widgets/haptic_section.dart';
|
||||
@@ -13,7 +12,8 @@ import 'widgets/currency_conversions_section.dart';
|
||||
import 'widgets/language_section.dart';
|
||||
import 'widgets/currency_section.dart';
|
||||
import 'widgets/amount_format_section.dart';
|
||||
import 'widgets/budget_section.dart';
|
||||
import 'widgets/categories_section.dart';
|
||||
import '../../shared/widgets/pro_subscription_card.dart';
|
||||
|
||||
class SettingsScreen extends ConsumerWidget {
|
||||
const SettingsScreen({super.key});
|
||||
@@ -111,70 +111,66 @@ class SettingsScreen extends ConsumerWidget {
|
||||
|
||||
return Scaffold(
|
||||
backgroundColor: Theme.of(context).scaffoldBackgroundColor,
|
||||
appBar: AppBar(
|
||||
title: Text(
|
||||
s.settings,
|
||||
style: Theme.of(context).textTheme.titleLarge?.copyWith(
|
||||
fontWeight: FontWeight.w700,
|
||||
color: Theme.of(context).colorScheme.onSurface,
|
||||
),
|
||||
body: SafeArea(
|
||||
child: ListView(
|
||||
physics: const ClampingScrollPhysics(),
|
||||
padding: const EdgeInsets.fromLTRB(20, 16, 20, 40),
|
||||
children: [
|
||||
const ProSubscriptionCard(),
|
||||
const SizedBox(height: 12),
|
||||
const CurrencySection(),
|
||||
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 SizedBox(height: 12),
|
||||
const CurrencyConversionsSection(),
|
||||
const SizedBox(height: 12),
|
||||
const CategoriesSection(),
|
||||
const SizedBox(height: 24),
|
||||
Text(
|
||||
s.dangerZone,
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
letterSpacing: 1.2,
|
||||
color: const Color(0xFFE05C6B).withOpacity(0.8),
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
SizedBox(
|
||||
width: double.infinity,
|
||||
child: OutlinedButton.icon(
|
||||
onPressed: () => _confirmClearData(context, ref),
|
||||
icon: const Icon(Icons.delete_forever, color: Color(0xFFE05C6B)),
|
||||
label: Text(
|
||||
s.clearAllTransactions,
|
||||
style: const TextStyle(color: Color(0xFFE05C6B)),
|
||||
),
|
||||
style: OutlinedButton.styleFrom(
|
||||
side: BorderSide(
|
||||
color: const Color(0xFFE05C6B).withOpacity(0.5),
|
||||
),
|
||||
padding: const EdgeInsets.symmetric(vertical: 14),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 40),
|
||||
const _FooterWidget(),
|
||||
],
|
||||
),
|
||||
),
|
||||
body: ListView(
|
||||
physics: const ClampingScrollPhysics(),
|
||||
padding: const EdgeInsets.fromLTRB(20, 16, 20, 40),
|
||||
children: [
|
||||
const ThemeSection(),
|
||||
const SizedBox(height: 16),
|
||||
const CardTextColorSection(),
|
||||
const SizedBox(height: 16),
|
||||
const HapticSection(),
|
||||
const SizedBox(height: 16),
|
||||
const CurrencyConversionsSection(),
|
||||
const SizedBox(height: 16),
|
||||
const _BiometricSection(),
|
||||
const LanguageSection(),
|
||||
const SizedBox(height: 16),
|
||||
const CurrencySection(),
|
||||
const SizedBox(height: 16),
|
||||
const AmountFormatSection(),
|
||||
const SizedBox(height: 16),
|
||||
const BudgetSection(),
|
||||
const SizedBox(height: 24),
|
||||
Text(
|
||||
s.dangerZone,
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
letterSpacing: 1.2,
|
||||
color: const Color(0xFFE05C6B).withOpacity(0.8),
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
SizedBox(
|
||||
width: double.infinity,
|
||||
child: OutlinedButton.icon(
|
||||
onPressed: () => _confirmClearData(context, ref),
|
||||
icon: const Icon(Icons.delete_forever, color: Color(0xFFE05C6B)),
|
||||
label: Text(
|
||||
s.clearAllTransactions,
|
||||
style: const TextStyle(color: Color(0xFFE05C6B)),
|
||||
),
|
||||
style: OutlinedButton.styleFrom(
|
||||
side: BorderSide(
|
||||
color: const Color(0xFFE05C6B).withOpacity(0.5),
|
||||
),
|
||||
padding: const EdgeInsets.symmetric(vertical: 14),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 40),
|
||||
const _FooterWidget(),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -287,12 +283,12 @@ class _BiometricSectionState extends ConsumerState<_BiometricSection> {
|
||||
Container(
|
||||
padding: const EdgeInsets.all(10),
|
||||
decoration: BoxDecoration(
|
||||
color: AppColors.accent.withOpacity(0.15),
|
||||
color: const Color(0xFF7C6DED).withOpacity(0.15),
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
),
|
||||
child: const Icon(
|
||||
Icons.fingerprint,
|
||||
color: AppColors.accent,
|
||||
color: const Color(0xFF7C6DED),
|
||||
size: 20,
|
||||
),
|
||||
),
|
||||
|
||||
@@ -33,12 +33,12 @@ class AmountFormatSection extends ConsumerWidget {
|
||||
Container(
|
||||
padding: const EdgeInsets.all(10),
|
||||
decoration: BoxDecoration(
|
||||
color: AppColors.accent.withOpacity(0.15),
|
||||
color: const Color(0xFF7C6DED).withOpacity(0.15),
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
),
|
||||
child: const Icon(
|
||||
Icons.format_list_numbered_rounded,
|
||||
color: AppColors.accent,
|
||||
color: const Color(0xFF7C6DED),
|
||||
size: 20,
|
||||
),
|
||||
),
|
||||
@@ -69,11 +69,11 @@ class AmountFormatSection extends ConsumerWidget {
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
color: isSelected
|
||||
? AppColors.accent.withOpacity(0.2)
|
||||
? const Color(0xFF7C6DED).withOpacity(0.2)
|
||||
: Theme.of(context).scaffoldBackgroundColor,
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
border: isSelected
|
||||
? Border.all(color: AppColors.accent, width: 1.5)
|
||||
? Border.all(color: const Color(0xFF7C6DED), width: 1.5)
|
||||
: (isDark
|
||||
? null
|
||||
: Border.all(
|
||||
@@ -88,7 +88,7 @@ class AmountFormatSection extends ConsumerWidget {
|
||||
format.label,
|
||||
style: TextStyle(
|
||||
color: isSelected
|
||||
? AppColors.accent
|
||||
? const Color(0xFF7C6DED)
|
||||
: Theme.of(context).colorScheme.onSurface,
|
||||
fontWeight: isSelected
|
||||
? FontWeight.w600
|
||||
|
||||
@@ -1,219 +0,0 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import '../../../core/constants.dart';
|
||||
import '../../../core/l10n/locale_provider.dart';
|
||||
import '../../../shared/providers/amount_format_provider.dart';
|
||||
import '../../../shared/utils/currency_utils.dart';
|
||||
import '../../../shared/widgets/byn_sign.dart';
|
||||
import '../provider.dart';
|
||||
|
||||
class BudgetSection extends ConsumerStatefulWidget {
|
||||
const BudgetSection({super.key});
|
||||
|
||||
@override
|
||||
ConsumerState<BudgetSection> createState() => _BudgetSectionState();
|
||||
}
|
||||
|
||||
class _BudgetSectionState extends ConsumerState<BudgetSection> {
|
||||
final _budgetController = TextEditingController();
|
||||
bool _isEditing = false;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
final budget = ref.read(budgetProvider);
|
||||
if (budget != null) {
|
||||
_budgetController.text = budget.toStringAsFixed(2);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_budgetController.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
Future<void> _saveBudget() async {
|
||||
final text = _budgetController.text.trim();
|
||||
if (text.isEmpty) {
|
||||
await ref.read(budgetProvider.notifier).setBudget(null);
|
||||
} else {
|
||||
final value = double.tryParse(text);
|
||||
if (value != null && value > 0) {
|
||||
await ref.read(budgetProvider.notifier).setBudget(value);
|
||||
}
|
||||
}
|
||||
setState(() => _isEditing = false);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final s = ref.watch(stringsProvider);
|
||||
final budget = ref.watch(budgetProvider);
|
||||
final currencyInfo = ref.watch(currencyProvider);
|
||||
final fmt = ref.watch(amountFormatProvider);
|
||||
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: AppColors.accent.withOpacity(0.15),
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
),
|
||||
child: const Icon(
|
||||
Icons.account_balance_wallet_rounded,
|
||||
color: AppColors.accent,
|
||||
size: 20,
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 12),
|
||||
Expanded(
|
||||
child: Text(
|
||||
s.monthlyBudgetSetting,
|
||||
style: Theme.of(context).textTheme.titleMedium?.copyWith(
|
||||
fontWeight: FontWeight.w600,
|
||||
color: Theme.of(context).colorScheme.onSurface,
|
||||
),
|
||||
),
|
||||
),
|
||||
if (!_isEditing)
|
||||
IconButton(
|
||||
icon: const Icon(Icons.edit_rounded, size: 20),
|
||||
color: Theme.of(
|
||||
context,
|
||||
).colorScheme.onSurface.withOpacity(0.6),
|
||||
onPressed: () => setState(() => _isEditing = true),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
if (_isEditing)
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
TextFormField(
|
||||
controller: _budgetController,
|
||||
keyboardType: const TextInputType.numberWithOptions(
|
||||
decimal: true,
|
||||
),
|
||||
inputFormatters: [
|
||||
FilteringTextInputFormatter.allow(
|
||||
RegExp(r'^\d+\.?\d{0,2}'),
|
||||
),
|
||||
],
|
||||
decoration: InputDecoration(
|
||||
prefix: currencyInfo.code == 'BYN'
|
||||
? Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
BynSign(
|
||||
fontSize: 16,
|
||||
color: Theme.of(context).colorScheme.onSurface,
|
||||
),
|
||||
const SizedBox(width: 4),
|
||||
],
|
||||
)
|
||||
: null,
|
||||
prefixText: currencyInfo.code != 'BYN'
|
||||
? (currencyInfo.symbol == '₽'
|
||||
? '${currencyInfo.symbol} '
|
||||
: currencyInfo.symbol)
|
||||
: null,
|
||||
hintText: '0.00',
|
||||
helperText: s.leaveEmptyToRemove,
|
||||
),
|
||||
autofocus: true,
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
children: [
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
final budget = ref.read(budgetProvider);
|
||||
_budgetController.text =
|
||||
budget?.toStringAsFixed(2) ?? '';
|
||||
setState(() => _isEditing = false);
|
||||
},
|
||||
child: Text(s.cancel),
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
ElevatedButton(
|
||||
onPressed: _saveBudget,
|
||||
style: ElevatedButton.styleFrom(
|
||||
minimumSize: const Size(80, 40),
|
||||
),
|
||||
child: Text(s.save),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
)
|
||||
else
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
budget != null && currencyInfo.code == 'BYN'
|
||||
? Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
BynSign(fontSize: 24, color: AppColors.accent),
|
||||
const SizedBox(width: 2),
|
||||
Text(
|
||||
formatAmount('', budget, fmt),
|
||||
style: Theme.of(context).textTheme.headlineSmall
|
||||
?.copyWith(
|
||||
color: AppColors.accent,
|
||||
fontWeight: FontWeight.w700,
|
||||
),
|
||||
),
|
||||
],
|
||||
)
|
||||
: Text(
|
||||
budget != null
|
||||
? formatAmount(currencyInfo.symbol, budget, fmt)
|
||||
: s.budgetNone,
|
||||
style: Theme.of(context).textTheme.headlineSmall
|
||||
?.copyWith(
|
||||
color: budget != null
|
||||
? AppColors.accent
|
||||
: Theme.of(
|
||||
context,
|
||||
).colorScheme.onSurface.withOpacity(0.6),
|
||||
fontWeight: FontWeight.w700,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
Text(
|
||||
budget != null
|
||||
? s.yourMonthlySpendingLimit
|
||||
: s.setMonthlySpendingLimit,
|
||||
style: Theme.of(context).textTheme.bodySmall?.copyWith(
|
||||
color: Theme.of(
|
||||
context,
|
||||
).colorScheme.onSurface.withOpacity(0.6),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -14,7 +14,7 @@ class CardTextColorSection extends ConsumerWidget {
|
||||
final isDark = Theme.of(context).brightness == Brightness.dark;
|
||||
|
||||
return Container(
|
||||
padding: const EdgeInsets.all(20),
|
||||
padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 14),
|
||||
decoration: BoxDecoration(
|
||||
color: Theme.of(context).colorScheme.surface,
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
@@ -30,12 +30,12 @@ class CardTextColorSection extends ConsumerWidget {
|
||||
Container(
|
||||
padding: const EdgeInsets.all(10),
|
||||
decoration: BoxDecoration(
|
||||
color: AppColors.accent.withOpacity(0.15),
|
||||
color: const Color(0xFF7C6DED).withOpacity(0.15),
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
),
|
||||
child: const Icon(
|
||||
Icons.text_fields_rounded,
|
||||
color: AppColors.accent,
|
||||
color: const Color(0xFF7C6DED),
|
||||
size: 20,
|
||||
),
|
||||
),
|
||||
@@ -49,7 +49,7 @@ class CardTextColorSection extends ConsumerWidget {
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
const SizedBox(height: 12),
|
||||
Row(
|
||||
children: [
|
||||
Expanded(
|
||||
@@ -113,17 +113,17 @@ class _CardTextColorOption extends StatelessWidget {
|
||||
onTap: onTap,
|
||||
child: AnimatedContainer(
|
||||
duration: const Duration(milliseconds: 200),
|
||||
padding: const EdgeInsets.symmetric(vertical: 12),
|
||||
padding: const EdgeInsets.symmetric(vertical: 10),
|
||||
decoration: BoxDecoration(
|
||||
color: isSelected
|
||||
? AppColors.accent.withOpacity(0.15)
|
||||
? const Color(0xFF7C6DED).withOpacity(0.15)
|
||||
: (isDark
|
||||
? Colors.white.withOpacity(0.05)
|
||||
: Colors.black.withOpacity(0.03)),
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
border: Border.all(
|
||||
color: isSelected
|
||||
? AppColors.accent
|
||||
? const Color(0xFF7C6DED)
|
||||
: (isDark
|
||||
? Colors.white.withOpacity(0.1)
|
||||
: Colors.black.withOpacity(0.08)),
|
||||
@@ -136,7 +136,7 @@ class _CardTextColorOption extends StatelessWidget {
|
||||
Icon(
|
||||
icon,
|
||||
color: isSelected
|
||||
? AppColors.accent
|
||||
? const Color(0xFF7C6DED)
|
||||
: Theme.of(context).colorScheme.onSurface.withOpacity(0.5),
|
||||
size: 22,
|
||||
),
|
||||
@@ -147,7 +147,7 @@ class _CardTextColorOption extends StatelessWidget {
|
||||
fontSize: 11,
|
||||
fontWeight: isSelected ? FontWeight.w600 : FontWeight.normal,
|
||||
color: isSelected
|
||||
? AppColors.accent
|
||||
? const Color(0xFF7C6DED)
|
||||
: Theme.of(context).colorScheme.onSurface.withOpacity(0.6),
|
||||
),
|
||||
textAlign: TextAlign.center,
|
||||
|
||||
@@ -0,0 +1,75 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import '../../../core/constants.dart';
|
||||
import '../../../core/l10n/locale_provider.dart';
|
||||
import '../../../core/services/haptic_service.dart';
|
||||
|
||||
class CategoriesSection extends ConsumerWidget {
|
||||
const CategoriesSection({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final s = ref.watch(stringsProvider);
|
||||
final theme = Theme.of(context);
|
||||
final isDark = theme.brightness == Brightness.dark;
|
||||
|
||||
return GestureDetector(
|
||||
onTap: () {
|
||||
HapticService.light();
|
||||
context.push('/settings/categories');
|
||||
},
|
||||
child: Container(
|
||||
padding: const EdgeInsets.all(20),
|
||||
decoration: BoxDecoration(
|
||||
color: theme.colorScheme.surface,
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
border: isDark
|
||||
? null
|
||||
: Border.all(color: const Color(0xFFDDDDEE), width: 1),
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
Container(
|
||||
padding: const EdgeInsets.all(10),
|
||||
decoration: BoxDecoration(
|
||||
color: const Color(0xFF7C6DED).withOpacity(0.15),
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
),
|
||||
child: const Icon(
|
||||
Icons.category_rounded,
|
||||
color: const Color(0xFF7C6DED),
|
||||
size: 20,
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 12),
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
s.manageCategories,
|
||||
style: theme.textTheme.titleMedium?.copyWith(
|
||||
fontWeight: FontWeight.w600,
|
||||
color: theme.colorScheme.onSurface,
|
||||
),
|
||||
),
|
||||
Text(
|
||||
s.manageCategoriesSubtitle,
|
||||
style: theme.textTheme.bodySmall?.copyWith(
|
||||
color: theme.colorScheme.onSurface.withOpacity(0.6),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
Icon(
|
||||
Icons.chevron_right_rounded,
|
||||
color: theme.colorScheme.onSurface.withOpacity(0.4),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -27,12 +27,12 @@ class CurrencyConversionsSection extends ConsumerWidget {
|
||||
Container(
|
||||
padding: const EdgeInsets.all(10),
|
||||
decoration: BoxDecoration(
|
||||
color: AppColors.accent.withOpacity(0.15),
|
||||
color: const Color(0xFF7C6DED).withOpacity(0.15),
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
),
|
||||
child: const Icon(
|
||||
Icons.currency_exchange_rounded,
|
||||
color: AppColors.accent,
|
||||
color: const Color(0xFF7C6DED),
|
||||
size: 20,
|
||||
),
|
||||
),
|
||||
|
||||
@@ -15,7 +15,7 @@ class CurrencySection extends ConsumerWidget {
|
||||
final isDark = Theme.of(context).brightness == Brightness.dark;
|
||||
|
||||
return Container(
|
||||
padding: const EdgeInsets.all(20),
|
||||
padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 14),
|
||||
decoration: BoxDecoration(
|
||||
color: Theme.of(context).colorScheme.surface,
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
@@ -31,12 +31,12 @@ class CurrencySection extends ConsumerWidget {
|
||||
Container(
|
||||
padding: const EdgeInsets.all(10),
|
||||
decoration: BoxDecoration(
|
||||
color: AppColors.accent.withOpacity(0.15),
|
||||
color: const Color(0xFF7C6DED).withOpacity(0.15),
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
),
|
||||
child: const Icon(
|
||||
Icons.attach_money_rounded,
|
||||
color: AppColors.accent,
|
||||
color: const Color(0xFF7C6DED),
|
||||
size: 20,
|
||||
),
|
||||
),
|
||||
@@ -52,7 +52,7 @@ class CurrencySection extends ConsumerWidget {
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
const SizedBox(height: 12),
|
||||
Row(
|
||||
children: ['USD', 'EUR', 'BYN', 'RUB'].map((code) {
|
||||
final info = currencyMap[code]!;
|
||||
@@ -62,22 +62,17 @@ class CurrencySection extends ConsumerWidget {
|
||||
padding: const EdgeInsets.only(right: 8),
|
||||
child: GestureDetector(
|
||||
onTap: () {
|
||||
final oldCode = ref.read(currencyProvider).code;
|
||||
final rates = ref.read(exchangeRateServiceProvider);
|
||||
ref
|
||||
.read(budgetProvider.notifier)
|
||||
.onCurrencyChanged(oldCode, code, rates);
|
||||
ref.read(currencyProvider.notifier).setCurrency(code);
|
||||
},
|
||||
child: Container(
|
||||
padding: const EdgeInsets.symmetric(vertical: 12),
|
||||
padding: const EdgeInsets.symmetric(vertical: 10),
|
||||
decoration: BoxDecoration(
|
||||
color: isSelected
|
||||
? AppColors.accent.withOpacity(0.2)
|
||||
? const Color(0xFF7C6DED).withOpacity(0.2)
|
||||
: Theme.of(context).scaffoldBackgroundColor,
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
border: isSelected
|
||||
? Border.all(color: AppColors.accent, width: 1.5)
|
||||
? Border.all(color: const Color(0xFF7C6DED), width: 1.5)
|
||||
: (isDark
|
||||
? null
|
||||
: Border.all(
|
||||
@@ -88,19 +83,25 @@ class CurrencySection extends ConsumerWidget {
|
||||
child: Column(
|
||||
children: [
|
||||
code == 'BYN'
|
||||
? BynSign(
|
||||
fontSize: 28,
|
||||
color: isSelected
|
||||
? AppColors.accent
|
||||
: Theme.of(context).colorScheme.onSurface
|
||||
.withOpacity(0.6),
|
||||
? SizedBox(
|
||||
height: 28,
|
||||
child: Align(
|
||||
alignment: Alignment.center,
|
||||
child: BynSign(
|
||||
fontSize: 24,
|
||||
color: isSelected
|
||||
? const Color(0xFF7C6DED)
|
||||
: Theme.of(context).colorScheme.onSurface
|
||||
.withOpacity(0.6),
|
||||
),
|
||||
),
|
||||
)
|
||||
: Text(
|
||||
info.symbol,
|
||||
style: Theme.of(context).textTheme.titleLarge
|
||||
?.copyWith(
|
||||
color: isSelected
|
||||
? AppColors.accent
|
||||
? const Color(0xFF7C6DED)
|
||||
: Theme.of(context)
|
||||
.colorScheme
|
||||
.onSurface
|
||||
@@ -116,7 +117,7 @@ class CurrencySection extends ConsumerWidget {
|
||||
style: Theme.of(context).textTheme.bodySmall
|
||||
?.copyWith(
|
||||
color: isSelected
|
||||
? AppColors.accent
|
||||
? const Color(0xFF7C6DED)
|
||||
: Theme.of(context).colorScheme.onSurface
|
||||
.withOpacity(0.6),
|
||||
fontWeight: isSelected
|
||||
|
||||
@@ -25,12 +25,12 @@ class HapticSection extends ConsumerWidget {
|
||||
Container(
|
||||
padding: const EdgeInsets.all(10),
|
||||
decoration: BoxDecoration(
|
||||
color: AppColors.accent.withOpacity(0.15),
|
||||
color: const Color(0xFF7C6DED).withOpacity(0.15),
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
),
|
||||
child: const Icon(
|
||||
Icons.vibration_rounded,
|
||||
color: AppColors.accent,
|
||||
color: const Color(0xFF7C6DED),
|
||||
size: 20,
|
||||
),
|
||||
),
|
||||
|
||||
@@ -28,12 +28,12 @@ class LanguageSection extends ConsumerWidget {
|
||||
Container(
|
||||
padding: const EdgeInsets.all(10),
|
||||
decoration: BoxDecoration(
|
||||
color: AppColors.accent.withOpacity(0.15),
|
||||
color: const Color(0xFF7C6DED).withOpacity(0.15),
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
),
|
||||
child: const Icon(
|
||||
Icons.language_rounded,
|
||||
color: AppColors.accent,
|
||||
color: const Color(0xFF7C6DED),
|
||||
size: 20,
|
||||
),
|
||||
),
|
||||
@@ -59,11 +59,11 @@ class LanguageSection extends ConsumerWidget {
|
||||
padding: const EdgeInsets.symmetric(vertical: 12),
|
||||
decoration: BoxDecoration(
|
||||
color: currentLocale == AppLocale.en
|
||||
? AppColors.accent.withOpacity(0.2)
|
||||
? const Color(0xFF7C6DED).withOpacity(0.2)
|
||||
: Theme.of(context).scaffoldBackgroundColor,
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
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)),
|
||||
),
|
||||
child: Text(
|
||||
@@ -71,7 +71,7 @@ class LanguageSection extends ConsumerWidget {
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
color: currentLocale == AppLocale.en
|
||||
? AppColors.accent
|
||||
? const Color(0xFF7C6DED)
|
||||
: Theme.of(context).colorScheme.onSurface.withOpacity(0.6),
|
||||
fontWeight: currentLocale == AppLocale.en ? FontWeight.w600 : FontWeight.normal,
|
||||
),
|
||||
@@ -87,11 +87,11 @@ class LanguageSection extends ConsumerWidget {
|
||||
padding: const EdgeInsets.symmetric(vertical: 12),
|
||||
decoration: BoxDecoration(
|
||||
color: currentLocale == AppLocale.ru
|
||||
? AppColors.accent.withOpacity(0.2)
|
||||
? const Color(0xFF7C6DED).withOpacity(0.2)
|
||||
: Theme.of(context).scaffoldBackgroundColor,
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
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)),
|
||||
),
|
||||
child: Text(
|
||||
@@ -99,7 +99,7 @@ class LanguageSection extends ConsumerWidget {
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
color: currentLocale == AppLocale.ru
|
||||
? AppColors.accent
|
||||
? const Color(0xFF7C6DED)
|
||||
: Theme.of(context).colorScheme.onSurface.withOpacity(0.6),
|
||||
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;
|
||||
|
||||
return Container(
|
||||
padding: const EdgeInsets.all(20),
|
||||
padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 14),
|
||||
decoration: BoxDecoration(
|
||||
color: Theme.of(context).colorScheme.surface,
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
@@ -28,7 +28,7 @@ class ThemeSection extends ConsumerWidget {
|
||||
Container(
|
||||
padding: const EdgeInsets.all(10),
|
||||
decoration: BoxDecoration(
|
||||
color: AppColors.accent.withOpacity(0.15),
|
||||
color: const Color(0xFF7C6DED).withOpacity(0.15),
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
),
|
||||
child: Icon(
|
||||
@@ -37,7 +37,7 @@ class ThemeSection extends ConsumerWidget {
|
||||
: themeMode == ThemeMode.light
|
||||
? Icons.light_mode_rounded
|
||||
: Icons.brightness_auto_rounded,
|
||||
color: AppColors.accent,
|
||||
color: const Color(0xFF7C6DED),
|
||||
size: 20,
|
||||
),
|
||||
),
|
||||
@@ -51,7 +51,7 @@ class ThemeSection extends ConsumerWidget {
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
const SizedBox(height: 12),
|
||||
Row(
|
||||
children: [
|
||||
Expanded(
|
||||
@@ -109,15 +109,15 @@ class _ThemeOption extends StatelessWidget {
|
||||
onTap: onTap,
|
||||
child: AnimatedContainer(
|
||||
duration: const Duration(milliseconds: 200),
|
||||
padding: const EdgeInsets.symmetric(vertical: 12),
|
||||
padding: const EdgeInsets.symmetric(vertical: 10),
|
||||
decoration: BoxDecoration(
|
||||
color: isSelected
|
||||
? AppColors.accent.withOpacity(0.15)
|
||||
? const Color(0xFF7C6DED).withOpacity(0.15)
|
||||
: (isDark ? Colors.white.withOpacity(0.05) : Colors.black.withOpacity(0.03)),
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
border: Border.all(
|
||||
color: isSelected
|
||||
? AppColors.accent
|
||||
? const Color(0xFF7C6DED)
|
||||
: (isDark ? Colors.white.withOpacity(0.1) : Colors.black.withOpacity(0.08)),
|
||||
width: isSelected ? 2 : 1,
|
||||
),
|
||||
@@ -128,7 +128,7 @@ class _ThemeOption extends StatelessWidget {
|
||||
Icon(
|
||||
icon,
|
||||
color: isSelected
|
||||
? AppColors.accent
|
||||
? const Color(0xFF7C6DED)
|
||||
: Theme.of(context).colorScheme.onSurface.withOpacity(0.5),
|
||||
size: 22,
|
||||
),
|
||||
@@ -139,7 +139,7 @@ class _ThemeOption extends StatelessWidget {
|
||||
fontSize: 11,
|
||||
fontWeight: isSelected ? FontWeight.w600 : FontWeight.normal,
|
||||
color: isSelected
|
||||
? AppColors.accent
|
||||
? const Color(0xFF7C6DED)
|
||||
: Theme.of(context).colorScheme.onSurface.withOpacity(0.6),
|
||||
),
|
||||
textAlign: TextAlign.center,
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:intl/date_symbol_data_local.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
@@ -6,6 +7,10 @@ import 'app/app.dart';
|
||||
import 'core/services/haptic_service.dart';
|
||||
import 'data/database/app_database.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 {
|
||||
WidgetsFlutterBinding.ensureInitialized();
|
||||
@@ -17,14 +22,22 @@ void main() async {
|
||||
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
await HapticService.init();
|
||||
OnboardingService(prefs);
|
||||
|
||||
final database = AppDatabase();
|
||||
|
||||
final billing = kDebugMode
|
||||
? DebugBillingService(prefs)
|
||||
: PlayBillingService();
|
||||
final premiumManager = PremiumManager(prefs, billing);
|
||||
await premiumManager.autoRestore();
|
||||
|
||||
runApp(
|
||||
ProviderScope(
|
||||
overrides: [
|
||||
sharedPreferencesProvider.overrideWithValue(prefs),
|
||||
appDatabaseProvider.overrideWithValue(database),
|
||||
billingServiceProvider.overrideWithValue(billing),
|
||||
],
|
||||
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;
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'transaction.dart';
|
||||
|
||||
class AppCategory {
|
||||
final String key;
|
||||
final TransactionType type;
|
||||
final String labelEn;
|
||||
final String labelRu;
|
||||
final IconData icon;
|
||||
final Color color;
|
||||
final String iconName;
|
||||
final bool isCustom;
|
||||
final int? id;
|
||||
|
||||
const AppCategory({
|
||||
required this.key,
|
||||
required this.type,
|
||||
required this.labelEn,
|
||||
required this.labelRu,
|
||||
required this.icon,
|
||||
required this.color,
|
||||
required this.iconName,
|
||||
this.isCustom = false,
|
||||
this.id,
|
||||
});
|
||||
|
||||
String label(bool isRu) {
|
||||
final value = isRu ? labelRu : labelEn;
|
||||
return value.isEmpty ? key : value;
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
@@ -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),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -2,9 +2,11 @@ import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
import '../../core/constants.dart';
|
||||
|
||||
class AmountFormatNotifier extends StateNotifier<AmountFormat> {
|
||||
AmountFormatNotifier() : super(AmountFormat.commasDot) {
|
||||
class AmountFormatNotifier extends Notifier<AmountFormat> {
|
||||
@override
|
||||
AmountFormat build() {
|
||||
_load();
|
||||
return AmountFormat.commasDot;
|
||||
}
|
||||
|
||||
void _load() async {
|
||||
@@ -20,6 +22,6 @@ class AmountFormatNotifier extends StateNotifier<AmountFormat> {
|
||||
}
|
||||
}
|
||||
|
||||
final amountFormatProvider = StateNotifierProvider<AmountFormatNotifier, AmountFormat>(
|
||||
(ref) => AmountFormatNotifier(),
|
||||
final amountFormatProvider = NotifierProvider<AmountFormatNotifier, AmountFormat>(
|
||||
AmountFormatNotifier.new,
|
||||
);
|
||||
|
||||
@@ -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();
|
||||
});
|
||||
@@ -0,0 +1,180 @@
|
||||
import 'package:collection/collection.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import '../../core/constants.dart';
|
||||
import '../../core/utils/result.dart';
|
||||
import '../../data/database/app_database.dart';
|
||||
import '../../data/repositories/category_repository.dart';
|
||||
import '../../features/dashboard/provider.dart';
|
||||
import '../models/app_category.dart';
|
||||
import '../models/transaction.dart';
|
||||
import '../services/translation_service.dart';
|
||||
|
||||
final categoryRepositoryProvider = Provider<CategoryRepository>((ref) {
|
||||
return CategoryRepository(ref.watch(appDatabaseProvider));
|
||||
});
|
||||
|
||||
final customCategoriesProvider = StreamProvider<List<Category>>((ref) {
|
||||
return ref.watch(categoryRepositoryProvider).watchAll();
|
||||
});
|
||||
|
||||
final translationServiceProvider = Provider<TranslationService>((ref) {
|
||||
return TranslationService();
|
||||
});
|
||||
|
||||
final categoryActionsProvider = Provider<CategoryActions>((ref) {
|
||||
return CategoryActions(ref);
|
||||
});
|
||||
|
||||
class CategoryActions {
|
||||
final Ref _ref;
|
||||
|
||||
CategoryActions(this._ref);
|
||||
|
||||
CategoryRepository get _repo => _ref.read(categoryRepositoryProvider);
|
||||
|
||||
Future<Result<void>> create({
|
||||
required TransactionType type,
|
||||
required String labelEn,
|
||||
required String labelRu,
|
||||
required String iconName,
|
||||
required int colorValue,
|
||||
}) {
|
||||
return asyncResultOf(() async {
|
||||
final en = labelEn.trim();
|
||||
final ru = labelRu.trim();
|
||||
if (en.isEmpty && ru.isEmpty) {
|
||||
throw Exception('Category name is required');
|
||||
}
|
||||
final key = 'cat_${DateTime.now().microsecondsSinceEpoch}';
|
||||
await _repo.add(
|
||||
name: key,
|
||||
type: type.name,
|
||||
labelEn: en.isEmpty ? ru : en,
|
||||
labelRu: ru.isEmpty ? en : ru,
|
||||
iconName: iconName,
|
||||
colorValue: colorValue,
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
Future<Result<void>> edit({
|
||||
required int id,
|
||||
required TransactionType type,
|
||||
required String labelEn,
|
||||
required String labelRu,
|
||||
required String iconName,
|
||||
required int colorValue,
|
||||
}) {
|
||||
return asyncResultOf(() async {
|
||||
final en = labelEn.trim();
|
||||
final ru = labelRu.trim();
|
||||
if (en.isEmpty && ru.isEmpty) {
|
||||
throw Exception('Category name is required');
|
||||
}
|
||||
await _repo.updateFields(
|
||||
id,
|
||||
type: type.name,
|
||||
labelEn: en.isEmpty ? ru : en,
|
||||
labelRu: ru.isEmpty ? en : ru,
|
||||
iconName: iconName,
|
||||
colorValue: colorValue,
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
Future<Result<void>> remove(int id) {
|
||||
return asyncResultOf(() async {
|
||||
await _repo.delete(id);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
class CategoryCatalog {
|
||||
final List<AppCategory> all;
|
||||
|
||||
const CategoryCatalog(this.all);
|
||||
|
||||
List<AppCategory> forType(TransactionType type) =>
|
||||
all.where((c) => c.type == type).toList();
|
||||
|
||||
List<AppCategory> get custom => all.where((c) => c.isCustom).toList();
|
||||
|
||||
AppCategory? byKey(String key) =>
|
||||
all.firstWhereOrNull((c) => c.key == key);
|
||||
|
||||
IconData iconFor(String key) =>
|
||||
byKey(key)?.icon ?? Icons.category_rounded;
|
||||
|
||||
Color colorFor(String key, [Color? fallback]) =>
|
||||
byKey(key)?.color ?? fallback ?? const Color(0xFF7C6DED);
|
||||
|
||||
String labelFor(String key, bool isRu) {
|
||||
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;
|
||||
}
|
||||
|
||||
final categoryCatalogProvider = Provider<CategoryCatalog>((ref) {
|
||||
final custom = ref.watch(customCategoriesProvider).value ?? const [];
|
||||
final mapped = custom.map(_fromRow).toList();
|
||||
return CategoryCatalog([..._defaultCategories(), ...mapped]);
|
||||
});
|
||||
|
||||
List<AppCategory> _defaultCategories() {
|
||||
final result = <AppCategory>[];
|
||||
for (final key in AppCategories.expenseCategories) {
|
||||
result.add(_defaultCategory(key, TransactionType.expense));
|
||||
}
|
||||
for (final key in AppCategories.incomeCategories) {
|
||||
result.add(_defaultCategory(key, TransactionType.income));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
AppCategory _defaultCategory(String key, TransactionType type) {
|
||||
final iconName = AppCategories.iconNames[key] ?? 'category';
|
||||
return AppCategory(
|
||||
key: key,
|
||||
type: type,
|
||||
labelEn: key,
|
||||
labelRu: AppCategories.ruLabels[key] ?? key,
|
||||
icon: categoryIconByName(iconName),
|
||||
color: AppCategories.colors[key] ?? const Color(0xFF7C6DED),
|
||||
iconName: iconName,
|
||||
isCustom: false,
|
||||
);
|
||||
}
|
||||
|
||||
AppCategory _fromRow(Category row) {
|
||||
final type =
|
||||
row.type == 'income' ? TransactionType.income : TransactionType.expense;
|
||||
final labelEn = (row.labelEn != null && row.labelEn!.isNotEmpty)
|
||||
? row.labelEn!
|
||||
: row.name;
|
||||
final labelRu = (row.labelRu != null && row.labelRu!.isNotEmpty)
|
||||
? row.labelRu!
|
||||
: row.name;
|
||||
final colorValue = int.tryParse(row.color ?? '');
|
||||
final color = colorValue != null
|
||||
? Color(colorValue)
|
||||
: kCategoryColors[row.id % kCategoryColors.length];
|
||||
return AppCategory(
|
||||
key: row.name,
|
||||
type: type,
|
||||
labelEn: labelEn,
|
||||
labelRu: labelRu,
|
||||
icon: categoryIconByName(row.icon),
|
||||
color: color,
|
||||
iconName: row.icon ?? 'category',
|
||||
isCustom: true,
|
||||
id: row.id,
|
||||
);
|
||||
}
|
||||
@@ -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;
|
||||
});
|
||||
@@ -0,0 +1,72 @@
|
||||
import 'dart:convert';
|
||||
import 'dart:typed_data';
|
||||
|
||||
class BackupData {
|
||||
final String ownerPurchaseToken;
|
||||
final DateTime createdAt;
|
||||
final Map<String, dynamic> payload;
|
||||
|
||||
const BackupData({
|
||||
required this.ownerPurchaseToken,
|
||||
required this.createdAt,
|
||||
required this.payload,
|
||||
});
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
'owner_purchase_token': ownerPurchaseToken,
|
||||
'created_at': createdAt.toIso8601String(),
|
||||
'payload': payload,
|
||||
};
|
||||
|
||||
factory BackupData.fromJson(Map<String, dynamic> json) {
|
||||
return BackupData(
|
||||
ownerPurchaseToken: json['owner_purchase_token'] as String? ?? '',
|
||||
createdAt: DateTime.tryParse(json['created_at'] as String? ?? '') ??
|
||||
DateTime.now(),
|
||||
payload: json['payload'] as Map<String, dynamic>? ?? {},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
enum BackupVerifyResult { ok, tokenMismatch, noToken, invalidFormat }
|
||||
|
||||
class BackupService {
|
||||
String _currentPurchaseToken;
|
||||
|
||||
BackupService(this._currentPurchaseToken);
|
||||
|
||||
void updatePurchaseToken(String token) {
|
||||
_currentPurchaseToken = token;
|
||||
}
|
||||
|
||||
String get currentPurchaseToken => _currentPurchaseToken;
|
||||
|
||||
Uint8List createBackup(Map<String, dynamic> payload) {
|
||||
final data = BackupData(
|
||||
ownerPurchaseToken: _currentPurchaseToken,
|
||||
createdAt: DateTime.now(),
|
||||
payload: payload,
|
||||
);
|
||||
final json = jsonEncode(data.toJson());
|
||||
return Uint8List.fromList(utf8.encode(json));
|
||||
}
|
||||
|
||||
(BackupVerifyResult, BackupData?) verifyAndParse(Uint8List raw) {
|
||||
try {
|
||||
final json = jsonDecode(utf8.decode(raw)) as Map<String, dynamic>;
|
||||
final data = BackupData.fromJson(json);
|
||||
|
||||
if (data.ownerPurchaseToken.isEmpty) {
|
||||
return (BackupVerifyResult.noToken, null);
|
||||
}
|
||||
|
||||
if (data.ownerPurchaseToken != _currentPurchaseToken) {
|
||||
return (BackupVerifyResult.tokenMismatch, null);
|
||||
}
|
||||
|
||||
return (BackupVerifyResult.ok, data);
|
||||
} catch (e) {
|
||||
return (BackupVerifyResult.invalidFormat, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,197 @@
|
||||
import 'dart:async';
|
||||
import 'package:in_app_purchase/in_app_purchase.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
|
||||
class PurchaseResult {
|
||||
final bool success;
|
||||
final String? purchaseToken;
|
||||
final String? error;
|
||||
|
||||
const PurchaseResult({this.success = false, this.purchaseToken, this.error});
|
||||
|
||||
factory PurchaseResult.ok(String token) =>
|
||||
PurchaseResult(success: true, purchaseToken: token);
|
||||
|
||||
factory PurchaseResult.failed([String? error]) =>
|
||||
PurchaseResult(success: false, error: error);
|
||||
|
||||
factory PurchaseResult.cancelled() =>
|
||||
const PurchaseResult(success: false);
|
||||
}
|
||||
|
||||
abstract class BillingService {
|
||||
static const proProductId = 'casha_pro_lifetime';
|
||||
|
||||
Future<PurchaseResult> purchasePro();
|
||||
Future<PurchaseResult> restorePurchases();
|
||||
Future<PurchaseResult> queryPastPurchase();
|
||||
Future<void> dispose();
|
||||
}
|
||||
|
||||
class PlayBillingService implements BillingService {
|
||||
final InAppPurchase _inAppPurchase = InAppPurchase.instance;
|
||||
|
||||
@override
|
||||
Future<PurchaseResult> purchasePro() async {
|
||||
final available = await _inAppPurchase.isAvailable();
|
||||
if (!available) {
|
||||
return PurchaseResult.failed('Billing not available');
|
||||
}
|
||||
|
||||
final response = await _inAppPurchase.queryProductDetails(
|
||||
{BillingService.proProductId},
|
||||
);
|
||||
if (response.error != null) {
|
||||
return PurchaseResult.failed(response.error!.message);
|
||||
}
|
||||
if (response.productDetails.isEmpty) {
|
||||
return PurchaseResult.failed('Product not found');
|
||||
}
|
||||
|
||||
final product = response.productDetails.first;
|
||||
return _waitForPurchase(
|
||||
timeout: const Duration(minutes: 2),
|
||||
timeoutError: 'Purchase timed out',
|
||||
start: () async {
|
||||
final started = await _inAppPurchase.buyNonConsumable(
|
||||
purchaseParam: PurchaseParam(productDetails: product),
|
||||
);
|
||||
if (!started) {
|
||||
throw StateError('Could not start purchase');
|
||||
}
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<PurchaseResult> restorePurchases() async {
|
||||
final available = await _inAppPurchase.isAvailable();
|
||||
if (!available) {
|
||||
return PurchaseResult.failed('Billing not available');
|
||||
}
|
||||
|
||||
return _waitForPurchase(
|
||||
timeout: const Duration(seconds: 30),
|
||||
timeoutError: 'No purchases found',
|
||||
start: _inAppPurchase.restorePurchases,
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<PurchaseResult> queryPastPurchase() => restorePurchases();
|
||||
|
||||
Future<PurchaseResult> _waitForPurchase({
|
||||
required Future<void> Function() start,
|
||||
required Duration timeout,
|
||||
required String timeoutError,
|
||||
}) async {
|
||||
final completer = Completer<PurchaseResult>();
|
||||
var handlingPurchase = false;
|
||||
late final StreamSubscription<List<PurchaseDetails>> subscription;
|
||||
late final Timer timeoutTimer;
|
||||
|
||||
void finish(PurchaseResult result) {
|
||||
if (!completer.isCompleted) {
|
||||
completer.complete(result);
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> handlePurchase(PurchaseDetails purchase) async {
|
||||
if (purchase.productID != BillingService.proProductId) return;
|
||||
|
||||
switch (purchase.status) {
|
||||
case PurchaseStatus.pending:
|
||||
return;
|
||||
case PurchaseStatus.purchased:
|
||||
case PurchaseStatus.restored:
|
||||
if (handlingPurchase) return;
|
||||
handlingPurchase = true;
|
||||
try {
|
||||
final token = purchase.verificationData.serverVerificationData;
|
||||
if (token.isEmpty) {
|
||||
finish(PurchaseResult.failed('Purchase verification data is empty'));
|
||||
return;
|
||||
}
|
||||
if (purchase.pendingCompletePurchase) {
|
||||
await _inAppPurchase.completePurchase(purchase);
|
||||
}
|
||||
finish(PurchaseResult.ok(token));
|
||||
} catch (error) {
|
||||
finish(PurchaseResult.failed(error.toString()));
|
||||
} finally {
|
||||
handlingPurchase = false;
|
||||
}
|
||||
case PurchaseStatus.error:
|
||||
finish(PurchaseResult.failed(purchase.error?.message));
|
||||
case PurchaseStatus.canceled:
|
||||
finish(PurchaseResult.cancelled());
|
||||
}
|
||||
}
|
||||
|
||||
subscription = _inAppPurchase.purchaseStream.listen(
|
||||
(purchases) {
|
||||
for (final purchase in purchases) {
|
||||
unawaited(handlePurchase(purchase));
|
||||
}
|
||||
},
|
||||
onError: (Object error) {
|
||||
finish(PurchaseResult.failed(error.toString()));
|
||||
},
|
||||
);
|
||||
timeoutTimer = Timer(
|
||||
timeout,
|
||||
() => finish(PurchaseResult.failed(timeoutError)),
|
||||
);
|
||||
|
||||
try {
|
||||
await start();
|
||||
} catch (error) {
|
||||
finish(PurchaseResult.failed(error.toString()));
|
||||
}
|
||||
|
||||
final result = await completer.future;
|
||||
timeoutTimer.cancel();
|
||||
await subscription.cancel();
|
||||
return result;
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> dispose() async {}
|
||||
}
|
||||
|
||||
class DebugBillingService implements BillingService {
|
||||
static const _key = 'debug_purchase_token';
|
||||
final SharedPreferences _prefs;
|
||||
|
||||
DebugBillingService(this._prefs);
|
||||
|
||||
@override
|
||||
Future<PurchaseResult> purchasePro() async {
|
||||
await Future.delayed(const Duration(seconds: 1));
|
||||
final token = 'debug_token_${DateTime.now().millisecondsSinceEpoch}';
|
||||
await _prefs.setString(_key, token);
|
||||
return PurchaseResult.ok(token);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<PurchaseResult> restorePurchases() async {
|
||||
await Future.delayed(const Duration(seconds: 1));
|
||||
final token = _prefs.getString(_key);
|
||||
if (token != null) {
|
||||
return PurchaseResult.ok(token);
|
||||
}
|
||||
return const PurchaseResult();
|
||||
}
|
||||
|
||||
@override
|
||||
Future<PurchaseResult> queryPastPurchase() async {
|
||||
final token = _prefs.getString(_key);
|
||||
if (token != null) {
|
||||
return PurchaseResult.ok(token);
|
||||
}
|
||||
return const PurchaseResult();
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> dispose() async {}
|
||||
}
|
||||
@@ -97,6 +97,7 @@ class ExchangeRateService {
|
||||
|
||||
final fromRate = currentRates[from] ?? 1.0;
|
||||
final toRate = currentRates[to] ?? 1.0;
|
||||
if (fromRate == 0) return amount;
|
||||
|
||||
final amountInUsd = amount / fromRate;
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -8,7 +8,6 @@ const _uuid = Uuid();
|
||||
|
||||
class StorageService {
|
||||
static const _transactionsKey = 'transactions';
|
||||
static const _budgetKey = 'monthly_budget';
|
||||
static const _currencyKey = 'currency_symbol';
|
||||
static const _themeKey = 'is_dark_mode';
|
||||
|
||||
@@ -90,23 +89,6 @@ class StorageService {
|
||||
});
|
||||
}
|
||||
|
||||
double? loadBudget() {
|
||||
return _prefs.getDouble(_budgetKey);
|
||||
}
|
||||
|
||||
Future<Result<void>> saveBudget(double? budget) async {
|
||||
return asyncResultOf(() async {
|
||||
if (budget == null) {
|
||||
await _prefs.remove(_budgetKey);
|
||||
} else {
|
||||
if (budget < 0) {
|
||||
throw Exception('Budget cannot be negative');
|
||||
}
|
||||
await _prefs.setDouble(_budgetKey, budget);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
String loadCurrency() {
|
||||
return _prefs.getString(_currencyKey) ?? '\$';
|
||||
}
|
||||
|
||||
@@ -0,0 +1,107 @@
|
||||
import 'dart:convert';
|
||||
import 'package:http/http.dart' as http;
|
||||
|
||||
enum TranslateDirection { ruToEn, enToRu }
|
||||
|
||||
class TranslationResult {
|
||||
final String text;
|
||||
final bool fromCache;
|
||||
|
||||
const TranslationResult(this.text, {this.fromCache = false});
|
||||
}
|
||||
|
||||
class TranslationService {
|
||||
static const Map<String, String> _ruToEn = {
|
||||
'еда': 'Food',
|
||||
'продукты': 'Groceries',
|
||||
'транспорт': 'Transport',
|
||||
'покупки': 'Shopping',
|
||||
'здоровье': 'Health',
|
||||
'развлечения': 'Entertainment',
|
||||
'жильё': 'Housing',
|
||||
'жилье': 'Housing',
|
||||
'аренда': 'Rent',
|
||||
'образование': 'Education',
|
||||
'путешествия': 'Travel',
|
||||
'зарплата': 'Salary',
|
||||
'фриланс': 'Freelance',
|
||||
'инвестиции': 'Investment',
|
||||
'подарок': 'Gift',
|
||||
'подарки': 'Gifts',
|
||||
'возврат': 'Refund',
|
||||
'другое': 'Other',
|
||||
'коммунальные': 'Utilities',
|
||||
'одежда': 'Clothing',
|
||||
'спорт': 'Sports',
|
||||
'красота': 'Beauty',
|
||||
'питомцы': 'Pets',
|
||||
'животные': 'Pets',
|
||||
'бизнес': 'Business',
|
||||
'накопления': 'Savings',
|
||||
'кафе': 'Cafe',
|
||||
'кофе': 'Coffee',
|
||||
'ресторан': 'Restaurant',
|
||||
'связь': 'Communication',
|
||||
'интернет': 'Internet',
|
||||
'налоги': 'Taxes',
|
||||
'страховка': 'Insurance',
|
||||
'медицина': 'Medicine',
|
||||
'дети': 'Children',
|
||||
'хобби': 'Hobby',
|
||||
'музыка': 'Music',
|
||||
'игры': 'Games',
|
||||
'книги': 'Books',
|
||||
'топливо': 'Fuel',
|
||||
'такси': 'Taxi',
|
||||
};
|
||||
|
||||
static final Map<String, String> _enToRu = {
|
||||
for (final entry in _ruToEn.entries) entry.value.toLowerCase(): entry.key,
|
||||
};
|
||||
|
||||
String? dictionaryLookup(String input, TranslateDirection direction) {
|
||||
final normalized = input.trim().toLowerCase();
|
||||
if (normalized.isEmpty) return null;
|
||||
final map = direction == TranslateDirection.ruToEn ? _ruToEn : _enToRu;
|
||||
final hit = map[normalized];
|
||||
if (hit == null) return null;
|
||||
return _capitalize(hit);
|
||||
}
|
||||
|
||||
Future<TranslationResult?> translate(
|
||||
String input,
|
||||
TranslateDirection direction,
|
||||
) async {
|
||||
final trimmed = input.trim();
|
||||
if (trimmed.isEmpty) return null;
|
||||
|
||||
final cached = dictionaryLookup(trimmed, direction);
|
||||
if (cached != null) {
|
||||
return TranslationResult(cached, fromCache: true);
|
||||
}
|
||||
|
||||
final pair = direction == TranslateDirection.ruToEn ? 'ru|en' : 'en|ru';
|
||||
final uri = Uri.parse(
|
||||
'https://api.mymemory.translated.net/get'
|
||||
'?q=${Uri.encodeQueryComponent(trimmed)}&langpair=$pair',
|
||||
);
|
||||
|
||||
try {
|
||||
final response =
|
||||
await http.get(uri).timeout(const Duration(seconds: 8));
|
||||
if (response.statusCode != 200) return null;
|
||||
final decoded = jsonDecode(response.body) as Map<String, dynamic>;
|
||||
final data = decoded['responseData'] as Map<String, dynamic>?;
|
||||
final translated = data?['translatedText'] as String?;
|
||||
if (translated == null || translated.trim().isEmpty) return null;
|
||||
return TranslationResult(_capitalize(translated.trim()));
|
||||
} catch (_) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
String _capitalize(String value) {
|
||||
if (value.isEmpty) return value;
|
||||
return value[0].toUpperCase() + value.substring(1);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import '../../core/services/card_color_service.dart';
|
||||
|
||||
Gradient buildCardGradient(Color primary, Color secondary, GradientType type) {
|
||||
final colorDark = Color.lerp(secondary, Colors.black, 0.3)!;
|
||||
|
||||
switch (type) {
|
||||
case GradientType.linear:
|
||||
return LinearGradient(
|
||||
begin: Alignment.topLeft,
|
||||
end: Alignment.bottomRight,
|
||||
colors: [primary, secondary, colorDark],
|
||||
stops: const [0.0, 0.6, 1.0],
|
||||
);
|
||||
case GradientType.linearReverse:
|
||||
return LinearGradient(
|
||||
begin: Alignment.topRight,
|
||||
end: Alignment.bottomLeft,
|
||||
colors: [primary, secondary, colorDark],
|
||||
stops: const [0.0, 0.6, 1.0],
|
||||
);
|
||||
case GradientType.radial:
|
||||
return RadialGradient(
|
||||
center: Alignment.center,
|
||||
radius: 1.4,
|
||||
colors: [primary, secondary, colorDark],
|
||||
stops: const [0.0, 0.6, 1.0],
|
||||
);
|
||||
case GradientType.sweep:
|
||||
return SweepGradient(
|
||||
center: Alignment.center,
|
||||
startAngle: 0.0,
|
||||
endAngle: 3.14159 * 2,
|
||||
colors: [primary, secondary, colorDark, secondary, primary],
|
||||
stops: const [0.0, 0.25, 0.5, 0.75, 1.0],
|
||||
);
|
||||
case GradientType.solid:
|
||||
return LinearGradient(
|
||||
colors: [primary, primary, primary],
|
||||
stops: const [0.0, 0.5, 1.0],
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,360 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import '../../core/l10n/app_strings.dart';
|
||||
import '../../core/l10n/locale_provider.dart';
|
||||
import '../../core/services/haptic_service.dart';
|
||||
import '../providers/backup_provider.dart';
|
||||
import '../providers/google_drive_provider.dart';
|
||||
import '../providers/premium_provider.dart';
|
||||
import 'error_snackbar.dart';
|
||||
import '../services/backup_service.dart';
|
||||
|
||||
class BackupScreen extends ConsumerStatefulWidget {
|
||||
const BackupScreen({super.key});
|
||||
|
||||
@override
|
||||
ConsumerState<BackupScreen> createState() => _BackupScreenState();
|
||||
}
|
||||
|
||||
class _BackupScreenState extends ConsumerState<BackupScreen> {
|
||||
bool _backingUp = false;
|
||||
bool _restoring = false;
|
||||
DateTime? _lastBackupTime;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_loadLastBackupTime();
|
||||
}
|
||||
|
||||
Future<void> _loadLastBackupTime() async {
|
||||
final service = ref.read(googleDriveServiceProvider);
|
||||
final time = await service.getLastBackupTime();
|
||||
if (mounted) {
|
||||
setState(() => _lastBackupTime = time);
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _handleBackup() async {
|
||||
final s = ref.read(stringsProvider);
|
||||
final driveService = ref.read(googleDriveServiceProvider);
|
||||
|
||||
if (driveService.currentUser == null) {
|
||||
showErrorSnackbar(context, s.backupRequiresSignIn);
|
||||
return;
|
||||
}
|
||||
|
||||
HapticService.light();
|
||||
setState(() => _backingUp = true);
|
||||
|
||||
try {
|
||||
final backupService = ref.read(backupServiceProvider);
|
||||
final payload = <String, dynamic>{
|
||||
'version': 1,
|
||||
'exported_at': DateTime.now().toIso8601String(),
|
||||
};
|
||||
final data = backupService.createBackup(payload);
|
||||
final result = await driveService.uploadBackup(data);
|
||||
|
||||
if (result.success) {
|
||||
setState(() => _lastBackupTime = result.modifiedTime);
|
||||
HapticService.medium();
|
||||
if (mounted) {
|
||||
showSuccessSnackbar(context, s.backupSuccess);
|
||||
}
|
||||
} else {
|
||||
if (mounted) {
|
||||
showErrorSnackbar(context, result.error ?? s.backupRestoreFailed);
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
if (mounted) {
|
||||
showErrorSnackbar(context, e.toString());
|
||||
}
|
||||
} finally {
|
||||
if (mounted) setState(() => _backingUp = false);
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _handleRestore() async {
|
||||
final s = ref.read(stringsProvider);
|
||||
final driveService = ref.read(googleDriveServiceProvider);
|
||||
|
||||
if (driveService.currentUser == null) {
|
||||
showErrorSnackbar(context, s.backupRequiresSignIn);
|
||||
return;
|
||||
}
|
||||
|
||||
HapticService.light();
|
||||
setState(() => _restoring = true);
|
||||
|
||||
try {
|
||||
final raw = await driveService.downloadBackup();
|
||||
if (raw == null) {
|
||||
if (mounted) {
|
||||
showWarningSnackbar(context, s.backupNoFileFound);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
final backupService = ref.read(backupServiceProvider);
|
||||
final (result, data) = backupService.verifyAndParse(raw);
|
||||
|
||||
switch (result) {
|
||||
case BackupVerifyResult.ok:
|
||||
HapticService.medium();
|
||||
if (mounted) {
|
||||
showSuccessSnackbar(context, s.backupRestoreSuccess);
|
||||
}
|
||||
case BackupVerifyResult.tokenMismatch:
|
||||
if (mounted) {
|
||||
showErrorSnackbar(context, s.backupTokenMismatch);
|
||||
}
|
||||
case BackupVerifyResult.noToken:
|
||||
if (mounted) {
|
||||
showErrorSnackbar(context, s.backupNoToken);
|
||||
}
|
||||
case BackupVerifyResult.invalidFormat:
|
||||
if (mounted) {
|
||||
showErrorSnackbar(context, s.backupInvalidFormat);
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
if (mounted) {
|
||||
showErrorSnackbar(context, e.toString());
|
||||
}
|
||||
} finally {
|
||||
if (mounted) setState(() => _restoring = false);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final s = ref.watch(stringsProvider);
|
||||
final isPremium = ref.watch(isPremiumProvider);
|
||||
final driveUserAsync = ref.watch(googleDriveUserProvider);
|
||||
final driveUser = driveUserAsync.value;
|
||||
final colorScheme = Theme.of(context).colorScheme;
|
||||
|
||||
return Scaffold(
|
||||
body: SafeArea(
|
||||
child: Column(
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.fromLTRB(8, 4, 16, 0),
|
||||
child: Row(
|
||||
children: [
|
||||
IconButton(
|
||||
icon: const Icon(Icons.arrow_back_rounded),
|
||||
onPressed: () => context.pop(),
|
||||
),
|
||||
Text(
|
||||
s.backupTitle,
|
||||
style: Theme.of(context).textTheme.titleLarge?.copyWith(
|
||||
fontWeight: FontWeight.w800,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: SingleChildScrollView(
|
||||
padding: const EdgeInsets.all(20),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
if (!isPremium) ...[
|
||||
_buildLockedState(context, s, colorScheme),
|
||||
] else ...[
|
||||
_buildSyncStatus(context, s, colorScheme, driveUser),
|
||||
const SizedBox(height: 20),
|
||||
_buildBackupActions(context, s, colorScheme, driveUser),
|
||||
const SizedBox(height: 20),
|
||||
_buildLastBackup(context, s, colorScheme),
|
||||
],
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildLockedState(
|
||||
BuildContext context,
|
||||
AppStrings s,
|
||||
ColorScheme colorScheme,
|
||||
) {
|
||||
return Container(
|
||||
width: double.infinity,
|
||||
padding: const EdgeInsets.all(24),
|
||||
decoration: BoxDecoration(
|
||||
color: colorScheme.surface,
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
border: Border.all(color: colorScheme.outlineVariant),
|
||||
),
|
||||
child: Column(
|
||||
children: [
|
||||
Icon(Icons.lock_outline_rounded, size: 48, color: colorScheme.primary),
|
||||
const SizedBox(height: 16),
|
||||
Text(
|
||||
s.backupRequiresPremium,
|
||||
style: Theme.of(context).textTheme.titleMedium?.copyWith(
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
FilledButton(
|
||||
onPressed: () => context.push('/pro'),
|
||||
child: Text(s.proBuy),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildSyncStatus(
|
||||
BuildContext context,
|
||||
AppStrings s,
|
||||
ColorScheme colorScheme,
|
||||
dynamic driveUser,
|
||||
) {
|
||||
return Container(
|
||||
width: double.infinity,
|
||||
padding: const EdgeInsets.all(16),
|
||||
decoration: BoxDecoration(
|
||||
color: colorScheme.surface,
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
border: Border.all(color: colorScheme.outlineVariant),
|
||||
),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
Icon(
|
||||
driveUser != null
|
||||
? Icons.cloud_done_rounded
|
||||
: Icons.cloud_off_rounded,
|
||||
color: driveUser != null ? colorScheme.primary : colorScheme.onSurface.withOpacity(0.4),
|
||||
size: 24,
|
||||
),
|
||||
const SizedBox(width: 12),
|
||||
Expanded(
|
||||
child: Text(
|
||||
driveUser != null
|
||||
? s.proSyncEnabled
|
||||
: s.backupRequiresSignIn,
|
||||
style: Theme.of(context).textTheme.titleMedium?.copyWith(
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
if (driveUser != null) ...[
|
||||
const SizedBox(height: 8),
|
||||
Text(
|
||||
driveUser.email,
|
||||
style: Theme.of(context).textTheme.bodySmall?.copyWith(
|
||||
color: colorScheme.onSurface.withOpacity(0.6),
|
||||
),
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildBackupActions(
|
||||
BuildContext context,
|
||||
AppStrings s,
|
||||
ColorScheme colorScheme,
|
||||
dynamic driveUser,
|
||||
) {
|
||||
final disabled = driveUser == null;
|
||||
return Column(
|
||||
children: [
|
||||
SizedBox(
|
||||
width: double.infinity,
|
||||
child: FilledButton.icon(
|
||||
onPressed: (disabled || _backingUp) ? null : _handleBackup,
|
||||
icon: _backingUp
|
||||
? SizedBox(
|
||||
width: 18,
|
||||
height: 18,
|
||||
child: CircularProgressIndicator(
|
||||
strokeWidth: 2,
|
||||
color: colorScheme.onPrimary,
|
||||
),
|
||||
)
|
||||
: const Icon(Icons.backup_outlined),
|
||||
label: Text(_backingUp ? s.backupCreating : s.backupCreate),
|
||||
style: FilledButton.styleFrom(
|
||||
padding: const EdgeInsets.symmetric(vertical: 14),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
SizedBox(
|
||||
width: double.infinity,
|
||||
child: OutlinedButton.icon(
|
||||
onPressed: (disabled || _restoring) ? null : _handleRestore,
|
||||
icon: _restoring
|
||||
? SizedBox(
|
||||
width: 18,
|
||||
height: 18,
|
||||
child: CircularProgressIndicator(
|
||||
strokeWidth: 2,
|
||||
color: colorScheme.primary,
|
||||
),
|
||||
)
|
||||
: const Icon(Icons.restore_rounded),
|
||||
label: Text(_restoring ? s.backupRestoring : s.backupRestore),
|
||||
style: OutlinedButton.styleFrom(
|
||||
padding: const EdgeInsets.symmetric(vertical: 14),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildLastBackup(
|
||||
BuildContext context,
|
||||
AppStrings s,
|
||||
ColorScheme colorScheme,
|
||||
) {
|
||||
return Row(
|
||||
children: [
|
||||
Icon(
|
||||
Icons.schedule_rounded,
|
||||
size: 18,
|
||||
color: colorScheme.onSurface.withOpacity(0.5),
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
Text(
|
||||
'${s.backupLastBackup}: ${_lastBackupTime != null ? _formatDate(_lastBackupTime!) : s.backupNever}',
|
||||
style: Theme.of(context).textTheme.bodySmall?.copyWith(
|
||||
color: colorScheme.onSurface.withOpacity(0.5),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
String _formatDate(DateTime dt) {
|
||||
final d = dt.toLocal();
|
||||
return '${d.day.toString().padLeft(2, '0')}.${d.month.toString().padLeft(2, '0')}.${d.year} ${d.hour.toString().padLeft(2, '0')}:${d.minute.toString().padLeft(2, '0')}';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,528 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import '../../core/l10n/app_strings.dart';
|
||||
import '../../core/l10n/locale_provider.dart';
|
||||
import '../../core/services/haptic_service.dart';
|
||||
import '../providers/current_user_provider.dart';
|
||||
import '../providers/premium_provider.dart';
|
||||
import 'error_snackbar.dart';
|
||||
|
||||
class ProScreen extends ConsumerStatefulWidget {
|
||||
const ProScreen({super.key});
|
||||
|
||||
@override
|
||||
ConsumerState<ProScreen> createState() => _ProScreenState();
|
||||
}
|
||||
|
||||
class _ProScreenState extends ConsumerState<ProScreen>
|
||||
with SingleTickerProviderStateMixin {
|
||||
bool _purchasing = false;
|
||||
bool _restoring = false;
|
||||
bool _resetting = false;
|
||||
bool _showSuccess = false;
|
||||
String _successTitle = '';
|
||||
late final AnimationController _successController;
|
||||
late final Animation<double> _successScale;
|
||||
|
||||
static const _gradientColors = [
|
||||
Color(0xFF5B4DCC),
|
||||
Color(0xFF7C6DED),
|
||||
Color(0xFF9D8FF5),
|
||||
];
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_successController = AnimationController(
|
||||
vsync: this,
|
||||
duration: const Duration(milliseconds: 400),
|
||||
);
|
||||
_successScale = Tween<double>(begin: 0.0, end: 1.0).animate(
|
||||
CurvedAnimation(
|
||||
parent: _successController,
|
||||
curve: Curves.elasticOut,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_successController.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
void _showSuccessOverlay(String title) {
|
||||
setState(() {
|
||||
_successTitle = title;
|
||||
_showSuccess = true;
|
||||
});
|
||||
_successController.forward(from: 0.0);
|
||||
}
|
||||
|
||||
void _dismissSuccessOverlay() {
|
||||
_successController.stop();
|
||||
if (mounted) {
|
||||
setState(() => _showSuccess = false);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final s = ref.watch(stringsProvider);
|
||||
final isPremium = ref.watch(isPremiumProvider);
|
||||
final colorScheme = Theme.of(context).colorScheme;
|
||||
|
||||
return Stack(
|
||||
children: [
|
||||
Scaffold(
|
||||
body: SafeArea(
|
||||
child: Column(
|
||||
children: [
|
||||
_buildHeader(context),
|
||||
Expanded(
|
||||
child: SingleChildScrollView(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 20),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
const SizedBox(height: 4),
|
||||
_buildHeroBanner(context, s, isPremium),
|
||||
const SizedBox(height: 20),
|
||||
_buildFeatureList(context, s, colorScheme),
|
||||
const SizedBox(height: 16),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
_buildBottomBar(context, s, colorScheme, isPremium),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
if (_showSuccess) _buildSuccessOverlay(context, s, colorScheme),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildHeader(BuildContext context) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.fromLTRB(8, 4, 16, 0),
|
||||
child: Row(
|
||||
children: [
|
||||
IconButton(
|
||||
icon: const Icon(Icons.arrow_back_rounded),
|
||||
onPressed: () => context.pop(),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildHeroBanner(
|
||||
BuildContext context,
|
||||
AppStrings s,
|
||||
bool isVip,
|
||||
) {
|
||||
return Container(
|
||||
width: double.infinity,
|
||||
padding: const EdgeInsets.symmetric(vertical: 36, horizontal: 20),
|
||||
decoration: BoxDecoration(
|
||||
gradient: const LinearGradient(
|
||||
begin: Alignment.topLeft,
|
||||
end: Alignment.bottomRight,
|
||||
colors: _gradientColors,
|
||||
),
|
||||
borderRadius: BorderRadius.circular(20),
|
||||
),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
s.proTitle,
|
||||
style: Theme.of(context).textTheme.displaySmall?.copyWith(
|
||||
fontWeight: FontWeight.w900,
|
||||
color: Colors.white,
|
||||
letterSpacing: -0.5,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 6),
|
||||
Text(
|
||||
isVip ? s.proActive : s.proSubtitle,
|
||||
style: Theme.of(context).textTheme.titleMedium?.copyWith(
|
||||
color: Colors.white.withOpacity(0.9),
|
||||
fontWeight: isVip ? FontWeight.w700 : FontWeight.w500,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildSuccessOverlay(
|
||||
BuildContext context,
|
||||
AppStrings s,
|
||||
ColorScheme colorScheme,
|
||||
) {
|
||||
return GestureDetector(
|
||||
onTap: _dismissSuccessOverlay,
|
||||
child: Container(
|
||||
color: Colors.black54,
|
||||
child: Center(
|
||||
child: GestureDetector(
|
||||
onTap: _dismissSuccessOverlay,
|
||||
child: AnimatedBuilder(
|
||||
animation: _successController,
|
||||
builder: (context, child) {
|
||||
return Transform.scale(
|
||||
scale: _successScale.value,
|
||||
child: child,
|
||||
);
|
||||
},
|
||||
child: Container(
|
||||
padding: const EdgeInsets.all(32),
|
||||
margin: const EdgeInsets.symmetric(horizontal: 40),
|
||||
decoration: BoxDecoration(
|
||||
color: colorScheme.surface,
|
||||
borderRadius: BorderRadius.circular(24),
|
||||
),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Container(
|
||||
padding: const EdgeInsets.all(16),
|
||||
decoration: BoxDecoration(
|
||||
color: colorScheme.primary.withOpacity(0.15),
|
||||
shape: BoxShape.circle,
|
||||
),
|
||||
child: Icon(
|
||||
Icons.check_circle_rounded,
|
||||
color: colorScheme.primary,
|
||||
size: 64,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
Text(
|
||||
_successTitle,
|
||||
style: Theme.of(context).textTheme.titleLarge?.copyWith(
|
||||
fontWeight: FontWeight.w800,
|
||||
color: colorScheme.onSurface,
|
||||
),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
Text(
|
||||
s.proTapToClose,
|
||||
style: Theme.of(context).textTheme.bodySmall?.copyWith(
|
||||
color: colorScheme.onSurface.withOpacity(0.5),
|
||||
),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildFeatureList(
|
||||
BuildContext context,
|
||||
AppStrings s,
|
||||
ColorScheme colorScheme,
|
||||
) {
|
||||
final features = [
|
||||
(Icons.analytics_rounded, s.proFeatureAnalytics, s.proFeatureAnalyticsDesc),
|
||||
(Icons.palette_rounded, s.proFeatureCustomization, s.proFeatureCustomizationDesc),
|
||||
(Icons.fingerprint_rounded, s.proFeatureBiometric, s.proFeatureBiometricDesc),
|
||||
(Icons.account_balance_wallet_rounded, s.proFeatureAccounts, s.proFeatureAccountsDesc),
|
||||
];
|
||||
|
||||
return Column(
|
||||
children: features.map((f) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.only(bottom: 14),
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Container(
|
||||
padding: const EdgeInsets.all(10),
|
||||
decoration: BoxDecoration(
|
||||
color: colorScheme.primary.withOpacity(0.1),
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
),
|
||||
child: Icon(
|
||||
f.$1,
|
||||
color: colorScheme.primary,
|
||||
size: 22,
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 14),
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
f.$2,
|
||||
style: Theme.of(context).textTheme.titleSmall?.copyWith(
|
||||
fontWeight: FontWeight.w700,
|
||||
color: colorScheme.onSurface,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
Text(
|
||||
f.$3,
|
||||
style: Theme.of(context).textTheme.bodyMedium?.copyWith(
|
||||
color: colorScheme.onSurface.withOpacity(0.6),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}).toList(),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildBottomBar(
|
||||
BuildContext context,
|
||||
AppStrings s,
|
||||
ColorScheme colorScheme,
|
||||
bool isVip,
|
||||
) {
|
||||
return Container(
|
||||
padding: const EdgeInsets.fromLTRB(20, 12, 20, 24),
|
||||
decoration: BoxDecoration(
|
||||
color: Theme.of(context).scaffoldBackgroundColor,
|
||||
border: Border(
|
||||
top: BorderSide(
|
||||
color: colorScheme.outlineVariant.withOpacity(0.3),
|
||||
width: 1,
|
||||
),
|
||||
),
|
||||
),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
if (!isVip) ...[
|
||||
SizedBox(
|
||||
width: double.infinity,
|
||||
child: FilledButton(
|
||||
onPressed: _purchasing ? null : _handlePurchase,
|
||||
style: FilledButton.styleFrom(
|
||||
padding: const EdgeInsets.symmetric(vertical: 16),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
),
|
||||
),
|
||||
child: _purchasing
|
||||
? SizedBox(
|
||||
width: 20,
|
||||
height: 20,
|
||||
child: CircularProgressIndicator(
|
||||
strokeWidth: 2,
|
||||
color: colorScheme.onPrimary,
|
||||
),
|
||||
)
|
||||
: Text(
|
||||
s.proBuy,
|
||||
style: const TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.w700,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
SizedBox(
|
||||
width: double.infinity,
|
||||
child: TextButton(
|
||||
onPressed: _restoring ? null : _handleRestore,
|
||||
child: _restoring
|
||||
? SizedBox(
|
||||
width: 16,
|
||||
height: 16,
|
||||
child: CircularProgressIndicator(
|
||||
strokeWidth: 2,
|
||||
color: colorScheme.primary,
|
||||
),
|
||||
)
|
||||
: Text(s.proRestorePurchases),
|
||||
),
|
||||
),
|
||||
] else ...[
|
||||
Container(
|
||||
width: double.infinity,
|
||||
padding: const EdgeInsets.symmetric(vertical: 12, horizontal: 16),
|
||||
decoration: BoxDecoration(
|
||||
color: colorScheme.primary.withOpacity(0.08),
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
border: Border.all(
|
||||
color: colorScheme.primary.withOpacity(0.2),
|
||||
width: 1,
|
||||
),
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
Icon(
|
||||
Icons.verified_rounded,
|
||||
color: colorScheme.primary,
|
||||
size: 20,
|
||||
),
|
||||
const SizedBox(width: 10),
|
||||
Expanded(
|
||||
child: Text(
|
||||
s.proActive,
|
||||
style: TextStyle(
|
||||
color: colorScheme.primary,
|
||||
fontWeight: FontWeight.w700,
|
||||
fontSize: 14,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
SizedBox(
|
||||
width: double.infinity,
|
||||
child: OutlinedButton.icon(
|
||||
onPressed: _resetting ? null : _handleResetData,
|
||||
icon: _resetting
|
||||
? SizedBox(
|
||||
width: 16,
|
||||
height: 16,
|
||||
child: CircularProgressIndicator(
|
||||
strokeWidth: 2,
|
||||
color: colorScheme.onSurface.withOpacity(0.5),
|
||||
),
|
||||
)
|
||||
: Icon(
|
||||
Icons.restart_alt_rounded,
|
||||
size: 18,
|
||||
color: colorScheme.onSurface.withOpacity(0.6),
|
||||
),
|
||||
label: Text(
|
||||
s.proResetData,
|
||||
style: TextStyle(
|
||||
fontSize: 13,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: colorScheme.onSurface.withOpacity(0.6),
|
||||
),
|
||||
),
|
||||
style: OutlinedButton.styleFrom(
|
||||
padding: const EdgeInsets.symmetric(vertical: 12),
|
||||
side: BorderSide(
|
||||
color: colorScheme.onSurface.withOpacity(0.15),
|
||||
),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> _handlePurchase() async {
|
||||
HapticService.light();
|
||||
setState(() => _purchasing = true);
|
||||
try {
|
||||
final manager = ref.read(premiumManagerProvider);
|
||||
final result = await manager.purchase();
|
||||
if (result.success) {
|
||||
await ref.read(currentUserProvider.notifier).refreshFromPremium();
|
||||
if (mounted) {
|
||||
_showSuccessOverlay(ref.read(stringsProvider).proPurchaseSuccess);
|
||||
HapticService.medium();
|
||||
}
|
||||
} else {
|
||||
if (mounted) {
|
||||
showErrorSnackbar(context, result.error ?? ref.read(stringsProvider).proPurchaseFailed);
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
if (mounted) {
|
||||
showErrorSnackbar(context, e.toString());
|
||||
}
|
||||
} finally {
|
||||
if (mounted) setState(() => _purchasing = false);
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _handleRestore() async {
|
||||
HapticService.light();
|
||||
setState(() => _restoring = true);
|
||||
try {
|
||||
final manager = ref.read(premiumManagerProvider);
|
||||
final result = await manager.restore();
|
||||
if (result.success) {
|
||||
await ref.read(currentUserProvider.notifier).refreshFromPremium();
|
||||
if (mounted) {
|
||||
_showSuccessOverlay(ref.read(stringsProvider).proRestoreSuccessTitle);
|
||||
HapticService.medium();
|
||||
}
|
||||
} else {
|
||||
if (mounted) {
|
||||
showWarningSnackbar(context, ref.read(stringsProvider).proRestoreNotFound);
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
if (mounted) {
|
||||
showErrorSnackbar(context, e.toString());
|
||||
}
|
||||
} finally {
|
||||
if (mounted) setState(() => _restoring = false);
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _handleResetData() async {
|
||||
final s = ref.read(stringsProvider);
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (ctx) => AlertDialog(
|
||||
title: Text(s.proResetData),
|
||||
content: Text(s.proResetDataConfirm),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => Navigator.pop(ctx),
|
||||
child: Text(s.cancel),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () async {
|
||||
Navigator.pop(ctx);
|
||||
HapticService.light();
|
||||
setState(() => _resetting = true);
|
||||
try {
|
||||
final manager = ref.read(premiumManagerProvider);
|
||||
await manager.clear();
|
||||
await ref.read(currentUserProvider.notifier).refreshFromPremium();
|
||||
if (mounted) {
|
||||
showSuccessSnackbar(context, s.proResetDataSuccess);
|
||||
HapticService.medium();
|
||||
}
|
||||
} catch (e) {
|
||||
if (mounted) {
|
||||
showErrorSnackbar(context, e.toString());
|
||||
}
|
||||
} finally {
|
||||
if (mounted) setState(() => _resetting = false);
|
||||
}
|
||||
},
|
||||
style: TextButton.styleFrom(
|
||||
foregroundColor: const Color(0xFFE05C6B),
|
||||
),
|
||||
child: Text(s.proResetData),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,264 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import '../../core/l10n/locale_provider.dart';
|
||||
import '../../core/services/haptic_service.dart';
|
||||
import '../providers/premium_provider.dart';
|
||||
|
||||
class ProSubscriptionCard extends StatefulWidget {
|
||||
const ProSubscriptionCard({super.key});
|
||||
|
||||
@override
|
||||
State<ProSubscriptionCard> createState() =>
|
||||
_ProSubscriptionCardState();
|
||||
}
|
||||
|
||||
class _ProSubscriptionCardState extends State<ProSubscriptionCard>
|
||||
with SingleTickerProviderStateMixin {
|
||||
late final AnimationController _shimmerController;
|
||||
|
||||
static const _gradientColors = [
|
||||
Color(0xFF5B4DCC),
|
||||
Color(0xFF7C6DED),
|
||||
Color(0xFF9D8FF5),
|
||||
];
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_shimmerController = AnimationController(
|
||||
vsync: this,
|
||||
duration: const Duration(milliseconds: 2800),
|
||||
)..repeat();
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_shimmerController.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Consumer(
|
||||
builder: (context, ref, _) {
|
||||
final s = ref.watch(stringsProvider);
|
||||
final isPremium = ref.watch(isPremiumProvider);
|
||||
|
||||
return ClipRRect(
|
||||
borderRadius: BorderRadius.circular(20),
|
||||
child: Stack(
|
||||
children: [
|
||||
Container(
|
||||
padding: const EdgeInsets.fromLTRB(20, 22, 20, 18),
|
||||
decoration: const BoxDecoration(
|
||||
gradient: LinearGradient(
|
||||
begin: Alignment.topLeft,
|
||||
end: Alignment.bottomRight,
|
||||
colors: _gradientColors,
|
||||
),
|
||||
),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
Container(
|
||||
padding: const EdgeInsets.all(10),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white.withOpacity(0.18),
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
border: Border.all(
|
||||
color: Colors.white.withOpacity(0.25),
|
||||
width: 1,
|
||||
),
|
||||
),
|
||||
child: Icon(
|
||||
isPremium
|
||||
? Icons.verified_rounded
|
||||
: Icons.workspace_premium_rounded,
|
||||
color: Colors.white,
|
||||
size: 26,
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 14),
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
s.proTitle,
|
||||
style: Theme.of(context)
|
||||
.textTheme
|
||||
.titleLarge
|
||||
?.copyWith(
|
||||
fontWeight: FontWeight.w800,
|
||||
color: Colors.white,
|
||||
letterSpacing: -0.3,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 3),
|
||||
Text(
|
||||
isPremium ? s.proActive : s.proSubtitle,
|
||||
style: isPremium
|
||||
? Theme.of(context)
|
||||
.textTheme
|
||||
.bodyMedium
|
||||
?.copyWith(
|
||||
color: Colors.white.withOpacity(0.95),
|
||||
fontWeight: FontWeight.w600,
|
||||
)
|
||||
: Theme.of(context)
|
||||
.textTheme
|
||||
.bodySmall
|
||||
?.copyWith(
|
||||
color: Colors.white.withOpacity(0.75),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
if (isPremium)
|
||||
Container(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 10,
|
||||
vertical: 5,
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white.withOpacity(0.2),
|
||||
borderRadius: BorderRadius.circular(20),
|
||||
border: Border.all(
|
||||
color: Colors.white.withOpacity(0.3),
|
||||
width: 1,
|
||||
),
|
||||
),
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Icon(
|
||||
Icons.check_circle_rounded,
|
||||
color: Colors.white.withOpacity(0.95),
|
||||
size: 14,
|
||||
),
|
||||
const SizedBox(width: 4),
|
||||
Text(
|
||||
'Pro',
|
||||
style: TextStyle(
|
||||
color: Colors.white.withOpacity(0.95),
|
||||
fontSize: 11,
|
||||
fontWeight: FontWeight.w700,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 18),
|
||||
SizedBox(
|
||||
width: double.infinity,
|
||||
child: _GlassButton(
|
||||
label: s.proAboutPro,
|
||||
icon: Icons.arrow_forward_rounded,
|
||||
onTap: () {
|
||||
HapticService.light();
|
||||
context.push('/pro');
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
Positioned.fill(
|
||||
child: IgnorePointer(
|
||||
child: AnimatedBuilder(
|
||||
animation: _shimmerController,
|
||||
builder: (context, _) {
|
||||
final t = _shimmerController.value;
|
||||
final startX = -1.5;
|
||||
final endX = 2.5;
|
||||
final x = startX + (endX - startX) * t;
|
||||
return ShaderMask(
|
||||
blendMode: BlendMode.srcOver,
|
||||
shaderCallback: (Rect bounds) {
|
||||
return LinearGradient(
|
||||
begin: Alignment(x, 0),
|
||||
end: Alignment(x + 0.5, 0),
|
||||
colors: [
|
||||
Colors.white.withOpacity(0),
|
||||
Colors.white.withOpacity(0.12),
|
||||
Colors.white.withOpacity(0),
|
||||
],
|
||||
stops: const [0.0, 0.5, 1.0],
|
||||
).createShader(bounds);
|
||||
},
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(20),
|
||||
border: Border.all(
|
||||
color: Colors.white.withOpacity(0.15),
|
||||
width: 1,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _GlassButton extends StatelessWidget {
|
||||
final String label;
|
||||
final IconData icon;
|
||||
final VoidCallback onTap;
|
||||
|
||||
const _GlassButton({
|
||||
required this.label,
|
||||
required this.icon,
|
||||
required this.onTap,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Material(
|
||||
color: Colors.white.withOpacity(0.15),
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
child: InkWell(
|
||||
onTap: onTap,
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
child: Container(
|
||||
padding: const EdgeInsets.symmetric(vertical: 12, horizontal: 16),
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
border: Border.all(
|
||||
color: Colors.white.withOpacity(0.25),
|
||||
width: 1,
|
||||
),
|
||||
),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Text(
|
||||
label,
|
||||
style: const TextStyle(
|
||||
color: Colors.white,
|
||||
fontWeight: FontWeight.w700,
|
||||
fontSize: 14,
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 6),
|
||||
Icon(icon, color: Colors.white, size: 18),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -6,10 +6,6 @@
|
||||
|
||||
#include "generated_plugin_registrant.h"
|
||||
|
||||
#include <sqlite3_flutter_libs/sqlite3_flutter_libs_plugin.h>
|
||||
|
||||
void fl_register_plugins(FlPluginRegistry* registry) {
|
||||
g_autoptr(FlPluginRegistrar) sqlite3_flutter_libs_registrar =
|
||||
fl_plugin_registry_get_registrar_for_plugin(registry, "Sqlite3FlutterLibsPlugin");
|
||||
sqlite3_flutter_libs_plugin_register_with_registrar(sqlite3_flutter_libs_registrar);
|
||||
}
|
||||
|
||||
@@ -3,10 +3,10 @@
|
||||
#
|
||||
|
||||
list(APPEND FLUTTER_PLUGIN_LIST
|
||||
sqlite3_flutter_libs
|
||||
)
|
||||
|
||||
list(APPEND FLUTTER_FFI_PLUGIN_LIST
|
||||
jni
|
||||
)
|
||||
|
||||
set(PLUGIN_BUNDLED_LIBRARIES)
|
||||
|
||||
@@ -5,12 +5,14 @@
|
||||
import FlutterMacOS
|
||||
import Foundation
|
||||
|
||||
import google_sign_in_ios
|
||||
import in_app_purchase_storekit
|
||||
import local_auth_darwin
|
||||
import shared_preferences_foundation
|
||||
import sqlite3_flutter_libs
|
||||
|
||||
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"))
|
||||
SharedPreferencesPlugin.register(with: registry.registrar(forPlugin: "SharedPreferencesPlugin"))
|
||||
Sqlite3FlutterLibsPlugin.register(with: registry.registrar(forPlugin: "Sqlite3FlutterLibsPlugin"))
|
||||
}
|
||||
|
||||
+308
-92
@@ -1,22 +1,30 @@
|
||||
# Generated by pub
|
||||
# See https://dart.dev/tools/pub/glossary#lockfile
|
||||
packages:
|
||||
_discoveryapis_commons:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: _discoveryapis_commons
|
||||
sha256: "113c4100b90a5b70a983541782431b82168b3cae166ab130649c36eb3559d498"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.0.7"
|
||||
_fe_analyzer_shared:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: _fe_analyzer_shared
|
||||
sha256: "8d7ff3948166b8ec5da0fbb5962000926b8e02f2ed9b3e51d1738905fbd4c98d"
|
||||
sha256: a49d6cf99e8d8e7a8e93668d09ced0bbdb954d0b4fccc2f5f9241c6b87fad95c
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "93.0.0"
|
||||
version: "99.0.0"
|
||||
analyzer:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: analyzer
|
||||
sha256: de7148ed2fcec579b19f122c1800933dfa028f6d9fd38a152b04b1516cec120b
|
||||
sha256: "663efa951fb8a45e06f491223a604c93820598f20e6a99c25617a1576065e8b7"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "10.0.1"
|
||||
version: "12.1.0"
|
||||
ansicolor:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -45,10 +53,10 @@ packages:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: async
|
||||
sha256: "758e6d74e971c3e5aceb4110bfd6698efc7f501675bcfe0c775459a8140750eb"
|
||||
sha256: e2eb0491ba5ddb6177742d2da23904574082139b07c1e33b8503b9f46f3e1a37
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.13.0"
|
||||
version: "2.13.1"
|
||||
boolean_selector:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -61,10 +69,10 @@ packages:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: build
|
||||
sha256: aadd943f4f8cc946882c954c187e6115a84c98c81ad1d9c6cbf0895a8c85da9c
|
||||
sha256: a156715e7cd728130c592f30552575908aae5b100005fbc1f0fb16b3c03a3d10
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "4.0.5"
|
||||
version: "4.0.6"
|
||||
build_config:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -85,10 +93,10 @@ packages:
|
||||
dependency: "direct dev"
|
||||
description:
|
||||
name: build_runner
|
||||
sha256: "521daf8d189deb79ba474e43a696b41c49fb3987818dbacf3308f1e03673a75e"
|
||||
sha256: "1523ce62448ebac2c15a8ba5fbad8acac169788658a7dd2a1c2d9c2a9318b9a6"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.13.1"
|
||||
version: "2.15.0"
|
||||
built_collection:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -101,10 +109,10 @@ packages:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: built_value
|
||||
sha256: "6ae8a6435a8c6520c7077b107e77f1fb4ba7009633259a4d49a8afd8e7efc5e9"
|
||||
sha256: "34e4067d30ce212937df995f03b69992eea683539ceeac7f679a1f1eba055b56"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "8.12.4"
|
||||
version: "8.12.6"
|
||||
characters:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -129,6 +137,14 @@ packages:
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.0.4"
|
||||
cli_config:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: cli_config
|
||||
sha256: ac20a183a07002b700f0c25e61b7ee46b23c309d76ab7b7640a028f18e4d99ec
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.2.0"
|
||||
cli_util:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -149,18 +165,10 @@ packages:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: code_assets
|
||||
sha256: "83ccdaa064c980b5596c35dd64a8d3ecc68620174ab9b90b6343b753aa721687"
|
||||
sha256: bf394f466ba9205f1812a0433b392d6af280f155f56651eda7c18cc32ed493b8
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.0.0"
|
||||
code_builder:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: code_builder
|
||||
sha256: "6a6cab2ba4680d6423f34a9b972a4c9a94ebe1b62ecec4e1a1f2cba91fd1319d"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "4.11.1"
|
||||
version: "1.2.1"
|
||||
collection:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -177,6 +185,14 @@ packages:
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "3.1.2"
|
||||
coverage:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: coverage
|
||||
sha256: "956a3de0725ca232ad353565a8290d3357592bf4250f6f298a185e2d949c5d3d"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.15.1"
|
||||
crypto:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -197,34 +213,34 @@ packages:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: cupertino_icons
|
||||
sha256: ba631d1c7f7bef6b729a622b7b752645a2d076dba9976925b8f25725a30e1ee6
|
||||
sha256: "41e005c33bd814be4d3096aff55b1908d419fde52ca656c8c47719ec745873cd"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.0.8"
|
||||
version: "1.0.9"
|
||||
dart_style:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: dart_style
|
||||
sha256: "29f7ecc274a86d32920b1d9cfc7502fa87220da41ec60b55f329559d5732e2b2"
|
||||
sha256: a4c1ccfee44c7e75ed80484071a5c142a385345e658fd8bd7c4b5c97e7198f98
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "3.1.7"
|
||||
version: "3.1.8"
|
||||
drift:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: drift
|
||||
sha256: "055c249d1f91be5a47fe447f88afc24c4ca6f4cd6c5ed66767b4797d48acc2e5"
|
||||
sha256: "6cc0b623c0e83f7080524d8396e9301b1d78b9c66a4fdceeb0f798211303254c"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.32.1"
|
||||
version: "2.34.0"
|
||||
drift_dev:
|
||||
dependency: "direct dev"
|
||||
description:
|
||||
name: drift_dev
|
||||
sha256: "88a9de3af8571518148a6d8a513b57779fd1e60a026d3ab8a481a878fba01d91"
|
||||
sha256: "9cfff1576b49725da0d32c040651a41ae195e8c4af8d8da301593e41d7abc2f7"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.32.1"
|
||||
version: "2.34.0"
|
||||
equatable:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -233,6 +249,14 @@ packages:
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
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:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -269,10 +293,10 @@ packages:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: fl_chart
|
||||
sha256: "74959b99b92b9eebeed1a4049426fd67c4abc3c5a0f4d12e2877097d6a11ae08"
|
||||
sha256: b938f77d042cbcd822936a7a359a7235bad8bd72070de1f827efc2cc297ac888
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.69.2"
|
||||
version: "1.2.0"
|
||||
flutter:
|
||||
dependency: "direct main"
|
||||
description: flutter
|
||||
@@ -306,26 +330,26 @@ packages:
|
||||
dependency: "direct dev"
|
||||
description:
|
||||
name: flutter_native_splash
|
||||
sha256: "4fb9f4113350d3a80841ce05ebf1976a36de622af7d19aca0ca9a9911c7ff002"
|
||||
sha256: "9db4b80b044e9af17cc4b1272137fc7ace0054d879ef8210a76adc34aaf4cdff"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.4.7"
|
||||
version: "2.4.8"
|
||||
flutter_plugin_android_lifecycle:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: flutter_plugin_android_lifecycle
|
||||
sha256: ee8068e0e1cd16c4a82714119918efdeed33b3ba7772c54b5d094ab53f9b7fd1
|
||||
sha256: "3854fe5e3bff0b113c658f260b90c95dea17c92db0f2addeac2e343dd9969785"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.0.33"
|
||||
version: "2.0.35"
|
||||
flutter_riverpod:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: flutter_riverpod
|
||||
sha256: "9532ee6db4a943a1ed8383072a2e3eeda041db5657cdf6d2acecf3c21ecbe7e1"
|
||||
sha256: "9255e1e3ad6e38906a1b4f8287678f95f378744c5b46b1985588543f3f19046e"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.6.1"
|
||||
version: "3.3.2"
|
||||
flutter_test:
|
||||
dependency: "direct dev"
|
||||
description: flutter
|
||||
@@ -336,6 +360,14 @@ packages:
|
||||
description: flutter
|
||||
source: sdk
|
||||
version: "0.0.0"
|
||||
frontend_server_client:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: frontend_server_client
|
||||
sha256: f64a0333a82f30b0cca061bc3d143813a486dc086b574bfb233b7c1372427694
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "4.0.0"
|
||||
glob:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -348,18 +380,82 @@ packages:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: go_router
|
||||
sha256: f02fd7d2a4dc512fec615529824fdd217fecb3a3d3de68360293a551f21634b3
|
||||
sha256: "5922b2861e2235a3504896f0d6fa07d84141b480cf52eecd2f42cd25585a9e8a"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "14.8.1"
|
||||
version: "17.3.0"
|
||||
google_fonts:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: google_fonts
|
||||
sha256: ba03d03bcaa2f6cb7bd920e3b5027181db75ab524f8891c8bc3aa603885b8055
|
||||
sha256: "4e9391085e524954a51e3625b7c9c7e9851dc3f376603208bb45c24b9a66255d"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "6.3.3"
|
||||
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:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -372,10 +468,10 @@ packages:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: hooks
|
||||
sha256: e79ed1e8e1929bc6ecb6ec85f0cb519c887aa5b423705ded0d0f2d9226def388
|
||||
sha256: "9a62a50b50b769a737bc0a8ff381f333529df3ab746b2f6b02e83760231455ba"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.0.2"
|
||||
version: "2.0.2"
|
||||
html:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -412,18 +508,50 @@ packages:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: image
|
||||
sha256: f9881ff4998044947ec38d098bc7c8316ae1186fa786eddffdb867b9bc94dfce
|
||||
sha256: "6300175e00616bbc832e2fc91bfa4d776af5402c81c7151bee6905bb08473c52"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "4.8.0"
|
||||
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:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: intl
|
||||
sha256: d6f56758b7d3014a48af9701c085700aac781a92a87a62b1333b46d8879661cf
|
||||
sha256: "3df61194eb431efc39c4ceba583b95633a403f46c9fd341e550ce0bfa50e9aa5"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.19.0"
|
||||
version: "0.20.2"
|
||||
io:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -432,14 +560,30 @@ packages:
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.0.5"
|
||||
jni:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: jni
|
||||
sha256: c2230682d5bc2362c1c9e8d3c7f406d9cbba23ab3f2e203a025dd47e0fb2e68f
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.0.0"
|
||||
jni_flutter:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: jni_flutter
|
||||
sha256: "8b59e590786050b1cd866677dddaf76b1ade5e7bc751abe04b86e84d379d3ba6"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.0.1"
|
||||
json_annotation:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: json_annotation
|
||||
sha256: cb09e7dac6210041fad964ed7fbee004f14258b4eca4040f72d1234062ace4c8
|
||||
sha256: "2a743920d81b7910627f68ee2c9ac1fc0bfee32b9fc3403587d7c6791ca12f80"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "4.11.0"
|
||||
version: "4.12.0"
|
||||
leak_tracker:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -476,26 +620,26 @@ packages:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: local_auth
|
||||
sha256: "434d854cf478f17f12ab29a76a02b3067f86a63a6d6c4eb8fbfdcfe4879c1b7b"
|
||||
sha256: ae6f382f638108c6becd134318d7c3f0a93875383a54010f61d7c97ac05d5137
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.3.0"
|
||||
version: "3.0.1"
|
||||
local_auth_android:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: local_auth_android
|
||||
sha256: a0bdfcc0607050a26ef5b31d6b4b254581c3d3ce3c1816ab4d4f4a9173e84467
|
||||
sha256: fdb936d59ab945c7af297defd67bd1ed87b11b6db1bc16d01e94677a8f1c38ec
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.0.56"
|
||||
version: "2.0.9"
|
||||
local_auth_darwin:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: local_auth_darwin
|
||||
sha256: "699873970067a40ef2f2c09b4c72eb1cfef64224ef041b3df9fdc5c4c1f91f49"
|
||||
sha256: a8c3d4e17454111f7fd31ff72a31222359f6059f7fe956c2dcfe0f88f49826d4
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.6.1"
|
||||
version: "2.0.3"
|
||||
local_auth_platform_interface:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -508,10 +652,10 @@ packages:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: local_auth_windows
|
||||
sha256: bc4e66a29b0fdf751aafbec923b5bed7ad6ed3614875d8151afe2578520b2ab5
|
||||
sha256: be12c5b8ba5e64896983123655c5f67d2484ecfcc95e367952ad6e3bff94cb16
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.0.11"
|
||||
version: "2.0.1"
|
||||
logging:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -540,10 +684,10 @@ packages:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: meta
|
||||
sha256: "23f08335362185a5ea2ad3a4e597f1375e78bce8a040df5c600c8d3552ef2394"
|
||||
sha256: "1741988757a65eb6b36abe716829688cf01910bbf91c34354ff7ec1c3de2b349"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.17.0"
|
||||
version: "1.18.0"
|
||||
mime:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -556,18 +700,26 @@ packages:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: native_toolchain_c
|
||||
sha256: "6ba77bb18063eebe9de401f5e6437e95e1438af0a87a3a39084fbd37c90df572"
|
||||
sha256: f59351d28f49520cd3a74eb1f41c5f19ae15e53c65a3231d14af672e46510a96
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.17.6"
|
||||
version: "0.19.1"
|
||||
node_preamble:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: node_preamble
|
||||
sha256: "6e7eac89047ab8a8d26cf16127b5ed26de65209847630400f9aefd7cd5c730db"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.0.2"
|
||||
objective_c:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: objective_c
|
||||
sha256: "100a1c87616ab6ed41ec263b083c0ef3261ee6cd1dc3b0f35f8ddfa4f996fe52"
|
||||
sha256: "6cb691c686fa2838c6deb34980d426145c2a5d537491cb83d463c33cdbc726ed"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "9.3.0"
|
||||
version: "9.4.1"
|
||||
package_config:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -596,10 +748,10 @@ packages:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: path_provider_android
|
||||
sha256: f2c65e21139ce2c3dad46922be8272bb5963516045659e71bb16e151c93b580e
|
||||
sha256: "69cbd515a62b94d32a7944f086b2f82b4ac40a1d45bebfc00813a430ab2dabcd"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.2.22"
|
||||
version: "2.3.1"
|
||||
path_provider_foundation:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -696,22 +848,30 @@ packages:
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "4.1.0"
|
||||
record_use:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: record_use
|
||||
sha256: "2551bd8eecfe95d14ae75f6021ad0248be5c27f138c2ec12fcb52b500b3ba1ed"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.6.0"
|
||||
riverpod:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: riverpod
|
||||
sha256: "59062512288d3056b2321804332a13ffdd1bf16df70dcc8e506e411280a72959"
|
||||
sha256: "17100416c51db7810c71a7bb2c34d1f881faa0074fd452afb0c4db6f8f126c76"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.6.1"
|
||||
version: "3.3.2"
|
||||
sensors_plus:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: sensors_plus
|
||||
sha256: "89e2bfc3d883743539ce5774a2b93df61effde40ff958ecad78cd66b1a8b8d52"
|
||||
sha256: "56e8cd4260d9ed8e00ecd8da5d9fdc8a1b2ec12345a750dfa51ff83fcf12e3fa"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "6.1.2"
|
||||
version: "7.0.0"
|
||||
sensors_plus_platform_interface:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -724,18 +884,18 @@ packages:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: shared_preferences
|
||||
sha256: "2939ae520c9024cb197fc20dee269cd8cdbf564c8b5746374ec6cacdc5169e64"
|
||||
sha256: c3025c5534b01739267eb7d76959bbc25a6d10f6988e1c2a3036940133dd10bf
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.5.4"
|
||||
version: "2.5.5"
|
||||
shared_preferences_android:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: shared_preferences_android
|
||||
sha256: "8374d6200ab33ac99031a852eba4c8eb2170c4bf20778b3e2c9eccb45384fb41"
|
||||
sha256: "93ae5884a9df5d3bb696825bceb3a17590754548b5d740eba51500afc8d088f5"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.4.21"
|
||||
version: "2.4.26"
|
||||
shared_preferences_foundation:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -756,10 +916,10 @@ packages:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: shared_preferences_platform_interface
|
||||
sha256: "57cbf196c486bc2cf1f02b85784932c6094376284b3ad5779d1b1c6c6a816b80"
|
||||
sha256: "649dc798a33931919ea356c4305c2d1f81619ea6e92244070b520187b5140ef9"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.4.1"
|
||||
version: "2.4.2"
|
||||
shared_preferences_web:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -784,6 +944,22 @@ packages:
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.4.2"
|
||||
shelf_packages_handler:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: shelf_packages_handler
|
||||
sha256: "89f967eca29607c933ba9571d838be31d67f53f6e4ee15147d5dc2934fee1b1e"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "3.0.2"
|
||||
shelf_static:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: shelf_static
|
||||
sha256: c87c3875f91262785dade62d135760c2c69cb217ac759485334c5857ad89f6e3
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.1.3"
|
||||
shelf_web_socket:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -801,10 +977,26 @@ packages:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: source_gen
|
||||
sha256: "732792cfd197d2161a65bb029606a46e0a18ff30ef9e141a7a82172b05ea8ecd"
|
||||
sha256: ec37cc0e6694374cbef59ed79685572c870a54ede6fa30a3e420feb3adffea02
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "4.2.2"
|
||||
version: "4.2.3"
|
||||
source_map_stack_trace:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: source_map_stack_trace
|
||||
sha256: c0713a43e323c3302c2abe2a1cc89aa057a387101ebd280371d6a6c9fa68516b
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.1.2"
|
||||
source_maps:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: source_maps
|
||||
sha256: "190222579a448b03896e0ca6eca5998fa810fda630c1d65e2f78b3f638f54812"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.10.13"
|
||||
source_span:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -817,26 +1009,26 @@ packages:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: sqlite3
|
||||
sha256: caa693ad15a587a2b4fde093b728131a1827903872171089dedb16f7665d3a91
|
||||
sha256: "37356bcb56ce0d9404d602c41e4bdb7765e7e9732a3e47adb3d98c556a6abdad"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "3.2.0"
|
||||
version: "3.3.3"
|
||||
sqlite3_flutter_libs:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: sqlite3_flutter_libs
|
||||
sha256: eeb9e3a45207649076b808f8a5a74d68770d0b7f26ccef6d5f43106eee5375ad
|
||||
sha256: "3ed7553eee7bb368f8950f58ba29f634e06e813c029aff6a0d60862b96de8454"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.5.42"
|
||||
version: "0.6.0+eol"
|
||||
sqlparser:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: sqlparser
|
||||
sha256: ab2b467425f1d4f3acfa5fd11a08226f7d6c26ff102c06be1807e1dff34e050b
|
||||
sha256: "40bdddb306a727be9ce510bd2d2b9a6c9db6c586d846ef7b22e3990a2b24f02d"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.44.3"
|
||||
version: "0.44.5"
|
||||
stack_trace:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -885,14 +1077,30 @@ packages:
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.2.2"
|
||||
test:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: test
|
||||
sha256: "8d9ceddbab833f180fbefed08afa76d7c03513dfdba87ffcec2718b02bbcbf20"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.31.0"
|
||||
test_api:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: test_api
|
||||
sha256: "8161c84903fd860b26bfdefb7963b3f0b68fee7adea0f59ef805ecca346f0c7a"
|
||||
sha256: "949a932224383300f01be9221c39180316445ecb8e7547f70a41a35bf421fb9e"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.7.10"
|
||||
version: "0.7.11"
|
||||
test_core:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: test_core
|
||||
sha256: "1991d4cfe85d5043241acac92962c3977c8d2f2add1ee73130c7b286417d1d34"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.6.17"
|
||||
typed_data:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -929,10 +1137,10 @@ packages:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: vm_service
|
||||
sha256: "45caa6c5917fa127b5dbcfbd1fa60b14e583afdc08bfc96dda38886ca252eb60"
|
||||
sha256: "0016aef94fc66495ac78af5859181e3f3bf2026bd8eecc72b9565601e19ab360"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "15.0.2"
|
||||
version: "15.2.0"
|
||||
watcher:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -965,6 +1173,14 @@ packages:
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "3.0.3"
|
||||
webkit_inspection_protocol:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: webkit_inspection_protocol
|
||||
sha256: "87d3f2333bb240704cd3f1c6b5b7acd8a10e7f0bc28c28dcf14e782014f4a572"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.2.1"
|
||||
xdg_directories:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -977,10 +1193,10 @@ packages:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: xml
|
||||
sha256: "971043b3a0d3da28727e40ed3e0b5d18b742fa5a68665cca88e74b7876d5e025"
|
||||
sha256: "67f0aff7be013d107995e9b75bf4e7f2c3ef2dfdb2c8e68024bba0a7fd5756a4"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "6.6.1"
|
||||
version: "7.0.1"
|
||||
yaml:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -990,5 +1206,5 @@ packages:
|
||||
source: hosted
|
||||
version: "3.1.3"
|
||||
sdks:
|
||||
dart: ">=3.11.1 <4.0.0"
|
||||
flutter: ">=3.38.4"
|
||||
dart: ">=3.12.0 <4.0.0"
|
||||
flutter: ">=3.44.0"
|
||||
|
||||
+13
-8
@@ -10,21 +10,26 @@ dependencies:
|
||||
flutter:
|
||||
sdk: flutter
|
||||
cupertino_icons: ^1.0.8
|
||||
flutter_riverpod: ^2.6.1
|
||||
go_router: ^14.6.2
|
||||
flutter_riverpod: ^3.3.2
|
||||
go_router: ^17.3.0
|
||||
shared_preferences: ^2.3.3
|
||||
fl_chart: ^0.69.0
|
||||
google_fonts: ^6.2.1
|
||||
intl: ^0.19.0
|
||||
fl_chart: ^1.2.0
|
||||
google_fonts: ^8.1.0
|
||||
intl: ^0.20.2
|
||||
uuid: ^4.5.1
|
||||
path_provider: ^2.1.5
|
||||
http: ^1.2.0
|
||||
sensors_plus: ^6.1.0
|
||||
local_auth: ^2.3.0
|
||||
sensors_plus: ^7.0.0
|
||||
local_auth: ^3.0.1
|
||||
flutter_colorpicker: ^1.1.0
|
||||
drift: ^2.14.1
|
||||
sqlite3_flutter_libs: ^0.5.20
|
||||
sqlite3_flutter_libs: ^0.6.0+eol
|
||||
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:
|
||||
android: true
|
||||
|
||||
@@ -7,11 +7,8 @@
|
||||
#include "generated_plugin_registrant.h"
|
||||
|
||||
#include <local_auth_windows/local_auth_plugin.h>
|
||||
#include <sqlite3_flutter_libs/sqlite3_flutter_libs_plugin.h>
|
||||
|
||||
void RegisterPlugins(flutter::PluginRegistry* registry) {
|
||||
LocalAuthPluginRegisterWithRegistrar(
|
||||
registry->GetRegistrarForPlugin("LocalAuthPlugin"));
|
||||
Sqlite3FlutterLibsPluginRegisterWithRegistrar(
|
||||
registry->GetRegistrarForPlugin("Sqlite3FlutterLibsPlugin"));
|
||||
}
|
||||
|
||||
@@ -4,10 +4,10 @@
|
||||
|
||||
list(APPEND FLUTTER_PLUGIN_LIST
|
||||
local_auth_windows
|
||||
sqlite3_flutter_libs
|
||||
)
|
||||
|
||||
list(APPEND FLUTTER_FFI_PLUGIN_LIST
|
||||
jni
|
||||
)
|
||||
|
||||
set(PLUGIN_BUNDLED_LIBRARIES)
|
||||
|
||||
Reference in New Issue
Block a user