1
0
mirror of https://github.com/git-touch/git-touch synced 2024-12-19 19:54:54 +01:00
git-touch-android-ios-app/lib/widgets/user_contributions.dart

57 lines
1.5 KiB
Dart
Raw Normal View History

2019-10-06 14:25:07 +02:00
import 'package:flutter/material.dart';
2019-11-08 11:13:17 +01:00
import 'package:git_touch/models/theme.dart';
2019-10-06 14:25:07 +02:00
import 'package:git_touch/utils/utils.dart';
import 'package:github_contributions/github_contributions.dart';
2019-11-08 11:13:17 +01:00
import 'package:provider/provider.dart';
2019-10-06 14:25:07 +02:00
class UserContributions extends StatelessWidget {
final List<ContributionsInfo> contributions;
UserContributions(this.contributions);
@override
Widget build(BuildContext context) {
2019-11-08 11:13:17 +01:00
final theme = Provider.of<ThemeModel>(context);
2019-10-06 14:25:07 +02:00
final row = Row(
children: <Widget>[],
crossAxisAlignment: CrossAxisAlignment.start,
);
Column column;
contributions.asMap().forEach((i, v) {
2019-11-08 11:13:17 +01:00
var color = convertColor(v.color);
if (theme.brightness == Brightness.dark) {
color = Color.fromRGBO(
0xff - color.red, 0xff - color.green, 0xff - color.blue, 1);
}
final rect = SizedBox(
2019-10-06 14:25:07 +02:00
width: 10,
height: 10,
child: DecoratedBox(
2019-11-08 11:13:17 +01:00
decoration: BoxDecoration(color: color),
2019-10-06 14:25:07 +02:00
),
);
if (i % 7 == 0) {
column = Column(children: <Widget>[rect]);
row.children.add(column);
row.children.add(SizedBox(width: 3));
} else {
column.children.add(SizedBox(height: 3));
column.children.add(rect);
}
});
return Container(
2019-11-08 11:13:17 +01:00
color: theme.palette.background,
2019-10-06 14:25:07 +02:00
padding: CommonStyle.padding,
child: SingleChildScrollView(
scrollDirection: Axis.horizontal,
reverse: true,
child: row,
),
);
}
}