Repository list sort by date
All checks were successful
ci/woodpecker/push/flutterBuild Pipeline was successful
All checks were successful
ci/woodpecker/push/flutterBuild Pipeline was successful
This commit is contained in:
parent
69704a20f0
commit
29a89b951c
4 changed files with 9 additions and 6 deletions
|
@ -21,7 +21,7 @@ class RepoBloc extends Bloc<RepoEvent, RepoState> {
|
|||
if (state.hasReachedMax) return;
|
||||
try {
|
||||
if (state.status == RepoStatus.initial) {
|
||||
final repos = await giteaService.getUserRepositories();
|
||||
final repos = await giteaService.getUserRepositories(1,100);
|
||||
return emit(state.copyWith(
|
||||
status: RepoStatus.success,
|
||||
repos: repos,
|
||||
|
@ -30,7 +30,7 @@ class RepoBloc extends Bloc<RepoEvent, RepoState> {
|
|||
error_message: null,
|
||||
));
|
||||
}
|
||||
final repos = await giteaService.getUserRepositories(state.loadedPages+1);
|
||||
final repos = await giteaService.getUserRepositories(state.loadedPages+1,100);
|
||||
emit(repos.isEmpty
|
||||
? state.copyWith(hasReachedMax: true)
|
||||
: state.copyWith(
|
||||
|
|
|
@ -29,7 +29,7 @@ class Repository extends Equatable {
|
|||
String? defaultBranch;
|
||||
bool? archived;
|
||||
String? createdAt;
|
||||
String? updatedAt;
|
||||
DateTime? updatedAt;
|
||||
Permissions? permissions;
|
||||
bool? hasIssues;
|
||||
InternalTracker? internalTracker;
|
||||
|
@ -121,7 +121,7 @@ class Repository extends Equatable {
|
|||
defaultBranch = json['default_branch'];
|
||||
archived = json['archived'];
|
||||
createdAt = json['created_at'];
|
||||
updatedAt = json['updated_at'];
|
||||
updatedAt = DateTime.parse(json['updated_at']);
|
||||
permissions = json['permissions'] != null
|
||||
? Permissions.fromJson(json['permissions'])
|
||||
: null;
|
||||
|
|
|
@ -34,9 +34,12 @@ class GiteaService {
|
|||
);
|
||||
if (response.statusCode == 200) {
|
||||
final body = json.decode(response.body) as List;
|
||||
return body.map((dynamic json) {
|
||||
var result = body.map((dynamic json) {
|
||||
return Repository.fromJson(json);
|
||||
}).toList();
|
||||
|
||||
result.sort((a,b) => -1*a.updatedAt!.compareTo(b.updatedAt!));
|
||||
return result;
|
||||
}
|
||||
throw Exception('error fetching posts');
|
||||
}
|
||||
|
|
|
@ -92,7 +92,7 @@ class RepoListItem extends StatelessWidget {
|
|||
final textTheme = Theme.of(context).textTheme;
|
||||
return Material(
|
||||
child: ListTile(
|
||||
leading: Text('${post.id}', style: textTheme.caption),
|
||||
leading: Text('${post.updatedAt!.toString()}', style: textTheme.caption),
|
||||
title: Text(post.name),
|
||||
isThreeLine: true,
|
||||
subtitle: Text(post.owner.username!),
|
||||
|
|
Loading…
Reference in a new issue