Skip to content

Commit

Permalink
Add TOS to onboarding (#1516)
Browse files Browse the repository at this point in the history
![image](https://github.com/SharezoneApp/sharezone-app/assets/24459435/ac5ed4b2-9dcf-4a6a-918a-478e194fcece)


Also tested it with teacher account.

---------

Co-authored-by: Jonas Sander <[email protected]>
  • Loading branch information
nilsreichardt and Jonas-Sander authored Apr 23, 2024
1 parent 59f1e5d commit 6468623
Show file tree
Hide file tree
Showing 11 changed files with 123 additions and 109 deletions.
5 changes: 1 addition & 4 deletions app/lib/onboarding/sign_up/pages/advantages.dart
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,7 @@ class _Advantages extends StatelessWidget {
),
),
bottomNavigationBar: const OnboardingNavigationBar(
action: OnboardingNavigationBarContinueButton(
nextPage: _PrivacyPolicy(),
nextTag: _PrivacyPolicy.tag,
),
action: _SignUpButton(),
),
);
}
Expand Down
33 changes: 32 additions & 1 deletion app/lib/onboarding/sign_up/pages/choose_type_of_user.dart
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,14 @@ class ChooseTypeOfUser extends StatelessWidget {
style: Theme.of(context).textTheme.headlineSmall),
const SizedBox(height: 12),
typeOfUserButtons(context),
const SizedBox(height: 12),
const _LegalText(),
if (withLogin) ...[
const Divider(height: 46),
const _LoginButton(
key: K.goToLoginButton,
),
]
],
],
),
),
Expand Down Expand Up @@ -106,6 +108,35 @@ class ChooseTypeOfUser extends StatelessWidget {
}
}

class _LegalText extends StatelessWidget {
const _LegalText();

@override
Widget build(BuildContext context) {
return MaxWidthConstraintBox(
maxWidth: 500,
child: MarkdownBody(
data:
'Mit Nutzung unserer Plattform stimmst du den [ANBs](https://sharezone.net/terms-of-service) zu. Wir verarbeiten deine Daten gemäß unserer [Datenschutzerklärung](https://sharezone.net/privacy-policy).',
onTapLink: (text, href, title) {
if (href == "https://sharezone.net/terms-of-service") {
Navigator.pushNamed(context, TermsOfServicePage.tag);
} else if (href == "https://sharezone.net/privacy-policy") {
Navigator.pushNamed(context, PrivacyPolicyPage.tag);
}
},
styleSheet: MarkdownStyleSheet.fromTheme(Theme.of(context)).copyWith(
a: TextStyle(
color: Theme.of(context).colorScheme.primary,
decoration: TextDecoration.underline,
),
textAlign: WrapAlignment.center,
),
),
);
}
}

class _StudentNew extends StatelessWidget {
const _StudentNew();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,7 @@ class _DataProtectionOverview extends StatelessWidget {
),
),
bottomNavigationBar: const OnboardingNavigationBar(
action: OnboardingNavigationBarContinueButton(
nextPage: _PrivacyPolicy(),
nextTag: _PrivacyPolicy.tag,
),
action: _SignUpButton(),
),
);
}
Expand Down
95 changes: 0 additions & 95 deletions app/lib/onboarding/sign_up/pages/privacy_policy.dart

This file was deleted.

68 changes: 66 additions & 2 deletions app/lib/onboarding/sign_up/sign_up_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,14 @@
import 'package:bloc_provider/bloc_provider.dart';
import 'package:flare_flutter/flare_actor.dart';
import 'package:flutter/material.dart';
import 'package:flutter_markdown/flutter_markdown.dart';
import 'package:flutter_staggered_animations/flutter_staggered_animations.dart';
import 'package:sharezone/auth/login_page.dart';
import 'package:sharezone/keys.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/onboarding/bloc/registration_bloc.dart';
import 'package:sharezone/onboarding/group_onboarding/widgets/bottom_bar_button.dart';
import 'package:sharezone/legal/privacy_policy/privacy_policy_page.dart';
import 'package:sharezone/widgets/animation/color_fade_in.dart';
import 'package:sharezone_common/api_errors.dart';
import 'package:sharezone_widgets/sharezone_widgets.dart';
Expand All @@ -23,7 +25,6 @@ import 'package:user/user.dart';
part 'pages/advantages.dart';
part 'pages/choose_type_of_user.dart';
part 'pages/data_protection_overview.dart';
part 'pages/privacy_policy.dart';

class SignUpPage extends StatefulWidget {
static const tag = 'sign-up-page';
Expand Down Expand Up @@ -192,3 +193,66 @@ class OnboardingNavigationBarContinueButton extends StatelessWidget {
);
}
}

class _SignUpButton extends StatefulWidget {
const _SignUpButton();

@override
_SignUpButtonState createState() => _SignUpButtonState();
}

