Skip to content

Commit

Permalink
Add buying Sharezone Plus for child via Plus Page on website. (#1522)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonas-Sander and nilsreichardt authored Apr 24, 2024
1 parent 99c7e29 commit c1aea0f
Show file tree
Hide file tree
Showing 9 changed files with 403 additions and 82 deletions.
8 changes: 7 additions & 1 deletion app/lib/sharezone_plus/page/sharezone_plus_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,15 @@ import 'package:flutter_markdown/flutter_markdown.dart';
import 'package:platform_check/platform_check.dart';
import 'package:provider/provider.dart';
import 'package:share/share.dart';
import 'package:sharezone/legal/privacy_policy/privacy_policy_page.dart';
import 'package:sharezone/legal/terms_of_service/terms_of_service_page.dart';
import 'package:sharezone/navigation/logic/navigation_bloc.dart';
import 'package:sharezone/navigation/models/navigation_item.dart';
import 'package:sharezone/navigation/scaffold/sharezone_main_scaffold.dart';
import 'package:sharezone/sharezone_plus/page/sharezone_plus_page_controller.dart';
import 'package:sharezone/support/support_page.dart';
import 'package:sharezone_utils/launch_link.dart';
import 'package:sharezone_plus_page_ui/sharezone_plus_page_ui.dart';
import 'package:sharezone_utils/launch_link.dart';
import 'package:sharezone_widgets/sharezone_widgets.dart';
import 'package:user/user.dart';

Expand Down Expand Up @@ -356,6 +358,10 @@ class _PurchaseSection extends StatelessWidget {
onLetParentsBuy: () => onLetParentsBuy(context),
showLetParentsBuyButton: controller.showLetParentsBuyButton,
isLetParentsBuyButtonLoading: controller.isLetParentsBuyButtonLoading,
onPressedPrivacyPolicy: () =>
Navigator.pushNamed(context, PrivacyPolicyPage.tag),
onPressedTermsOfService: () =>
Navigator.pushNamed(context, TermsOfServicePage.tag),
onPurchase: () async {
final controller = context.read<SharezonePlusPageController>();

Expand Down
57 changes: 45 additions & 12 deletions lib/sharezone_plus/sharezone_plus_page_ui/lib/src/buy_section.dart
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,14 @@ class BuySection extends StatelessWidget {
required this.onPurchase,
required this.currentPeriod,
required this.onPeriodChanged,
required this.onPressedTermsOfService,
required this.onPressedPrivacyPolicy,
this.isPriceLoading = false,
this.isPurchaseButtonLoading = false,
this.onLetParentsBuy,
this.showLetParentsBuyButton = false,
this.isLetParentsBuyButtonLoading = false,
this.bottom,
});

final bool isPriceLoading;
Expand All @@ -50,6 +53,9 @@ class BuySection extends StatelessWidget {
final bool isLetParentsBuyButtonLoading;
final PurchasePeriod currentPeriod;
final ValueChanged<PurchasePeriod> onPeriodChanged;
final Widget? bottom;
final VoidCallback? onPressedTermsOfService;
final VoidCallback? onPressedPrivacyPolicy;

@override
Widget build(BuildContext context) {
Expand Down Expand Up @@ -114,7 +120,10 @@ class BuySection extends StatelessWidget {
period: currentPeriod,
monthlyPrice: monthlyPrice,
lifetimePrice: lifetimePrice,
onPressedTermsOfService: onPressedTermsOfService,
onPressedPrivacyPolicy: onPressedPrivacyPolicy,
),
if (bottom != null) bottom!,
],
),
);
Expand Down Expand Up @@ -247,18 +256,29 @@ class _LegalText extends StatelessWidget {
required this.period,
required this.monthlyPrice,
required this.lifetimePrice,
required this.onPressedTermsOfService,
required this.onPressedPrivacyPolicy,
});

final PurchasePeriod period;
final String? monthlyPrice;
final String? lifetimePrice;
final VoidCallback? onPressedTermsOfService;
final VoidCallback? onPressedPrivacyPolicy;

