mirror of
https://github.com/git-touch/git-touch
synced 2024-12-15 17:59:35 +01:00
improvement(gitlab): repo item style
This commit is contained in:
parent
65e45f6b7f
commit
3db932b284
@ -11,6 +11,7 @@ class GitlabUserProject {
|
||||
int starCount;
|
||||
int forksCount;
|
||||
String visibility;
|
||||
DateTime createdAt;
|
||||
|
||||
GitlabUserProject();
|
||||
|
||||
|
@ -16,7 +16,10 @@ GitlabUserProject _$GitlabUserProjectFromJson(Map<String, dynamic> json) {
|
||||
..description = json['description'] as String
|
||||
..starCount = json['star_count'] as int
|
||||
..forksCount = json['forks_count'] as int
|
||||
..visibility = json['visibility'] as String;
|
||||
..visibility = json['visibility'] as String
|
||||
..createdAt = json['created_at'] == null
|
||||
? null
|
||||
: DateTime.parse(json['created_at'] as String);
|
||||
}
|
||||
|
||||
Map<String, dynamic> _$GitlabUserProjectToJson(GitlabUserProject instance) =>
|
||||
@ -28,6 +31,7 @@ Map<String, dynamic> _$GitlabUserProjectToJson(GitlabUserProject instance) =>
|
||||
'star_count': instance.starCount,
|
||||
'forks_count': instance.forksCount,
|
||||
'visibility': instance.visibility,
|
||||
'created_at': instance.createdAt?.toIso8601String(),
|
||||
};
|
||||
|
||||
GitlabUser _$GitlabUserFromJson(Map<String, dynamic> json) {
|
||||
|
@ -10,6 +10,7 @@ import 'package:git_touch/widgets/user_item.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:tuple/tuple.dart';
|
||||
import 'package:git_touch/utils/utils.dart';
|
||||
import 'package:timeago/timeago.dart' as timeago;
|
||||
|
||||
final gitlabUserRouter = RouterScreen(
|
||||
'/gitlab/user/:id',
|
||||
@ -21,19 +22,6 @@ class GitlabUserScreen extends StatelessWidget {
|
||||
GitlabUserScreen(this.id);
|
||||
bool get isViewer => id == null;
|
||||
|
||||
static _getGitlabIcon(String visibility) {
|
||||
switch (visibility) {
|
||||
case 'internal':
|
||||
return FontAwesome.shield;
|
||||
case 'public':
|
||||
return FontAwesome.globe;
|
||||
case 'private':
|
||||
return FontAwesome.lock;
|
||||
default:
|
||||
return Octicons.repo;
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return RefreshStatefulScaffold<
|
||||
@ -74,14 +62,16 @@ class GitlabUserScreen extends StatelessWidget {
|
||||
Column(
|
||||
children: <Widget>[
|
||||
for (var v in projects)
|
||||
RepositoryItem(
|
||||
RepositoryItem.gl(
|
||||
id: v.id,
|
||||
owner: v.owner.username,
|
||||
avatarUrl: v.owner.avatarUrl,
|
||||
name: v.name,
|
||||
description: v.description,
|
||||
starCount: v.starCount,
|
||||
forkCount: v.forksCount,
|
||||
url: '/gitlab/projects/${v.id}',
|
||||
note: 'Created ${timeago.format(v.createdAt)}',
|
||||
visibility: v.visibility,
|
||||
)
|
||||
],
|
||||
)
|
||||
|
@ -1,7 +1,6 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:git_touch/graphql/gh.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:git_touch/models/auth.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
@ -33,6 +33,21 @@ class RepositoryItem extends StatelessWidget {
|
||||
@required this.url,
|
||||
});
|
||||
|
||||
RepositoryItem.gl({
|
||||
@required id,
|
||||
@required this.owner,
|
||||
@required this.avatarUrl,
|
||||
@required this.name,
|
||||
@required this.description,
|
||||
@required this.starCount,
|
||||
@required this.forkCount,
|
||||
@required visibility,
|
||||
this.primaryLanguageName,
|
||||
this.primaryLanguageColor,
|
||||
this.note,
|
||||
}) : url = '/gitlab/projects/$id',
|
||||
iconData = _buildGlIconData(visibility);
|
||||
|
||||
RepositoryItem.gh({
|
||||
@required this.owner,
|
||||
@required this.avatarUrl,
|
||||
@ -45,8 +60,8 @@ class RepositoryItem extends StatelessWidget {
|
||||
this.note,
|
||||
@required bool isPrivate,
|
||||
@required bool isFork,
|
||||
}) : this.iconData = _buildIconData(isPrivate, isFork),
|
||||
this.url = '$owner/$name';
|
||||
}) : iconData = _buildIconData(isPrivate, isFork),
|
||||
url = '$owner/$name';
|
||||
|
||||
static IconData _buildIconData(bool isPrivate, bool isFork) {
|
||||
if (isPrivate == true) return Octicons.lock;
|
||||
@ -54,6 +69,19 @@ class RepositoryItem extends StatelessWidget {
|
||||
return null;
|
||||
}
|
||||
|
||||
static IconData _buildGlIconData(String visibility) {
|
||||
switch (visibility) {
|
||||
case 'internal':
|
||||
return FontAwesome.shield;
|
||||
case 'public':
|
||||
return FontAwesome.globe;
|
||||
case 'private':
|
||||
return FontAwesome.lock;
|
||||
default:
|
||||
return Octicons.repo;
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final theme = Provider.of<ThemeModel>(context);
|
||||
|
Loading…
Reference in New Issue
Block a user