2021-08-17 09:40:05 +00:00
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:photos/core/event_bus.dart';
|
|
|
|
import 'package:photos/events/subscription_purchased_event.dart';
|
2023-04-06 07:15:22 +00:00
|
|
|
import "package:photos/generated/l10n.dart";
|
2021-08-17 09:40:05 +00:00
|
|
|
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";
|
2021-08-17 09:40:05 +00:00
|
|
|
|
|
|
|
class SkipSubscriptionWidget extends StatelessWidget {
|
|
|
|
const SkipSubscriptionWidget({
|
2022-12-27 12:23:25 +00:00
|
|
|
Key? key,
|
|
|
|
required this.freePlan,
|
2021-08-17 09:40:05 +00:00
|
|
|
}) : super(key: key);
|
|
|
|
|
|
|
|
final FreePlan freePlan;
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return Container(
|
|
|
|
width: double.infinity,
|
|
|
|
height: 64,
|
2022-06-03 07:21:53 +00:00
|
|
|
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) {
|
2022-12-27 12:23:25 +00:00
|
|
|
return Theme.of(context).textTheme.subtitle1!;
|
2022-05-30 02:30:51 +00:00
|
|
|
},
|
|
|
|
),
|
|
|
|
),
|
2021-08-17 09:40:05 +00:00
|
|
|
onPressed: () async {
|
|
|
|
Bus.instance.fire(SubscriptionPurchasedEvent());
|
2022-06-28 07:47:36 +00:00
|
|
|
Navigator.of(context).pushAndRemoveUntil(
|
|
|
|
MaterialPageRoute(
|
|
|
|
builder: (BuildContext context) {
|
2022-07-04 06:02:17 +00:00
|
|
|
return const HomeWidget();
|
2022-06-28 07:47:36 +00:00
|
|
|
},
|
|
|
|
),
|
|
|
|
(route) => false,
|
|
|
|
);
|
2021-08-17 09:40:05 +00:00
|
|
|
BillingService.instance
|
2022-09-19 05:11:02 +00:00
|
|
|
.verifySubscription(freeProductID, "", paymentProvider: "ente");
|
2021-08-17 09:40:05 +00:00
|
|
|
},
|
2023-04-06 07:15:22 +00:00
|
|
|
child: Text(S.of(context).continueOnFreeTrial),
|
2021-08-17 09:40:05 +00:00
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|