Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions sample_app/lib/app/content/auth_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ class AuthController extends ValueNotifier<AuthState> {
PushTokenManager? _pushTokenManager;

Future<void> connect(UserCredentials credentials) async {
value = const Authenticating();

final token = UserToken(credentials.token);

final client = StreamFeedsClient(
Expand Down Expand Up @@ -83,3 +85,7 @@ final class Authenticated extends AuthState {
final class Unauthenticated extends AuthState {
const Unauthenticated();
}

final class Authenticating extends AuthState {
const Authenticating();
}
6 changes: 6 additions & 0 deletions sample_app/lib/navigation/app_router.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import 'package:stream_feeds/stream_feeds.dart';
import '../screens/choose_user/choose_user_screen.dart';
import '../screens/home/home_screen.dart';
import '../screens/user_feed/user_feed_screen.dart';
import '../widgets/app_splash.dart';
import '../widgets/attachment_gallery/attachment_gallery.dart';
import '../widgets/attachment_gallery/attachment_metadata.dart';
import 'guards/auth_guard.dart';
Expand Down Expand Up @@ -45,6 +46,11 @@ class AppRouter extends RootStackRouter {
page: ChooseUserRoute.page,
keepHistory: false,
),
AutoRoute(
path: '/loading',
page: AppSplashRoute.page,
keepHistory: false,
),
AutoRoute(
path: '/attachment_gallery',
page: AttachmentGalleryRoute.page,
Expand Down
16 changes: 16 additions & 0 deletions sample_app/lib/navigation/app_router.gr.dart

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

6 changes: 6 additions & 0 deletions sample_app/lib/navigation/guards/auth_guard.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@ class AuthGuard extends AutoRouteGuard {
final isAuthenticated = _authController.value is Authenticated;
// If the user is authenticated, allow navigation to the requested route.
if (isAuthenticated) return resolver.next();

// If the user is being authenticated, show the splash screen.
if (_authController.value is Authenticating) {
resolver.redirectUntil(const AppSplashRoute(), replace: true);
}

// Otherwise, redirect to the Choose user page.
resolver.redirectUntil(const ChooseUserRoute(), replace: true);
}
Expand Down
2 changes: 2 additions & 0 deletions sample_app/lib/widgets/app_splash.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'package:auto_route/auto_route.dart';
import 'package:flutter/material.dart';
import 'package:flutter_svg/flutter_svg.dart';

Expand All @@ -7,6 +8,7 @@ import '../theme/theme.dart';
///
/// Displays only the app logo in a clean, minimal style while the app initializes.
/// Follows true minimalistic principles with perfect simplicity.
@RoutePage(name: 'AppSplashRoute')
class AppSplash extends StatelessWidget {
const AppSplash({super.key});

Expand Down
Loading