@override
Widget build(BuildContext context) {
return switch (period) {
PurchasePeriod.monthly =>
_MonthlySubscriptionLegalText(price: monthlyPrice),
PurchasePeriod.lifetime => _LifetimeLegalText(price: lifetimePrice),
PurchasePeriod.monthly => _MonthlySubscriptionLegalText(
price: monthlyPrice,
onPressedTermsOfService: onPressedTermsOfService,
onPressedPrivacyPolicy: onPressedPrivacyPolicy,
),
PurchasePeriod.lifetime => _LifetimeLegalText(
price: lifetimePrice,
onPressedTermsOfService: onPressedTermsOfService,
onPressedPrivacyPolicy: onPressedPrivacyPolicy,
),
};
}
}
Expand All @@ -269,40 +289,53 @@ const _termsOfServiceSentence =
class _LifetimeLegalText extends StatelessWidget {
const _LifetimeLegalText({
required this.price,
required this.onPressedTermsOfService,
required this.onPressedPrivacyPolicy,
});

final String? price;
final VoidCallback? onPressedTermsOfService;
final VoidCallback? onPressedPrivacyPolicy;

@override
Widget build(BuildContext context) {
final price = this.price ?? '...';
return StyledMarkdownText(
text:
'Einmalige Zahlung von $price (kein Abo o. ä.). $_termsOfServiceSentence',
onPressedPrivacyPolicy: onPressedPrivacyPolicy,
onPressedTermsOfService: onPressedTermsOfService,
);
}
}

