2021-01-09 17:52:45 +01:00
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:flutter/cupertino.dart';
|
|
|
|
import 'package:git_touch/models/gitee.dart';
|
|
|
|
import 'package:git_touch/models/theme.dart';
|
|
|
|
import 'package:git_touch/scaffolds/list_stateful.dart';
|
|
|
|
import 'package:git_touch/utils/utils.dart';
|
|
|
|
import 'package:git_touch/widgets/app_bar_title.dart';
|
|
|
|
import 'package:provider/provider.dart';
|
|
|
|
import 'package:git_touch/models/auth.dart';
|
2021-02-03 05:04:41 +01:00
|
|
|
import 'package:flutter_gen/gen_l10n/S.dart';
|
2021-01-09 17:52:45 +01:00
|
|
|
|
|
|
|
class GeContributorsScreen extends StatelessWidget {
|
|
|
|
final String owner;
|
|
|
|
final String name;
|
|
|
|
GeContributorsScreen(this.owner, this.name);
|
|
|
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return ListStatefulScaffold<GiteeContributor, int>(
|
2021-05-16 09:16:35 +02:00
|
|
|
title: AppBarTitle(AppLocalizations.of(context)!.contributors),
|
2021-01-09 17:52:45 +01:00
|
|
|
fetch: (page) async {
|
|
|
|
page = page ?? 1;
|
|
|
|
final res = await context
|
|
|
|
.read<AuthModel>()
|
|
|
|
.fetchGiteeWithPage('/repos/$owner/$name/contributors')
|
|
|
|
.then((v) {
|
|
|
|
return [
|
|
|
|
for (var contributor in v.data)
|
|
|
|
GiteeContributor.fromJson(contributor)
|
|
|
|
];
|
|
|
|
});
|
|
|
|
return ListPayload(
|
|
|
|
cursor: page + 1,
|
|
|
|
items: res,
|
|
|
|
hasMore: res.isNotEmpty,
|
|
|
|
);
|
|
|
|
},
|
|
|
|
itemBuilder: (v) {
|
|
|
|
final theme = context.read<ThemeModel>();
|
|
|
|
return Container(
|
|
|
|
padding: CommonStyle.padding,
|
|
|
|
child: Row(
|
|
|
|
children: <Widget>[
|
|
|
|
SizedBox(width: 10),
|
|
|
|
Expanded(
|
|
|
|
child: Column(
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
children: <Widget>[
|
|
|
|
Row(
|
|
|
|
children: <Widget>[
|
|
|
|
Text(
|
2021-05-16 09:16:35 +02:00
|
|
|
v.name!,
|
2021-01-09 17:52:45 +01:00
|
|
|
style: TextStyle(
|
|
|
|
color: theme.palette.primary,
|
|
|
|
fontSize: 18,
|
|
|
|
fontWeight: FontWeight.w600,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
SizedBox(height: 6),
|
|
|
|
if (v.contributions != null)
|
|
|
|
DefaultTextStyle(
|
|
|
|
style: TextStyle(
|
|
|
|
color: theme.palette.secondaryText,
|
|
|
|
fontSize: 16,
|
|
|
|
),
|
|
|
|
child: Text(
|
|
|
|
"Contributions: " + v.contributions.toString()),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
)
|
|
|
|
],
|
|
|
|
),
|
|
|
|
);
|
|
|
|
},
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|