Skip to content

Commit

Permalink
Added arrows to change date (#56)
Browse files Browse the repository at this point in the history
* ✨  Logo change and app name for android bug bug when launching

* 🐛 Fixed round corner on schedule page

* 💥: Added EI bool to timetable response

* 🚧 Change EI color in schedule page

* 🐛: Fixed EI detection

* 🐛: Fixed EI detection and DS

* ✨ Added arrows to change date
  • Loading branch information
PHPLukaas authored Apr 11, 2024
1 parent f29943a commit 3c216bd
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 13 deletions.
2 changes: 1 addition & 1 deletion backend/.php-cs-fixer.cache

Large diffs are not rendered by default.

4 changes: 1 addition & 3 deletions backend/src/Service/TimetableService.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,7 @@ public function parseData(array $parsedData): array
$event->setSalle($creneau['Salles'] ?? '');
$event->setRepas('3' === $creneau['Creneau'] && empty($creneau['Activite']));
$event->setVisio(str_contains($creneau['Salles'] ?? null, 'Teams'));
// Si le nom de l'activité contient "EI" entouré d'espaces on considère que c'est une evaluation
$event->setEval(str_contains($creneau['Activite'] ?? null, ' EI '));

$event->setEval(str_contains($creneau['Activite'] ?? null, ' EI') || str_contains($creneau['Activite'] ?? null, ' DS'));
$daySchedule->addEvent($event);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,4 +98,16 @@ class WeekScheduleCubit extends Cubit<WeekScheduleState> {
emit(WeekScheduleDateChanged(newDate));
fetchUserAndSchedule();
}

void changeToNextOrPreviousDate(bool isNext) {
if (state is WeekScheduleLoaded) {
final currentIndex = (state as WeekScheduleLoaded).todayIndex;
final allDaySchedules = (state as WeekScheduleLoaded).allDaySchedules;
if (isNext && currentIndex < allDaySchedules.length - 1) {
changeDate(allDaySchedules[currentIndex + 1].date);
} else if (!isNext && currentIndex > 0) {
changeDate(allDaySchedules[currentIndex - 1].date);
}
}
}
}
16 changes: 11 additions & 5 deletions frontend/app_student/lib/week_schedule/views/week_schedule.dart
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@ class WeekSchedulePage extends StatelessWidget {
appBar: const CustomAppBar(widget: DatePickerButton()),
body: BlocBuilder<WeekScheduleCubit, WeekScheduleState>(
builder: (context, state) {
final pageController = PageController(
initialPage:
state is WeekScheduleLoaded && state.todayIndex != -1
? state.todayIndex
: 0,
);
if (state is WeekScheduleLoading) {
return const Center(child: CircularProgressIndicator());
} else if (state is WeekScheduleLoaded) {
Expand All @@ -48,14 +54,14 @@ class WeekSchedulePage extends StatelessWidget {
child: SizedBox(
height: MediaQuery.of(context).size.height,
child: PageView.builder(
controller: PageController(
initialPage:
state.todayIndex != -1 ? state.todayIndex : 0,
),
controller: pageController,
itemCount: allEvents.length,
itemBuilder: (context, index) {
final daySchedule = allEvents[index];
return DayScheduleWidget(daySchedule: daySchedule);
return DayScheduleWidget(
daySchedule: daySchedule,
pageController: pageController,
);
},
),
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@ import 'package:intl/intl.dart';

class DayScheduleWidget extends StatelessWidget {
final DayScheduleModel daySchedule;
final PageController pageController;

const DayScheduleWidget({super.key, required this.daySchedule});
const DayScheduleWidget(
{super.key, required this.daySchedule, required this.pageController});

@override
Widget build(BuildContext context) {
Expand All @@ -19,9 +21,35 @@ class DayScheduleWidget extends StatelessWidget {
child: Column(
children: [
Center(
child: Text(
capitalizedDate,
style: CustomTheme.subtitle.toBold,
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
IconButton(
icon: const Icon(Icons.arrow_back),
onPressed: () {
pageController.previousPage(
duration: const Duration(milliseconds: 400),
curve: Curves.easeInOut,
);
},
),
Padding(
padding: const EdgeInsets.only(right: 25, left: 25),
child: Text(
capitalizedDate,
style: CustomTheme.subtitle.toBold,
),
),
IconButton(
icon: const Icon(Icons.arrow_forward),
onPressed: () {
pageController.nextPage(
duration: const Duration(milliseconds: 400),
curve: Curves.easeInOut,
);
},
),
],
),
),
const SizedBox(height: 30),
Expand Down

0 comments on commit 3c216bd

Please sign in to comment.