From 2cfddace9a40c3e8e30a1cf059f6e466d79549ad Mon Sep 17 00:00:00 2001 From: otsmr Date: Sat, 12 Jul 2025 15:44:19 +0200 Subject: [PATCH] showing testing account --- lib/src/localization/app_de.arb | 5 +- lib/src/localization/app_en.arb | 5 +- .../generated/app_localizations.dart | 18 ++++++ .../generated/app_localizations_de.dart | 11 ++++ .../generated/app_localizations_en.dart | 11 ++++ lib/src/model/json/userdata.dart | 3 + lib/src/model/json/userdata.g.dart | 3 + .../subscription/select_payment.view.dart | 14 +++++ .../subscription/subscription.view.dart | 55 +++++++++++++++++++ 9 files changed, 123 insertions(+), 2 deletions(-) diff --git a/lib/src/localization/app_de.arb b/lib/src/localization/app_de.arb index 1e05221..4d30728 100644 --- a/lib/src/localization/app_de.arb +++ b/lib/src/localization/app_de.arb @@ -328,5 +328,8 @@ "appOutdated": "Deine Version von twonly ist veraltet.", "appOutdatedBtn": "Jetzt aktualisieren.", "doubleClickToReopen": "Doppelklicken zum\nerneuten Öffnen.", - "retransmissionRequested": "Wird erneut versucht." + "retransmissionRequested": "Wird erneut versucht.", + "testPaymentMethode": "twonly befindet sich derzeit in einer Testphase und kann nur mit einem Einladungscode vollständig genutzt werden. Es gibt derzeit keine Zahlungsmethode, um Ihr twonly-Guthaben aufzuladen!", + "testingAccountTitle": "Tester-Zugang", + "testingAccountBody": "Danke für dein Interesse! Wir werden deine Anfrage prüfen und den Plan so schnell wie möglich aktivieren. Da wir uns jedoch noch in einer Testphase befinden, ist die Anzahl der Tester-Konten begrenzt. Wir werden dich jedoch benachrichtigen, sobald dir ein Platz zugewiesen wurde." } \ No newline at end of file diff --git a/lib/src/localization/app_en.arb b/lib/src/localization/app_en.arb index c38fe9f..fd2e44e 100644 --- a/lib/src/localization/app_en.arb +++ b/lib/src/localization/app_en.arb @@ -485,5 +485,8 @@ "appOutdated": "Your version of twonly is out of date.", "appOutdatedBtn": "Update Now", "doubleClickToReopen": "Double-click\nto open again", - "retransmissionRequested": "Retransmission requested" + "retransmissionRequested": "Retransmission requested", + "testPaymentMethode": "twonly is currently in a test phase and can only be used in full with an invitation code. There is currently no payment method to top up your twonly credit!", + "testingAccountTitle": "Tester account activation", + "testingAccountBody": "Thank you for your interest! We will check your request and activate the plan as soon as possible. However, as we are currently still in a test phase, the number of tester accounts is limited. However, we will notify you as soon as you have been allocated a place." } \ No newline at end of file diff --git a/lib/src/localization/generated/app_localizations.dart b/lib/src/localization/generated/app_localizations.dart index f3979ea..7719bdf 100644 --- a/lib/src/localization/generated/app_localizations.dart +++ b/lib/src/localization/generated/app_localizations.dart @@ -2011,6 +2011,24 @@ abstract class AppLocalizations { /// In en, this message translates to: /// **'Retransmission requested'** String get retransmissionRequested; + + /// No description provided for @testPaymentMethode. + /// + /// In en, this message translates to: + /// **'twonly is currently in a test phase and can only be used in full with an invitation code. There is currently no payment method to top up your twonly credit!'** + String get testPaymentMethode; + + /// No description provided for @testingAccountTitle. + /// + /// In en, this message translates to: + /// **'Tester account activation'** + String get testingAccountTitle; + + /// No description provided for @testingAccountBody. + /// + /// In en, this message translates to: + /// **'Thank you for your interest! We will check your request and activate the plan as soon as possible. However, as we are currently still in a test phase, the number of tester accounts is limited. However, we will notify you as soon as you have been allocated a place.'** + String get testingAccountBody; } class _AppLocalizationsDelegate diff --git a/lib/src/localization/generated/app_localizations_de.dart b/lib/src/localization/generated/app_localizations_de.dart index 20dbcbd..777c39d 100644 --- a/lib/src/localization/generated/app_localizations_de.dart +++ b/lib/src/localization/generated/app_localizations_de.dart @@ -1066,4 +1066,15 @@ class AppLocalizationsDe extends AppLocalizations { @override String get retransmissionRequested => 'Wird erneut versucht.'; + + @override + String get testPaymentMethode => + 'twonly befindet sich derzeit in einer Testphase und kann nur mit einem Einladungscode vollständig genutzt werden. Es gibt derzeit keine Zahlungsmethode, um Ihr twonly-Guthaben aufzuladen!'; + + @override + String get testingAccountTitle => 'Tester-Zugang'; + + @override + String get testingAccountBody => + 'Danke für dein Interesse! Wir werden deine Anfrage prüfen und den Plan so schnell wie möglich aktivieren. Da wir uns jedoch noch in einer Testphase befinden, ist die Anzahl der Tester-Konten begrenzt. Wir werden dich jedoch benachrichtigen, sobald dir ein Platz zugewiesen wurde.'; } diff --git a/lib/src/localization/generated/app_localizations_en.dart b/lib/src/localization/generated/app_localizations_en.dart index d4d4d06..382dfc3 100644 --- a/lib/src/localization/generated/app_localizations_en.dart +++ b/lib/src/localization/generated/app_localizations_en.dart @@ -1060,4 +1060,15 @@ class AppLocalizationsEn extends AppLocalizations { @override String get retransmissionRequested => 'Retransmission requested'; + + @override + String get testPaymentMethode => + 'twonly is currently in a test phase and can only be used in full with an invitation code. There is currently no payment method to top up your twonly credit!'; + + @override + String get testingAccountTitle => 'Tester account activation'; + + @override + String get testingAccountBody => + 'Thank you for your interest! We will check your request and activate the plan as soon as possible. However, as we are currently still in a test phase, the number of tester accounts is limited. However, we will notify you as soon as you have been allocated a place.'; } diff --git a/lib/src/model/json/userdata.dart b/lib/src/model/json/userdata.dart index c222ac1..3f9b2d5 100644 --- a/lib/src/model/json/userdata.dart +++ b/lib/src/model/json/userdata.dart @@ -65,6 +65,9 @@ class UserData { DateTime? signalLastSignedPreKeyUpdated; + @JsonKey(defaultValue: false) + bool requestedTesterAccount = false; + // -- Custom DATA -- @JsonKey(defaultValue: 100_000) diff --git a/lib/src/model/json/userdata.g.dart b/lib/src/model/json/userdata.g.dart index 8a8cad7..817f4ef 100644 --- a/lib/src/model/json/userdata.g.dart +++ b/lib/src/model/json/userdata.g.dart @@ -49,6 +49,8 @@ UserData _$UserDataFromJson(Map json) => UserData( json['signalLastSignedPreKeyUpdated'] == null ? null : DateTime.parse(json['signalLastSignedPreKeyUpdated'] as String) + ..requestedTesterAccount = + json['requestedTesterAccount'] as bool? ?? false ..currentPreKeyIndexStart = (json['currentPreKeyIndexStart'] as num?)?.toInt() ?? 100000 ..currentSignedPreKeyIndexStart = @@ -89,6 +91,7 @@ Map _$UserDataToJson(UserData instance) => { 'myBestFriendContactId': instance.myBestFriendContactId, 'signalLastSignedPreKeyUpdated': instance.signalLastSignedPreKeyUpdated?.toIso8601String(), + 'requestedTesterAccount': instance.requestedTesterAccount, 'currentPreKeyIndexStart': instance.currentPreKeyIndexStart, 'currentSignedPreKeyIndexStart': instance.currentSignedPreKeyIndexStart, 'nextTimeToShowBackupNotice': diff --git a/lib/src/views/settings/subscription/select_payment.view.dart b/lib/src/views/settings/subscription/select_payment.view.dart index e7c6f8d..96686df 100644 --- a/lib/src/views/settings/subscription/select_payment.view.dart +++ b/lib/src/views/settings/subscription/select_payment.view.dart @@ -86,6 +86,20 @@ class _SelectPaymentViewState extends State { child: Column( crossAxisAlignment: CrossAxisAlignment.stretch, children: [ + Padding( + padding: EdgeInsets.all(16), + child: Container( + decoration: BoxDecoration( + color: Colors.red, + borderRadius: BorderRadius.circular(16), + ), + padding: EdgeInsets.all(16), + child: Text( + context.lang.testPaymentMethode, + textAlign: TextAlign.center, + ), + ), + ), Expanded( child: ListView( children: [ diff --git a/lib/src/views/settings/subscription/subscription.view.dart b/lib/src/views/settings/subscription/subscription.view.dart index 18bb2f4..316dcda 100644 --- a/lib/src/views/settings/subscription/subscription.view.dart +++ b/lib/src/views/settings/subscription/subscription.view.dart @@ -1,6 +1,7 @@ import 'package:collection/collection.dart'; import 'package:flutter/material.dart'; import 'package:font_awesome_flutter/font_awesome_flutter.dart'; +import 'package:http/http.dart' as http; import 'package:intl/intl.dart'; import 'package:provider/provider.dart'; import 'package:twonly/globals.dart'; @@ -12,6 +13,7 @@ import 'package:twonly/src/providers/connection.provider.dart'; import 'package:twonly/src/utils/log.dart'; import 'package:twonly/src/utils/misc.dart'; import 'package:twonly/src/utils/storage.dart'; +import 'package:twonly/src/views/components/alert_dialog.dart'; import 'package:twonly/src/views/components/better_list_title.dart'; import 'package:twonly/src/views/settings/subscription/additional_users.view.dart'; import 'package:twonly/src/views/settings/subscription/checkout.view.dart'; @@ -105,6 +107,7 @@ class SubscriptionView extends StatefulWidget { class _SubscriptionViewState extends State { bool loaded = false; + bool testerRequested = true; Response_PlanBallance? ballance; String? additionalOwnerName; @@ -127,9 +130,47 @@ class _SubscriptionViewState extends State { additionalOwnerName = ownerId.toString(); } } + final user = await getUser(); + if (user != null) { + testerRequested = user.requestedTesterAccount; + // if (kDebugMode) { + // testerRequested = false; + // } + } setState(() {}); } + Future _submitTesterRequest() async { + final user = await getUser(); + if (user == null) return; + final response = await http.post( + Uri.parse('https://twonly.theconnectapp.de/subscribe.twonly.php'), + headers: { + 'Content-Type': 'application/x-www-form-urlencoded', + }, + body: { + 'feedback': "[TESTER REQUEST] ${user.username} ${user.userId}", + }, + ); + if (!mounted) return; + if (response.statusCode == 200) { + // Handle successful response + ScaffoldMessenger.of(context).showSnackBar( + SnackBar(content: Text("Your request has been submitted.")), + ); + await updateUserdata((u) { + u.requestedTesterAccount = true; + return u; + }); + initAsync(); + } else { + // Handle error response + ScaffoldMessenger.of(context).showSnackBar( + SnackBar(content: Text('Failed to submit your request.')), + ); + } + } + @override Widget build(BuildContext context) { Locale myLocale = Localizations.localeOf(context); @@ -222,6 +263,20 @@ class _SubscriptionViewState extends State { ), ), ), + if (currentPlan != "Tester" && !testerRequested) + PlanCard( + planId: "Tester", + onTap: () async { + bool activate = await showAlertDialog( + context, + context.lang.testingAccountTitle, + context.lang.testingAccountBody, + ); + if (activate) { + _submitTesterRequest(); + } + }, + ), if (currentPlan != "Family" && currentPlan != "Pro") PlanCard( planId: "Pro",