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 3 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
12 changes: 6 additions & 6 deletions .idea/libraries/Dart_Packages.xml

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

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.
2 changes: 0 additions & 2 deletions frontend/app_student/lib/classes/bloc/class_bloc.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ import 'dart:async';
import 'package:app_student/api/classes/entities/class.dart';
import 'package:app_student/api/classes/repositories/class_repository.dart';



class ClassBloc {
final ClassRepository classRepository;
final _classController = StreamController<List<Class>>();
Expand Down
52 changes: 27 additions & 25 deletions frontend/app_student/lib/classes/views/class.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import 'package:app_student/api/classes/entities/class.dart';
import 'package:app_student/classes/widgets/custom_card.dart';
import 'package:flutter/material.dart';
import 'package:app_student/classes/bloc/class_bloc.dart';

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

class ClassListPage extends StatefulWidget {
final ClassBloc classBloc;
Expand All @@ -24,30 +27,29 @@ class ClassListPageState extends State<ClassListPage> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('Class List'),
),
body: StreamBuilder<List<Class>>(
stream: _classBloc.classStream,
builder: (BuildContext context, AsyncSnapshot<List<Class>> snapshot) {
if (snapshot.hasError) {
return Center(child: Text('Error: ${snapshot.error}'));
}

if (!snapshot.hasData) {
return const Center(child: CircularProgressIndicator());
}

return ListView.builder(
itemCount: snapshot.data!.length,
itemBuilder: (context, index) {
return ListTile(
title: Text(snapshot.data![index].name),
subtitle: Text(snapshot.data![index].file),
);
},
);
},
body: Column(
children: [
HeaderLogo(),
HeaderTitle("Bonjour, Yan"),
HeaderText("Dans quelle classe êtes-vous ?"),
Expanded(
child: StreamBuilder<List<Class>>(
stream: _classBloc.classStream,
builder:
(BuildContext context, AsyncSnapshot<List<Class>> snapshot) {
if (snapshot.hasError) {
return Center(child: Text('Error: ${snapshot.error}'));
}

if (!snapshot.hasData) {
return const Center(child: CircularProgressIndicator());
}

return CustomCard(classesList: snapshot.data!);
},
),
),
],
),
);
}
Expand Down
25 changes: 25 additions & 0 deletions frontend/app_student/lib/classes/widgets/custom_card.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import 'package:app_student/api/classes/entities/class.dart';
import 'package:flutter/material.dart';

class CustomCard extends StatelessWidget {
final List<Class> classesList;

CustomCard({required this.classesList});

@override
Widget build(BuildContext context) {
return ListView.builder(
itemCount: classesList.length,
itemBuilder: (context, index) {
return Card(
margin: EdgeInsets.all(8.0),
child: ListTile(
title: Text(
classesList[index].name,
),
),
);
},
);
}
}
18 changes: 18 additions & 0 deletions frontend/app_student/lib/classes/widgets/header/header_logo.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import 'package:flutter/material.dart';

class HeaderLogo extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Row(
mainAxisAlignment:
MainAxisAlignment.spaceBetween, // Aligne les éléments horizontalement
children: <Widget>[
Image.asset(
'assets/images/logo.png',
fit: BoxFit.contain,
height: 32,
),
],
);
}
}
28 changes: 28 additions & 0 deletions frontend/app_student/lib/classes/widgets/header/header_text.dart
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,
),
),
),
);
}
}
28 changes: 28 additions & 0 deletions frontend/app_student/lib/classes/widgets/header/header_title.dart
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,
),
),
),
);
}
}
29 changes: 29 additions & 0 deletions frontend/app_student/lib/main_test.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import 'package:app_student/config/dev_config.dart';
import 'package:app_student/timetable/view/timetable_view.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'config/config.dart';

void main() {
runApp(
Provider<Config>(
create: (_) => DevConfig(),
child: const MyApp(),
),
);
}

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

@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Class List',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: TimeTableView(),
);
}
}
21 changes: 21 additions & 0 deletions frontend/app_student/lib/timetable/datepicker_button.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import 'package:flutter/material.dart';

class DatePickerButton extends StatelessWidget {
@override
Widget build(BuildContext context) {
return IconButton(
icon: 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
}
},
);
}
}
32 changes: 32 additions & 0 deletions frontend/app_student/lib/timetable/repository_test.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
final List<Map<String, dynamic>> course = [
{
'horaire-debut': '08:30',
'horaire-fin': '10:00',
'salle': 'Salle 101',
'cours': 'Créneau 1',
},
{
'horaire-debut': '10:30',
'horaire-fin': '12:00',
'salle': 'Salle 102',
'cours': 'Créneau 2',
},
{
'horaire-debut': '13:30',
'horaire-fin': '15:00',
'salle': 'Salle 103',
'cours': 'Créneau 3',
},
{
'horaire-debut': '15:15',
'horaire-fin': '16:45',
'salle': 'Salle 104',
'cours': 'Créneau 4',
},
{
'horaire-debut': '17:00',
'horaire-fin': '18:30',
'salle': 'Salle 105',
'cours': 'Créneau 5',
},
];
20 changes: 20 additions & 0 deletions frontend/app_student/lib/timetable/view/timetable_view.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import 'package:app_student/timetable/repository_test.dart';
import 'package:flutter/material.dart';
import 'package:app_student/timetable/widgets/header/header_logo.dart';
import 'package:app_student/classes/widgets/header/header_text.dart';
import 'package:app_student/timetable/widgets/card/courses_card.dart';

class TimeTableView extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
body: ListView(
children: [
const HeaderLogo(),
const HeaderText("Date du jour"),
...course.map((course) => CourseCard(course: course)),
],
),
);
}
}
21 changes: 21 additions & 0 deletions frontend/app_student/lib/timetable/widgets/card/courses_card.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import 'package:flutter/material.dart';
import 'package:app_student/timetable/widgets/card/courses_time.dart';
import 'courses_details.dart';

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

const CourseCard({Key? key, required this.course}) : super(key: key);

@override
Widget build(BuildContext context) {
return Center(
child: Row(
children: <Widget>[
CourseTime(course: course),
CourseDetails(course: course),
],
),
);
}
}
24 changes: 24 additions & 0 deletions frontend/app_student/lib/timetable/widgets/card/courses_cours.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import 'package:flutter/material.dart';
import 'package:flutter_svg/svg.dart';

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

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

@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,
color: Colors.white,
),
],
);
}
}
Loading