admob e icone
No files matched your search
@@ -39,6 +39,11 @@
|
||||
<meta-data
|
||||
android:name="flutterEmbedding"
|
||||
android:value="2" />
|
||||
|
||||
<!-- Google AdMob Application ID -->
|
||||
<meta-data
|
||||
android:name="com.google.android.gms.ads.APPLICATION_ID"
|
||||
android:value="ca-app-pub-8592989118033227~7564566063" />
|
||||
</application>
|
||||
<!-- Required to query activities that can process text, see:
|
||||
https://developer.android.com/training/package-visibility and
|
||||
|
||||
|
Before Width: | Height: | Size: 544 B After Width: | Height: | Size: 7.5 KiB |
|
Before Width: | Height: | Size: 442 B After Width: | Height: | Size: 4.1 KiB |
|
Before Width: | Height: | Size: 721 B After Width: | Height: | Size: 12 KiB |
|
Before Width: | Height: | Size: 1.0 KiB After Width: | Height: | Size: 23 KiB |
|
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 38 KiB |
|
After Width: | Height: | Size: 898 KiB |
|
After Width: | Height: | Size: 240 KiB |
@@ -0,0 +1,109 @@
|
||||
import 'dart:async';
|
||||
import 'dart:io' show Platform;
|
||||
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:google_mobile_ads/google_mobile_ads.dart';
|
||||
|
||||
/// Service managing Google AdMob SDK initialization and Rewarded Ads.
|
||||
class AdService {
|
||||
AdService();
|
||||
|
||||
static const String androidProductionRewardedAdUnitId =
|
||||
'ca-app-pub-8592989118033227/7181422681';
|
||||
|
||||
// Official Google demo ad unit ID for testing rewarded video ads safely
|
||||
static const String androidTestRewardedAdUnitId =
|
||||
'ca-app-pub-3940256099942544/5224354917';
|
||||
|
||||
RewardedAd? _rewardedAd;
|
||||
bool _isLoading = false;
|
||||
bool _isInitialized = false;
|
||||
|
||||
static bool get _isFlutterTest =>
|
||||
!kIsWeb && Platform.environment.containsKey('FLUTTER_TEST');
|
||||
|
||||
String get rewardedAdUnitId {
|
||||
if (kReleaseMode) {
|
||||
return androidProductionRewardedAdUnitId;
|
||||
}
|
||||
return androidTestRewardedAdUnitId;
|
||||
}
|
||||
|
||||
bool get isInitialized => _isInitialized;
|
||||
bool get isAdReady => _rewardedAd != null;
|
||||
|
||||
Future<void> initialize() async {
|
||||
if (_isFlutterTest || kIsWeb) return;
|
||||
try {
|
||||
await MobileAds.instance.initialize();
|
||||
_isInitialized = true;
|
||||
loadRewardedAd();
|
||||
} catch (e) {
|
||||
debugPrint('AdService initialize error: $e');
|
||||
}
|
||||
}
|
||||
|
||||
void loadRewardedAd() {
|
||||
if (_isFlutterTest || kIsWeb || _isLoading || _rewardedAd != null) return;
|
||||
_isLoading = true;
|
||||
|
||||
RewardedAd.load(
|
||||
adUnitId: rewardedAdUnitId,
|
||||
request: const AdRequest(),
|
||||
rewardedAdLoadCallback: RewardedAdLoadCallback(
|
||||
onAdLoaded: (ad) {
|
||||
_rewardedAd = ad;
|
||||
_isLoading = false;
|
||||
},
|
||||
onAdFailedToLoad: (error) {
|
||||
debugPrint('RewardedAd failed to load: $error');
|
||||
_rewardedAd = null;
|
||||
_isLoading = false;
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Future<bool> showRewardedAd({required VoidCallback onUserEarnedReward}) async {
|
||||
if (_isFlutterTest) {
|
||||
onUserEarnedReward();
|
||||
return true;
|
||||
}
|
||||
|
||||
if (_rewardedAd == null) {
|
||||
loadRewardedAd();
|
||||
return false;
|
||||
}
|
||||
|
||||
final completer = Completer<bool>();
|
||||
final ad = _rewardedAd!;
|
||||
_rewardedAd = null;
|
||||
|
||||
ad.fullScreenContentCallback = FullScreenContentCallback(
|
||||
onAdDismissedFullScreenContent: (ad) {
|
||||
ad.dispose();
|
||||
loadRewardedAd();
|
||||
if (!completer.isCompleted) completer.complete(true);
|
||||
},
|
||||
onAdFailedToShowFullScreenContent: (ad, error) {
|
||||
ad.dispose();
|
||||
loadRewardedAd();
|
||||
if (!completer.isCompleted) completer.complete(false);
|
||||
},
|
||||
);
|
||||
|
||||
await ad.show(
|
||||
onUserEarnedReward: (_, reward) {
|
||||
onUserEarnedReward();
|
||||
},
|
||||
);
|
||||
|
||||
return completer.future;
|
||||
}
|
||||
|
||||
void dispose() {
|
||||
_rewardedAd?.dispose();
|
||||
_rewardedAd = null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,118 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
|
||||
import '../../../../core/services/ad_service.dart';
|
||||
import 'monetization_state.dart';
|
||||
|
||||
class MonetizationCubit extends Cubit<MonetizationState> {
|
||||
late final SharedPreferences _prefs;
|
||||
late final AdService _adService;
|
||||
Timer? _countdownTimer;
|
||||
|
||||
static const String _keyExpiresAt = 'monetization_unlimited_expires_at';
|
||||
static const String _keyFreeScans = 'monetization_free_scans_remaining';
|
||||
|
||||
MonetizationCubit({
|
||||
required SharedPreferences prefs,
|
||||
required AdService adService,
|
||||
}) : super(const MonetizationState()) {
|
||||
_prefs = prefs;
|
||||
_adService = adService;
|
||||
_loadState();
|
||||
}
|
||||
|
||||
void _loadState() {
|
||||
final rawExpires = _prefs.getInt(_keyExpiresAt);
|
||||
final freeScans = _prefs.getInt(_keyFreeScans) ?? 15;
|
||||
|
||||
DateTime? expiresAt;
|
||||
if (rawExpires != null) {
|
||||
final date = DateTime.fromMillisecondsSinceEpoch(rawExpires);
|
||||
if (date.isAfter(DateTime.now())) {
|
||||
expiresAt = date;
|
||||
}
|
||||
}
|
||||
|
||||
emit(MonetizationState(
|
||||
unlimitedExpiresAt: expiresAt,
|
||||
freeScansRemaining: freeScans,
|
||||
));
|
||||
|
||||
if (expiresAt != null) {
|
||||
_startCountdownTimer();
|
||||
}
|
||||
}
|
||||
|
||||
void _startCountdownTimer() {
|
||||
_countdownTimer?.cancel();
|
||||
_countdownTimer = Timer.periodic(const Duration(seconds: 1), (timer) {
|
||||
if (isClosed) {
|
||||
timer.cancel();
|
||||
return;
|
||||
}
|
||||
|
||||
if (!state.isUnlimited) {
|
||||
timer.cancel();
|
||||
emit(state.copyWith(clearUnlimited: true));
|
||||
_prefs.remove(_keyExpiresAt);
|
||||
} else {
|
||||
// Force state update for UI countdown tick
|
||||
emit(state.copyWith());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/// Verifies if a scan can proceed. If yes, consumes one free scan (if not unlimited).
|
||||
/// Returns `true` if allowed, `false` if scan limit reached.
|
||||
bool tryConsumeScan() {
|
||||
if (state.isUnlimited) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (state.freeScansRemaining > 0) {
|
||||
final nextCount = state.freeScansRemaining - 1;
|
||||
emit(state.copyWith(freeScansRemaining: nextCount));
|
||||
_prefs.setInt(_keyFreeScans, nextCount);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/// Grants a block of unlimited scanning (default 15 minutes).
|
||||
Future<void> grantRewardedMinutes([int minutes = 15]) async {
|
||||
final newExpires = DateTime.now().add(Duration(minutes: minutes));
|
||||
await _prefs.setInt(_keyExpiresAt, newExpires.millisecondsSinceEpoch);
|
||||
|
||||
emit(state.copyWith(
|
||||
unlimitedExpiresAt: newExpires,
|
||||
isAdLoading: false,
|
||||
));
|
||||
|
||||
_startCountdownTimer();
|
||||
}
|
||||
|
||||
/// Triggers the Rewarded Ad display and unlocks 15 minutes upon completion.
|
||||
Future<bool> watchAdAndUnlock() async {
|
||||
emit(state.copyWith(isAdLoading: true));
|
||||
|
||||
final success = await _adService.showRewardedAd(
|
||||
onUserEarnedReward: () {
|
||||
grantRewardedMinutes(15);
|
||||
},
|
||||
);
|
||||
|
||||
if (!success) {
|
||||
emit(state.copyWith(isAdLoading: false));
|
||||
}
|
||||
return success;
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> close() {
|
||||
_countdownTimer?.cancel();
|
||||
return super.close();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
import 'package:equatable/equatable.dart';
|
||||
|
||||
class MonetizationState extends Equatable {
|
||||
final DateTime? unlimitedExpiresAt;
|
||||
final int freeScansRemaining;
|
||||
final bool isAdLoading;
|
||||
|
||||
const MonetizationState({
|
||||
this.unlimitedExpiresAt,
|
||||
this.freeScansRemaining = 15, // 15 initial free scans for new users to test immediately
|
||||
this.isAdLoading = false,
|
||||
});
|
||||
|
||||
bool get isUnlimited {
|
||||
final expires = unlimitedExpiresAt;
|
||||
if (expires == null) return false;
|
||||
return expires.isAfter(DateTime.now());
|
||||
}
|
||||
|
||||
bool get canScan => isUnlimited || freeScansRemaining > 0;
|
||||
|
||||
Duration get remainingDuration {
|
||||
final expires = unlimitedExpiresAt;
|
||||
if (expires == null) return Duration.zero;
|
||||
final diff = expires.difference(DateTime.now());
|
||||
return diff.isNegative ? Duration.zero : diff;
|
||||
}
|
||||
|
||||
String get formattedRemainingTime {
|
||||
final rem = remainingDuration;
|
||||
final m = rem.inMinutes;
|
||||
final s = rem.inSeconds % 60;
|
||||
return '${m.toString().padLeft(2, '0')}:${s.toString().padLeft(2, '0')}';
|
||||
}
|
||||
|
||||
MonetizationState copyWith({
|
||||
DateTime? unlimitedExpiresAt,
|
||||
bool clearUnlimited = false,
|
||||
int? freeScansRemaining,
|
||||
bool? isAdLoading,
|
||||
}) {
|
||||
return MonetizationState(
|
||||
unlimitedExpiresAt: clearUnlimited
|
||||
? null
|
||||
: (unlimitedExpiresAt ?? this.unlimitedExpiresAt),
|
||||
freeScansRemaining: freeScansRemaining ?? this.freeScansRemaining,
|
||||
isAdLoading: isAdLoading ?? this.isAdLoading,
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
List<Object?> get props => [
|
||||
unlimitedExpiresAt,
|
||||
freeScansRemaining,
|
||||
isAdLoading,
|
||||
];
|
||||
}
|
||||
|
||||
@@ -0,0 +1,178 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
|
||||
import '../../../../core/theme/app_theme.dart';
|
||||
import '../cubit/monetization_cubit.dart';
|
||||
import '../cubit/monetization_state.dart';
|
||||
|
||||
/// Bottom sheet dialog prompting user to watch a rewarded video for 15 min unlimited scanning.
|
||||
class RewardSessionDialog extends StatelessWidget {
|
||||
const RewardSessionDialog({super.key});
|
||||
|
||||
static Future<bool?> show(BuildContext context) {
|
||||
return showModalBottomSheet<bool>(
|
||||
context: context,
|
||||
backgroundColor: Colors.transparent,
|
||||
isScrollControlled: true,
|
||||
builder: (_) => BlocProvider.value(
|
||||
value: context.read<MonetizationCubit>(),
|
||||
child: const RewardSessionDialog(),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
padding: EdgeInsets.fromLTRB(
|
||||
24,
|
||||
20,
|
||||
24,
|
||||
MediaQuery.paddingOf(context).bottom + 24,
|
||||
),
|
||||
decoration: const BoxDecoration(
|
||||
color: AppTheme.darkCard,
|
||||
borderRadius: BorderRadius.vertical(top: Radius.circular(28)),
|
||||
border: Border(
|
||||
top: BorderSide(color: AppTheme.darkBorder, width: 1.5),
|
||||
),
|
||||
),
|
||||
child: BlocBuilder<MonetizationCubit, MonetizationState>(
|
||||
builder: (context, state) {
|
||||
return Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
// Drag handle
|
||||
Container(
|
||||
width: 40,
|
||||
height: 4,
|
||||
margin: const EdgeInsets.only(bottom: 20),
|
||||
decoration: BoxDecoration(
|
||||
color: AppTheme.darkTextSecondary.withValues(alpha: 0.4),
|
||||
borderRadius: BorderRadius.circular(2),
|
||||
),
|
||||
),
|
||||
|
||||
// Icon badge
|
||||
Container(
|
||||
width: 64,
|
||||
height: 64,
|
||||
decoration: BoxDecoration(
|
||||
color: AppTheme.primary.withValues(alpha: 0.15),
|
||||
shape: BoxShape.circle,
|
||||
border: Border.all(
|
||||
color: AppTheme.primary.withValues(alpha: 0.4),
|
||||
width: 2,
|
||||
),
|
||||
),
|
||||
child: const Icon(
|
||||
Icons.play_circle_fill_rounded,
|
||||
color: AppTheme.primary,
|
||||
size: 34,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
|
||||
const Text(
|
||||
'Scansioni Illimitate',
|
||||
style: TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.bold,
|
||||
letterSpacing: -0.4,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
|
||||
Text(
|
||||
'Guarda un breve video per sbloccare 15 minuti di scansioni illimitate al PC senza interruzioni.',
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
color: AppTheme.darkTextSecondary,
|
||||
fontSize: 14,
|
||||
height: 1.4,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 24),
|
||||
|
||||
// Watch video CTA button
|
||||
SizedBox(
|
||||
width: double.infinity,
|
||||
height: 52,
|
||||
child: FilledButton.icon(
|
||||
onPressed: state.isAdLoading
|
||||
? null
|
||||
: () async {
|
||||
final cubit = context.read<MonetizationCubit>();
|
||||
final success = await cubit.watchAdAndUnlock();
|
||||
if (context.mounted) {
|
||||
if (success) {
|
||||
Navigator.of(context).pop(true);
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
const SnackBar(
|
||||
content: Text(
|
||||
'15 minuti di scansioni illimitate sbloccati!',
|
||||
),
|
||||
duration: Duration(milliseconds: 1600),
|
||||
backgroundColor: AppTheme.success,
|
||||
),
|
||||
);
|
||||
} else {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
const SnackBar(
|
||||
content: Text(
|
||||
'Caricamento video in corso... Riprova tra pochi istanti.',
|
||||
),
|
||||
duration: Duration(milliseconds: 1800),
|
||||
backgroundColor: AppTheme.darkCard,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
},
|
||||
style: FilledButton.styleFrom(
|
||||
backgroundColor: AppTheme.primary,
|
||||
foregroundColor: Colors.white,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
),
|
||||
),
|
||||
icon: state.isAdLoading
|
||||
? const SizedBox(
|
||||
width: 20,
|
||||
height: 20,
|
||||
child: CircularProgressIndicator(
|
||||
strokeWidth: 2,
|
||||
color: Colors.white,
|
||||
),
|
||||
)
|
||||
: const Icon(Icons.ondemand_video_rounded, size: 22),
|
||||
label: Text(
|
||||
state.isAdLoading ? 'Caricamento video...' : 'Guarda Video (+15 min)',
|
||||
style: const TextStyle(
|
||||
fontSize: 15,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
|
||||
// Cancel button
|
||||
TextButton(
|
||||
onPressed: () => Navigator.of(context).pop(false),
|
||||
child: const Text(
|
||||
'Più tardi',
|
||||
style: TextStyle(
|
||||
color: AppTheme.darkTextSecondary,
|
||||
fontSize: 14,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -9,6 +9,9 @@ import '../../../../core/theme/app_theme.dart';
|
||||
import '../../../connection/presentation/cubit/connection_cubit.dart';
|
||||
import '../../../connection/presentation/widgets/connection_status_chip.dart';
|
||||
import '../../../connection/presentation/widgets/server_selection_sheet.dart';
|
||||
import '../../../monetization/presentation/cubit/monetization_cubit.dart';
|
||||
import '../../../monetization/presentation/cubit/monetization_state.dart';
|
||||
import '../../../monetization/presentation/widgets/reward_session_dialog.dart';
|
||||
import '../../../settings/presentation/cubit/settings_cubit.dart';
|
||||
import '../../../settings/presentation/cubit/settings_state.dart';
|
||||
import '../../../settings/presentation/screens/settings_screen.dart';
|
||||
@@ -270,6 +273,7 @@ class _ScannerScreenState extends State<ScannerScreen>
|
||||
(b.center - standardReticle.center).distanceSquared));
|
||||
|
||||
final best = inside.first;
|
||||
if (!_ensureCanScan()) return;
|
||||
context.read<ScannerCubit>().processBarcode(
|
||||
best.code,
|
||||
format: best.format,
|
||||
@@ -282,6 +286,7 @@ class _ScannerScreenState extends State<ScannerScreen>
|
||||
final rawValue = first.rawValue ?? first.displayValue;
|
||||
if (rawValue == null || rawValue.trim().isEmpty) return;
|
||||
final formatName = first.format.name.replaceAll('BarcodeFormat.', '');
|
||||
if (!_ensureCanScan()) return;
|
||||
context.read<ScannerCubit>().processBarcode(rawValue, format: formatName);
|
||||
}
|
||||
|
||||
@@ -304,6 +309,7 @@ class _ScannerScreenState extends State<ScannerScreen>
|
||||
_updateLiveArItems(items, precisionTargetIndex: target?.index);
|
||||
|
||||
if (target != null) {
|
||||
if (!_ensureCanScan()) return;
|
||||
context.read<ScannerCubit>().processBarcode(
|
||||
target.code,
|
||||
format: target.format,
|
||||
@@ -473,7 +479,18 @@ class _ScannerScreenState extends State<ScannerScreen>
|
||||
});
|
||||
}
|
||||
|
||||
bool _ensureCanScan() {
|
||||
final monetization = context.read<MonetizationCubit>();
|
||||
if (!monetization.tryConsumeScan()) {
|
||||
RewardSessionDialog.show(context);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
Future<void> _onTapArBarcode(DetectedBarcodeItem item) async {
|
||||
if (!_ensureCanScan()) return;
|
||||
|
||||
final success = await context.read<ScannerCubit>().sendSelectedBarcode(
|
||||
item.code,
|
||||
format: item.format,
|
||||
@@ -646,7 +663,16 @@ class _ScannerScreenState extends State<ScannerScreen>
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
const Center(child: ConnectionStatusChip()),
|
||||
Wrap(
|
||||
alignment: WrapAlignment.center,
|
||||
crossAxisAlignment: WrapCrossAlignment.center,
|
||||
spacing: 8,
|
||||
runSpacing: 6,
|
||||
children: const [
|
||||
ConnectionStatusChip(),
|
||||
_SessionStatusChip(),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
Row(
|
||||
mainAxisAlignment:
|
||||
@@ -872,3 +898,59 @@ class _CircleGlassButton extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _SessionStatusChip extends StatelessWidget {
|
||||
const _SessionStatusChip();
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return BlocBuilder<MonetizationCubit, MonetizationState>(
|
||||
builder: (context, state) {
|
||||
final isUnlimited = state.isUnlimited;
|
||||
final color = isUnlimited
|
||||
? AppTheme.success
|
||||
: (state.freeScansRemaining > 0 ? AppTheme.primary : AppTheme.warning);
|
||||
final label = isUnlimited
|
||||
? '${state.formattedRemainingTime} Illimitati'
|
||||
: (state.freeScansRemaining > 0
|
||||
? '${state.freeScansRemaining} libere'
|
||||
: 'Sblocca 15 min');
|
||||
|
||||
return Material(
|
||||
color: Colors.transparent,
|
||||
child: InkWell(
|
||||
onTap: () => RewardSessionDialog.show(context),
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
child: Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 5),
|
||||
decoration: BoxDecoration(
|
||||
color: color.withValues(alpha: 0.15),
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
border: Border.all(color: color.withValues(alpha: 0.4), width: 1),
|
||||
),
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Icon(
|
||||
isUnlimited ? Icons.timer_outlined : Icons.ondemand_video_rounded,
|
||||
color: color,
|
||||
size: 14,
|
||||
),
|
||||
const SizedBox(width: 5),
|
||||
Text(
|
||||
label,
|
||||
style: TextStyle(
|
||||
color: color,
|
||||
fontSize: 12,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,7 @@ import 'package:flutter/services.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
|
||||
import 'core/services/ad_service.dart';
|
||||
import 'core/services/feedback_service.dart';
|
||||
import 'core/theme/app_theme.dart';
|
||||
import 'features/connection/data/datasources/connection_local_datasource.dart';
|
||||
@@ -12,6 +13,7 @@ import 'features/connection/data/repositories/connection_repository_impl.dart';
|
||||
import 'features/connection/domain/repositories/connection_repository.dart';
|
||||
import 'features/connection/presentation/cubit/connection_cubit.dart';
|
||||
import 'features/connection/presentation/cubit/discovery_cubit.dart';
|
||||
import 'features/monetization/presentation/cubit/monetization_cubit.dart';
|
||||
import 'features/scanner/data/datasources/scan_history_datasource.dart';
|
||||
import 'features/scanner/data/repositories/scan_repository_impl.dart';
|
||||
import 'features/scanner/domain/repositories/scan_repository.dart';
|
||||
@@ -36,6 +38,7 @@ void main() async {
|
||||
|
||||
// Core services
|
||||
const feedbackService = FeedbackService();
|
||||
final adService = AdService()..initialize();
|
||||
|
||||
// Repositories
|
||||
final SettingsRepository settingsRepository = SettingsRepositoryImpl(
|
||||
@@ -58,6 +61,8 @@ void main() async {
|
||||
connectionRepository: connectionRepository,
|
||||
scanRepository: scanRepository,
|
||||
feedbackService: feedbackService,
|
||||
adService: adService,
|
||||
prefs: prefs,
|
||||
),
|
||||
);
|
||||
}
|
||||
@@ -67,6 +72,8 @@ class BarcodeReaderApp extends StatelessWidget {
|
||||
final ConnectionRepository connectionRepository;
|
||||
final ScanRepository scanRepository;
|
||||
final FeedbackService feedbackService;
|
||||
final AdService adService;
|
||||
final SharedPreferences prefs;
|
||||
|
||||
const BarcodeReaderApp({
|
||||
super.key,
|
||||
@@ -74,12 +81,17 @@ class BarcodeReaderApp extends StatelessWidget {
|
||||
required this.connectionRepository,
|
||||
required this.scanRepository,
|
||||
required this.feedbackService,
|
||||
required this.adService,
|
||||
required this.prefs,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return MultiBlocProvider(
|
||||
providers: [
|
||||
BlocProvider<MonetizationCubit>(
|
||||
create: (_) => MonetizationCubit(prefs: prefs, adService: adService),
|
||||
),
|
||||
BlocProvider<SettingsCubit>(
|
||||
create: (_) => SettingsCubit(settingsRepository)..loadSettings(),
|
||||
),
|
||||
|
||||
@@ -9,10 +9,12 @@ import audioplayers_darwin
|
||||
import device_info_plus
|
||||
import mobile_scanner
|
||||
import shared_preferences_foundation
|
||||
import webview_flutter_wkwebview
|
||||
|
||||
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"))
|
||||
SharedPreferencesPlugin.register(with: registry.registrar(forPlugin: "SharedPreferencesPlugin"))
|
||||
WebViewFlutterPlugin.register(with: registry.registrar(forPlugin: "WebViewFlutterPlugin"))
|
||||
}
|
||||
@@ -232,6 +232,14 @@ packages:
|
||||
description: flutter
|
||||
source: sdk
|
||||
version: "0.0.0"
|
||||
google_mobile_ads:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: google_mobile_ads
|
||||
sha256: "439e018d73b47565d1cf21410e893a8f46d5fb95110c41c266a6fb78449d7106"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "9.2.0"
|
||||
hooks:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -661,6 +669,38 @@ packages:
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "3.0.3"
|
||||
webview_flutter:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: webview_flutter
|
||||
sha256: d53e1ccf5516f25017e3c9d44c39034db352d20fa34fe200674270242c2c5111
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "4.14.1"
|
||||
webview_flutter_android:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: webview_flutter_android
|
||||
sha256: "4de8b3d1ff4ebe1bdb42e68a5e4f809194a3cb0117a8f495f590004f00da3964"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "4.14.1"
|
||||
webview_flutter_platform_interface:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: webview_flutter_platform_interface
|
||||
sha256: "1221c1b12f5278791042f2ec2841743784cf25c5a644e23d6680e5d718824f04"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.15.1"
|
||||
webview_flutter_wkwebview:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: webview_flutter_wkwebview
|
||||
sha256: acac45e0a8d7beb1d0805521f44842f406c46eb5a69410f53d935e3c62138afc
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "3.27.2"
|
||||
win32:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -695,4 +735,4 @@ packages:
|
||||
version: "3.1.4"
|
||||
sdks:
|
||||
dart: ">=3.13.4 <4.0.0"
|
||||
flutter: ">=3.44.0"
|
||||
flutter: ">=3.47.0"
|
||||
@@ -42,6 +42,7 @@ dependencies:
|
||||
equatable: ^3.0.0
|
||||
audioplayers: ^6.8.1
|
||||
vibration: ^3.2.1
|
||||
google_mobile_ads: ^9.2.0
|
||||
|
||||
dev_dependencies:
|
||||
flutter_test:
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
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/features/connection/data/datasources/connection_local_datasource.dart';
|
||||
import 'package:barcode_reader_app/features/connection/data/datasources/connection_remote_datasource.dart';
|
||||
@@ -24,6 +25,7 @@ void main() {
|
||||
);
|
||||
final scanRepo = ScanRepositoryImpl(ScanHistoryDataSource(prefs));
|
||||
const feedbackService = FeedbackService();
|
||||
final adService = AdService();
|
||||
|
||||
await tester.pumpWidget(
|
||||
BarcodeReaderApp(
|
||||
@@ -31,6 +33,8 @@ void main() {
|
||||
connectionRepository: connectionRepo,
|
||||
scanRepository: scanRepo,
|
||||
feedbackService: feedbackService,
|
||||
adService: adService,
|
||||
prefs: prefs,
|
||||
),
|
||||
);
|
||||
|
||||
|
||||