ente/mobile/lib/ui/payment/skip_subscription_widget.dart

56 lines
1.7 KiB
Dart
Raw Normal View History

2023-12-21 07:34:06 +00:00
import "dart:async";
import 'package:flutter/material.dart';
import 'package:photos/core/event_bus.dart';
import 'package:photos/events/subscription_purchased_event.dart';
import "package:photos/generated/l10n.dart";
import 'package:photos/models/billing_plan.dart';
import 'package:photos/models/subscription.dart';
import 'package:photos/services/billing_service.dart';
2023-06-06 09:57:17 +00:00
import "package:photos/ui/tabs/home_widget.dart";
class SkipSubscriptionWidget extends StatelessWidget {
const SkipSubscriptionWidget({
2022-12-27 12:23:25 +00:00
Key? key,
required this.freePlan,
}) : super(key: key);
final FreePlan freePlan;
@override
Widget build(BuildContext context) {
return Container(
width: double.infinity,
height: 64,
margin: const EdgeInsets.fromLTRB(0, 30, 0, 0),
padding: const EdgeInsets.fromLTRB(20, 0, 20, 0),
2022-05-30 02:30:51 +00:00
child: OutlinedButton(
2022-12-27 12:23:25 +00:00
style: Theme.of(context).outlinedButtonTheme.style?.copyWith(
2022-05-30 02:30:51 +00:00
textStyle: MaterialStateProperty.resolveWith<TextStyle>(
(Set<MaterialState> states) {
2023-06-13 06:41:31 +00:00
return Theme.of(context).textTheme.titleMedium!;
2022-05-30 02:30:51 +00:00
},
),
),
onPressed: () async {
Bus.instance.fire(SubscriptionPurchasedEvent());
2023-12-21 07:34:06 +00:00
// ignore: unawaited_futures
Navigator.of(context).pushAndRemoveUntil(
MaterialPageRoute(
builder: (BuildContext context) {
2022-07-04 06:02:17 +00:00
return const HomeWidget();
},
),
(route) => false,
);
2023-12-21 07:34:06 +00:00
unawaited(
BillingService.instance
.verifySubscription(freeProductID, "", paymentProvider: "ente"),
);
},
child: Text(S.of(context).continueOnFreeTrial),
),
);
}
}