support_dev_widget.dart 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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: const EdgeInsets.symmetric(vertical: 12.0, horizontal: 6),
  42. child: Column(
  43. crossAxisAlignment: CrossAxisAlignment.start,
  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. style: const TextStyle(
  61. color: Colors.grey,
  62. ),
  63. ),
  64. ],
  65. ),
  66. ),
  67. );
  68. }
  69. }