mirror of
https://github.com/git-touch/git-touch
synced 2025-02-21 14:01:02 +01:00
refactor: repo header
This commit is contained in:
parent
bc436d2f9e
commit
3272780515
@ -7,9 +7,9 @@ import 'package:git_touch/models/gitlab.dart';
|
||||
import 'package:git_touch/scaffolds/refresh_stateful.dart';
|
||||
import 'package:git_touch/utils/utils.dart';
|
||||
import 'package:git_touch/widgets/app_bar_title.dart';
|
||||
import 'package:git_touch/widgets/avatar.dart';
|
||||
import 'package:git_touch/widgets/entry_item.dart';
|
||||
import 'package:git_touch/widgets/markdown_view.dart';
|
||||
import 'package:git_touch/widgets/repo_header.dart';
|
||||
import 'package:git_touch/widgets/table_view.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:git_touch/models/theme.dart';
|
||||
@ -72,44 +72,19 @@ class GitlabProjectScreen extends StatelessWidget {
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: <Widget>[
|
||||
Container(
|
||||
padding: CommonStyle.padding,
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: join(SizedBox(height: 12), [
|
||||
Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
Avatar(
|
||||
url: p.avatarUrl,
|
||||
size: AvatarSize.small,
|
||||
linkUrl: '/${p.namespace.name}',
|
||||
),
|
||||
SizedBox(width: 8),
|
||||
Text(
|
||||
'${p.namespace.name} / ${p.name}',
|
||||
style: TextStyle(
|
||||
fontSize: 20,
|
||||
color: theme.palette.primary,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
if (p.description != null && p.description.isNotEmpty)
|
||||
Text(
|
||||
p.description,
|
||||
style: TextStyle(
|
||||
color: theme.palette.secondaryText,
|
||||
fontSize: 17,
|
||||
),
|
||||
),
|
||||
RepoHeader(
|
||||
avatarUrl: p.avatarUrl,
|
||||
avatarLink: '/${p.namespace.name}',
|
||||
owner: p.namespace.name,
|
||||
name: p.name,
|
||||
description: p.description,
|
||||
trailings: <Widget>[
|
||||
if (badges.isNotEmpty)
|
||||
Wrap(spacing: 4, runSpacing: 4, children: [
|
||||
for (var label in badges)
|
||||
SvgPicture.network(label.renderedImageUrl, height: 20),
|
||||
])
|
||||
]),
|
||||
),
|
||||
],
|
||||
),
|
||||
CommonStyle.border,
|
||||
Row(
|
||||
|
@ -7,12 +7,12 @@ import 'package:git_touch/models/auth.dart';
|
||||
import 'package:git_touch/scaffolds/refresh_stateful.dart';
|
||||
import 'package:git_touch/utils/utils.dart';
|
||||
import 'package:git_touch/widgets/app_bar_title.dart';
|
||||
import 'package:git_touch/widgets/avatar.dart';
|
||||
import 'package:git_touch/widgets/entry_item.dart';
|
||||
import 'package:git_touch/widgets/label.dart';
|
||||
import 'package:git_touch/widgets/mutation_button.dart';
|
||||
import 'package:git_touch/widgets/link.dart';
|
||||
|
||||
import 'package:git_touch/widgets/markdown_view.dart';
|
||||
import 'package:git_touch/widgets/repo_header.dart';
|
||||
import 'package:git_touch/widgets/table_view.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:git_touch/models/theme.dart';
|
||||
@ -152,31 +152,14 @@ class RepositoryScreen extends StatelessWidget {
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: <Widget>[
|
||||
Container(
|
||||
padding: CommonStyle.padding,
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: join(SizedBox(height: 12), [
|
||||
Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
Avatar(
|
||||
url: repo.owner.avatarUrl,
|
||||
size: AvatarSize.small,
|
||||
linkUrl: '/$owner',
|
||||
),
|
||||
SizedBox(width: 8),
|
||||
Text(
|
||||
'$owner / $name',
|
||||
style: TextStyle(
|
||||
fontSize: 20,
|
||||
color: theme.palette.primary,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
Row(
|
||||
children: <Widget>[
|
||||
RepoHeader(
|
||||
avatarUrl: repo.owner.avatarUrl,
|
||||
avatarLink: '/${repo.owner.login}',
|
||||
name: repo.name,
|
||||
owner: repo.owner.login,
|
||||
description: repo.description,
|
||||
homepageUrl: repo.homepageUrl,
|
||||
actions: [
|
||||
MutationButton(
|
||||
text: repo.viewerHasStarred ? 'Unstar' : 'Star',
|
||||
onPressed: () async {
|
||||
@ -189,8 +172,8 @@ class RepositoryScreen extends StatelessWidget {
|
||||
),
|
||||
);
|
||||
setState(() {
|
||||
repo.viewerHasStarred = res.data.removeStar
|
||||
?.starrable?.viewerHasStarred ??
|
||||
repo.viewerHasStarred =
|
||||
res.data.removeStar?.starrable?.viewerHasStarred ??
|
||||
res.data.addStar.starrable.viewerHasStarred;
|
||||
});
|
||||
},
|
||||
@ -245,26 +228,7 @@ class RepositoryScreen extends StatelessWidget {
|
||||
// },
|
||||
// ),
|
||||
],
|
||||
),
|
||||
if (repo.description != null && repo.description.isNotEmpty)
|
||||
Text(
|
||||
repo.description,
|
||||
style: TextStyle(
|
||||
color: theme.palette.secondaryText,
|
||||
fontSize: 17,
|
||||
),
|
||||
),
|
||||
if (repo.homepageUrl != null && repo.homepageUrl.isNotEmpty)
|
||||
Link(
|
||||
url: repo.homepageUrl,
|
||||
child: Text(
|
||||
repo.homepageUrl,
|
||||
style: TextStyle(
|
||||
color: theme.palette.primary,
|
||||
fontSize: 17,
|
||||
),
|
||||
),
|
||||
),
|
||||
trailings: <Widget>[
|
||||
if (repo.repositoryTopics.nodes.isNotEmpty)
|
||||
// TODO: link
|
||||
Wrap(
|
||||
@ -279,8 +243,7 @@ class RepositoryScreen extends StatelessWidget {
|
||||
);
|
||||
}).toList(),
|
||||
)
|
||||
]),
|
||||
),
|
||||
],
|
||||
),
|
||||
CommonStyle.border,
|
||||
Row(
|
||||
|
80
lib/widgets/repo_header.dart
Normal file
80
lib/widgets/repo_header.dart
Normal file
@ -0,0 +1,80 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:git_touch/models/theme.dart';
|
||||
import 'package:git_touch/utils/utils.dart';
|
||||
import 'package:git_touch/widgets/avatar.dart';
|
||||
import 'package:git_touch/widgets/link.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
class RepoHeader extends StatelessWidget {
|
||||
final String avatarUrl;
|
||||
final String avatarLink;
|
||||
final String owner;
|
||||
final String name;
|
||||
final String description;
|
||||
final String homepageUrl;
|
||||
final List<Widget> actions;
|
||||
final List<Widget> trailings;
|
||||
|
||||
RepoHeader({
|
||||
@required this.avatarUrl,
|
||||
@required this.avatarLink,
|
||||
@required this.owner,
|
||||
@required this.name,
|
||||
@required this.description,
|
||||
this.homepageUrl,
|
||||
this.actions,
|
||||
this.trailings,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final theme = Provider.of<ThemeModel>(context);
|
||||
return Container(
|
||||
padding: CommonStyle.padding,
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: join(SizedBox(height: 12), [
|
||||
Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
Avatar(
|
||||
url: avatarUrl,
|
||||
size: AvatarSize.small,
|
||||
linkUrl: '/$owner',
|
||||
),
|
||||
SizedBox(width: 8),
|
||||
Text(
|
||||
'$owner / $name',
|
||||
style: TextStyle(
|
||||
fontSize: 20,
|
||||
color: theme.palette.primary,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
if (actions != null) ...actions,
|
||||
if (description != null && description.isNotEmpty)
|
||||
Text(
|
||||
description,
|
||||
style: TextStyle(
|
||||
color: theme.palette.secondaryText,
|
||||
fontSize: 17,
|
||||
),
|
||||
),
|
||||
if (homepageUrl != null && homepageUrl.isNotEmpty)
|
||||
Link(
|
||||
url: homepageUrl,
|
||||
child: Text(
|
||||
homepageUrl,
|
||||
style: TextStyle(
|
||||
color: theme.palette.primary,
|
||||
fontSize: 17,
|
||||
),
|
||||
),
|
||||
),
|
||||
if (trailings != null) ...trailings
|
||||
]),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user