Skip to content

Commit

Permalink
implement loading in app prices from store instead of hardcoding them
Browse files Browse the repository at this point in the history
  • Loading branch information
NeXTormer committed Mar 5, 2024
1 parent 80a3ed5 commit 6a26f7d
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 17 deletions.
8 changes: 4 additions & 4 deletions assets/translations/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -244,13 +244,13 @@
"list_item_1": "Plane deine Workouts",
"list_item_2": "Verfolge deinen Fortschritt",
"list_item_3": "Bleibe motiviert",
"discount_description": "Wenn du die App noch während der Testzeit kaufst, bekommst du einen €{} Rabatt!",
"purchase_button_discount": "In der Testphase kaufen ({})",
"purchase_button_normal": "Nach der Testphase kaufen ({})",
"discount_description": "Wenn du die App noch während der Testzeit kaufst, bekommst du einen Rabatt!",
"purchase_button_discount": "In der Testphase kaufen ({})",
"purchase_button_normal": "Nach der Testphase kaufen ({})",
"help_text": "Wenn du noch Fragen bezüglich des Kaufprozesses hast, schreib mir gerne eine E-Mail: [email protected]",
"purchase_pending_text": "Zahlung erfolgt...\nBitte lass die App offen, bis die Zahlung bestätigt ist.",
"day_free_trial_text": "{} Tage Testversion",
"trial_description": "Du kannst die App {} Tage lang gratis verwenden. Damit hast du genügend Zeit um alle Features zu testen.\n\nWenn du die App noch während der Testzeit kaufst, bekommst du einen €2 Rabatt!",
"trial_description": "Du kannst die App {} Tage lang gratis verwenden. Damit hast du genügend Zeit um alle Features zu testen.\n\nWenn du die App noch während der Testzeit kaufst, bekommst du einen kleinen Rabatt!",
"start_trial_button": "Starte die Testphase",
"trial_over_dialog": {
"buy": "Kaufen",
Expand Down
8 changes: 4 additions & 4 deletions assets/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -244,13 +244,13 @@
"list_item_1": "Plan your workouts",
"list_item_2": "See your progress",
"list_item_3": "Stay motivated",
"discount_description": "If you purchase within the trial period you get a €{} discount!",
"purchase_button_discount": "Purchase during trial for {}",
"purchase_button_normal": "Purchase after trial for {}",
"discount_description": "If you purchase within the trial period you get a discount!",
"purchase_button_discount": "Purchase during trial for {}",
"purchase_button_normal": "Purchase after trial for {}",
"help_text": "If you have any questions regarding the purchase process feel free to contact me at [email protected].",
"purchase_pending_text": "Purchase is pending, please keep the app open until the purchase is completed.",
"day_free_trial_text": "{} day free trial",
"trial_description": "You get a generous {} day free trial, so you have enough time to test and use all features.\n\nIf you purchase the app within the trial period you get a €2 discount!",
"trial_description": "You get a generous {} day free trial, so you have enough time to test and use all features.\n\nIf you purchase the app within the trial period you get a small discount!",
"start_trial_button": "Start your free trial",
"trial_over_dialog": {
"buy": "Buy",
Expand Down
5 changes: 5 additions & 0 deletions lib/backend/purchases/purchase_manager.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ class PurchaseManager {
ProductDetails? purchaseAppProduct;
ProductDetails? purchaseAppDiscountedProduct;

String normalPrice = '';
String discountPrince = '';

bool isAvailable = false;

PurchaseManager(this._userManager) {
Expand All @@ -45,10 +48,12 @@ class PurchaseManager {
for (var product in products) {
if (product.id == PURCHASE_APP_KEY) {
purchaseAppProduct = product;
normalPrice = product.price;
continue;
}
if (product.id == PURCHASE_APP_DISCOUNTED_KEY) {
purchaseAppDiscountedProduct = product;
discountPrince = product.price;
continue;
}
}
Expand Down
17 changes: 8 additions & 9 deletions lib/screens/purchase_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,6 @@ import 'package:frederic/widgets/standard_elements/frederic_scaffold.dart';
class PurchaseScreen extends StatelessWidget {
const PurchaseScreen({Key? key}) : super(key: key);

final String normalPrice = "13,99";
final String discountPrice = '11,99';
final String discount = "2";

@override
Widget build(BuildContext context) {
return FredericScaffold(
Expand Down Expand Up @@ -86,7 +82,7 @@ class PurchaseScreen extends StatelessWidget {
const SizedBox(height: 30),
const SizedBox(height: 30),
Text(
tr('trial.discount_description', args: [discount]),
tr('trial.discount_description'),
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 12,
Expand All @@ -96,8 +92,10 @@ class PurchaseScreen extends StatelessWidget {
),
const SizedBox(height: 18),
FredericButton(
tr('trial.purchase_button_discount',
args: [discountPrice]),
tr('trial.purchase_button_discount', args: [
FredericBackend
.instance.purchaseManager.discountPrince
]),
loading: user.hasActiveTrial &&
(user.tempPurchaseIsPending ?? false),
mainColor: user.hasActiveTrial
Expand All @@ -109,8 +107,9 @@ class PurchaseScreen extends StatelessWidget {
}),
const SizedBox(height: 18),
FredericButton(
tr('trial.purchase_button_normal',
args: [normalPrice]),
tr('trial.purchase_button_normal', args: [
FredericBackend.instance.purchaseManager.normalPrice
]),
loading: (!user.hasActiveTrial) &&
(user.tempPurchaseIsPending ?? false),
mainColor: user.hasActiveTrial
Expand Down

0 comments on commit 6a26f7d

Please sign in to comment.