initial work to add enable notifications to onboarding
This commit is contained in:
parent
1353170a7f
commit
fb3365c62d
4 changed files with 129 additions and 3 deletions
|
|
@ -21,6 +21,7 @@ import 'package:fluffychat/pages/device_settings/device_settings.dart';
|
|||
import 'package:fluffychat/pages/login/login.dart';
|
||||
import 'package:fluffychat/pages/new_group/new_group.dart';
|
||||
import 'package:fluffychat/pages/new_private_chat/new_private_chat.dart';
|
||||
import 'package:fluffychat/pages/onboarding/enable_notificatons.dart';
|
||||
import 'package:fluffychat/pages/onboarding/space_code_onboarding.dart';
|
||||
import 'package:fluffychat/pages/settings/settings.dart';
|
||||
import 'package:fluffychat/pages/settings_3pid/settings_3pid.dart';
|
||||
|
|
@ -208,6 +209,14 @@ abstract class AppRoutes {
|
|||
const CreatePangeaAccountPage(),
|
||||
),
|
||||
),
|
||||
GoRoute(
|
||||
path: 'notifications',
|
||||
pageBuilder: (context, state) => defaultPageBuilder(
|
||||
context,
|
||||
state,
|
||||
const EnableNotifications(),
|
||||
),
|
||||
),
|
||||
GoRoute(
|
||||
path: 'course',
|
||||
pageBuilder: (context, state) => defaultPageBuilder(
|
||||
|
|
|
|||
117
lib/pages/onboarding/enable_notificatons.dart
Normal file
117
lib/pages/onboarding/enable_notificatons.dart
Normal file
|
|
@ -0,0 +1,117 @@
|
|||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:matrix/matrix.dart';
|
||||
|
||||
import 'package:fluffychat/l10n/l10n.dart';
|
||||
import 'package:fluffychat/pangea/authentication/p_logout.dart';
|
||||
import 'package:fluffychat/pangea/common/utils/error_handler.dart';
|
||||
import 'package:fluffychat/pangea/login/pages/pangea_login_scaffold.dart';
|
||||
import 'package:fluffychat/widgets/matrix.dart';
|
||||
|
||||
class EnableNotifications extends StatefulWidget {
|
||||
const EnableNotifications({super.key});
|
||||
|
||||
@override
|
||||
EnabledNotificationsController createState() =>
|
||||
EnabledNotificationsController();
|
||||
}
|
||||
|
||||
class EnabledNotificationsController extends State<EnableNotifications> {
|
||||
Profile? profile;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
_setProfile();
|
||||
super.initState();
|
||||
}
|
||||
|
||||
Future<void> _setProfile() async {
|
||||
final client = Matrix.of(context).client;
|
||||
try {
|
||||
profile = await client.getProfileFromUserId(
|
||||
client.userID!,
|
||||
);
|
||||
} catch (e, s) {
|
||||
ErrorHandler.logError(
|
||||
e: e,
|
||||
s: s,
|
||||
data: {
|
||||
'userId': client.userID,
|
||||
},
|
||||
);
|
||||
} finally {
|
||||
if (mounted) setState(() {});
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return PangeaLoginScaffold(
|
||||
customAppBar: AppBar(
|
||||
title: ConstrainedBox(
|
||||
constraints: const BoxConstraints(
|
||||
maxWidth: 450,
|
||||
),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
BackButton(
|
||||
onPressed: () => pLogoutAction(
|
||||
context,
|
||||
bypassWarning: true,
|
||||
),
|
||||
),
|
||||
const SizedBox(
|
||||
width: 40.0,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
automaticallyImplyLeading: false,
|
||||
),
|
||||
showAppName: false,
|
||||
mainAssetUrl: profile?.avatarUrl,
|
||||
children: [
|
||||
Column(
|
||||
spacing: 8.0,
|
||||
children: [
|
||||
Text(
|
||||
L10n.of(context).welcomeUser(
|
||||
profile?.displayName ??
|
||||
Matrix.of(context).client.userID?.localpart ??
|
||||
"",
|
||||
),
|
||||
style: Theme.of(context)
|
||||
.textTheme
|
||||
.titleLarge
|
||||
?.copyWith(fontWeight: FontWeight.bold),
|
||||
),
|
||||
Text(
|
||||
L10n.of(context).enableNotificationsTitle,
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
ElevatedButton(
|
||||
onPressed: null,
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: Theme.of(context).colorScheme.primaryContainer,
|
||||
foregroundColor:
|
||||
Theme.of(context).colorScheme.onPrimaryContainer,
|
||||
),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Text(L10n.of(context).enableNotificationsDesc),
|
||||
],
|
||||
),
|
||||
),
|
||||
TextButton(
|
||||
child: Text(L10n.of(context).skipForNow),
|
||||
onPressed: () => context.go("/registration/course"),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
@ -48,7 +48,7 @@ class PAuthGaurd {
|
|||
// If user hasn't set their L2,
|
||||
// and their URL doesn’t include ‘course,’ redirect
|
||||
final bool hasSetL2 = await pController!.userController.isUserL2Set;
|
||||
return !hasSetL2 ? '/registration/create' : null;
|
||||
return !hasSetL2 ? '/registration' : null;
|
||||
}
|
||||
|
||||
/// Redirect for onboarding routes
|
||||
|
|
|
|||
|
|
@ -154,7 +154,7 @@ class CreatePangeaAccountPageState extends State<CreatePangeaAccountPage> {
|
|||
|
||||
if (l2Set) {
|
||||
if (targetLangCode == null) {
|
||||
context.go('/registration/course');
|
||||
context.go('/registration/notifications');
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -216,7 +216,7 @@ class CreatePangeaAccountPageState extends State<CreatePangeaAccountPage> {
|
|||
context.go(
|
||||
_spaceId != null
|
||||
? '/rooms/spaces/$_spaceId/details'
|
||||
: '/registration/course',
|
||||
: '/registration/notifications',
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue