diff --git a/lib/l10n/arb/app_en.arb b/lib/l10n/arb/app_en.arb index eb58fbec5..d58027c50 100644 --- a/lib/l10n/arb/app_en.arb +++ b/lib/l10n/arb/app_en.arb @@ -55,6 +55,8 @@ "incorrectPassword": "Incorrect password", "welcomeBackTitle": "Welcome back!", "madeWithLoveAtPrefix": "made with ❤️ at ", + "supportDevs" : "Subscribe to ente Photos to support this project.", + "supportDiscount" : "Use coupon code \"AUTH\" to get 10% off first year", "changeEmail": "change email", "ok": "OK", "cancel": "Cancel", diff --git a/lib/theme/colors.dart b/lib/theme/colors.dart index d00ac7d4b..b7de982f0 100644 --- a/lib/theme/colors.dart +++ b/lib/theme/colors.dart @@ -28,6 +28,7 @@ class EnteColorScheme { final Color strokeFaint; // Fixed Colors + final Color primaryGreen; final Color primary700; final Color primary500; final Color primary400; @@ -53,6 +54,7 @@ class EnteColorScheme { this.strokeBase, this.strokeMuted, this.strokeFaint, { + this.primaryGreen = _primaryGreen, this.primary700 = _primary700, this.primary500 = _primary500, this.primary400 = _primary400, @@ -143,6 +145,8 @@ const Color strokeFaintDark = Color.fromRGBO(255, 255, 255, 0.16); // Fixed Colors +const Color _primaryGreen = Color.fromRGBO(29, 185, 84, 1); + const Color _primary700 = Color.fromARGB(255, 164, 0, 182); const Color _primary500 = Color.fromARGB(255, 204, 10, 101); const Color _primary400 = Color.fromARGB(255, 122, 41, 193); diff --git a/lib/ui/settings/support_dev_widget.dart b/lib/ui/settings/support_dev_widget.dart new file mode 100644 index 000000000..695323a48 --- /dev/null +++ b/lib/ui/settings/support_dev_widget.dart @@ -0,0 +1,68 @@ +import 'dart:io'; + +import 'package:ente_auth/l10n/l10n.dart'; +import 'package:ente_auth/models/subscription.dart'; +// ignore: import_of_legacy_library_into_null_safe +import 'package:ente_auth/services/billing_service.dart'; +import 'package:ente_auth/theme/ente_theme.dart'; +import 'package:flutter/material.dart'; +import 'package:styled_text/styled_text.dart'; +import 'package:url_launcher/url_launcher.dart'; + +class SupportDevWidget extends StatelessWidget { + const SupportDevWidget({ + Key? key, + }) : super(key: key); + + @override + Widget build(BuildContext context) { + final l10n = context.l10n; + + // fetch + return FutureBuilder( + future: BillingService.instance.fetchSubscription(), + builder: (context, snapshot) { + if (snapshot.hasData) { + final subscription = snapshot.data; + if (subscription != null && subscription.productID != "free") { + return GestureDetector( + onTap: () { + launchUrl(Uri.parse("https://ente.io")); + }, + child: Padding( + padding: + const EdgeInsets.symmetric(vertical: 12.0, horizontal: 6), + child: Column( + children: [ + StyledText( + text: l10n.supportDevs, + tags: { + 'bold-green': StyledTextTag( + style: TextStyle( + fontWeight: FontWeight.bold, + color: getEnteColorScheme(context).primaryGreen, + ), + ), + }, + ), + const Padding(padding: EdgeInsets.all(6)), + Platform.isAndroid + ? Text( + l10n.supportDiscount, + textAlign: TextAlign.center, + style: const TextStyle( + color: Colors.grey, + ), + ) + : const SizedBox.shrink(), + ], + ), + ), + ); + } + } + return const SizedBox.shrink(); + }, + ); + } +} diff --git a/lib/ui/settings_page.dart b/lib/ui/settings_page.dart index 22e4a472d..c7a983534 100644 --- a/lib/ui/settings_page.dart +++ b/lib/ui/settings_page.dart @@ -9,9 +9,9 @@ import 'package:ente_auth/ui/settings/account_section_widget.dart'; import 'package:ente_auth/ui/settings/app_version_widget.dart'; import 'package:ente_auth/ui/settings/danger_section_widget.dart'; import 'package:ente_auth/ui/settings/data_section_widget.dart'; -import 'package:ente_auth/ui/settings/made_with_love_widget.dart'; import 'package:ente_auth/ui/settings/security_section_widget.dart'; import 'package:ente_auth/ui/settings/social_section_widget.dart'; +import 'package:ente_auth/ui/settings/support_dev_widget.dart'; import 'package:ente_auth/ui/settings/support_section_widget.dart'; import 'package:ente_auth/ui/settings/theme_switch_widget.dart'; import 'package:ente_auth/ui/settings/title_bar_widget.dart'; @@ -84,7 +84,7 @@ class SettingsPage extends StatelessWidget { sectionSpacing, const DangerSectionWidget(), const AppVersionWidget(), - const MadeWithLoveWidget(), + const SupportDevWidget(), const Padding( padding: EdgeInsets.only(bottom: 60), ), diff --git a/pubspec.lock b/pubspec.lock index d04628008..a76bd08a9 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -1307,6 +1307,14 @@ packages: url: "https://pub.dev" source: hosted version: "1.2.0" + styled_text: + dependency: "direct main" + description: + name: styled_text + sha256: f72928d1ebe8cb149e3b34a689cb1ddca696b808187cf40ac3a0bd183dff379c + url: "https://pub.dev" + source: hosted + version: "7.0.0" synchronized: dependency: transitive description: @@ -1515,6 +1523,14 @@ packages: url: "https://pub.dev" source: hosted version: "6.1.0" + xmlstream: + dependency: transitive + description: + name: xmlstream + sha256: "2d10c69a9d5fc46f71798b80ee6db15bc0d5bf560fdbdd264776cbeee0c83631" + url: "https://pub.dev" + source: hosted + version: "1.0.0" yaml: dependency: transitive description: @@ -1525,4 +1541,4 @@ packages: version: "3.1.1" sdks: dart: ">=2.18.0 <3.0.0" - flutter: ">=3.3.0" + flutter: ">=3.7.0" diff --git a/pubspec.yaml b/pubspec.yaml index 5757f656d..90a8e5944 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -62,6 +62,7 @@ dependencies: shared_preferences: ^2.0.5 sqflite: ^2.1.0 step_progress_indicator: ^1.0.2 + styled_text: ^7.0.0 url_launcher: ^6.1.5 uuid: ^3.0.4