class _SignUpButtonState extends State<_SignUpButton> {
bool isLoading = false;

@override
Widget build(BuildContext context) {
return TextButton(
style: TextButton.styleFrom(
foregroundColor: Colors.white,
backgroundColor: Theme.of(context).primaryColor,
disabledForegroundColor:
Theme.of(context).primaryColor.withOpacity(0.38),
),
onPressed: isLoading
? null
: () async {
final bloc = BlocProvider.of<RegistrationBloc>(context);
try {
setState(() => isLoading = true);
await bloc.signUp();
if (!context.mounted) return;
Navigator.popUntil(context, ModalRoute.withName('/'));
} catch (e, s) {
setState(() => isLoading = false);
showSnackSec(
text: handleErrorMessage(e.toString(), s),
context: context,
);
}
},
child: Stack(
key: const ValueKey('SubmitButton'),
alignment: Alignment.center,
children: [
Text(
"Weiter".toUpperCase(),
style: TextStyle(
fontSize: 20,
color: isLoading ? Colors.transparent : Colors.white,
),
),
AnimatedSwitcher(
duration: const Duration(milliseconds: 275),
child: isLoading
? const SizedBox(
height: 20,
width: 20,
child: CircularProgressIndicator(color: Colors.white),
)
: Container(),
)
],
),
);
}
}
4 changes: 4 additions & 0 deletions app/test/settings/notifications/notification_test.mocks.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import 'dart:math';
import 'package:analytics/analytics.dart';
import 'package:authentification_base/authentification_analytics.dart';
import 'package:bloc_base/bloc_base.dart';
import 'package:clock/clock.dart';
import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:firebase_auth/firebase_auth.dart';
import 'package:user/user.dart';
Expand Down Expand Up @@ -42,7 +43,10 @@ class RegistrationGateway extends BlocBase {
RegistrationGateway(this.userCollection, this._auth);

void _addUserToFirestore(AppUser user) {
userCollection.doc(user.id).set(user.toEditJson(), SetOptions(merge: true));
final data = user.toEditJson();
data['legal'] = user.legalData;

userCollection.doc(user.id).set(data, SetOptions(merge: true));
}

Future<AppUser> registerUser(TypeOfUser typeOfUser) async {
Expand All @@ -61,6 +65,13 @@ class RegistrationGateway extends BlocBase {
typeOfUser: typeOfUser,
state: StateEnum.notSelected,
referralScore: 0,
legalData: {
'v2_0-legal-accepted': {
"source": "registration",
'deviceTime': clock.now(),
'serverTime': FieldValue.serverTimestamp(),
},
},
);

_addUserToFirestore(user);
Expand Down
2 changes: 1 addition & 1 deletion lib/authentification/authentification_base/pubspec.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions lib/authentification/authentification_base/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ dependencies:
streaming_shared_preferences: ^2.0.0
user:
path: ../../user
clock: ^1.1.1
cloud_firestore: ^4.15.5
firebase_auth: ^4.17.5
google_sign_in: ^6.1.6
Expand Down
4 changes: 3 additions & 1 deletion lib/user/lib/src/models/user.dart
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ class AppUser {
'settings': userSettings.toJson(),
'tips': userTipData.toJson(),
'features': features?.toJson(),
'legal': legalData,
};
}

Expand Down Expand Up @@ -178,6 +179,7 @@ class AppUser {
UserTipData? userTipData,
SharezonePlusStatus? sharezonePlus,
Features? features,
Map<String, dynamic>? legalData,
}) {
return AppUser._(
id: id ?? this.id,
Expand All @@ -199,7 +201,7 @@ class AppUser {
referredBy: referredBy,
features: features ?? this.features,
sharezonePlus: sharezonePlus ?? this.sharezonePlus,
legalData: legalData,
legalData: legalData ?? this.legalData,
);
}
}
Expand Down
2 changes: 2 additions & 0 deletions website/macos/Flutter/GeneratedPluginRegistrant.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@
import FlutterMacOS
import Foundation

import device_info_plus
import firebase_analytics
import firebase_core
import firebase_crashlytics
import url_launcher_macos

func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
DeviceInfoPlusMacosPlugin.register(with: registry.registrar(forPlugin: "DeviceInfoPlusMacosPlugin"))
FLTFirebaseAnalyticsPlugin.register(with: registry.registrar(forPlugin: "FLTFirebaseAnalyticsPlugin"))
FLTFirebaseCorePlugin.register(with: registry.registrar(forPlugin: "FLTFirebaseCorePlugin"))
FLTFirebaseCrashlyticsPlugin.register(with: registry.registrar(forPlugin: "FLTFirebaseCrashlyticsPlugin"))
Expand Down

0 comments on commit 6468623

Please sign in to comment.