Skip to content

Commit

Permalink
🐛 Fix overflow issues in calendar
Browse files Browse the repository at this point in the history
Calendar did sometimes overflow.
I fixed this by making the rows smaller.
Also I replaced the List built at the bottom of the calendar
with a Modal that opens on press
  • Loading branch information
strifel committed Aug 1, 2020
1 parent 0f1e36c commit bba01fe
Showing 1 changed file with 26 additions and 22 deletions.
48 changes: 26 additions & 22 deletions lib/Views/Calendar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -463,6 +463,8 @@ class _TableCalendarState extends State<_TableCalendar> with TickerProviderState
if (_selectedEvents.length == 1) {
Navigator.push(context,
MaterialPageRoute(builder: (context) => CalendarDetail(_selectedEvents[0])));
} else {
_showEventListModal();
}
});
}
Expand All @@ -484,9 +486,6 @@ class _TableCalendarState extends State<_TableCalendar> with TickerProviderState
mainAxisSize: MainAxisSize.max,
children: <Widget>[
_buildTableCalendar(),
const SizedBox(height: 8.0),
const SizedBox(height: 8.0),
Expanded(child: _buildEventList()),
],
);
}
Expand All @@ -511,7 +510,7 @@ class _TableCalendarState extends State<_TableCalendar> with TickerProviderState
return [new Container(), new Container()];
},
),
rowHeight: MediaQuery.of(context).size.height / 8,
rowHeight: (MediaQuery.of(context).size.height - 150) / 7,
calendarStyle: CalendarStyle(
selectedColor: Color.fromRGBO(255, 145, 10, 1),
outsideDaysVisible: false,
Expand All @@ -534,7 +533,6 @@ class _TableCalendarState extends State<_TableCalendar> with TickerProviderState
return Container(
margin: const EdgeInsets.all(4.0),
padding: const EdgeInsets.only(top: 5.0, left: 6.0),
color: selected ? Color.fromRGBO(255, 145, 10, 1) : null,
child: Column(
children: [
Text(
Expand All @@ -561,22 +559,28 @@ class _TableCalendarState extends State<_TableCalendar> with TickerProviderState


// Builds the list shown after a day has been selected
Widget _buildEventList() {
return ListView(
children: _selectedEvents
.map((event) => Container(
decoration: BoxDecoration(
border: Border.all(width: 0.8),
borderRadius: BorderRadius.circular(12.0),
),
margin: const EdgeInsets.symmetric(horizontal: 8.0, vertical: 4.0),
child: ListTile(
title: Text(event.title),
onTap: () => Navigator.push(context,
MaterialPageRoute(builder: (context) => CalendarDetail(event))),
),
))
.toList(),
);
void _showEventListModal() {
showCupertinoDialog(context: context, builder: (context) {
return CupertinoAlertDialog(
title: Text("Es gibt mehrere Termine"),
content: Column(
children: _selectedEvents
.map((event) => Container(
decoration: BoxDecoration(
border: Border.all(width: 0.8),
borderRadius: BorderRadius.circular(12.0),
color: Theme.of(context).buttonColor
),
margin: const EdgeInsets.symmetric(horizontal: 8.0, vertical: 4.0),
child: MaterialButton(
child: Text(event.title, style: TextStyle(color: Colors.white),),
onPressed: () => Navigator.push(context,
MaterialPageRoute(builder: (context) => CalendarDetail(event))),
),
))
.toList(),
)
);
}, barrierDismissible: true);
}
}

0 comments on commit bba01fe

Please sign in to comment.