skip_subscription_widget.dart 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. import 'package:flutter/material.dart';
  2. import 'package:photos/core/event_bus.dart';
  3. import 'package:photos/events/subscription_purchased_event.dart';
  4. import 'package:photos/models/billing_plan.dart';
  5. import 'package:photos/models/subscription.dart';
  6. import 'package:photos/services/billing_service.dart';
  7. import 'package:photos/ui/home_widget.dart';
  8. class SkipSubscriptionWidget extends StatelessWidget {
  9. const SkipSubscriptionWidget({
  10. Key key,
  11. @required this.freePlan,
  12. }) : super(key: key);
  13. final FreePlan freePlan;
  14. @override
  15. Widget build(BuildContext context) {
  16. return Container(
  17. width: double.infinity,
  18. height: 64,
  19. margin: const EdgeInsets.fromLTRB(0, 30, 0, 0),
  20. padding: const EdgeInsets.fromLTRB(20, 0, 20, 0),
  21. child: OutlinedButton(
  22. style: Theme.of(context).outlinedButtonTheme.style.copyWith(
  23. textStyle: MaterialStateProperty.resolveWith<TextStyle>(
  24. (Set<MaterialState> states) {
  25. return Theme.of(context).textTheme.subtitle1;
  26. },
  27. ),
  28. ),
  29. onPressed: () async {
  30. Bus.instance.fire(SubscriptionPurchasedEvent());
  31. Navigator.of(context).pushAndRemoveUntil(
  32. MaterialPageRoute(
  33. builder: (BuildContext context) {
  34. return const HomeWidget();
  35. },
  36. ),
  37. (route) => false,
  38. );
  39. BillingService.instance
  40. .verifySubscription(kFreeProductID, "", paymentProvider: "ente");
  41. },
  42. child: const Text("Continue on free plan"),
  43. ),
  44. );
  45. }
  46. }