Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
230 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import 'package:flutter/material.dart'; | ||
|
||
class IssuesScreen extends StatefulWidget { | ||
@override | ||
_IssuesScreenState createState() => _IssuesScreenState(); | ||
} | ||
|
||
class _IssuesScreenState extends State<IssuesScreen> { | ||
@override | ||
Widget build(BuildContext context) { | ||
return Container(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import 'package:flutter/material.dart'; | ||
|
||
class PullRequestsScreen extends StatefulWidget { | ||
@override | ||
_PullRequestsScreenState createState() => _PullRequestsScreenState(); | ||
} | ||
|
||
class _PullRequestsScreenState extends State<PullRequestsScreen> { | ||
@override | ||
Widget build(BuildContext context) { | ||
return Container(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,120 @@ | ||
import 'dart:convert'; | ||
import 'package:flutter/material.dart'; | ||
import 'package:flutter/cupertino.dart'; | ||
import 'package:flutter_markdown/flutter_markdown.dart'; | ||
import '../widgets/refresh_scaffold.dart'; | ||
import '../utils/utils.dart'; | ||
import '../widgets/repo_item.dart'; | ||
import '../widgets/entry_item.dart'; | ||
import '../screens/issues.dart'; | ||
import '../screens/pull_requests.dart'; | ||
|
||
Future fetchReadme(String owner, String name) async { | ||
var data = await getWithCredentials('/repos/$owner/$name/readme'); | ||
var bits = base64.decode(data['content'].replaceAll('\n', '')); | ||
var str = utf8.decode(bits); | ||
return str; | ||
} | ||
|
||
Future queryRepo(String owner, String name) async { | ||
var data = await query(''' | ||
{ | ||
repository(owner: "$owner", name: "$name") { | ||
owner { | ||
login | ||
} | ||
name | ||
isPrivate | ||
isFork | ||
description | ||
stargazers { | ||
totalCount | ||
} | ||
forks { | ||
totalCount | ||
} | ||
primaryLanguage { | ||
color | ||
name | ||
} | ||
issues(states: OPEN) { | ||
totalCount | ||
} | ||
pullRequests(states: OPEN) { | ||
totalCount | ||
} | ||
} | ||
} | ||
'''); | ||
return data['repository']; | ||
} | ||
|
||
class RepoScreen extends StatefulWidget { | ||
final String owner; | ||
final String name; | ||
|
||
RepoScreen(this.owner, this.name); | ||
|
||
@override | ||
_RepoScreenState createState() => _RepoScreenState(); | ||
} | ||
|
||
class _RepoScreenState extends State<RepoScreen> { | ||
Map<String, dynamic> payload; | ||
String readme; | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return Container( | ||
child: Text(widget.owner), | ||
return RefreshScaffold( | ||
title: Text(widget.owner + '/' + widget.name), | ||
onRefresh: () async { | ||
List items = await Future.wait([ | ||
queryRepo(widget.owner, widget.name), | ||
fetchReadme(widget.owner, widget.name), | ||
]); | ||
setState(() { | ||
payload = items[0]; | ||
readme = items[1]; | ||
}); | ||
}, | ||
bodyBuilder: () { | ||
return Column( | ||
children: <Widget>[ | ||
RepoItem(payload), | ||
Container( | ||
decoration: BoxDecoration( | ||
border: Border( | ||
bottom: BorderSide(color: Colors.black12), | ||
top: BorderSide(color: Colors.black12), | ||
), | ||
), | ||
child: Row( | ||
children: <Widget>[ | ||
EntryItem( | ||
count: payload['issues']['totalCount'], | ||
text: 'Issues', | ||
route: CupertinoPageRoute( | ||
builder: (context) => IssuesScreen(), | ||
), | ||
), | ||
EntryItem( | ||
count: payload['pullRequests']['totalCount'], | ||
text: 'Pull Requests', | ||
route: CupertinoPageRoute( | ||
builder: (context) => PullRequestsScreen(), | ||
), | ||
), | ||
], | ||
), | ||
), | ||
Container( | ||
padding: EdgeInsets.all(16), | ||
child: MarkdownBody(data: readme), | ||
), | ||
], | ||
); | ||
}, | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import 'package:flutter/material.dart'; | ||
|
||
class UsersScreen extends StatefulWidget { | ||
@override | ||
_UsersScreenState createState() => _UsersScreenState(); | ||
} | ||
|
||
class _UsersScreenState extends State<UsersScreen> { | ||
@override | ||
Widget build(BuildContext context) { | ||
return Container(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import 'package:flutter/cupertino.dart'; | ||
import 'link.dart'; | ||
|
||
class EntryItem extends StatelessWidget { | ||
final int count; | ||
final String text; | ||
final CupertinoPageRoute route; | ||
|
||
EntryItem({this.count, this.text, this.route}); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return Expanded( | ||
flex: 1, | ||
child: Link( | ||
child: Container( | ||
padding: EdgeInsets.symmetric(vertical: 10), | ||
child: Column( | ||
children: <Widget>[ | ||
Text(count.toString()), | ||
Text(text, style: TextStyle(fontSize: 13)) | ||
], | ||
), | ||
), | ||
onTap: () { | ||
Navigator.of(context).push(route); | ||
}, | ||
), | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters