diff --git a/uni/lib/view/calendar/calendar.dart b/uni/lib/view/calendar/calendar.dart index ffd8791b7..9e83ca779 100644 --- a/uni/lib/view/calendar/calendar.dart +++ b/uni/lib/view/calendar/calendar.dart @@ -3,6 +3,7 @@ import 'package:provider/provider.dart'; import 'package:timelines/timelines.dart'; import 'package:uni/model/entities/calendar_event.dart'; import 'package:uni/model/providers/lazy/calendar_provider.dart'; +import 'package:uni/view/calendar/widgets/calendar_tile.dart'; import 'package:uni/view/common_widgets/page_title.dart'; import 'package:uni/view/common_widgets/pages_layouts/general/general.dart'; import 'package:uni/view/common_widgets/request_dependent_widget_builder.dart'; @@ -20,7 +21,9 @@ class CalendarPageViewState extends GeneralPageViewState { Widget getBody(BuildContext context) { return LazyConsumer( builder: (context, calendarProvider) => ListView(children: [ - _getPageTitle(), + Container( + padding: const EdgeInsets.only(bottom: 6.0), + child: const PageTitle(name: 'Calendário Escolar')), RequestDependentWidgetBuilder( status: calendarProvider.status, builder: () => @@ -32,12 +35,6 @@ class CalendarPageViewState extends GeneralPageViewState { ])); } - Widget _getPageTitle() { - return Container( - padding: const EdgeInsets.only(bottom: 6.0), - child: const PageTitle(name: 'Calendário Escolar')); - } - Widget getTimeline(BuildContext context, List calendar) { return FixedTimeline.tileBuilder( theme: TimelineTheme.of(context).copyWith( @@ -50,21 +47,9 @@ class CalendarPageViewState extends GeneralPageViewState { ), builder: TimelineTileBuilder.fromStyle( contentsAlign: ContentsAlign.alternating, - contentsBuilder: (context, index) => Padding( - padding: const EdgeInsets.all(24.0), - child: Text(calendar[index].name, - style: Theme.of(context) - .textTheme - .titleLarge - ?.copyWith(fontWeight: FontWeight.w500)), - ), - oppositeContentsBuilder: (context, index) => Padding( - padding: const EdgeInsets.all(24.0), - child: Text(calendar[index].date, - style: Theme.of(context).textTheme.titleMedium?.copyWith( - fontStyle: FontStyle.italic, - )), - ), + contentsBuilder: (_, index) => CalendarTile(text: calendar[index].name), + oppositeContentsBuilder: (_, index) => + CalendarTile(text: calendar[index].date, isOposite: true), itemCount: calendar.length, ), ); diff --git a/uni/lib/view/calendar/widgets/calendar_tile.dart b/uni/lib/view/calendar/widgets/calendar_tile.dart new file mode 100644 index 000000000..be8e00bb4 --- /dev/null +++ b/uni/lib/view/calendar/widgets/calendar_tile.dart @@ -0,0 +1,24 @@ +import 'package:flutter/material.dart'; + +class CalendarTile extends StatelessWidget { + final String text; + final bool isOposite; + const CalendarTile({Key? key, required this.text, this.isOposite = false}) + : super(key: key); + + @override + Widget build(BuildContext context) { + return Padding( + padding: const EdgeInsets.all(24.0), + child: Text(text, + style: !isOposite + ? Theme.of(context) + .textTheme + .titleLarge + ?.copyWith(fontWeight: FontWeight.w500) + : Theme.of(context).textTheme.titleMedium?.copyWith( + fontStyle: FontStyle.italic, + )), + ); + } +}