class _MonthlySubscriptionLegalText extends StatelessWidget {
const _MonthlySubscriptionLegalText({
required this.price,
required this.onPressedTermsOfService,
required this.onPressedPrivacyPolicy,
});

final String? price;
final VoidCallback? onPressedTermsOfService;
final VoidCallback? onPressedPrivacyPolicy;

@override
Widget build(BuildContext context) {
final currentPlatform = PlatformCheck.currentPlatform;
final price = this.price ?? '...';
return StyledMarkdownText(
text: switch (currentPlatform) {
Platform.android =>
'Dein Abo ($price/Monat) ist monatlich kündbar. Es wird automatisch verlängert, wenn du es nicht mindestens 24 Stunden vor Ablauf der aktuellen Zahlungsperiode über Google Play kündigst. $_termsOfServiceSentence',
Platform.iOS ||
Platform.macOS =>
'Dein Abo ($price/Monat) ist monatlich kündbar. Es wird automatisch verlängert, wenn du es nicht mindestens 24 Stunden vor Ablauf der aktuellen Zahlungsperiode über den App Store kündigst. $_termsOfServiceSentence',
_ =>
'Dein Abo ($price/Monat) ist monatlich kündbar. Es wird automatisch verlängert, wenn du es nicht vor Ablauf der aktuellen Zahlungsperiode über die App kündigst. $_termsOfServiceSentence',
});
text: switch (currentPlatform) {
Platform.android =>
'Dein Abo ($price/Monat) ist monatlich kündbar. Es wird automatisch verlängert, wenn du es nicht mindestens 24 Stunden vor Ablauf der aktuellen Zahlungsperiode über Google Play kündigst. $_termsOfServiceSentence',
Platform.iOS ||
Platform.macOS =>
'Dein Abo ($price/Monat) ist monatlich kündbar. Es wird automatisch verlängert, wenn du es nicht mindestens 24 Stunden vor Ablauf der aktuellen Zahlungsperiode über den App Store kündigst. $_termsOfServiceSentence',
_ =>
'Dein Abo ($price/Monat) ist monatlich kündbar. Es wird automatisch verlängert, wenn du es nicht vor Ablauf der aktuellen Zahlungsperiode über die App kündigst. $_termsOfServiceSentence',
},
onPressedPrivacyPolicy: onPressedPrivacyPolicy,
onPressedTermsOfService: onPressedTermsOfService,
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,14 @@ class StyledMarkdownText extends StatelessWidget {
super.key,
required this.text,
this.alignment = WrapAlignment.center,
this.onPressedTermsOfService,
this.onPressedPrivacyPolicy,
});

final String text;
final WrapAlignment alignment;
final VoidCallback? onPressedTermsOfService;
final VoidCallback? onPressedPrivacyPolicy;

@override
Widget build(BuildContext context) {
Expand All @@ -34,13 +38,15 @@ class StyledMarkdownText extends StatelessWidget {
onTapLink: (text, href, title) async {
if (href == null) return;

if (href == 'https://sharezone.net/terms-of-service') {
Navigator.pushNamed(context, 'terms-of-service');
if (href == 'https://sharezone.net/terms-of-service' &&
onPressedTermsOfService != null) {
onPressedTermsOfService!();
return;
}

if (href == 'https://sharezone.net/privacy-policy') {
Navigator.pushNamed(context, 'privacy-policy');
if (href == 'https://sharezone.net/privacy-policy' &&
onPressedPrivacyPolicy != null) {
onPressedPrivacyPolicy!();
return;
}

Expand Down
2 changes: 0 additions & 2 deletions website/lib/home/src/all_in_one_platform.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import 'package:sharezone_website/widgets/row_spacing.dart';
import 'package:sharezone_website/widgets/section.dart';
import 'package:sharezone_widgets/sharezone_widgets.dart' hide Headline;

import '../../main.dart';
import '../home_page.dart';

class AllInOnePlace extends StatefulWidget {
Expand Down Expand Up @@ -216,7 +215,6 @@ class __FeatureCardState extends State<_FeatureCard> {
child: DefaultTextStyle(
style: TextStyle(
color: Colors.grey[600],
fontFamily: SharezoneStyle.font,
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
Expand Down
2 changes: 0 additions & 2 deletions website/lib/home/src/welcome.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import 'package:flutter_staggered_animations/flutter_staggered_animations.dart';
import 'package:flutter_svg/svg.dart';
import 'package:sharezone_website/widgets/section.dart';

import '../../main.dart';
import '../home_page.dart';

class Welcome extends StatelessWidget {
Expand Down Expand Up @@ -47,7 +46,6 @@ class Welcome extends StatelessWidget {
fontSize: isTablet(context) ? 64 : 85,
fontWeight: FontWeight.w700,
color: Colors.black87,
fontFamily: SharezoneStyle.font,
),
textAlign: TextAlign.center,
),
Expand Down
35 changes: 14 additions & 21 deletions website/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,13 @@ import 'package:sharezone_widgets/sharezone_widgets.dart';

import 'home/home_page.dart';
import 'legal/imprint_page.dart';
import 'sharezone_plus/success_page.dart';

void main() {
usePathUrlStrategy();
runApp(const MyApp());
}

class SharezoneStyle {
static const primaryColor = Color(0xFF68B3E9);
static const font = 'Rubik';
}

/// The route configuration.
final GoRouter _router = GoRouter(
routes: <RouteBase>[
Expand Down Expand Up @@ -61,11 +57,18 @@ final GoRouter _router = GoRouter(
},
),
GoRoute(
path: SharezonePlusPage.tag,
builder: (BuildContext context, GoRouterState state) {
return const SharezonePlusPage();
},
),
path: SharezonePlusPage.tag,
builder: (BuildContext context, GoRouterState state) {
return const SharezonePlusPage();
},
routes: [
GoRoute(
path: 'success',
builder: (BuildContext context, GoRouterState state) {
return const PlusSuccessPage();
},
),
]),
],
),
],
Expand All @@ -81,17 +84,7 @@ class MyApp extends StatelessWidget {
child: MaterialApp.router(
routerConfig: _router,
title: 'Sharezone - Vernetzter Schulplaner',
theme: ThemeData(
useMaterial3: false,
primaryColor: SharezoneStyle.primaryColor,
fontFamily: SharezoneStyle.font,
scaffoldBackgroundColor: Colors.white,
pageTransitionsTheme: const PageTransitionsTheme(
builders: {
TargetPlatform.macOS: FadeTransiationsBuilder(),
},
),
),
theme: getLightTheme(),
),
);
}
Expand Down
Loading

0 comments on commit c1aea0f

Please sign in to comment.