40 lines
1.5 KiB
Dart
40 lines
1.5 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:provider/provider.dart';
|
|
|
|
import '../services/app_state.dart';
|
|
|
|
/// Shown right after a user watches the app's one ad placement (see
|
|
/// [AdService.showGateAd] / [AppState.syncNow]) — not on every sync, only
|
|
/// the moment an ad was actually just shown to them, since that's when the
|
|
/// "you could skip these" pitch is most relevant. Purely informational: it
|
|
/// doesn't block or delay the sync that triggered it, which is already
|
|
/// proceeding underneath it by the time this appears.
|
|
Future<void> showAdFreeUpsellDialog(BuildContext context) {
|
|
return showDialog<void>(
|
|
context: context,
|
|
builder: (context) => AlertDialog(
|
|
title: const Text('Tired of Ads?'),
|
|
content: Consumer<AppState>(
|
|
builder: (context, appState, _) => Text(
|
|
appState.adFreeYearPriceLabel == null
|
|
? "You can remove ads for a full year with a single one-time purchase."
|
|
: 'You can remove ads for a full year for '
|
|
'${appState.adFreeYearPriceLabel} — a single one-time purchase.',
|
|
),
|
|
),
|
|
actions: [
|
|
TextButton(
|
|
onPressed: () => Navigator.of(context).pop(),
|
|
child: const Text('Not Now'),
|
|
),
|
|
FilledButton(
|
|
onPressed: () {
|
|
Navigator.of(context).pop();
|
|
context.read<AppState>().buyAdFreeYear();
|
|
},
|
|
child: const Text('Remove Ads'),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|