Application propre sans erreurs. Bonne base sur laquelle repartir de zero en cas de soucis majeurs.

This commit is contained in:
DahoudG
2024-08-26 22:45:58 +00:00
parent bcf714ab73
commit eb8368b1ee
24 changed files with 397 additions and 201 deletions

View File

@@ -0,0 +1,18 @@
import 'package:flutter/material.dart';
class EventScreen extends StatelessWidget {
const EventScreen({super.key});
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('Événements'),
),
body: const Center(
child: Text('Liste des événements'),
),
);
}
}

View File

@@ -0,0 +1,17 @@
import 'package:flutter/material.dart';
class HomeScreen extends StatelessWidget {
const HomeScreen({super.key});
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('AfterWork'),
),
body: const Center(
child: Text('Bienvenue sur AfterWork!'),
),
);
}
}

View File

@@ -0,0 +1,43 @@
import 'package:afterwork/domain/entities/user.dart';
import 'package:afterwork/domain/usecases/get_user.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
class UserBloc extends Bloc<UserEvent, UserState> {
final GetUser getUser;
UserBloc({required this.getUser}) : super(UserInitial());
Stream<UserState> mapEventToState(UserEvent event) async* {
if (event is GetUserById) {
yield UserLoading();
final either = await getUser(event.id);
yield either.fold(
(failure) => UserError(),
(user) => UserLoaded(user: user),
);
}
}
}
abstract class UserEvent {}
class GetUserById extends UserEvent {
final String id;
GetUserById(this.id);
}
abstract class UserState {}
class UserInitial extends UserState {}
class UserLoading extends UserState {}
class UserLoaded extends UserState {
final User user;
UserLoaded({required this.user});
}
class UserError extends UserState {}

View File

@@ -0,0 +1,17 @@
import 'package:flutter/material.dart';
class CustomButton extends StatelessWidget {
final String text;
final VoidCallback onPressed;
const CustomButton({super.key, required this.text, required this.onPressed});
@override
Widget build(BuildContext context) {
return ElevatedButton(
onPressed: onPressed,
child: Text(text),
);
}
}