63 lines
1.6 KiB
Dart
63 lines
1.6 KiB
Dart
import 'package:flutter/material.dart';
|
|
|
|
import 'bootstrap.dart';
|
|
import 'models/app_user.dart';
|
|
import 'screens/home_screen.dart';
|
|
import 'screens/landing_screen.dart';
|
|
import 'services/auth_service.dart';
|
|
import 'theme/app_theme.dart';
|
|
import 'widgets/profile_session.dart';
|
|
|
|
Future<void> main() async {
|
|
WidgetsFlutterBinding.ensureInitialized();
|
|
await bootstrap();
|
|
runApp(const CyberHybridHubApp());
|
|
}
|
|
|
|
class CyberHybridHubApp extends StatelessWidget {
|
|
const CyberHybridHubApp({super.key});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return MaterialApp(
|
|
title: 'Cyber Hybrid Hub',
|
|
theme: buildAppTheme(),
|
|
home: const AuthGate(),
|
|
);
|
|
}
|
|
}
|
|
|
|
class AuthGate extends StatelessWidget {
|
|
const AuthGate({super.key});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return StreamBuilder<AppUser?>(
|
|
stream: AuthService.instance.authStateChanges,
|
|
builder: (BuildContext context, AsyncSnapshot<AppUser?> snapshot) {
|
|
if (snapshot.connectionState == ConnectionState.waiting) {
|
|
return const Scaffold(
|
|
body: Center(
|
|
child: CircularProgressIndicator(color: AppColors.accent),
|
|
),
|
|
);
|
|
}
|
|
|
|
final AppUser? user = snapshot.data;
|
|
if (user == null) {
|
|
return const LandingScreen();
|
|
}
|
|
|
|
return ProfileSession(
|
|
user: user,
|
|
builder: (context, profile, syncStatus) => HomeScreen(
|
|
user: user,
|
|
profile: profile,
|
|
syncStatus: syncStatus,
|
|
),
|
|
);
|
|
},
|
|
);
|
|
}
|
|
}
|