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;
|
if (state.hasReachedMax) return;
|
||||||
try {
|
try {
|
||||||
if (state.status == RepoStatus.initial) {
|
if (state.status == RepoStatus.initial) {
|
||||||
final repos = await giteaService.getUserRepositories();
|
final repos = await giteaService.getUserRepositories(1,100);
|
||||||
return emit(state.copyWith(
|
return emit(state.copyWith(
|
||||||
status: RepoStatus.success,
|
status: RepoStatus.success,
|
||||||
repos: repos,
|
repos: repos,
|
||||||
|
@ -30,7 +30,7 @@ class RepoBloc extends Bloc<RepoEvent, RepoState> {
|
||||||
error_message: null,
|
error_message: null,
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
final repos = await giteaService.getUserRepositories(state.loadedPages+1);
|
final repos = await giteaService.getUserRepositories(state.loadedPages+1,100);
|
||||||
emit(repos.isEmpty
|
emit(repos.isEmpty
|
||||||
? state.copyWith(hasReachedMax: true)
|
? state.copyWith(hasReachedMax: true)
|
||||||
: state.copyWith(
|
: state.copyWith(
|
||||||
|
|
|
@ -29,7 +29,7 @@ class Repository extends Equatable {
|
||||||
String? defaultBranch;
|
String? defaultBranch;
|
||||||
bool? archived;
|
bool? archived;
|
||||||
String? createdAt;
|
String? createdAt;
|
||||||
String? updatedAt;
|
DateTime? updatedAt;
|
||||||
Permissions? permissions;
|
Permissions? permissions;
|
||||||
bool? hasIssues;
|
bool? hasIssues;
|
||||||
InternalTracker? internalTracker;
|
InternalTracker? internalTracker;
|
||||||
|
@ -121,7 +121,7 @@ class Repository extends Equatable {
|
||||||
defaultBranch = json['default_branch'];
|
defaultBranch = json['default_branch'];
|
||||||
archived = json['archived'];
|
archived = json['archived'];
|
||||||
createdAt = json['created_at'];
|
createdAt = json['created_at'];
|
||||||
updatedAt = json['updated_at'];
|
updatedAt = DateTime.parse(json['updated_at']);
|
||||||
permissions = json['permissions'] != null
|
permissions = json['permissions'] != null
|
||||||
? Permissions.fromJson(json['permissions'])
|
? Permissions.fromJson(json['permissions'])
|
||||||
: null;
|
: null;
|
||||||
|
|
|
@ -34,9 +34,12 @@ class GiteaService {
|
||||||
);
|
);
|
||||||
if (response.statusCode == 200) {
|
if (response.statusCode == 200) {
|
||||||
final body = json.decode(response.body) as List;
|
final body = json.decode(response.body) as List;
|
||||||
return body.map((dynamic json) {
|
var result = body.map((dynamic json) {
|
||||||
return Repository.fromJson(json);
|
return Repository.fromJson(json);
|
||||||
}).toList();
|
}).toList();
|
||||||
|
|
||||||
|
result.sort((a,b) => -1*a.updatedAt!.compareTo(b.updatedAt!));
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
throw Exception('error fetching posts');
|
throw Exception('error fetching posts');
|
||||||
}
|
}
|
||||||
|
|
|
@ -92,7 +92,7 @@ class RepoListItem extends StatelessWidget {
|
||||||
final textTheme = Theme.of(context).textTheme;
|
final textTheme = Theme.of(context).textTheme;
|
||||||
return Material(
|
return Material(
|
||||||
child: ListTile(
|
child: ListTile(
|
||||||
leading: Text('${post.id}', style: textTheme.caption),
|
leading: Text('${post.updatedAt!.toString()}', style: textTheme.caption),
|
||||||
title: Text(post.name),
|
title: Text(post.name),
|
||||||
isThreeLine: true,
|
isThreeLine: true,
|
||||||
subtitle: Text(post.owner.username!),
|
subtitle: Text(post.owner.username!),
|
||||||
|
|
Loading…
Reference in a new issue