mirror of
https://github.com/git-touch/git-touch
synced 2025-03-05 11:48:02 +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 starCount;
|
||||||
int forksCount;
|
int forksCount;
|
||||||
String visibility;
|
String visibility;
|
||||||
|
DateTime createdAt;
|
||||||
|
|
||||||
GitlabUserProject();
|
GitlabUserProject();
|
||||||
|
|
||||||
|
@ -16,7 +16,10 @@ GitlabUserProject _$GitlabUserProjectFromJson(Map<String, dynamic> json) {
|
|||||||
..description = json['description'] as String
|
..description = json['description'] as String
|
||||||
..starCount = json['star_count'] as int
|
..starCount = json['star_count'] as int
|
||||||
..forksCount = json['forks_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) =>
|
Map<String, dynamic> _$GitlabUserProjectToJson(GitlabUserProject instance) =>
|
||||||
@ -28,6 +31,7 @@ Map<String, dynamic> _$GitlabUserProjectToJson(GitlabUserProject instance) =>
|
|||||||
'star_count': instance.starCount,
|
'star_count': instance.starCount,
|
||||||
'forks_count': instance.forksCount,
|
'forks_count': instance.forksCount,
|
||||||
'visibility': instance.visibility,
|
'visibility': instance.visibility,
|
||||||
|
'created_at': instance.createdAt?.toIso8601String(),
|
||||||
};
|
};
|
||||||
|
|
||||||
GitlabUser _$GitlabUserFromJson(Map<String, dynamic> json) {
|
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:provider/provider.dart';
|
||||||
import 'package:tuple/tuple.dart';
|
import 'package:tuple/tuple.dart';
|
||||||
import 'package:git_touch/utils/utils.dart';
|
import 'package:git_touch/utils/utils.dart';
|
||||||
|
import 'package:timeago/timeago.dart' as timeago;
|
||||||
|
|
||||||
final gitlabUserRouter = RouterScreen(
|
final gitlabUserRouter = RouterScreen(
|
||||||
'/gitlab/user/:id',
|
'/gitlab/user/:id',
|
||||||
@ -21,19 +22,6 @@ class GitlabUserScreen extends StatelessWidget {
|
|||||||
GitlabUserScreen(this.id);
|
GitlabUserScreen(this.id);
|
||||||
bool get isViewer => id == null;
|
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
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return RefreshStatefulScaffold<
|
return RefreshStatefulScaffold<
|
||||||
@ -74,14 +62,16 @@ class GitlabUserScreen extends StatelessWidget {
|
|||||||
Column(
|
Column(
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
for (var v in projects)
|
for (var v in projects)
|
||||||
RepositoryItem(
|
RepositoryItem.gl(
|
||||||
|
id: v.id,
|
||||||
owner: v.owner.username,
|
owner: v.owner.username,
|
||||||
avatarUrl: v.owner.avatarUrl,
|
avatarUrl: v.owner.avatarUrl,
|
||||||
name: v.name,
|
name: v.name,
|
||||||
description: v.description,
|
description: v.description,
|
||||||
starCount: v.starCount,
|
starCount: v.starCount,
|
||||||
forkCount: v.forksCount,
|
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:flutter/material.dart';
|
||||||
import 'package:git_touch/graphql/gh.dart';
|
import 'package:git_touch/graphql/gh.dart';
|
||||||
import 'package:git_touch/scaffolds/list_stateful.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/widgets/app_bar_title.dart';
|
||||||
import 'package:git_touch/models/auth.dart';
|
import 'package:git_touch/models/auth.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
|
@ -33,6 +33,21 @@ class RepositoryItem extends StatelessWidget {
|
|||||||
@required this.url,
|
@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({
|
RepositoryItem.gh({
|
||||||
@required this.owner,
|
@required this.owner,
|
||||||
@required this.avatarUrl,
|
@required this.avatarUrl,
|
||||||
@ -45,8 +60,8 @@ class RepositoryItem extends StatelessWidget {
|
|||||||
this.note,
|
this.note,
|
||||||
@required bool isPrivate,
|
@required bool isPrivate,
|
||||||
@required bool isFork,
|
@required bool isFork,
|
||||||
}) : this.iconData = _buildIconData(isPrivate, isFork),
|
}) : iconData = _buildIconData(isPrivate, isFork),
|
||||||
this.url = '$owner/$name';
|
url = '$owner/$name';
|
||||||
|
|
||||||
static IconData _buildIconData(bool isPrivate, bool isFork) {
|
static IconData _buildIconData(bool isPrivate, bool isFork) {
|
||||||
if (isPrivate == true) return Octicons.lock;
|
if (isPrivate == true) return Octicons.lock;
|
||||||
@ -54,6 +69,19 @@ class RepositoryItem extends StatelessWidget {
|
|||||||
return null;
|
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
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final theme = Provider.of<ThemeModel>(context);
|
final theme = Provider.of<ThemeModel>(context);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user