65 lines
2.4 KiB
Dart
65 lines
2.4 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
|
import 'package:prosappco/blocs/my_user_bloc/my_user_bloc.dart';
|
|
import 'package:prosappco/blocs/sing_in_bloc/sign_in_bloc.dart';
|
|
import 'package:prosappco/blocs/update_user_info_bloc/update_user_info_bloc.dart';
|
|
import 'package:prosappco/screens/authentication/welcome_screen.dart';
|
|
import 'package:prosappco/screens/home/home_screen.dart';
|
|
import 'package:prosappco/screens/profile/profile_screen.dart';
|
|
|
|
import 'blocs/authentication_bloc/authentication_bloc.dart';
|
|
|
|
class MyAppView extends StatelessWidget {
|
|
const MyAppView({super.key});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return MaterialApp(
|
|
debugShowCheckedModeBanner: false,
|
|
title: 'Prosappco',
|
|
theme: ThemeData(
|
|
colorScheme: const ColorScheme.light(
|
|
background: Colors.white,
|
|
onBackground: Colors.black,
|
|
primary: Color.fromRGBO(66, 164, 239, 1),
|
|
onPrimary: Colors.black,
|
|
secondary: Color.fromRGBO(35, 108, 244, 1),
|
|
onSecondary: Colors.white,
|
|
tertiary: Color.fromRGBO(255, 204, 128, 1),
|
|
error: Colors.red,
|
|
outline: Color(0xFF424242)),
|
|
),
|
|
home: BlocBuilder<AuthenticationBloc, AuthenticationState>(
|
|
builder: (context, state) {
|
|
if (state.status == AuthenticationStatus.authenticated) {
|
|
return MultiBlocProvider(
|
|
providers: [
|
|
BlocProvider(
|
|
create: (context) => SignInBloc(
|
|
userRepository:
|
|
context.read<AuthenticationBloc>().userRepository),
|
|
),
|
|
BlocProvider(
|
|
create: (context) => UpdateUserInfoBloc(
|
|
userRepository:
|
|
context.read<AuthenticationBloc>().userRepository),
|
|
),
|
|
BlocProvider(
|
|
create: (context) => MyUserBloc(
|
|
myUserRepository:
|
|
context.read<AuthenticationBloc>().userRepository)
|
|
..add(GetMyUser(
|
|
myUserId:
|
|
context.read<AuthenticationBloc>().state.user!.uid)),
|
|
),
|
|
],
|
|
child: const HomeScreen(),
|
|
);
|
|
} else {
|
|
return const WelcomeScreen();
|
|
}
|
|
}),
|
|
);
|
|
}
|
|
}
|