Refactor calendar on dashboard

The scrollable list view is now removed. There can't be that many different
types of events for a single day anyway.
This commit is contained in:
Roland Geider
2021-05-17 18:22:37 +02:00
parent 6c4a09bf97
commit 09ed4dc402
2 changed files with 23 additions and 32 deletions

View File

@@ -124,10 +124,7 @@ class _DashboardScreenState extends State<DashboardScreen> {
DashboardWorkoutWidget(),
DashboardNutritionWidget(),
DashboardWeightWidget(),
Container(
height: 650, // TODO: refactor calendar so we can get rid of size
child: DashboardCalendarWidget(),
),
DashboardCalendarWidget(),
],
),
),

View File

@@ -226,36 +226,30 @@ class _DashboardCalendarWidgetState extends State<DashboardCalendarWidget>
},
),
const SizedBox(height: 8.0),
Expanded(
child: ValueListenableBuilder<List<Event>>(
valueListenable: _selectedEvents,
builder: (context, value, _) {
return ListView.builder(
itemCount: value.length,
itemBuilder: (context, index) {
return Container(
width: double.infinity,
child: ListTile(
title: Text((() {
switch (value[index].type) {
case EventType.caloriesDiary:
return AppLocalizations.of(context)!.nutritionalDiary;
ValueListenableBuilder<List<Event>>(
valueListenable: _selectedEvents,
builder: (context, value, _) => Column(
children: [
...value
.map((event) => ListTile(
title: Text((() {
switch (event.type) {
case EventType.caloriesDiary:
return AppLocalizations.of(context)!.nutritionalDiary;
case EventType.session:
return AppLocalizations.of(context)!.workoutSession;
case EventType.session:
return AppLocalizations.of(context)!.workoutSession;
case EventType.weight:
return AppLocalizations.of(context)!.weight;
}
return value[index].description.toString();
})()),
subtitle: Text(value[index].description.toString()),
onTap: () => print('${value[index]} tapped!'),
),
);
},
);
},
case EventType.weight:
return AppLocalizations.of(context)!.weight;
}
return event.description.toString();
})()),
subtitle: Text(event.description.toString()),
//onTap: () => print('$event tapped!'),
))
.toList()
],
),
),
],