Skip to content

Commit

Permalink
Merge pull request roughike#86 from roughike/feature/ui-code-cleanup
Browse files Browse the repository at this point in the history
UI code cleanup
  • Loading branch information
roughike authored Jun 10, 2018
2 parents 8595458 + 4e09b2d commit 1b1f246
Show file tree
Hide file tree
Showing 9 changed files with 141 additions and 169 deletions.
54 changes: 28 additions & 26 deletions lib/ui/common/info_message_view.dart
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down Expand Up @@ -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 = <Widget>[
const CircleAvatar(
child: Icon(
Expand All @@ -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(
Expand Down
22 changes: 9 additions & 13 deletions lib/ui/event_details/actor_scroller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -53,6 +50,7 @@ class ActorScrollerContent extends StatelessWidget {
child: Column(
children: <Widget>[
_buildActorAvatar(context, actor),
const SizedBox(height: 8.0),
actorName,
],
),
Expand Down Expand Up @@ -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),
),
],
),
Expand Down
34 changes: 16 additions & 18 deletions lib/ui/event_details/event_details_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,9 @@ class _EventDetailsPageState extends State<EventDetailsPage> {
}

Widget _buildEventInfo() {
var content = <Widget>[]..addAll(_buildTitleAndLengthInMinutes());
var content = <Widget>[]..addAll(
_buildTitleAndLengthInMinutes(),
);

if (widget.event.directors.isNotEmpty) {
content.add(Padding(
Expand All @@ -109,14 +111,12 @@ class _EventDetailsPageState extends State<EventDetailsPage> {
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,
),
),
];
Expand All @@ -134,15 +134,13 @@ class _EventDetailsPageState extends State<EventDetailsPage> {
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,
),
),
),
Expand Down Expand Up @@ -231,7 +229,7 @@ class _EventDetailsPageState extends State<EventDetailsPage> {
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,
Expand Down
52 changes: 24 additions & 28 deletions lib/ui/event_details/showtime_information.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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: <Widget>[
Text(
weekdayFormat.format(show.start),
style: const TextStyle(
fontWeight: FontWeight.w500,
color: Colors.black,
),
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
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,
),
],
),
),
],
);
}

Expand All @@ -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'),
),
],
);
Expand Down
35 changes: 16 additions & 19 deletions lib/ui/event_details/storyline_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,10 @@ class _StorylineWidgetState extends State<StorylineWidget> {
];

if (_isExpandable) {
content.add(_buildCollapseExpandPrompt());
content.add(Padding(
padding: const EdgeInsets.only(left: 4.0),
child: _buildExpandCollapsePrompt(),
));
}

return Row(
Expand All @@ -47,34 +50,27 @@ class _StorylineWidgetState extends State<StorylineWidget> {
);
}

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,
);
}

Expand All @@ -91,6 +87,7 @@ class _StorylineWidgetState extends State<StorylineWidget> {
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
_buildCaption(),
const SizedBox(height: 8.0),
_buildContent(),
],
),
Expand Down
14 changes: 6 additions & 8 deletions lib/ui/events/event_grid_item.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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,
),
),
],
Expand Down
14 changes: 6 additions & 8 deletions lib/ui/showtimes/showtime_date_selector.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,12 @@ class ShowtimeDateSelector extends StatelessWidget {
var content = Column(
mainAxisAlignment: MainAxisAlignment.start,
children: <Widget>[
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(
Expand Down
Loading

0 comments on commit 1b1f246

Please sign in to comment.