Skip to content

Commit

Permalink
fix: event item tap screen
Browse files Browse the repository at this point in the history
  • Loading branch information
pd4d10 committed Feb 10, 2019
1 parent ce11da3 commit d476018
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 46 deletions.
20 changes: 10 additions & 10 deletions lib/utils/utils.dart
Expand Up @@ -126,16 +126,16 @@ TextSpan createLinkSpan(BuildContext context, String text, Function handle) {
fontWeight: FontWeight.w600,
// decoration: TextDecoration.underline,
),
recognizer: TapGestureRecognizer()
..onTap = () {
Navigator.of(context).push(
CupertinoPageRoute(
builder: (context) {
return handle();
},
),
);
},
// recognizer: TapGestureRecognizer()
// ..onTap = () {
// Navigator.of(context).push(
// CupertinoPageRoute(
// builder: (context) {
// return handle();
// },
// ),
// );
// },
);
}

Expand Down
1 change: 1 addition & 0 deletions lib/widgets/avatar.dart
Expand Up @@ -23,6 +23,7 @@ class Avatar extends StatelessWidget {
backgroundImage: NetworkImage(url),
radius: size,
),
material: false,
);
}
}
94 changes: 58 additions & 36 deletions lib/widgets/event_item.dart
Expand Up @@ -3,7 +3,9 @@ import 'package:flutter/cupertino.dart';
import '../screens/issue.dart';
import '../screens/pull_request.dart';
import '../screens/user.dart';
import '../screens/repo.dart';
import 'avatar.dart';
import 'link.dart';
import '../utils/utils.dart';

class EventPayload {
Expand Down Expand Up @@ -56,52 +58,56 @@ class EventItem extends StatelessWidget {
@required List<TextSpan> spans,
String detail,
IconData iconData = Octicons.octoface,
WidgetBuilder screenBuilder,
}) {
var _spans = [
createLinkSpan(
context, event.actorLogin, () => UserScreen(event.actorLogin))
];
_spans.addAll(spans);

return Container(
padding: EdgeInsets.all(8),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Row(
children: <Widget>[
Avatar(login: event.actorLogin, url: event.actorAvatarUrl),
Padding(padding: EdgeInsets.only(left: 10)),
Expanded(
child: RichText(
text: TextSpan(
style: TextStyle(
color: Colors.black, height: 1.3, fontSize: 15),
children: _spans,
return Link(
screenBuilder: screenBuilder,
child: Container(
padding: EdgeInsets.all(8),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Row(
children: <Widget>[
Avatar(login: event.actorLogin, url: event.actorAvatarUrl),
Padding(padding: EdgeInsets.only(left: 10)),
Expanded(
child: RichText(
text: TextSpan(
style: TextStyle(
color: Colors.black, height: 1.3, fontSize: 15),
children: _spans,
),
),
),
),
Padding(padding: EdgeInsets.only(left: 8)),
Icon(iconData, color: Colors.black45, size: 22),
],
),
detail == null
? Container()
: Container(
padding: EdgeInsets.only(left: 46, top: 6),
child: Text(
detail,
overflow: TextOverflow.ellipsis,
maxLines: 3,
style: TextStyle(
color: Colors.black87,
fontSize: 14,
height: 1.2,
fontWeight: FontWeight.w300,
Padding(padding: EdgeInsets.only(left: 8)),
Icon(iconData, color: Colors.black45, size: 22),
],
),
detail == null
? Container()
: Container(
padding: EdgeInsets.only(left: 46, top: 6),
child: Text(
detail,
overflow: TextOverflow.ellipsis,
maxLines: 3,
style: TextStyle(
color: Colors.black87,
fontSize: 14,
height: 1.2,
fontWeight: FontWeight.w300,
),
),
),
)
],
)
],
),
),
);
}
Expand Down Expand Up @@ -175,6 +181,10 @@ class EventItem extends StatelessWidget {
],
detail: event.payload['comment']['body'],
iconData: Octicons.comment_discussion,
screenBuilder: (_) => IssueScreen.fromFullName(
number: event.payload['issue']['number'],
fullName: event.repoFullName,
),
);
case 'IssuesEvent':
return _buildItem(
Expand All @@ -187,6 +197,10 @@ class EventItem extends StatelessWidget {
],
iconData: Octicons.issue_opened,
detail: event.payload['issue']['title'],
screenBuilder: (_) => IssueScreen.fromFullName(
number: event.payload['issue']['number'],
fullName: event.repoFullName,
),
);
case 'LabelEvent':
case 'MarketplacePurchaseEvent':
Expand All @@ -213,6 +227,10 @@ class EventItem extends StatelessWidget {
],
iconData: Octicons.git_pull_request,
detail: event.payload['pull_request']['title'],
screenBuilder: (_) => PullRequestScreen.fromFullName(
number: event.payload['pull_request']['number'],
fullName: event.repoFullName,
),
);
case 'PullRequestReviewEvent':
// TODO:
Expand All @@ -227,6 +245,10 @@ class EventItem extends StatelessWidget {
_buildRepo(context),
],
detail: event.payload['comment']['body'],
screenBuilder: (_) => PullRequestScreen.fromFullName(
number: event.payload['pull_request']['number'],
fullName: event.repoFullName,
),
);
case 'PushEvent':
return _buildItem(
Expand Down

0 comments on commit d476018

Please sign in to comment.