Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/create classes selection page #23

Merged
merged 10 commits into from
Mar 13, 2024
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
2 changes: 2 additions & 0 deletions frontend/app_student/assets/images/microsoft-teams.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
25 changes: 14 additions & 11 deletions frontend/app_student/lib/class_groups/views/class_group_view.dart
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
import 'package:app_student/api/class_groups/repositories/class_group_repository.dart';
import 'package:app_student/class_groups/cubit/class_group_cubit.dart';
import 'package:app_student/class_groups/views/widgets/card_list.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';

import 'package:app_student/class_groups/views/widgets/header/header_logo.dart';
import 'package:app_student/class_groups/views/widgets/header/header_text.dart';
import 'package:app_student/class_groups/views/widgets/header/header_title.dart';

class ClassListPage extends StatelessWidget {
const ClassListPage({super.key});

Expand All @@ -15,22 +20,20 @@ class ClassListPage extends StatelessWidget {
return BlocProvider<ClassGroupCubit>(
create: (context) => classCubit..fetchClasses(),
child: Scaffold(
appBar: AppBar(
title: const Text('Class List'),
),
body: BlocBuilder<ClassGroupCubit, ClassGroupState>(
builder: (context, state) {
if (state is ClassGroupLoading) {
return const Center(child: CircularProgressIndicator());
} else if (state is ClassGroupLoaded) {
return ListView.builder(
itemCount: state.classes.length,
itemBuilder: (context, index) {
return ListTile(
title: Text(state.classes[index].name),
subtitle: Text(state.classes[index].file),
);
},
return Column(
children: [
const HeaderLogo(),
const HeaderTitle('Bonjour, ####'),
const HeaderText('Dans quelle classe êtes-vous ?'),
Expanded(
child: CardList(classesList: state.classes),
),
],
);
} else if (state is ClassGroupError) {
return Center(child: Text(state.message));
Expand Down
25 changes: 25 additions & 0 deletions frontend/app_student/lib/class_groups/views/widgets/card_list.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import 'package:app_student/api/class_groups/models/class_group_model.dart';
import 'package:flutter/material.dart';

class CardList extends StatelessWidget {
final List<ClassGroupModel> classesList;

const CardList({super.key, required this.classesList});

@override
Widget build(BuildContext context) {
return ListView.builder(
itemCount: classesList.length,
itemBuilder: (context, index) {
return Card(
margin: const EdgeInsets.all(8.0),
child: ListTile(
title: Text(
classesList[index].name,
),
),
);
},
);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import 'package:flutter/material.dart';

class HeaderLogo extends StatelessWidget {
const HeaderLogo({super.key});

@override
Widget build(BuildContext context) {
return Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Image.asset(
'assets/images/3il-logo.jpg',
fit: BoxFit.contain,
height: 32,
),
],
);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import 'package:flutter/cupertino.dart';

class HeaderText extends StatelessWidget {
final String content;

const HeaderText(this.content, {super.key});

@override
Widget build(BuildContext context) {
return Padding(
padding: const EdgeInsets.only(
top: 5.0,
left: 25.0,
bottom: 10), // Ajout d'un espacement à gauche de 10px
child: Align(
alignment: Alignment.centerLeft,
child: Text(
content,
style: const TextStyle(
fontSize: 18.0,
fontFamily: 'Arial',
fontWeight: FontWeight.bold,
),
),
),
);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import 'package:flutter/cupertino.dart';

class HeaderTitle extends StatelessWidget {
final String content;

const HeaderTitle(this.content, {super.key});

@override
Widget build(BuildContext context) {
return Padding(
padding: const EdgeInsets.only(
top: 20.0,
left: 25.0,
bottom: 10), // Ajout un espacement à gauche de 10px
child: Align(
alignment: Alignment.centerLeft,
child: Text(
content,
style: const TextStyle(
fontSize: 34.0,
fontFamily: 'Arial',
fontWeight: FontWeight.bold,
),
),
),
);
}
}
47 changes: 47 additions & 0 deletions frontend/app_student/lib/main_test.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import 'package:app_student/api/week_schedule/repositories/week_schedule_repository.dart';
import 'package:app_student/config/dev_config.dart';
import 'package:app_student/week_schedule/views/week_schedule.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:provider/provider.dart';

import 'api/api_service.dart';
import 'api/class_groups/repositories/class_group_repository.dart';
import 'config/config.dart';

void main() {
final ClassGroupRepository classGroupRepository = ClassGroupRepository(
apiService: ApiService(apiUrl: DevConfig().apiUrl),
);

runApp(
MultiProvider(
providers: [
Provider<Config>(
create: (_) => DevConfig(),
),
RepositoryProvider<ClassGroupRepository>(
create: (context) => classGroupRepository,
),
],
child: const MyApp(),
),
);
}

class MyApp extends StatelessWidget {
const MyApp({super.key});

@override
Widget build(BuildContext context) {
return Provider<Config>(
create: (_) => DevConfig(),
child: RepositoryProvider<WeekScheduleRepository>(
create: (context) => WeekScheduleRepository(
apiService: ApiService(apiUrl: context.read<Config>().apiUrl),
className: 'B3 Groupe 3 DLW-FA'),
child: const MaterialApp(home: WeekSchedulePage()),
),
);
}
}
17 changes: 10 additions & 7 deletions frontend/app_student/lib/week_schedule/views/week_schedule.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import 'package:app_student/api/week_schedule/repositories/week_schedule_repository.dart';
import 'package:app_student/week_schedule/cubit/week_schedule_cubit.dart';
import 'package:app_student/week_schedule/views/widgets/week_schedule_widget.dart';
import 'package:app_student/week_schedule/views/widgets/day_schedule_widget.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';

Expand All @@ -26,12 +26,15 @@ class WeekSchedulePage extends StatelessWidget {
if (state is WeekScheduleLoading) {
return const Center(child: CircularProgressIndicator());
} else if (state is WeekScheduleLoaded) {
return ListView.builder(
itemCount: state.weekSchedule.length,
itemBuilder: (context, index) {
final weekSchedule = state.weekSchedule[index];
return WeekScheduleWidget(weekSchedule: weekSchedule);
},
return Expanded(
child: PageView.builder(
itemCount: state.weekSchedule[0].daySchedules.length,
itemBuilder: (context, index) {
final daySchedule =
state.weekSchedule[0].daySchedules[index];
return DayScheduleWidget(daySchedule: daySchedule);
},
),
);
} else if (state is WeekScheduleError) {
return Center(child: Text(state.message));
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// import 'package:flutter/material.dart';
// import 'courses_details.dart';
// import 'courses_time.dart';
//
// class CourseCard extends StatelessWidget {
// final Map<String, dynamic> course;
//
// const CourseCard({super.key, required this.course});
//
// @override
// Widget build(BuildContext context) {
// return Center(
// child: Row(
// children: <Widget>[
// CourseTime(course: course),
// CourseDetails(course: course),
// ],
// ),
// );
// }
// }
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import 'package:flutter/material.dart';
import 'package:flutter_svg/svg.dart';

class CourseCours extends StatelessWidget {
final Map<String, dynamic> course;

const CourseCours({super.key, required this.course});

@override
Widget build(BuildContext context) {
return Row(
children: <Widget>[
Text(course['cours']),
const Expanded(child: SizedBox.shrink()),
SvgPicture.asset(
'assets/images/microsoft-teams.svg',
width: 30,
height: 30,
),
],
);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import 'package:app_student/api/events/entities/event_entity.dart';
import 'package:flutter/material.dart';

class CourseDetails extends StatelessWidget {
final EventEntity event;

const CourseDetails({super.key, required this.event});

@override
Widget build(BuildContext context) {
const borderColor = Color(0xFF005067);
const cardColor = Color.fromARGB(255, 144, 205, 255);

return Card(
color: cardColor,
child: Container(
decoration: const BoxDecoration(
border: Border(
left: BorderSide(
color: borderColor,
width: 10.0,
),
),
),
width: 300,
height: 120,
child: Padding(
padding: const EdgeInsets.only(left: 20.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
const SizedBox(height: 45.0),
Text('Cours: ${event.activite}'),
const SizedBox(height: 10.0),
Text('Salle: ${event.salle}'),
],
),
),
),
);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import 'package:flutter/material.dart';

class CourseTime extends StatelessWidget {
final Map<String, dynamic> course;

const CourseTime({super.key, required this.course});

@override
Widget build(BuildContext context) {
return Padding(
padding: const EdgeInsets.symmetric(horizontal: 20.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Text(course['horaire-debut']),
Text(course['horaire-fin']),
],
),
);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import 'package:flutter/material.dart';

class DatePickerButton extends StatelessWidget {
const DatePickerButton({super.key});

@override
Widget build(BuildContext context) {
return IconButton(
icon: const Icon(Icons.calendar_today),
onPressed: () async {
final date = await showDatePicker(
context: context,
initialDate: DateTime.now(),
firstDate: DateTime(2000),
lastDate: DateTime(2100),
);
if (date != null) {
// Utilisez la date sélectionnée
}
},
);
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'package:app_student/api/day_schedule/models/day_schedule_model.dart';
import 'package:app_student/week_schedule/views/widgets/card/courses_details.dart';
import 'package:flutter/material.dart';

class DayScheduleWidget extends StatelessWidget {
Expand All @@ -8,14 +9,9 @@ class DayScheduleWidget extends StatelessWidget {

@override
Widget build(BuildContext context) {
return ExpansionTile(
title: Text('Date: ${daySchedule.date}'),
return Column(
children: daySchedule.events.map((event) {
return ListTile(
title: Text('Event: ${event.activite}'),
subtitle: Text(
'Start at: ${event.horaires.startAt}, End Time: ${event.horaires.endAt}'),
);
return CourseDetails(event: event);
}).toList(),
);
}
Expand Down
Loading
Loading