Skip to content

Commit

Permalink
Add payments popup if not connected (#1882)
Browse files Browse the repository at this point in the history
  • Loading branch information
beastoin authored Feb 28, 2025
2 parents 83e92ae + b8377d4 commit a6c1eff
Showing 1 changed file with 85 additions and 4 deletions.
89 changes: 85 additions & 4 deletions app/lib/pages/apps/add_app.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:cached_network_image/cached_network_image.dart';
import 'package:friend_private/utils/other/debouncer.dart';
import 'package:friend_private/pages/payments/payment_method_provider.dart';
import 'package:friend_private/pages/payments/payments_page.dart';
import 'package:shimmer/shimmer.dart';
import 'package:friend_private/backend/preferences.dart';
import 'package:friend_private/pages/apps/widgets/full_screen_image_viewer.dart';
Expand Down Expand Up @@ -30,7 +32,6 @@ class AddAppPage extends StatefulWidget {

class _AddAppPageState extends State<AddAppPage> {
late bool showSubmitAppConfirmation;
final _debouncer = Debouncer(delay: const Duration(milliseconds: 500));

@override
void initState() {
Expand Down Expand Up @@ -481,9 +482,89 @@ class _AddAppPageState extends State<AddAppPage> {
if (appId != null) {
app = await context.read<AppProvider>().getAppFromId(appId);
}
var paymentProvider = context.read<PaymentMethodProvider>();
paymentProvider.getPaymentMethodsStatus();

if (app != null && mounted && context.mounted) {
Navigator.pop(context);
routeToPage(context, AppDetailPage(app: app));
if (app.isPaid && paymentProvider.activeMethod == null) {
showCupertinoModalPopup(
context: context,
builder: (ctx) => Container(
padding: const EdgeInsets.all(20),
decoration: BoxDecoration(
color: Colors.grey.shade900,
borderRadius: const BorderRadius.vertical(
top: Radius.circular(20),
),
),
child: Material(
color: Colors.transparent,
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Container(
width: 40,
height: 4,
margin: const EdgeInsets.only(bottom: 20),
decoration: BoxDecoration(
color: Colors.grey.shade700,
borderRadius: BorderRadius.circular(2),
),
),
const SizedBox(height: 20),
const Text(
'Start Earning! 💰',
style: TextStyle(
color: Colors.white,
fontSize: 24,
fontWeight: FontWeight.bold,
),
),
const SizedBox(height: 12),
const Text(
'Connect Stripe or PayPal to receive payments for your app.',
textAlign: TextAlign.center,
style: TextStyle(
color: Colors.grey,
fontSize: 16,
),
),
const SizedBox(height: 32),
CupertinoButton(
color: Colors.white,
borderRadius: BorderRadius.circular(12),
onPressed: () {
Navigator.pop(ctx);
routeToPage(context, const PaymentsPage());
},
child: const Text(
'Connect Now',
style: TextStyle(
color: Colors.black,
fontWeight: FontWeight.w600,
),
),
),
const SizedBox(height: 8),
CupertinoButton(
onPressed: () => Navigator.pop(ctx),
child: Text(
'Maybe Later',
style: TextStyle(
color: Colors.grey.shade400,
),
),
),
SizedBox(height: MediaQuery.of(context).padding.bottom),
],
),
),
),
);
} else {
Navigator.pop(context);
routeToPage(context, AppDetailPage(app: app));
}
}
},
onCancel: () {
Expand Down

0 comments on commit a6c1eff

Please sign in to comment.