diff --git a/lib/screens/user.dart b/lib/screens/user.dart index 7b5ece4..6c0fbd6 100644 --- a/lib/screens/user.dart +++ b/lib/screens/user.dart @@ -4,7 +4,6 @@ import 'package:git_touch/widgets/table_view.dart'; import 'package:primer/primer.dart'; import 'package:url_launcher/url_launcher.dart'; import 'package:share/share.dart'; -import 'package:flutter_svg/flutter_svg.dart'; import 'package:github_contributions/github_contributions.dart'; import 'package:git_touch/models/settings.dart'; import 'package:provider/provider.dart'; @@ -119,12 +118,49 @@ class _UserScreenState extends State { ); } + Widget _buildContributions(List contributions) { + var row = Row( + children: [], + crossAxisAlignment: CrossAxisAlignment.start, + ); + Column column; + + contributions.asMap().forEach((i, v) { + var rect = SizedBox( + width: 10, + height: 10, + child: DecoratedBox( + decoration: BoxDecoration( + color: convertColor(v.color), + ), + ), + ); + + if (i % 7 == 0) { + column = Column(children: [rect]); + row.children.add(column); + row.children.add(SizedBox(width: 3)); + } else { + column.children.add(SizedBox(height: 3)); + column.children.add(rect); + } + }); + + return Container( + padding: EdgeInsets.all(10), + child: SingleChildScrollView( + scrollDirection: Axis.horizontal, + child: row, + ), + ); + } + @override Widget build(BuildContext context) { return RefreshScaffold( onRefresh: () { return Future.wait( - [query(), getContributionsSvg(widget.login)], + [query(), getContributions(widget.login)], ); }, title: Text(widget.login), @@ -177,7 +213,7 @@ class _UserScreenState extends State { }, bodyBuilder: (data) { var payload = data[0]; - var contributions = data[1]; + var contributions = data[1] as List; return Column( crossAxisAlignment: CrossAxisAlignment.stretch, @@ -246,13 +282,7 @@ class _UserScreenState extends State { ), ]), BorderView(height: 10), - Container( - padding: EdgeInsets.all(10), - child: SingleChildScrollView( - scrollDirection: Axis.horizontal, - child: SvgPicture.string(contributions), - ), - ), + _buildContributions(contributions), BorderView(height: 10), TableView(items: [ _buildTableViewItem( diff --git a/pubspec.yaml b/pubspec.yaml index 4235a4e..de391a9 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -26,7 +26,7 @@ dependencies: nanoid: ^0.0.6 share: ^0.6.0 flutter_vector_icons: ^0.2.1 - github_contributions: ^0.1.1 + github_contributions: ^0.2.0 flutter_svg: ^0.13.0 launch_review: ^2.0.0 flutter_highlight: ^0.3.0