mirror of
https://github.com/koloideal/Casha.git
synced 2026-08-08 17:51:14 +03:00
step
This commit is contained in:
@@ -37,7 +37,7 @@ class PaywallScreen extends ConsumerWidget {
|
||||
child: const Icon(
|
||||
Icons.workspace_premium_rounded,
|
||||
size: 64,
|
||||
color: Color(0xFF7C6DED),
|
||||
color: const Color(0xFF7C6DED),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 24),
|
||||
|
||||
@@ -1,6 +1,12 @@
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import '../../features/dashboard/provider.dart';
|
||||
import '../services/billing_service.dart';
|
||||
|
||||
final billingServiceProvider = Provider<BillingService>((ref) {
|
||||
if (kDebugMode) {
|
||||
final prefs = ref.watch(sharedPreferencesProvider);
|
||||
return DebugBillingService(prefs);
|
||||
}
|
||||
return PlayBillingService();
|
||||
});
|
||||
|
||||
@@ -107,7 +107,7 @@ class CategoryCatalog {
|
||||
byKey(key)?.icon ?? Icons.category_rounded;
|
||||
|
||||
Color colorFor(String key, [Color? fallback]) =>
|
||||
byKey(key)?.color ?? fallback ?? AppColors.accent;
|
||||
byKey(key)?.color ?? fallback ?? const Color(0xFF7C6DED);
|
||||
|
||||
String labelFor(String key, bool isRu) {
|
||||
final cat = byKey(key);
|
||||
@@ -147,7 +147,7 @@ AppCategory _defaultCategory(String key, TransactionType type) {
|
||||
labelEn: key,
|
||||
labelRu: AppCategories.ruLabels[key] ?? key,
|
||||
icon: categoryIconByName(iconName),
|
||||
color: AppCategories.colors[key] ?? AppColors.accent,
|
||||
color: AppCategories.colors[key] ?? const Color(0xFF7C6DED),
|
||||
iconName: iconName,
|
||||
isCustom: false,
|
||||
);
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
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);
|
||||
@@ -10,8 +12,8 @@ final premiumManagerProvider = Provider<PremiumManager>((ref) {
|
||||
});
|
||||
|
||||
final isPremiumProvider = Provider<bool>((ref) {
|
||||
final manager = ref.watch(premiumManagerProvider);
|
||||
return manager.isPremium;
|
||||
final user = ref.watch(currentUserProvider);
|
||||
return user.plan == UserPlan.vip;
|
||||
});
|
||||
|
||||
final purchaseTokenProvider = Provider<String?>((ref) {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import 'dart:async';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:in_app_purchase/in_app_purchase.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
|
||||
class PurchaseResult {
|
||||
final bool success;
|
||||
@@ -190,3 +191,49 @@ class PlayBillingService implements BillingService {
|
||||
await _controller.close();
|
||||
}
|
||||
}
|
||||
|
||||
class DebugBillingService implements BillingService {
|
||||
static const _key = 'debug_purchase_token';
|
||||
final SharedPreferences _prefs;
|
||||
final _controller = StreamController<List<PurchaseDetails>>.broadcast();
|
||||
|
||||
DebugBillingService(this._prefs);
|
||||
|
||||
@override
|
||||
Stream<List<PurchaseDetails>> get purchaseStream => _controller.stream;
|
||||
|
||||
@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> completePurchase(String purchaseToken) async {}
|
||||
|
||||
@override
|
||||
Future<void> dispose() async {
|
||||
await _controller.close();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,6 +24,9 @@ class PremiumManager {
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
@@ -25,9 +25,9 @@ class _ProScreenState extends ConsumerState<ProScreen>
|
||||
late final Animation<double> _successScale;
|
||||
|
||||
static const _gradientColors = [
|
||||
Color(0xFF283593),
|
||||
Color(0xFF5E35B1),
|
||||
Color(0xFFD81B60),
|
||||
Color(0xFF1B5E20),
|
||||
Color(0xFF2E7D32),
|
||||
Color(0xFF4CAF8C),
|
||||
];
|
||||
|
||||
@override
|
||||
@@ -132,7 +132,7 @@ class _ProScreenState extends ConsumerState<ProScreen>
|
||||
) {
|
||||
return Container(
|
||||
width: double.infinity,
|
||||
padding: const EdgeInsets.symmetric(vertical: 24, horizontal: 20),
|
||||
padding: const EdgeInsets.symmetric(vertical: 36, horizontal: 20),
|
||||
decoration: BoxDecoration(
|
||||
gradient: const LinearGradient(
|
||||
begin: Alignment.topLeft,
|
||||
|
||||
@@ -10,9 +10,9 @@ class ProSubscriptionCard extends ConsumerWidget {
|
||||
const ProSubscriptionCard({super.key});
|
||||
|
||||
static const _gradientColors = [
|
||||
Color(0xFF283593),
|
||||
Color(0xFF5E35B1),
|
||||
Color(0xFFD81B60),
|
||||
Color(0xFF1B5E20),
|
||||
Color(0xFF2E7D32),
|
||||
Color(0xFF4CAF8C),
|
||||
];
|
||||
|
||||
@override
|
||||
|
||||
Reference in New Issue
Block a user