diff --git a/lib/ui/common/info_message_view.dart b/lib/ui/common/info_message_view.dart index bff16ef2..5ab4dcb0 100644 --- a/lib/ui/common/info_message_view.dart +++ b/lib/ui/common/info_message_view.dart @@ -1,4 +1,5 @@ import 'package:flutter/material.dart'; +import 'package:inkino/utils/widget_utils.dart'; import 'package:meta/meta.dart'; class ErrorView extends InfoMessageView { @@ -31,9 +32,26 @@ class InfoMessageView extends StatelessWidget { final String description; final VoidCallback onActionButtonTapped; + Widget _buildActionButton(BuildContext context) { + if (onActionButtonTapped == null) { + return null; + } + + return Padding( + padding: const EdgeInsets.only(top: 12.0), + child: FlatButton( + key: actionButtonKey, + onPressed: onActionButtonTapped, + child: Text( + 'TRY AGAIN', + style: TextStyle(color: Theme.of(context).primaryColor), + ), + ), + ); + } + @override Widget build(BuildContext context) { - var theme = Theme.of(context); var content = [ const CircleAvatar( child: Icon( @@ -44,35 +62,19 @@ class InfoMessageView extends StatelessWidget { backgroundColor: Colors.black12, radius: 42.0, ), - Padding( - padding: const EdgeInsets.only(top: 16.0), - child: Text( - title, - style: const TextStyle(fontSize: 24.0), - ), + const SizedBox(height: 16.0), + Text( + title, + style: const TextStyle(fontSize: 24.0), ), - Padding( - padding: const EdgeInsets.only(top: 8.0), - child: Text( - description, - textAlign: TextAlign.center, - ), + const SizedBox(height: 8.0), + Text( + description, + textAlign: TextAlign.center, ), ]; - if (onActionButtonTapped != null) { - content.add(Padding( - padding: const EdgeInsets.only(top: 12.0), - child: FlatButton( - key: actionButtonKey, - onPressed: onActionButtonTapped, - child: Text( - 'TRY AGAIN', - style: TextStyle(color: theme.primaryColor), - ), - ), - )); - } + addIfNonNull(_buildActionButton(context), content); return SingleChildScrollView( child: Container( diff --git a/lib/ui/event_details/actor_scroller.dart b/lib/ui/event_details/actor_scroller.dart index 8dbbf765..8635be74 100644 --- a/lib/ui/event_details/actor_scroller.dart +++ b/lib/ui/event_details/actor_scroller.dart @@ -38,13 +38,10 @@ class ActorScrollerContent extends StatelessWidget { } Widget _buildActorListItem(BuildContext context, Actor actor) { - var actorName = Padding( - padding: const EdgeInsets.only(top: 8.0), - child: Text( - actor.name, - style: const TextStyle(fontSize: 12.0), - textAlign: TextAlign.center, - ), + var actorName = Text( + actor.name, + style: const TextStyle(fontSize: 12.0), + textAlign: TextAlign.center, ); return Container( @@ -53,6 +50,7 @@ class ActorScrollerContent extends StatelessWidget { child: Column( children: [ _buildActorAvatar(context, actor), + const SizedBox(height: 8.0), actorName, ], ), @@ -111,12 +109,10 @@ class ActorScrollerContent extends StatelessWidget { ), ), ), - Padding( - padding: const EdgeInsets.only(top: 16.0), - child: SizedBox.fromSize( - size: const Size.fromHeight(110.0), - child: _buildActorList(context), - ), + const SizedBox(height: 16.0), + SizedBox.fromSize( + size: const Size.fromHeight(110.0), + child: _buildActorList(context), ), ], ), diff --git a/lib/ui/event_details/event_details_page.dart b/lib/ui/event_details/event_details_page.dart index 4a6b8900..42fec930 100644 --- a/lib/ui/event_details/event_details_page.dart +++ b/lib/ui/event_details/event_details_page.dart @@ -82,7 +82,9 @@ class _EventDetailsPageState extends State { } Widget _buildEventInfo() { - var content = []..addAll(_buildTitleAndLengthInMinutes()); + var content = []..addAll( + _buildTitleAndLengthInMinutes(), + ); if (widget.event.directors.isNotEmpty) { content.add(Padding( @@ -109,14 +111,12 @@ class _EventDetailsPageState extends State { fontWeight: FontWeight.w800, ), ), - Padding( - padding: const EdgeInsets.only(top: 8.0), - child: Text( - '$length | $genres', - style: const TextStyle( - fontSize: 12.0, - fontWeight: FontWeight.w600, - ), + const SizedBox(height: 8.0), + Text( + '$length | $genres', + style: const TextStyle( + fontSize: 12.0, + fontWeight: FontWeight.w600, ), ), ]; @@ -134,15 +134,13 @@ class _EventDetailsPageState extends State { fontWeight: FontWeight.w600, ), ), + const SizedBox(width: 4.0), Expanded( - child: Padding( - padding: const EdgeInsets.only(left: 4.0), - child: Text( - widget.event.directors.first, - style: const TextStyle( - fontSize: 12.0, - color: Colors.black87, - ), + child: Text( + widget.event.directors.first, + style: const TextStyle( + fontSize: 12.0, + color: Colors.black87, ), ), ), @@ -231,7 +229,7 @@ class _EventDetailsPageState extends State { addIfNonNull(_buildActorScroller(), content); // Some padding for the bottom. - content.add(Container(height: 32.0)); + content.add(const SizedBox(height: 32.0)); return Scaffold( backgroundColor: Colors.white, diff --git a/lib/ui/event_details/showtime_information.dart b/lib/ui/event_details/showtime_information.dart index de176726..03620fcd 100644 --- a/lib/ui/event_details/showtime_information.dart +++ b/lib/ui/event_details/showtime_information.dart @@ -19,27 +19,24 @@ class ShowtimeInformation extends StatelessWidget { final Show show; Widget _buildTimeAndTheaterInformation() { - return Padding( - padding: const EdgeInsets.only(left: 8.0), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - weekdayFormat.format(show.start), - style: const TextStyle( - fontWeight: FontWeight.w500, - color: Colors.black, - ), + return Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + weekdayFormat.format(show.start), + style: const TextStyle( + fontWeight: FontWeight.w500, + color: Colors.black, ), - Text( - show.theaterAndAuditorium, - style: const TextStyle( - color: Colors.black54, - fontSize: 12.0, - ), + ), + Text( + show.theaterAndAuditorium, + style: const TextStyle( + color: Colors.black54, + fontSize: 12.0, ), - ], - ), + ), + ], ); } @@ -55,19 +52,18 @@ class ShowtimeInformation extends StatelessWidget { Icons.schedule, color: Colors.black87, ), + const SizedBox(width: 8.0), _buildTimeAndTheaterInformation(), ], ), ), - Padding( - padding: const EdgeInsets.only(left: 8.0), - child: RaisedButton( - key: ticketsButtonKey, - onPressed: () => launchTicketsUrl(show.url), - color: Theme.of(context).accentColor, - textColor: Colors.white, - child: const Text('Tickets'), - ), + const SizedBox(width: 8.0), + RaisedButton( + key: ticketsButtonKey, + onPressed: () => launchTicketsUrl(show.url), + color: Theme.of(context).accentColor, + textColor: Colors.white, + child: const Text('Tickets'), ), ], ); diff --git a/lib/ui/event_details/storyline_widget.dart b/lib/ui/event_details/storyline_widget.dart index f6b6f89e..731e20fb 100644 --- a/lib/ui/event_details/storyline_widget.dart +++ b/lib/ui/event_details/storyline_widget.dart @@ -37,7 +37,10 @@ class _StorylineWidgetState extends State { ]; if (_isExpandable) { - content.add(_buildCollapseExpandPrompt()); + content.add(Padding( + padding: const EdgeInsets.only(left: 4.0), + child: _buildExpandCollapsePrompt(), + )); } return Row( @@ -47,34 +50,27 @@ class _StorylineWidgetState extends State { ); } - Widget _buildCollapseExpandPrompt() { + Widget _buildExpandCollapsePrompt() { const captionStyle = const TextStyle( fontSize: 12.0, fontWeight: FontWeight.w600, color: Colors.black54, ); + if (_isExpanded) { - return const Padding( - padding: const EdgeInsets.only(left: 4.0), - child: const Text('[touch to collapse]', style: captionStyle), - ); + return const Text('[touch to collapse]', style: captionStyle); } - return const Padding( - padding: const EdgeInsets.only(left: 4.0), - child: const Text('[touch to expand]', style: captionStyle), - ); + + return const Text('[touch to expand]', style: captionStyle); } Widget _buildContent() { - return Padding( - padding: const EdgeInsets.only(top: 8.0), - child: AnimatedCrossFade( - firstChild: Text(widget.event.shortSynopsis), - secondChild: Text(widget.event.synopsis), - crossFadeState: - _isExpanded ? CrossFadeState.showSecond : CrossFadeState.showFirst, - duration: kThemeAnimationDuration, - ), + return AnimatedCrossFade( + firstChild: Text(widget.event.shortSynopsis), + secondChild: Text(widget.event.synopsis), + crossFadeState: + _isExpanded ? CrossFadeState.showSecond : CrossFadeState.showFirst, + duration: kThemeAnimationDuration, ); } @@ -91,6 +87,7 @@ class _StorylineWidgetState extends State { crossAxisAlignment: CrossAxisAlignment.start, children: [ _buildCaption(), + const SizedBox(height: 8.0), _buildContent(), ], ), diff --git a/lib/ui/events/event_grid_item.dart b/lib/ui/events/event_grid_item.dart index cec3fe27..0e6a081c 100644 --- a/lib/ui/events/event_grid_item.dart +++ b/lib/ui/events/event_grid_item.dart @@ -39,14 +39,12 @@ class EventGridItem extends StatelessWidget { fontSize: 16.0, ), ), - Padding( - padding: const EdgeInsets.only(top: 4.0), - child: Text( - event.genres, - style: const TextStyle( - fontSize: 12.0, - color: Colors.white70, - ), + const SizedBox(height: 4.0), + Text( + event.genres, + style: const TextStyle( + fontSize: 12.0, + color: Colors.white70, ), ), ], diff --git a/lib/ui/showtimes/showtime_date_selector.dart b/lib/ui/showtimes/showtime_date_selector.dart index b94e26b1..1257212c 100644 --- a/lib/ui/showtimes/showtime_date_selector.dart +++ b/lib/ui/showtimes/showtime_date_selector.dart @@ -14,14 +14,12 @@ class ShowtimeDateSelector extends StatelessWidget { var content = Column( mainAxisAlignment: MainAxisAlignment.start, children: [ - Padding( - padding: const EdgeInsets.only(top: 10.0), - child: Text( - DateFormat('E').format(date), - style: TextStyle( - fontSize: 12.0, - color: color, - ), + const SizedBox(height: 10.0), + Text( + DateFormat('E').format(date), + style: TextStyle( + fontSize: 12.0, + color: color, ), ), Text( diff --git a/lib/ui/showtimes/showtime_list_tile.dart b/lib/ui/showtimes/showtime_list_tile.dart index 71d13ec8..6b307786 100644 --- a/lib/ui/showtimes/showtime_list_tile.dart +++ b/lib/ui/showtimes/showtime_list_tile.dart @@ -68,26 +68,21 @@ class ShowtimeListTile extends StatelessWidget { ); return Expanded( - child: Padding( - padding: const EdgeInsets.only(left: 20.0), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Text( - show.title, - style: const TextStyle( - fontWeight: FontWeight.w500, - fontSize: 14.0, - ), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text( + show.title, + style: const TextStyle( + fontWeight: FontWeight.w500, + fontSize: 14.0, ), - Padding( - padding: const EdgeInsets.only(top: 4.0), - child: Text(show.theaterAndAuditorium), - ), - presentationMethodInfo, - ], - ), + ), + const SizedBox(height: 4.0), + Text(show.theaterAndAuditorium), + presentationMethodInfo, + ], ), ); } @@ -106,6 +101,7 @@ class ShowtimeListTile extends StatelessWidget { child: Row( children: [ _buildShowtimesInfo(), + const SizedBox(width: 20.0), _buildDetailedInfo(), ], ), diff --git a/lib/ui/theater_list/inkino_drawer_header.dart b/lib/ui/theater_list/inkino_drawer_header.dart index 4413652c..2c717d52 100644 --- a/lib/ui/theater_list/inkino_drawer_header.dart +++ b/lib/ui/theater_list/inkino_drawer_header.dart @@ -77,15 +77,13 @@ class _InKinoDrawerHeaderState extends State { color: Colors.white70, size: 18.0, ), - const Padding( - padding: const EdgeInsets.only(left: 8.0), - child: const Text( - 'About', - textAlign: TextAlign.end, - style: const TextStyle( - color: Colors.white70, - fontSize: 12.0, - ), + const SizedBox(width: 8.0), + const Text( + 'About', + textAlign: TextAlign.end, + style: const TextStyle( + color: Colors.white70, + fontSize: 12.0, ), ), ], @@ -116,6 +114,7 @@ class _InKinoDrawerHeaderState extends State { crossAxisAlignment: CrossAxisAlignment.start, children: [ _buildAboutText(), + const SizedBox(height: 16.0), _buildTMDBAttribution(), ], ), @@ -160,28 +159,20 @@ class _InKinoDrawerHeaderState extends State { } Widget _buildTMDBAttribution() { - return Padding( - padding: const EdgeInsets.only(top: 16.0), - child: Row( - children: [ - Padding( - padding: const EdgeInsets.only(top: 8.0), - child: Image.asset( - ImageAssets.poweredByTMDBLogo, - width: 32.0, - ), - ), - const Expanded( - child: Padding( - padding: EdgeInsets.only(left: 12.0), - child: Text( - 'This product uses the TMDb API but is not endorsed or certified by TMDb.', - style: TextStyle(fontSize: 12.0), - ), - ), + return Row( + children: [ + Image.asset( + ImageAssets.poweredByTMDBLogo, + width: 32.0, + ), + const SizedBox(width: 12.0), + const Expanded( + child: Text( + 'This product uses the TMDb API but is not endorsed or certified by TMDb.', + style: TextStyle(fontSize: 12.0), ), - ], - ), + ), + ], ); }