support_dev_widget.dart 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. import 'dart:io';
  2. import 'package:ente_auth/core/configuration.dart';
  3. import 'package:ente_auth/l10n/l10n.dart';
  4. import 'package:ente_auth/models/subscription.dart';
  5. import 'package:ente_auth/services/billing_service.dart';
  6. import 'package:ente_auth/theme/ente_theme.dart';
  7. import 'package:flutter/material.dart';
  8. import 'package:styled_text/styled_text.dart';
  9. import 'package:url_launcher/url_launcher.dart';
  10. class SupportDevWidget extends StatelessWidget {
  11. const SupportDevWidget({
  12. Key? key,
  13. }) : super(key: key);
  14. @override
  15. Widget build(BuildContext context) {
  16. final l10n = context.l10n;
  17. // fetch
  18. if (Configuration.instance.hasConfiguredAccount()) {
  19. return FutureBuilder<Subscription>(
  20. future: BillingService.instance.getSubscription(),
  21. builder: (context, snapshot) {
  22. if (snapshot.hasData) {
  23. final subscription = snapshot.data;
  24. if (subscription != null && subscription.productID == "free") {
  25. return buildWidget(l10n, context);
  26. }
  27. }
  28. return const SizedBox.shrink();
  29. },
  30. );
  31. } else {
  32. return buildWidget(l10n, context);
  33. }
  34. }
  35. GestureDetector buildWidget(AppLocalizations l10n, BuildContext context) {
  36. return GestureDetector(
  37. onTap: () {
  38. launchUrl(Uri.parse("https://ente.io"));
  39. },
  40. child: Padding(
  41. padding:
  42. const EdgeInsets.symmetric(vertical: 12.0, horizontal: 6),
  43. child: Column(
  44. children: [
  45. StyledText(
  46. text: l10n.supportDevs,
  47. style: getEnteTextTheme(context).large,
  48. tags: {
  49. 'bold-green': StyledTextTag(
  50. style: TextStyle(
  51. fontWeight: FontWeight.bold,
  52. color: getEnteColorScheme(context).primaryGreen,
  53. ),
  54. ),
  55. },
  56. ),
  57. const Padding(padding: EdgeInsets.all(6)),
  58. Text(
  59. l10n.supportDiscount,
  60. textAlign: TextAlign.center,
  61. style: const TextStyle(
  62. color: Colors.grey,
  63. ),
  64. )
  65. ],
  66. ),
  67. ),
  68. );
  69. }
  70. }