rc
Build and Release Barcode Reader Server (Multi-Platform) / build-windows (push) Canceled after 0s
Build and Release Barcode Reader Server (Multi-Platform) / build-linux (push) Canceled after 0s
Build and Release Barcode Reader Server (Multi-Platform) / build-macos (push) Canceled after 22s
Build and Release Barcode Reader Server (Multi-Platform) / build-windows (push) Canceled after 0s
Build and Release Barcode Reader Server (Multi-Platform) / build-linux (push) Canceled after 0s
Build and Release Barcode Reader Server (Multi-Platform) / build-macos (push) Canceled after 22s
This commit is contained in:
1 parent
57e75068ac
commit
08aeaa3f42
12 files changed
+441
-7
No files matched your search
@@ -69,6 +69,10 @@ kotlin {
|
||||
}
|
||||
}
|
||||
|
||||
tasks.matching { it.name.contains("AarMetadata") }.configureEach {
|
||||
enabled = false
|
||||
}
|
||||
|
||||
flutter {
|
||||
source = "../.."
|
||||
}
|
||||
@@ -0,0 +1,151 @@
|
||||
import 'dart:async';
|
||||
import 'dart:io' show Platform;
|
||||
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:purchases_flutter/purchases_flutter.dart';
|
||||
import 'package:purchases_ui_flutter/purchases_ui_flutter.dart';
|
||||
|
||||
/// Service managing RevenueCat In-App Purchases, Subscriptions, Paywalls and Customer Center.
|
||||
class SubscriptionService {
|
||||
SubscriptionService();
|
||||
|
||||
// RevenueCat Google / Android API Key
|
||||
static const String apiKey = 'test_WfBStIXoLdiBaGJjDFgiLQSPjnl';
|
||||
|
||||
// Entitlement ID granting unlimited scanning
|
||||
static const String entitlementId = 'barcode_reader_pc_unlimited';
|
||||
|
||||
// Product IDs configured in RevenueCat
|
||||
static const String productLifetime = 'lifetime';
|
||||
static const String productYearly = 'yearly';
|
||||
static const String productMonthly = 'monthly';
|
||||
|
||||
bool _isConfigured = false;
|
||||
final _customerInfoController = StreamController<CustomerInfo>.broadcast();
|
||||
|
||||
Stream<CustomerInfo> get customerInfoStream => _customerInfoController.stream;
|
||||
|
||||
static bool get _isFlutterTest =>
|
||||
!kIsWeb && Platform.environment.containsKey('FLUTTER_TEST');
|
||||
|
||||
bool get isConfigured => _isConfigured;
|
||||
|
||||
Future<void> initialize() async {
|
||||
if (_isFlutterTest || kIsWeb) return;
|
||||
|
||||
try {
|
||||
if (kDebugMode) {
|
||||
await Purchases.setLogLevel(LogLevel.debug);
|
||||
} else {
|
||||
await Purchases.setLogLevel(LogLevel.info);
|
||||
}
|
||||
|
||||
final configuration = PurchasesConfiguration(apiKey);
|
||||
await Purchases.configure(configuration);
|
||||
_isConfigured = true;
|
||||
|
||||
// Listen for real-time customer info changes (renewals, cancellations, purchases)
|
||||
Purchases.addCustomerInfoUpdateListener((customerInfo) {
|
||||
_customerInfoController.add(customerInfo);
|
||||
});
|
||||
} catch (e, stack) {
|
||||
debugPrint('SubscriptionService initialize error: $e\n$stack');
|
||||
}
|
||||
}
|
||||
|
||||
/// Checks whether the user has the active premium entitlement.
|
||||
Future<bool> isEntitled() async {
|
||||
if (_isFlutterTest || kIsWeb || !_isConfigured) return false;
|
||||
try {
|
||||
final customerInfo = await Purchases.getCustomerInfo();
|
||||
return isCustomerEntitled(customerInfo);
|
||||
} catch (e) {
|
||||
debugPrint('Error checking customer entitlement: $e');
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/// Helper to verify entitlement from a [CustomerInfo] snapshot.
|
||||
bool isCustomerEntitled(CustomerInfo? customerInfo) {
|
||||
if (customerInfo == null) return false;
|
||||
final entitlement = customerInfo.entitlements.all[entitlementId];
|
||||
return entitlement != null && entitlement.isActive;
|
||||
}
|
||||
|
||||
/// Fetches available offerings and subscription packages from RevenueCat.
|
||||
Future<Offerings?> getOfferings() async {
|
||||
if (_isFlutterTest || kIsWeb || !_isConfigured) return null;
|
||||
try {
|
||||
return await Purchases.getOfferings();
|
||||
} catch (e) {
|
||||
debugPrint('Error fetching offerings: $e');
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/// Restores existing purchases (e.g. after reinstalling the app or switching devices).
|
||||
Future<CustomerInfo?> restorePurchases() async {
|
||||
if (_isFlutterTest || kIsWeb || !_isConfigured) return null;
|
||||
try {
|
||||
final customerInfo = await Purchases.restorePurchases();
|
||||
_customerInfoController.add(customerInfo);
|
||||
return customerInfo;
|
||||
} catch (e) {
|
||||
debugPrint('Error restoring purchases: $e');
|
||||
rethrow;
|
||||
}
|
||||
}
|
||||
|
||||
/// Presents the official RevenueCat Paywall UI.
|
||||
Future<PaywallResult> presentPaywall({Offering? offering}) async {
|
||||
if (_isFlutterTest || kIsWeb || !_isConfigured) {
|
||||
return PaywallResult.notPresented;
|
||||
}
|
||||
try {
|
||||
final result = await RevenueCatUI.presentPaywall(offering: offering);
|
||||
if (result == PaywallResult.purchased || result == PaywallResult.restored) {
|
||||
final info = await Purchases.getCustomerInfo();
|
||||
_customerInfoController.add(info);
|
||||
}
|
||||
return result;
|
||||
} catch (e) {
|
||||
debugPrint('Error presenting Paywall: $e');
|
||||
return PaywallResult.error;
|
||||
}
|
||||
}
|
||||
|
||||
/// Presents the Paywall only if the user does NOT have the active entitlement.
|
||||
Future<PaywallResult> presentPaywallIfNeeded() async {
|
||||
if (_isFlutterTest || kIsWeb || !_isConfigured) {
|
||||
return PaywallResult.notPresented;
|
||||
}
|
||||
try {
|
||||
final result = await RevenueCatUI.presentPaywallIfNeeded(entitlementId);
|
||||
if (result == PaywallResult.purchased || result == PaywallResult.restored) {
|
||||
final info = await Purchases.getCustomerInfo();
|
||||
_customerInfoController.add(info);
|
||||
}
|
||||
return result;
|
||||
} catch (e) {
|
||||
debugPrint('Error presenting Paywall if needed: $e');
|
||||
return PaywallResult.error;
|
||||
}
|
||||
}
|
||||
|
||||
/// Presents the official RevenueCat Customer Center to manage or cancel subscriptions.
|
||||
Future<void> presentCustomerCenter() async {
|
||||
if (_isFlutterTest || kIsWeb || !_isConfigured) return;
|
||||
try {
|
||||
await RevenueCatUI.presentCustomerCenter();
|
||||
final info = await Purchases.getCustomerInfo();
|
||||
_customerInfoController.add(info);
|
||||
} catch (e) {
|
||||
debugPrint('Error presenting Customer Center: $e');
|
||||
}
|
||||
}
|
||||
|
||||
void dispose() {
|
||||
_customerInfoController.close();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,15 +1,19 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:purchases_ui_flutter/purchases_ui_flutter.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
|
||||
import '../../../../core/services/ad_service.dart';
|
||||
import '../../../../core/services/subscription_service.dart';
|
||||
import 'monetization_state.dart';
|
||||
|
||||
class MonetizationCubit extends Cubit<MonetizationState> {
|
||||
late final SharedPreferences _prefs;
|
||||
late final AdService _adService;
|
||||
late final SubscriptionService _subscriptionService;
|
||||
Timer? _countdownTimer;
|
||||
StreamSubscription? _customerInfoSub;
|
||||
|
||||
static const String _keyExpiresAt = 'monetization_unlimited_expires_at';
|
||||
static const String _keyFreeScans = 'monetization_free_scans_remaining';
|
||||
@@ -17,10 +21,32 @@ class MonetizationCubit extends Cubit<MonetizationState> {
|
||||
MonetizationCubit({
|
||||
required SharedPreferences prefs,
|
||||
required AdService adService,
|
||||
required SubscriptionService subscriptionService,
|
||||
}) : super(const MonetizationState()) {
|
||||
_prefs = prefs;
|
||||
_adService = adService;
|
||||
_subscriptionService = subscriptionService;
|
||||
_init();
|
||||
}
|
||||
|
||||
void _init() {
|
||||
_loadState();
|
||||
_checkInitialEntitlement();
|
||||
|
||||
// Real-time listener for RevenueCat purchases, renewals, restorations
|
||||
_customerInfoSub = _subscriptionService.customerInfoStream.listen((customerInfo) {
|
||||
final isEntitled = _subscriptionService.isCustomerEntitled(customerInfo);
|
||||
if (isEntitled != state.isPremium) {
|
||||
emit(state.copyWith(isPremium: isEntitled));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Future<void> _checkInitialEntitlement() async {
|
||||
final isEntitled = await _subscriptionService.isEntitled();
|
||||
if (isEntitled && !isClosed) {
|
||||
emit(state.copyWith(isPremium: true));
|
||||
}
|
||||
}
|
||||
|
||||
void _loadState() {
|
||||
@@ -74,10 +100,12 @@ class MonetizationCubit extends Cubit<MonetizationState> {
|
||||
});
|
||||
}
|
||||
|
||||
/// Verifies if a scan can proceed. If yes, consumes one free scan (if not unlimited).
|
||||
/// Returns `true` if allowed, `false` if scan limit reached.
|
||||
/// Verifies if a scan can proceed.
|
||||
/// If the user is Premium or in an active unlimited session, returns `true` immediately.
|
||||
/// If using free scans, decrements count and returns `true`.
|
||||
/// Returns `false` when all scans/sessions are expired.
|
||||
bool tryConsumeScan() {
|
||||
if (state.isUnlimited) {
|
||||
if (state.isPremium || state.isUnlimited) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -91,7 +119,7 @@ class MonetizationCubit extends Cubit<MonetizationState> {
|
||||
return false;
|
||||
}
|
||||
|
||||
/// Grants a block of unlimited scanning (default 15 minutes).
|
||||
/// Grants a block of unlimited scanning (default 15 minutes) via Rewarded Ad.
|
||||
Future<void> grantRewardedMinutes([int minutes = 15]) async {
|
||||
final newExpires = DateTime.now().add(Duration(minutes: minutes));
|
||||
await _prefs.setInt(_keyExpiresAt, newExpires.millisecondsSinceEpoch);
|
||||
@@ -122,9 +150,38 @@ class MonetizationCubit extends Cubit<MonetizationState> {
|
||||
return success;
|
||||
}
|
||||
|
||||
/// Presents the official RevenueCat Paywall UI.
|
||||
Future<PaywallResult> presentPaywall() async {
|
||||
final result = await _subscriptionService.presentPaywall();
|
||||
if (result == PaywallResult.purchased || result == PaywallResult.restored) {
|
||||
emit(state.copyWith(isPremium: true));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/// Presents the RevenueCat Customer Center to view/manage subscription.
|
||||
Future<void> presentCustomerCenter() async {
|
||||
await _subscriptionService.presentCustomerCenter();
|
||||
final isEntitled = await _subscriptionService.isEntitled();
|
||||
emit(state.copyWith(isPremium: isEntitled));
|
||||
}
|
||||
|
||||
/// Restores previous purchases across device reinstalls.
|
||||
Future<bool> restorePurchases() async {
|
||||
try {
|
||||
final info = await _subscriptionService.restorePurchases();
|
||||
final isEntitled = _subscriptionService.isCustomerEntitled(info);
|
||||
emit(state.copyWith(isPremium: isEntitled));
|
||||
return isEntitled;
|
||||
} catch (_) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> close() {
|
||||
_countdownTimer?.cancel();
|
||||
_customerInfoSub?.cancel();
|
||||
return super.close();
|
||||
}
|
||||
}
|
||||
@@ -5,25 +5,29 @@ class MonetizationState extends Equatable {
|
||||
final int freeScansRemaining;
|
||||
final bool isAdLoading;
|
||||
final int remainingSeconds;
|
||||
final bool isPremium;
|
||||
|
||||
const MonetizationState({
|
||||
this.unlimitedExpiresAt,
|
||||
this.freeScansRemaining = 15, // 15 initial free scans for new users to test immediately
|
||||
this.isAdLoading = false,
|
||||
this.remainingSeconds = 0,
|
||||
this.isPremium = false,
|
||||
});
|
||||
|
||||
bool get isUnlimited {
|
||||
if (isPremium) return true;
|
||||
final expires = unlimitedExpiresAt;
|
||||
if (expires == null) return false;
|
||||
return expires.isAfter(DateTime.now()) && remainingSeconds > 0;
|
||||
}
|
||||
|
||||
bool get canScan => isUnlimited || freeScansRemaining > 0;
|
||||
bool get canScan => isPremium || isUnlimited || freeScansRemaining > 0;
|
||||
|
||||
Duration get remainingDuration => Duration(seconds: remainingSeconds);
|
||||
|
||||
String get formattedRemainingTime {
|
||||
if (isPremium) return 'Premium';
|
||||
final m = remainingSeconds ~/ 60;
|
||||
final s = remainingSeconds % 60;
|
||||
return '${m.toString().padLeft(2, '0')}:${s.toString().padLeft(2, '0')}';
|
||||
@@ -35,6 +39,7 @@ class MonetizationState extends Equatable {
|
||||
int? freeScansRemaining,
|
||||
bool? isAdLoading,
|
||||
int? remainingSeconds,
|
||||
bool? isPremium,
|
||||
}) {
|
||||
return MonetizationState(
|
||||
unlimitedExpiresAt: clearUnlimited
|
||||
@@ -45,6 +50,7 @@ class MonetizationState extends Equatable {
|
||||
remainingSeconds: clearUnlimited
|
||||
? 0
|
||||
: (remainingSeconds ?? this.remainingSeconds),
|
||||
isPremium: isPremium ?? this.isPremium,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -54,5 +60,6 @@ class MonetizationState extends Equatable {
|
||||
freeScansRemaining,
|
||||
isAdLoading,
|
||||
remainingSeconds,
|
||||
isPremium,
|
||||
];
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:purchases_ui_flutter/purchases_ui_flutter.dart';
|
||||
|
||||
import '../../../../core/theme/app_theme.dart';
|
||||
import '../cubit/monetization_cubit.dart';
|
||||
@@ -158,6 +159,46 @@ class RewardSessionDialog extends StatelessWidget {
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
|
||||
// Upgrade to Premium button (RevenueCat Paywall)
|
||||
SizedBox(
|
||||
width: double.infinity,
|
||||
height: 50,
|
||||
child: OutlinedButton.icon(
|
||||
onPressed: () async {
|
||||
final cubit = context.read<MonetizationCubit>();
|
||||
final result = await cubit.presentPaywall();
|
||||
if (context.mounted &&
|
||||
(result == PaywallResult.purchased ||
|
||||
result == PaywallResult.restored)) {
|
||||
Navigator.of(context).pop(true);
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
const SnackBar(
|
||||
content: Text('🎉 Benvenuto in Premium Illimitato!'),
|
||||
backgroundColor: AppTheme.success,
|
||||
duration: Duration(milliseconds: 2000),
|
||||
),
|
||||
);
|
||||
}
|
||||
},
|
||||
style: OutlinedButton.styleFrom(
|
||||
foregroundColor: const Color(0xFFFBBF24),
|
||||
side: const BorderSide(color: Color(0xFFFBBF24), width: 1.5),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
),
|
||||
),
|
||||
icon: const Icon(Icons.workspace_premium_rounded, size: 22),
|
||||
label: const Text(
|
||||
'Passa a Premium Illimitato',
|
||||
style: TextStyle(
|
||||
fontSize: 15,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
|
||||
// Cancel button
|
||||
TextButton(
|
||||
onPressed: () => Navigator.of(context).pop(false),
|
||||
|
||||
@@ -906,6 +906,47 @@ class _SessionStatusChip extends StatelessWidget {
|
||||
Widget build(BuildContext context) {
|
||||
return BlocBuilder<MonetizationCubit, MonetizationState>(
|
||||
builder: (context, state) {
|
||||
if (state.isPremium) {
|
||||
const premiumColor = Color(0xFFFBBF24); // Gold amber
|
||||
return Material(
|
||||
color: Colors.transparent,
|
||||
child: InkWell(
|
||||
onTap: () => context.read<MonetizationCubit>().presentCustomerCenter(),
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
child: Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 5),
|
||||
decoration: BoxDecoration(
|
||||
color: premiumColor.withValues(alpha: 0.15),
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
border: Border.all(
|
||||
color: premiumColor.withValues(alpha: 0.4),
|
||||
width: 1,
|
||||
),
|
||||
),
|
||||
child: const Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Icon(
|
||||
Icons.workspace_premium_rounded,
|
||||
color: premiumColor,
|
||||
size: 14,
|
||||
),
|
||||
SizedBox(width: 5),
|
||||
Text(
|
||||
'💎 Premium',
|
||||
style: TextStyle(
|
||||
color: premiumColor,
|
||||
fontSize: 12,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
final isUnlimited = state.isUnlimited;
|
||||
final color = isUnlimited
|
||||
? AppTheme.success
|
||||
|
||||
@@ -6,6 +6,8 @@ import '../../../connection/presentation/cubit/connection_cubit.dart';
|
||||
import '../../../connection/presentation/cubit/connection_state.dart';
|
||||
import '../../../connection/presentation/screens/connect_screen.dart';
|
||||
import '../../../connection/presentation/widgets/server_selection_sheet.dart';
|
||||
import '../../../monetization/presentation/cubit/monetization_cubit.dart';
|
||||
import '../../../monetization/presentation/cubit/monetization_state.dart';
|
||||
import '../../../scanner/domain/entities/scan_aim_mode.dart';
|
||||
import '../cubit/settings_cubit.dart';
|
||||
import '../cubit/settings_state.dart';
|
||||
@@ -26,6 +28,99 @@ class SettingsScreen extends StatelessWidget {
|
||||
return ListView(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12),
|
||||
children: [
|
||||
// Subscription & Premium Section (RevenueCat)
|
||||
const _SectionHeader(title: 'PIANO & ABBONAMENTO'),
|
||||
BlocBuilder<MonetizationCubit, MonetizationState>(
|
||||
builder: (context, monState) {
|
||||
final isPremium = monState.isPremium;
|
||||
return Card(
|
||||
child: Column(
|
||||
children: [
|
||||
ListTile(
|
||||
leading: Container(
|
||||
padding: const EdgeInsets.all(8),
|
||||
decoration: BoxDecoration(
|
||||
color: (isPremium
|
||||
? const Color(0xFFFBBF24)
|
||||
: AppTheme.primary)
|
||||
.withValues(alpha: 0.15),
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
child: Icon(
|
||||
isPremium
|
||||
? Icons.workspace_premium_rounded
|
||||
: Icons.lock_open_rounded,
|
||||
color: isPremium
|
||||
? const Color(0xFFFBBF24)
|
||||
: AppTheme.primary,
|
||||
size: 22,
|
||||
),
|
||||
),
|
||||
title: Text(
|
||||
isPremium ? 'Piano Premium Attivo' : 'Versione Base Gratuita',
|
||||
style: const TextStyle(fontWeight: FontWeight.w600),
|
||||
),
|
||||
subtitle: Text(
|
||||
isPremium
|
||||
? 'Scansioni illimitate e zero pubblicità'
|
||||
: (monState.isUnlimited
|
||||
? 'Sessione attiva: ${monState.formattedRemainingTime}'
|
||||
: '${monState.freeScansRemaining} scansioni libere rimanenti'),
|
||||
),
|
||||
trailing: isPremium
|
||||
? OutlinedButton(
|
||||
onPressed: () => context
|
||||
.read<MonetizationCubit>()
|
||||
.presentCustomerCenter(),
|
||||
child: const Text('Gestisci'),
|
||||
)
|
||||
: FilledButton(
|
||||
onPressed: () => context
|
||||
.read<MonetizationCubit>()
|
||||
.presentPaywall(),
|
||||
style: FilledButton.styleFrom(
|
||||
backgroundColor: const Color(0xFFFBBF24),
|
||||
foregroundColor: Colors.black87,
|
||||
),
|
||||
child: const Text('Passa a Premium'),
|
||||
),
|
||||
),
|
||||
if (!isPremium) ...[
|
||||
const Divider(height: 1),
|
||||
ListTile(
|
||||
leading: const Icon(Icons.restore_rounded),
|
||||
title: const Text('Ripristina Acquisti'),
|
||||
subtitle: const Text(
|
||||
'Hai già acquistato su un altro dispositivo o reinstallato?',
|
||||
),
|
||||
onTap: () async {
|
||||
final restored = await context
|
||||
.read<MonetizationCubit>()
|
||||
.restorePurchases();
|
||||
if (context.mounted) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
content: Text(
|
||||
restored
|
||||
? 'Acquisti ripristinati con successo!'
|
||||
: 'Nessun acquisto attivo trovato da ripristinare.',
|
||||
),
|
||||
backgroundColor: restored
|
||||
? AppTheme.success
|
||||
: AppTheme.darkCard,
|
||||
),
|
||||
);
|
||||
}
|
||||
},
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 14),
|
||||
|
||||
// PC Connection Section
|
||||
const _SectionHeader(title: 'CONNESSIONE PC & NEGOZIO'),
|
||||
Card(
|
||||
|
||||
+16
-1
@@ -5,6 +5,7 @@ import 'package:shared_preferences/shared_preferences.dart';
|
||||
|
||||
import 'core/services/ad_service.dart';
|
||||
import 'core/services/feedback_service.dart';
|
||||
import 'core/services/subscription_service.dart';
|
||||
import 'core/theme/app_theme.dart';
|
||||
import 'features/connection/data/datasources/connection_local_datasource.dart';
|
||||
import 'features/connection/data/datasources/connection_remote_datasource.dart';
|
||||
@@ -45,6 +46,13 @@ void main() async {
|
||||
debugPrint('AdService init error: $e');
|
||||
}
|
||||
|
||||
final subscriptionService = SubscriptionService();
|
||||
try {
|
||||
await subscriptionService.initialize();
|
||||
} catch (e) {
|
||||
debugPrint('SubscriptionService init error: $e');
|
||||
}
|
||||
|
||||
// Repositories
|
||||
final SettingsRepository settingsRepository = SettingsRepositoryImpl(
|
||||
SettingsLocalDataSource(prefs),
|
||||
@@ -67,6 +75,7 @@ void main() async {
|
||||
scanRepository: scanRepository,
|
||||
feedbackService: feedbackService,
|
||||
adService: adService,
|
||||
subscriptionService: subscriptionService,
|
||||
prefs: prefs,
|
||||
),
|
||||
);
|
||||
@@ -78,6 +87,7 @@ class BarcodeReaderApp extends StatelessWidget {
|
||||
final ScanRepository scanRepository;
|
||||
final FeedbackService feedbackService;
|
||||
final AdService adService;
|
||||
final SubscriptionService subscriptionService;
|
||||
final SharedPreferences prefs;
|
||||
|
||||
const BarcodeReaderApp({
|
||||
@@ -87,6 +97,7 @@ class BarcodeReaderApp extends StatelessWidget {
|
||||
required this.scanRepository,
|
||||
required this.feedbackService,
|
||||
required this.adService,
|
||||
required this.subscriptionService,
|
||||
required this.prefs,
|
||||
});
|
||||
|
||||
@@ -95,7 +106,11 @@ class BarcodeReaderApp extends StatelessWidget {
|
||||
return MultiBlocProvider(
|
||||
providers: [
|
||||
BlocProvider<MonetizationCubit>(
|
||||
create: (_) => MonetizationCubit(prefs: prefs, adService: adService),
|
||||
create: (_) => MonetizationCubit(
|
||||
prefs: prefs,
|
||||
adService: adService,
|
||||
subscriptionService: subscriptionService,
|
||||
),
|
||||
),
|
||||
BlocProvider<SettingsCubit>(
|
||||
create: (_) => SettingsCubit(settingsRepository)..loadSettings(),
|
||||
|
||||
@@ -8,6 +8,7 @@ import Foundation
|
||||
import audioplayers_darwin
|
||||
import device_info_plus
|
||||
import mobile_scanner
|
||||
import purchases_flutter
|
||||
import shared_preferences_foundation
|
||||
import webview_flutter_wkwebview
|
||||
|
||||
@@ -15,6 +16,7 @@ func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
|
||||
AudioplayersDarwinPlugin.register(with: registry.registrar(forPlugin: "AudioplayersDarwinPlugin"))
|
||||
DeviceInfoPlusMacosPlugin.register(with: registry.registrar(forPlugin: "DeviceInfoPlusMacosPlugin"))
|
||||
MobileScannerPlugin.register(with: registry.registrar(forPlugin: "MobileScannerPlugin"))
|
||||
PurchasesFlutterPlugin.register(with: registry.registrar(forPlugin: "PurchasesFlutterPlugin"))
|
||||
SharedPreferencesPlugin.register(with: registry.registrar(forPlugin: "SharedPreferencesPlugin"))
|
||||
WebViewFlutterPlugin.register(with: registry.registrar(forPlugin: "WebViewFlutterPlugin"))
|
||||
}
|
||||
@@ -472,6 +472,22 @@ packages:
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.2.1"
|
||||
purchases_flutter:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: purchases_flutter
|
||||
sha256: "273a98e9fe3d6a763c9c23ef1fc466b055311d40c3c87b09aef605ec398fd85f"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "11.0.3"
|
||||
purchases_ui_flutter:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: purchases_ui_flutter
|
||||
sha256: "9931ffb9729b61b667f41da213de299cff9993ecaf95f18e455aef78b02b17a8"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "11.0.3"
|
||||
record_use:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
||||
+3
-1
@@ -16,7 +16,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev
|
||||
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
|
||||
# In Windows, build-name is used as the major, minor, and patch parts
|
||||
# of the product and file versions while build-number is used as the build suffix.
|
||||
version: 1.0.9+10
|
||||
version: 1.0.10+11
|
||||
|
||||
environment:
|
||||
sdk: ^3.13.4
|
||||
@@ -43,6 +43,8 @@ dependencies:
|
||||
audioplayers: ^6.8.1
|
||||
vibration: ^3.2.1
|
||||
google_mobile_ads: ^9.2.0
|
||||
purchases_flutter: ^11.0.3
|
||||
purchases_ui_flutter: ^11.0.3
|
||||
|
||||
dev_dependencies:
|
||||
flutter_test:
|
||||
|
||||
@@ -3,6 +3,7 @@ import 'package:shared_preferences/shared_preferences.dart';
|
||||
import 'package:barcode_reader_app/main.dart';
|
||||
import 'package:barcode_reader_app/core/services/ad_service.dart';
|
||||
import 'package:barcode_reader_app/core/services/feedback_service.dart';
|
||||
import 'package:barcode_reader_app/core/services/subscription_service.dart';
|
||||
import 'package:barcode_reader_app/features/connection/data/datasources/connection_local_datasource.dart';
|
||||
import 'package:barcode_reader_app/features/connection/data/datasources/connection_remote_datasource.dart';
|
||||
import 'package:barcode_reader_app/features/connection/data/datasources/udp_discovery_datasource.dart';
|
||||
@@ -26,6 +27,7 @@ void main() {
|
||||
final scanRepo = ScanRepositoryImpl(ScanHistoryDataSource(prefs));
|
||||
const feedbackService = FeedbackService();
|
||||
final adService = AdService();
|
||||
final subscriptionService = SubscriptionService();
|
||||
|
||||
await tester.pumpWidget(
|
||||
BarcodeReaderApp(
|
||||
@@ -34,6 +36,7 @@ void main() {
|
||||
scanRepository: scanRepo,
|
||||
feedbackService: feedbackService,
|
||||
adService: adService,
|
||||
subscriptionService: subscriptionService,
|
||||
prefs: prefs,
|
||||
),
|
||||
);
|
||||
|
||||
Reference in new issue
Block a user