mirror of
https://github.com/git-touch/git-touch
synced 2025-03-04 19:27:40 +01:00
refactor: use primer state label
This commit is contained in:
parent
1a2afb2775
commit
533b09352c
@ -1,5 +1,6 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:git_touch/screens/repo.dart';
|
||||
import 'package:primer/primer.dart';
|
||||
import 'providers/notification.dart';
|
||||
import 'providers/settings.dart';
|
||||
@ -75,6 +76,7 @@ class _HomeState extends State<Home> {
|
||||
// return ReposScreen('pd4d10');
|
||||
// return OrganizationScreen('flutter');
|
||||
// return TrendingScreen();
|
||||
// return RepoScreen('flutter', 'flutter');
|
||||
// return Image.asset('images/spinner.webp', width: 32, height: 32);
|
||||
switch (index) {
|
||||
case 0:
|
||||
|
@ -294,57 +294,26 @@ __typename
|
||||
return data['repository'][resource];
|
||||
}
|
||||
|
||||
Widget _buildBadge(payload) {
|
||||
Color bgColor;
|
||||
IconData iconData;
|
||||
String text;
|
||||
StateLabelStatus _getLabelStatus(payload) {
|
||||
StateLabelStatus status;
|
||||
|
||||
if (isPullRequest) {
|
||||
if (payload['merged']) {
|
||||
bgColor = PrimerColors.purple500;
|
||||
iconData = Octicons.git_merge;
|
||||
text = 'Merged';
|
||||
status = StateLabelStatus.pullMerged;
|
||||
} else if (payload['closed']) {
|
||||
bgColor = PrimerColors.red600;
|
||||
iconData = Octicons.git_pull_request;
|
||||
text = 'Closed';
|
||||
status = StateLabelStatus.pullClosed;
|
||||
} else {
|
||||
bgColor = Palette.green;
|
||||
iconData = Octicons.git_pull_request;
|
||||
text = 'Open';
|
||||
status = StateLabelStatus.pullOpened;
|
||||
}
|
||||
} else {
|
||||
if (payload['closed']) {
|
||||
bgColor = PrimerColors.red600;
|
||||
iconData = Octicons.issue_closed;
|
||||
text = 'Closed';
|
||||
status = StateLabelStatus.issueClosed;
|
||||
} else {
|
||||
bgColor = Palette.green;
|
||||
iconData = Octicons.issue_opened;
|
||||
text = 'Open';
|
||||
status = StateLabelStatus.issueOpened;
|
||||
}
|
||||
}
|
||||
return Container(
|
||||
decoration: BoxDecoration(
|
||||
color: bgColor,
|
||||
borderRadius: BorderRadius.all(Radius.circular(4)),
|
||||
),
|
||||
padding: EdgeInsets.all(6),
|
||||
child: Row(
|
||||
children: <Widget>[
|
||||
Icon(iconData, color: Colors.white, size: 15),
|
||||
Padding(padding: EdgeInsets.only(left: 2)),
|
||||
Text(
|
||||
text,
|
||||
style: TextStyle(
|
||||
color: Colors.white,
|
||||
fontWeight: FontWeight.w600,
|
||||
fontSize: 14,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
_handleReaction(payload) {
|
||||
@ -413,7 +382,7 @@ mutation {
|
||||
),
|
||||
),
|
||||
Padding(padding: EdgeInsets.only(right: 8)),
|
||||
_buildBadge(payload),
|
||||
StateLabel(_getLabelStatus(payload))
|
||||
],
|
||||
),
|
||||
Padding(padding: EdgeInsets.only(bottom: 16)),
|
||||
|
Loading…
x
Reference in New Issue
Block a user