mirror of
https://github.com/git-touch/git-touch
synced 2025-03-23 06:30:17 +01:00
improvement: event item more actions
This commit is contained in:
parent
c694b99bc7
commit
8097eb3bb4
@ -2,7 +2,7 @@ import 'package:git_touch/utils/utils.dart';
|
||||
import 'package:json_annotation/json_annotation.dart';
|
||||
import 'package:tuple/tuple.dart';
|
||||
|
||||
part 'github_event.g.dart';
|
||||
part 'github.g.dart';
|
||||
|
||||
@JsonSerializable(fieldRename: FieldRename.snake)
|
||||
class GithubEvent {
|
||||
@ -53,3 +53,21 @@ class GithubEventRepo {
|
||||
factory GithubEventRepo.fromJson(Map<String, dynamic> json) =>
|
||||
_$GithubEventRepoFromJson(json);
|
||||
}
|
||||
|
||||
@JsonSerializable()
|
||||
class GithubTrendingItem {
|
||||
String author;
|
||||
String name;
|
||||
String avatar;
|
||||
String description;
|
||||
String language;
|
||||
String languageColor;
|
||||
int stars;
|
||||
int forks;
|
||||
int currentPeriodStars;
|
||||
|
||||
GithubTrendingItem();
|
||||
|
||||
factory GithubTrendingItem.fromJson(Map<String, dynamic> json) =>
|
||||
_$GithubTrendingItemFromJson(json);
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'github_event.dart';
|
||||
part of 'github.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// JsonSerializableGenerator
|
||||
@ -48,3 +48,29 @@ Map<String, dynamic> _$GithubEventRepoToJson(GithubEventRepo instance) =>
|
||||
<String, dynamic>{
|
||||
'name': instance.name,
|
||||
};
|
||||
|
||||
GithubTrendingItem _$GithubTrendingItemFromJson(Map<String, dynamic> json) {
|
||||
return GithubTrendingItem()
|
||||
..author = json['author'] as String
|
||||
..name = json['name'] as String
|
||||
..avatar = json['avatar'] as String
|
||||
..description = json['description'] as String
|
||||
..language = json['language'] as String
|
||||
..languageColor = json['languageColor'] as String
|
||||
..stars = json['stars'] as int
|
||||
..forks = json['forks'] as int
|
||||
..currentPeriodStars = json['currentPeriodStars'] as int;
|
||||
}
|
||||
|
||||
Map<String, dynamic> _$GithubTrendingItemToJson(GithubTrendingItem instance) =>
|
||||
<String, dynamic>{
|
||||
'author': instance.author,
|
||||
'name': instance.name,
|
||||
'avatar': instance.avatar,
|
||||
'description': instance.description,
|
||||
'language': instance.language,
|
||||
'languageColor': instance.languageColor,
|
||||
'stars': instance.stars,
|
||||
'forks': instance.forks,
|
||||
'currentPeriodStars': instance.currentPeriodStars,
|
||||
};
|
@ -1,21 +0,0 @@
|
||||
import 'package:json_annotation/json_annotation.dart';
|
||||
|
||||
part 'github_trending.g.dart';
|
||||
|
||||
@JsonSerializable()
|
||||
class GithubTrendingItem {
|
||||
String author;
|
||||
String name;
|
||||
String avatar;
|
||||
String description;
|
||||
String language;
|
||||
String languageColor;
|
||||
int stars;
|
||||
int forks;
|
||||
int currentPeriodStars;
|
||||
|
||||
GithubTrendingItem();
|
||||
|
||||
factory GithubTrendingItem.fromJson(Map<String, dynamic> json) =>
|
||||
_$GithubTrendingItemFromJson(json);
|
||||
}
|
@ -1,33 +0,0 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'github_trending.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
GithubTrendingItem _$GithubTrendingItemFromJson(Map<String, dynamic> json) {
|
||||
return GithubTrendingItem()
|
||||
..author = json['author'] as String
|
||||
..name = json['name'] as String
|
||||
..avatar = json['avatar'] as String
|
||||
..description = json['description'] as String
|
||||
..language = json['language'] as String
|
||||
..languageColor = json['languageColor'] as String
|
||||
..stars = json['stars'] as int
|
||||
..forks = json['forks'] as int
|
||||
..currentPeriodStars = json['currentPeriodStars'] as int;
|
||||
}
|
||||
|
||||
Map<String, dynamic> _$GithubTrendingItemToJson(GithubTrendingItem instance) =>
|
||||
<String, dynamic>{
|
||||
'author': instance.author,
|
||||
'name': instance.name,
|
||||
'avatar': instance.avatar,
|
||||
'description': instance.description,
|
||||
'language': instance.language,
|
||||
'languageColor': instance.languageColor,
|
||||
'stars': instance.stars,
|
||||
'forks': instance.forks,
|
||||
'currentPeriodStars': instance.currentPeriodStars,
|
||||
};
|
@ -346,6 +346,7 @@ class ThemeModel with ChangeNotifier {
|
||||
}
|
||||
|
||||
showActions(BuildContext context, List<ActionItem> actionItems) async {
|
||||
if (actionItems == null) return;
|
||||
final value = await showCupertinoModalPopup<int>(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
|
@ -1,6 +1,6 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:git_touch/models/github_event.dart';
|
||||
import 'package:git_touch/models/github.dart';
|
||||
import 'package:git_touch/models/notification.dart';
|
||||
import 'package:git_touch/models/theme.dart';
|
||||
import 'package:git_touch/scaffolds/list_stateful.dart';
|
||||
|
@ -1,6 +1,6 @@
|
||||
import 'dart:convert';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:git_touch/models/github_trending.dart';
|
||||
import 'package:git_touch/models/github.dart';
|
||||
import 'package:git_touch/scaffolds/tab_stateful.dart';
|
||||
import 'package:git_touch/screens/repository.dart';
|
||||
import 'package:git_touch/utils/utils.dart';
|
||||
|
@ -43,7 +43,7 @@ class ActionItem {
|
||||
});
|
||||
ActionItem.issue(String owner, String name, int number,
|
||||
{isPullRequest = false})
|
||||
: text = (isPullRequest ? 'Pull Request' : 'Issue') + ' #$number',
|
||||
: text = '$owner/$name #$number',
|
||||
onPress = ((context) {
|
||||
Provider.of<ThemeModel>(context).pushRoute(
|
||||
context,
|
||||
|
@ -1,6 +1,6 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:git_touch/models/github_event.dart';
|
||||
import 'package:git_touch/models/github.dart';
|
||||
import 'package:git_touch/models/theme.dart';
|
||||
import 'package:git_touch/screens/repository.dart';
|
||||
import 'package:git_touch/widgets/action_button.dart';
|
||||
@ -57,12 +57,6 @@ class EventItem extends StatelessWidget {
|
||||
return Link(
|
||||
screenBuilder: screenBuilder,
|
||||
url: url,
|
||||
onLongPress: () async {
|
||||
if (actionItems == null) return;
|
||||
|
||||
await Provider.of<ThemeModel>(context)
|
||||
.showActions(context, actionItems);
|
||||
},
|
||||
child: Container(
|
||||
padding: CommonStyle.padding,
|
||||
child: Column(
|
||||
@ -109,7 +103,14 @@ class EventItem extends StatelessWidget {
|
||||
style: TextStyle(
|
||||
fontSize: 13,
|
||||
color: theme.palette.tertiaryText,
|
||||
))
|
||||
)),
|
||||
Expanded(child: Container()),
|
||||
GestureDetector(
|
||||
child: Icon(Icons.more_horiz),
|
||||
onTap: () {
|
||||
theme.showActions(context, actionItems);
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
]),
|
||||
@ -123,11 +124,9 @@ class EventItem extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
build(BuildContext context) {
|
||||
Widget _buildDefaultItem(BuildContext context) {
|
||||
final theme = Provider.of<ThemeModel>(context);
|
||||
|
||||
var defaultItem = _buildItem(
|
||||
return _buildItem(
|
||||
context: context,
|
||||
spans: [
|
||||
TextSpan(
|
||||
@ -138,6 +137,11 @@ class EventItem extends StatelessWidget {
|
||||
iconData: Octicons.octoface,
|
||||
detail: 'Woops, ${event.type} not implemented yet',
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
build(BuildContext context) {
|
||||
final theme = Provider.of<ThemeModel>(context);
|
||||
|
||||
// all events types here:
|
||||
// https://developer.github.com/v3/activity/events/types/#event-types--payloads
|
||||
@ -153,7 +157,7 @@ class EventItem extends StatelessWidget {
|
||||
case 'DownloadEvent':
|
||||
case 'FollowEvent':
|
||||
// TODO:
|
||||
return defaultItem;
|
||||
return _buildDefaultItem(context);
|
||||
case 'ForkEvent':
|
||||
final forkeeOwner = event.payload['forkee']['owner']['login'] as String;
|
||||
final forkeeName = event.payload['forkee']['name'] as String;
|
||||
@ -180,7 +184,7 @@ class EventItem extends StatelessWidget {
|
||||
case 'InstallationEvent':
|
||||
case 'InstallationRepositoriesEvent':
|
||||
// TODO:
|
||||
return defaultItem;
|
||||
return _buildDefaultItem(context);
|
||||
case 'IssueCommentEvent':
|
||||
final isPullRequest = event.payload['issue']['pull_request'] != null;
|
||||
final resource = isPullRequest ? 'pull request' : 'issue';
|
||||
@ -244,7 +248,7 @@ class EventItem extends StatelessWidget {
|
||||
case 'ProjectEvent':
|
||||
case 'PublicEvent':
|
||||
// TODO:
|
||||
return defaultItem;
|
||||
return _buildDefaultItem(context);
|
||||
case 'PullRequestEvent':
|
||||
final action = event.payload['action'];
|
||||
final number = event.payload['pull_request']['number'] as int;
|
||||
@ -274,7 +278,7 @@ class EventItem extends StatelessWidget {
|
||||
);
|
||||
case 'PullRequestReviewEvent':
|
||||
// TODO:
|
||||
return defaultItem;
|
||||
return _buildDefaultItem(context);
|
||||
case 'PullRequestReviewCommentEvent':
|
||||
final number = event.payload['pull_request']['number'] as int;
|
||||
|
||||
@ -355,7 +359,7 @@ class EventItem extends StatelessWidget {
|
||||
case 'TeamEvent':
|
||||
case 'TeamAddEvent':
|
||||
// TODO:
|
||||
return defaultItem;
|
||||
return _buildDefaultItem(context);
|
||||
case 'WatchEvent':
|
||||
return _buildItem(
|
||||
context: context,
|
||||
@ -369,7 +373,7 @@ class EventItem extends StatelessWidget {
|
||||
],
|
||||
);
|
||||
default:
|
||||
return defaultItem;
|
||||
return _buildDefaultItem(context);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user