perf: optimization des rebuilds (ValueNotifier pour calendrier/container_form, Selector pour pages de gestion et mon compte)
This commit is contained in:
@@ -51,7 +51,7 @@ class _CalendarPageState extends State<CalendarPage> {
|
||||
int _searchRequestId = 0;
|
||||
bool _isMobileSearchVisible = false;
|
||||
bool _isRefreshing = false;
|
||||
double _detailsPaneFraction = 0.35;
|
||||
final ValueNotifier<double> _detailsPaneFraction = ValueNotifier<double>(0.35);
|
||||
String? _lastLoadedUserId;
|
||||
bool _initialLoadScheduled = false;
|
||||
|
||||
@@ -207,6 +207,7 @@ class _CalendarPageState extends State<CalendarPage> {
|
||||
void dispose() {
|
||||
_searchDebounce?.cancel();
|
||||
_searchController.dispose();
|
||||
_detailsPaneFraction.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@@ -817,12 +818,10 @@ class _CalendarPageState extends State<CalendarPage> {
|
||||
child: GestureDetector(
|
||||
behavior: HitTestBehavior.opaque,
|
||||
onHorizontalDragUpdate: (details) {
|
||||
setState(() {
|
||||
_detailsPaneFraction = _clampDetailsPaneFraction(
|
||||
_detailsPaneFraction - (details.delta.dx / totalWidth),
|
||||
totalWidth,
|
||||
);
|
||||
});
|
||||
_detailsPaneFraction.value = _clampDetailsPaneFraction(
|
||||
_detailsPaneFraction.value - (details.delta.dx / totalWidth),
|
||||
totalWidth,
|
||||
);
|
||||
},
|
||||
child: SizedBox(
|
||||
width: _desktopResizeHandleWidth,
|
||||
@@ -935,25 +934,30 @@ class _CalendarPageState extends State<CalendarPage> {
|
||||
return LayoutBuilder(
|
||||
builder: (context, constraints) {
|
||||
final totalWidth = constraints.maxWidth;
|
||||
final detailsPaneFraction =
|
||||
_clampDetailsPaneFraction(_detailsPaneFraction, totalWidth);
|
||||
final detailsWidth = totalWidth * detailsPaneFraction;
|
||||
final calendarWidth =
|
||||
totalWidth - _desktopResizeHandleWidth - detailsWidth;
|
||||
return ValueListenableBuilder<double>(
|
||||
valueListenable: _detailsPaneFraction,
|
||||
builder: (context, fraction, child) {
|
||||
final detailsPaneFraction =
|
||||
_clampDetailsPaneFraction(fraction, totalWidth);
|
||||
final detailsWidth = totalWidth * detailsPaneFraction;
|
||||
final calendarWidth =
|
||||
totalWidth - _desktopResizeHandleWidth - detailsWidth;
|
||||
|
||||
return Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
SizedBox(
|
||||
width: calendarWidth,
|
||||
child: _buildCalendar(filteredEvents),
|
||||
),
|
||||
_buildDesktopResizeHandle(totalWidth),
|
||||
SizedBox(
|
||||
width: detailsWidth,
|
||||
child: _buildDesktopDetailsPane(filteredEvents),
|
||||
),
|
||||
],
|
||||
return Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
SizedBox(
|
||||
width: calendarWidth,
|
||||
child: _buildCalendar(filteredEvents),
|
||||
),
|
||||
_buildDesktopResizeHandle(totalWidth),
|
||||
SizedBox(
|
||||
width: detailsWidth,
|
||||
child: _buildDesktopDetailsPane(filteredEvents),
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
},
|
||||
);
|
||||
@@ -1194,7 +1198,7 @@ class _CalendarPageState extends State<CalendarPage> {
|
||||
),
|
||||
),
|
||||
if (!hasEvents)
|
||||
Center(
|
||||
const Center(
|
||||
child: Text(
|
||||
'Aucun événement ne démarre à cette date'),
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user