mirror of
https://github.com/git-touch/git-touch
synced 2025-02-20 13:30:38 +01:00
fix: pinnable item
This commit is contained in:
parent
7de4f1f78c
commit
e989ad9715
@ -18,38 +18,6 @@ class OrganizationScreen extends StatelessWidget {
|
||||
|
||||
OrganizationScreen(this.login);
|
||||
|
||||
Iterable<Widget> _buildRepos(payload) {
|
||||
String title;
|
||||
List items = [];
|
||||
|
||||
var pinnedItems = payload['pinnedItems']['nodes'] as List;
|
||||
var repositories = payload['pinnableItems']['nodes'] as List;
|
||||
|
||||
if (pinnedItems.isNotEmpty) {
|
||||
title = 'pinned repositories';
|
||||
items = pinnedItems;
|
||||
} else if (repositories.isNotEmpty) {
|
||||
title = 'popular repositories';
|
||||
items = repositories;
|
||||
}
|
||||
|
||||
items = items
|
||||
.where((x) => x != null)
|
||||
.toList(); // TODO: Pinned items may include somethings other than repo
|
||||
if (items.isEmpty) return [];
|
||||
|
||||
return [
|
||||
CommonStyle.verticalGap,
|
||||
if (title != null) TableViewHeader(title),
|
||||
...join(
|
||||
CommonStyle.border,
|
||||
items.map((item) {
|
||||
return RepositoryItem(item);
|
||||
}).toList(),
|
||||
)
|
||||
];
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return RefreshStatefulScaffold(
|
||||
@ -162,7 +130,8 @@ class OrganizationScreen extends StatelessWidget {
|
||||
),
|
||||
],
|
||||
),
|
||||
..._buildRepos(data),
|
||||
...buildPinnedItems(
|
||||
data['pinnedItems']['nodes'], data['pinnableItems']['nodes']),
|
||||
],
|
||||
);
|
||||
},
|
||||
|
@ -65,38 +65,6 @@ class UserScreen extends StatelessWidget {
|
||||
return data['user'];
|
||||
}
|
||||
|
||||
Iterable<Widget> _buildRepos(payload) {
|
||||
String title;
|
||||
List items = [];
|
||||
|
||||
var pinnedItems = payload['pinnedItems']['nodes'] as List;
|
||||
var repositories = payload['repositories']['nodes'] as List;
|
||||
|
||||
if (pinnedItems.isNotEmpty) {
|
||||
title = 'pinned repositories';
|
||||
items = pinnedItems;
|
||||
} else if (repositories.isNotEmpty) {
|
||||
title = 'popular repositories';
|
||||
items = repositories;
|
||||
}
|
||||
|
||||
items = items
|
||||
.where((x) => x != null)
|
||||
.toList(); // TODO: Pinned items may include somethings other than repo
|
||||
if (items.isEmpty) return [];
|
||||
|
||||
return [
|
||||
CommonStyle.verticalGap,
|
||||
if (title != null) TableViewHeader(title),
|
||||
...join(
|
||||
CommonStyle.border,
|
||||
items.map((item) {
|
||||
return RepositoryItem(item);
|
||||
}).toList(),
|
||||
),
|
||||
];
|
||||
}
|
||||
|
||||
Widget _buildContributions(List<ContributionsInfo> contributions) {
|
||||
final row = Row(
|
||||
children: <Widget>[],
|
||||
@ -260,7 +228,8 @@ class UserScreen extends StatelessWidget {
|
||||
),
|
||||
],
|
||||
),
|
||||
..._buildRepos(data),
|
||||
...buildPinnedItems(
|
||||
data['pinnedItems']['nodes'], data['repositories']['nodes']),
|
||||
CommonStyle.verticalGap,
|
||||
],
|
||||
);
|
||||
|
@ -6,6 +6,8 @@ import 'package:git_touch/models/theme.dart';
|
||||
import 'package:git_touch/screens/repository.dart';
|
||||
import 'package:git_touch/screens/user.dart';
|
||||
import 'package:git_touch/widgets/border_view.dart';
|
||||
import 'package:git_touch/widgets/repository_item.dart';
|
||||
import 'package:git_touch/widgets/table_view.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
import 'package:primer/primer.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
@ -173,3 +175,32 @@ launchUrl(String url) async {
|
||||
// TODO: fallback
|
||||
}
|
||||
}
|
||||
|
||||
Iterable<Widget> buildPinnedItems(List pinnedItems, List repositories) {
|
||||
String title;
|
||||
List items = [];
|
||||
|
||||
if (pinnedItems.isNotEmpty) {
|
||||
title = 'pinned repositories';
|
||||
items = pinnedItems;
|
||||
} else if (repositories.isNotEmpty) {
|
||||
title = 'popular repositories';
|
||||
items = repositories;
|
||||
}
|
||||
|
||||
items = items
|
||||
.where((x) => x.isNotEmpty)
|
||||
.toList(); // TODO: Pinned items may include Gist
|
||||
if (items.isEmpty) return [];
|
||||
|
||||
return [
|
||||
CommonStyle.verticalGap,
|
||||
if (title != null) TableViewHeader(title),
|
||||
...join(
|
||||
CommonStyle.border,
|
||||
items.map((item) {
|
||||
return RepositoryItem(item);
|
||||
}).toList(),
|
||||
),
|
||||
];
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user