mirror of
https://github.com/git-touch/git-touch
synced 2025-03-07 20:57:44 +01:00
improvement: repository languages
This commit is contained in:
parent
9bcd742c75
commit
4215ce8604
@ -18,7 +18,6 @@ import 'package:provider/provider.dart';
|
|||||||
import 'package:git_touch/models/theme.dart';
|
import 'package:git_touch/models/theme.dart';
|
||||||
import 'package:tuple/tuple.dart';
|
import 'package:tuple/tuple.dart';
|
||||||
import 'package:git_touch/widgets/action_button.dart';
|
import 'package:git_touch/widgets/action_button.dart';
|
||||||
import 'package:charts_flutter/flutter.dart' as charts;
|
|
||||||
|
|
||||||
final repositoryRouter = RouterScreen('/:owner/:name', (context, params) {
|
final repositoryRouter = RouterScreen('/:owner/:name', (context, params) {
|
||||||
if (params['ref'] == null) {
|
if (params['ref'] == null) {
|
||||||
@ -60,6 +59,53 @@ class RepositoryScreen extends StatelessWidget {
|
|||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Widget _buildLanguages(BuildContext context, GhRepoRepository repo) {
|
||||||
|
final theme = Provider.of<ThemeModel>(context);
|
||||||
|
return Container(
|
||||||
|
color: theme.paletteOf(context).background,
|
||||||
|
padding: CommonStyle.padding,
|
||||||
|
height: 300,
|
||||||
|
child: SingleChildScrollView(
|
||||||
|
child: Table(children: [
|
||||||
|
for (final edge in repo.languages.edges)
|
||||||
|
TableRow(children: [
|
||||||
|
Container(
|
||||||
|
padding: CommonStyle.padding,
|
||||||
|
child: Row(children: <Widget>[
|
||||||
|
Container(
|
||||||
|
width: 18,
|
||||||
|
height: 18,
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: convertColor(edge.node.color),
|
||||||
|
shape: BoxShape.circle,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
SizedBox(width: 8),
|
||||||
|
Text(
|
||||||
|
edge.node.name,
|
||||||
|
style: TextStyle(
|
||||||
|
color: theme.paletteOf(context).text,
|
||||||
|
fontSize: 18,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
]),
|
||||||
|
),
|
||||||
|
Container(
|
||||||
|
padding: CommonStyle.padding,
|
||||||
|
child: Text(
|
||||||
|
'${(edge.size / repo.languages.totalSize * 100).toStringAsFixed(1)}%',
|
||||||
|
style: TextStyle(
|
||||||
|
color: theme.paletteOf(context).secondaryText,
|
||||||
|
fontSize: 18,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
])
|
||||||
|
]),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return RefreshStatefulScaffold<Tuple2<GhRepoRepository, String>>(
|
return RefreshStatefulScaffold<Tuple2<GhRepoRepository, String>>(
|
||||||
@ -265,40 +311,7 @@ class RepositoryScreen extends StatelessWidget {
|
|||||||
onPressed: () {
|
onPressed: () {
|
||||||
showCupertinoModalPopup(
|
showCupertinoModalPopup(
|
||||||
context: context,
|
context: context,
|
||||||
builder: (context) {
|
builder: (context) => _buildLanguages(context, repo),
|
||||||
return Container(
|
|
||||||
color: theme.paletteOf(context).background,
|
|
||||||
padding: EdgeInsets.all(40),
|
|
||||||
height: 400,
|
|
||||||
child: charts.PieChart(
|
|
||||||
[
|
|
||||||
charts.Series<GhRepoLanguageEdge, String>(
|
|
||||||
id: 'languages',
|
|
||||||
domainFn: (v, _) => v.node.name,
|
|
||||||
measureFn: (v, _) => v.size,
|
|
||||||
colorFn: (v, _) =>
|
|
||||||
charts.Color.fromHex(code: v.node.color),
|
|
||||||
data: repo.languages.edges,
|
|
||||||
labelAccessorFn: (v, _) => v.node.name,
|
|
||||||
)
|
|
||||||
],
|
|
||||||
defaultRenderer: charts.ArcRendererConfig(
|
|
||||||
arcRendererDecorators: [
|
|
||||||
charts.ArcLabelDecorator(
|
|
||||||
insideLabelStyleSpec: charts.TextStyleSpec(
|
|
||||||
fontSize: 20,
|
|
||||||
color: charts.Color.white,
|
|
||||||
),
|
|
||||||
outsideLabelStyleSpec: charts.TextStyleSpec(
|
|
||||||
fontSize: 20,
|
|
||||||
color: charts.Color.black,
|
|
||||||
),
|
|
||||||
)
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
child: Container(
|
child: Container(
|
||||||
|
@ -43,7 +43,6 @@ dependencies:
|
|||||||
# ref: patch-1
|
# ref: patch-1
|
||||||
gql_link: ^0.2.0
|
gql_link: ^0.2.0
|
||||||
fluro: ^1.5.1
|
fluro: ^1.5.1
|
||||||
charts_flutter: ^0.8.1
|
|
||||||
package_info: ^0.4.0
|
package_info: ^0.4.0
|
||||||
|
|
||||||
# The following adds the Cupertino Icons font to your application.
|
# The following adds the Cupertino Icons font to your application.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user