diff --git a/lib/home.dart b/lib/home.dart index 271478f..3f19479 100644 --- a/lib/home.dart +++ b/lib/home.dart @@ -26,7 +26,6 @@ class Home extends StatefulWidget { } class _HomeState extends State { - // Created 5 different variables instead of a list as list doesn't work final GlobalKey tab1 = GlobalKey(); final GlobalKey tab2 = GlobalKey(); @@ -185,16 +184,16 @@ class _HomeState extends State { } GlobalKey getNavigatorKey(int index) { - switch(index) { + switch (index) { case 0: return tab1; case 1: return tab2; - case 2: + case 2: return tab3; - case 3: + case 3: return tab4; - case 4: + case 4: return tab5; } return tab1; @@ -211,30 +210,31 @@ class _HomeState extends State { switch (theme.theme) { case AppThemeType.cupertino: - return WillPopScope( - onWillPop: () async { - return !await getNavigatorKey(_controller.index).currentState.maybePop(); - }, - child: CupertinoTabScaffold( - controller: _controller, - tabBuilder: (context, index) { - return CupertinoTabView( - navigatorKey: getNavigatorKey(index), - builder: (context) { - return _buildScreen(index); - } - ); + return WillPopScope( + onWillPop: () async { + return !await getNavigatorKey(_controller.index) + .currentState + .maybePop(); }, - tabBar: CupertinoTabBar(items: _navigationItems, - onTap: (index) { - if(active == index) { - getNavigatorKey(index).currentState.popUntil((route) => route.isFirst); - } - active = index; - } - ) - ) - ); + child: CupertinoTabScaffold( + controller: _controller, + tabBuilder: (context, index) { + return CupertinoTabView( + navigatorKey: getNavigatorKey(index), + builder: (context) { + return _buildScreen(index); + }); + }, + tabBar: CupertinoTabBar( + items: _navigationItems, + onTap: (index) { + if (active == index) { + getNavigatorKey(index) + .currentState + .popUntil((route) => route.isFirst); + } + active = index; + }))); default: return Scaffold( body: _buildScreen(active), diff --git a/lib/models/github.dart b/lib/models/github.dart index a761ea7..9f6e7e4 100644 --- a/lib/models/github.dart +++ b/lib/models/github.dart @@ -219,7 +219,7 @@ class GithubPagesItem { String title; String action; GithubPagesItem(); - factory GithubPagesItem.fromJson(Map json) => + factory GithubPagesItem.fromJson(Map json) => _$GithubPagesItemFromJson(json); } @@ -229,7 +229,7 @@ class GithubSecurityItem { String description; String severity; GithubSecurityItem(); - factory GithubSecurityItem.fromJson(Map json) => + factory GithubSecurityItem.fromJson(Map json) => _$GithubSecurityItemFromJson(json); } @@ -260,7 +260,7 @@ class GithubProjectColumnItem { String name; GithubProjectColumnItem(); factory GithubProjectColumnItem.fromJson(Map json) => - _$GithubProjectColumnItemFromJson(json); + _$GithubProjectColumnItemFromJson(json); } @JsonSerializable(fieldRename: FieldRename.snake) @@ -269,7 +269,8 @@ class GithubInstallationRepositoriesItem { String repositoriesSelection; int id; GithubInstallationRepositoriesItem(); - factory GithubInstallationRepositoriesItem.fromJson(Map json) => + factory GithubInstallationRepositoriesItem.fromJson( + Map json) => _$GithubInstallationRepositoriesItemFromJson(json); } @@ -288,7 +289,7 @@ class GithubCheckSuiteItem { String status; String conclusion; GithubCheckSuiteItem(); - factory GithubCheckSuiteItem.fromJson(Map json) => + factory GithubCheckSuiteItem.fromJson(Map json) => _$GithubCheckSuiteItemFromJson(json); } @@ -300,4 +301,3 @@ class GithubContentReferenceItem { factory GithubContentReferenceItem.fromJson(Map json) => _$GithubContentReferenceItemFromJson(json); } - diff --git a/lib/screens/gh_issue.dart b/lib/screens/gh_issue.dart index a4fd800..7701342 100644 --- a/lib/screens/gh_issue.dart +++ b/lib/screens/gh_issue.dart @@ -638,4 +638,4 @@ fragment ReactableParts on Reactable { }, ); } -} \ No newline at end of file +} diff --git a/lib/screens/gh_search.dart b/lib/screens/gh_search.dart index da9b4be..f76011f 100644 --- a/lib/screens/gh_search.dart +++ b/lib/screens/gh_search.dart @@ -112,7 +112,7 @@ class _GhSearchScreenState extends State { } Widget _buildInput() { - final theme = Provider.of(context); + final theme = Provider.of(context); switch (Provider.of(context).theme) { case AppThemeType.cupertino: return Container( diff --git a/lib/screens/gh_trending.dart b/lib/screens/gh_trending.dart index cdeec55..80811fc 100644 --- a/lib/screens/gh_trending.dart +++ b/lib/screens/gh_trending.dart @@ -61,15 +61,14 @@ class GhTrendingScreen extends StatelessWidget { ), SizedBox(width: 4), Expanded( - child: Text( - '${v.username} / ${v.repo.name}', - style: TextStyle( - fontSize: 17, - color: theme.palette.secondaryText, - ), - overflow: TextOverflow.ellipsis, - ) - ) + child: Text( + '${v.username} / ${v.repo.name}', + style: TextStyle( + fontSize: 17, + color: theme.palette.secondaryText, + ), + overflow: TextOverflow.ellipsis, + )) ], ), ), diff --git a/lib/widgets/event_item.dart b/lib/widgets/event_item.dart index 524a9a7..8273c17 100644 --- a/lib/widgets/event_item.dart +++ b/lib/widgets/event_item.dart @@ -257,16 +257,15 @@ class EventItem extends StatelessWidget { // https://developer.github.com/v3/activity/events/types/#event-types--payloads switch (e.type) { case 'CheckRunEvent': - return _buildItem( - context: context, - spans: [ - TextSpan(text: ' ${e.payload.action} a check run for ${e.payload.checkRun.name} '), - ] - ); + return _buildItem(context: context, spans: [ + TextSpan( + text: + ' ${e.payload.action} a check run for ${e.payload.checkRun.name} '), + ]); case 'CheckSuiteEvent': - // Needs checks permission + // Needs checks permission String conclusion = ""; - switch(e.payload.checkSuite.conclusion) { + switch (e.payload.checkSuite.conclusion) { case 'success': case 'failure': conclusion = 'it is a ' + e.payload.checkSuite.conclusion; @@ -281,14 +280,16 @@ class EventItem extends StatelessWidget { conclusion = ' it requires more action'; break; } - return _buildItem( + return _buildItem( context: context, spans: [ - TextSpan(text: ' ${e.payload.action} the check suite and the conclusion is that $conclusion'), + TextSpan( + text: + ' ${e.payload.action} the check suite and the conclusion is that $conclusion'), ], ); case 'CommitCommentEvent': - return _buildItem( + return _buildItem( context: context, spans: [ TextSpan(text: ' ${e.payload.action} a comment on the commit at '), @@ -298,20 +299,16 @@ class EventItem extends StatelessWidget { card: _buildCommitsCard(context), ); case 'ContentReferenceEvent': - return _buildItem( - context: context, - spans: [ - TextSpan(text: ' ${e.payload.action} a content reference at '), - _buildLinkSpan( - context, e.payload.contentReference.reference, e.payload.contentReference.reference), - ] - ); + return _buildItem(context: context, spans: [ + TextSpan(text: ' ${e.payload.action} a content reference at '), + _buildLinkSpan(context, e.payload.contentReference.reference, + e.payload.contentReference.reference), + ]); case 'CreateEvent': return _buildItem( context: context, spans: [ - TextSpan( - text: ' created a ${e.payload.refType} '), + TextSpan(text: ' created a ${e.payload.refType} '), _buildRepo(context), ], ); @@ -319,9 +316,7 @@ class EventItem extends StatelessWidget { return _buildItem( context: context, spans: [ - TextSpan( - text: ' deleted ${e.payload.refType} ' - ), + TextSpan(text: ' deleted ${e.payload.refType} '), _buildRepo(context), ], ); @@ -340,61 +335,62 @@ class EventItem extends StatelessWidget { case 'GollumEvent': String pageNamesCreated = ""; String pageNamesEdited = ""; - for(GithubPagesItem page in e.payload.pages) { - if(page.action == "edited") { + for (GithubPagesItem page in e.payload.pages) { + if (page.action == "edited") { pageNamesEdited += ", " + page.pageName; } else { pageNamesCreated += ", " + page.pageName; } } - if(pageNamesCreated.length > 0) { + if (pageNamesCreated.length > 0) { pageNamesCreated = " created the pages: \n" + pageNamesCreated + "\n"; } - if(pageNamesEdited.length > 0) { + if (pageNamesEdited.length > 0) { pageNamesEdited = " edited the pages: \n" + pageNamesEdited + "\n"; } - return _buildItem( - context: context, - spans: [ - TextSpan( - text: ' $pageNamesCreated\n$pageNamesEdited ' - ) - ] - ); + return _buildItem( + context: context, + spans: [TextSpan(text: ' $pageNamesCreated\n$pageNamesEdited ')]); case 'InstallationEvent': String action = e.payload.action; - if(action == 'new_permissions_accepted') { + if (action == 'new_permissions_accepted') { action = "new permission were accepted for"; } return _buildItem( context: context, spans: [ - TextSpan(text: ' $action for the Github App with id ${e.payload.installation.id}'), + TextSpan( + text: + ' $action for the Github App with id ${e.payload.installation.id}'), ], ); case 'InstallationRepositoriesEvent': - List repositoriesAdded = e.payload.installation.repositoriesAdded; - List repositoriesRemoved = e.payload.installation.repositoriesRemoved; + List repositoriesAdded = + e.payload.installation.repositoriesAdded; + List repositoriesRemoved = + e.payload.installation.repositoriesRemoved; String addedRepos = ""; String removedRepos = ""; - for(GithubNotificationItemRepo repo in repositoriesAdded) { + for (GithubNotificationItemRepo repo in repositoriesAdded) { addedRepos += repo.fullName + ", "; } - for(GithubNotificationItemRepo repo in repositoriesRemoved) { + for (GithubNotificationItemRepo repo in repositoriesRemoved) { removedRepos += repo.fullName + ", "; } String finalListOfRepos = ""; - if(addedRepos != "") { + if (addedRepos != "") { finalListOfRepos += addedRepos + " were added to\n "; - } - if(removedRepos != "") { + } + if (removedRepos != "") { finalListOfRepos += removedRepos + " were removed from"; } - return _buildItem( + return _buildItem( context: context, spans: [ - TextSpan(text: ' $finalListOfRepos the installation id ${e.payload.installation.id} '), + TextSpan( + text: + ' $finalListOfRepos the installation id ${e.payload.installation.id} '), ], ); case 'IssueCommentEvent': @@ -434,22 +430,22 @@ class EventItem extends StatelessWidget { case 'MarketplacePurchaseEvent': final action = e.payload.action; var messageToDisplay; - switch(action) { - case "purchased": + switch (action) { + case "purchased": messageToDisplay = "purchased a Marketplace Plan"; - break; + break; case "cancelled": messageToDisplay = "cancelled their Marketplace Plan"; - break; + break; case "pending_change": messageToDisplay = " Marketplace Plan is pending change"; - break; + break; case "pending_change_cancelled": messageToDisplay = " Pending Marketplace Plan was cancelled"; - break; + break; case "changed": messageToDisplay = " changed their Marketplace Plan"; - break; + break; } return _buildItem( context: context, @@ -463,22 +459,22 @@ class EventItem extends StatelessWidget { case 'MemberEvent': final action = e.payload.action; return _buildItem( - context: context, spans: [ TextSpan( - text: ' was ${e.payload.action} ${action == 'added' ? 'to' : 'from' } '), + text: + ' was ${e.payload.action} ${action == 'added' ? 'to' : 'from'} '), _buildRepo(context), ], ); case 'ProjectCardEvent': String action = e.payload.action; - if(action == 'converted') { + if (action == 'converted') { action = ' converted the project card into an issue '; } else { action = action + ' the project card '; } - return _buildItem( + return _buildItem( context: context, spans: [ TextSpan(text: ' $action at '), @@ -486,20 +482,18 @@ class EventItem extends StatelessWidget { ], ); case 'ProjectColumnEvent': - return _buildItem( - context: context, - spans: [ - TextSpan(text: ' ${e.payload.action} the project column ${e.payload.projectColumn.name} at '), - _buildRepo(context), - ] - ); + return _buildItem(context: context, spans: [ + TextSpan( + text: + ' ${e.payload.action} the project column ${e.payload.projectColumn.name} at '), + _buildRepo(context), + ]); case 'ProjectEvent': - return _buildItem( - context: context, - spans: [ - TextSpan(text: ' ${e.payload.action} the project ${e.payload.project.name} '), - ] - ); + return _buildItem(context: context, spans: [ + TextSpan( + text: + ' ${e.payload.action} the project ${e.payload.project.name} '), + ]); case 'PublicEvent': return _buildItem( context: context, @@ -523,15 +517,12 @@ class EventItem extends StatelessWidget { ); case 'PullRequestReviewEvent': final pr = e.payload.pullRequest; - return _buildItem( - context: context, - spans: [ - TextSpan(text: ' ${e.payload.action} the pull request review '), - _buildIssue(context, pr.number, isPullRequest: true), - TextSpan(text: ' at '), - _buildRepo(context), - ] - ); + return _buildItem(context: context, spans: [ + TextSpan(text: ' ${e.payload.action} the pull request review '), + _buildIssue(context, pr.number, isPullRequest: true), + TextSpan(text: ' at '), + _buildRepo(context), + ]); case 'PullRequestReviewCommentEvent': final pr = e.payload.pullRequest; return _buildItem( @@ -565,23 +556,19 @@ class EventItem extends StatelessWidget { // case 'RepositoryImportEvent': // // Uses Source Imports API case 'RepositoryVulnerabilityAlertEvent': - return _buildItem( - context: context, - spans: [ - TextSpan( - text: ' Security alert involving the package ${e.payload.alert.affectedPackageName} between versions ${e.payload.alert.affectedRange} was {e.payload.action}ed', - ) - ] - ); + return _buildItem(context: context, spans: [ + TextSpan( + text: + ' Security alert involving the package ${e.payload.alert.affectedPackageName} between versions ${e.payload.alert.affectedRange} was {e.payload.action}ed', + ) + ]); case 'SecurityAdvisoryEvent': - return _buildItem( - context: context, - spans: [ - TextSpan( - text: ' Security advisory regarding ${e.payload.securityAdvisory.summary} was ${e.payload.action} ', - ) - ] - ); + return _buildItem(context: context, spans: [ + TextSpan( + text: + ' Security advisory regarding ${e.payload.securityAdvisory.summary} was ${e.payload.action} ', + ) + ]); case 'WatchEvent': return _buildItem( context: context, diff --git a/lib/widgets/repo_header.dart b/lib/widgets/repo_header.dart index a53852f..b10dc9b 100644 --- a/lib/widgets/repo_header.dart +++ b/lib/widgets/repo_header.dart @@ -45,13 +45,13 @@ class RepoHeader extends StatelessWidget { SizedBox(width: 8), Expanded( child: Text( - '$owner / $name', - style: TextStyle( - fontSize: 20, - color: theme.palette.primary, - ), - overflow: TextOverflow.visible, + '$owner / $name', + style: TextStyle( + fontSize: 20, + color: theme.palette.primary, ), + overflow: TextOverflow.visible, + ), ), ], ), diff --git a/lib/widgets/timeline_item.dart b/lib/widgets/timeline_item.dart index 82793e2..20f2f3a 100644 --- a/lib/widgets/timeline_item.dart +++ b/lib/widgets/timeline_item.dart @@ -134,7 +134,7 @@ class TimelineItem extends StatelessWidget { p: p, ); case 'UnsubscribedEvent': - return TimelineEventItem( + return TimelineEventItem( actor: p['actor']['login'], textSpan: TextSpan(text: ' unsubscribed from this issue '), p: p, @@ -145,7 +145,7 @@ class TimelineItem extends StatelessWidget { return Container(); } - if(p['isCrossRepository']) { + if (p['isCrossRepository']) { return TimelineEventItem( actor: p['actor']['login'], iconData: Octicons.bookmark, @@ -270,11 +270,13 @@ class TimelineItem extends StatelessWidget { // issue only types case 'TransferredEvent': - return TimelineEventItem( + return TimelineEventItem( actor: p['actor']['login'], - textSpan: TextSpan( + textSpan: TextSpan( children: [ - TextSpan(text: ' transferred this issue from ' + p['fromRepository']['name']) + TextSpan( + text: ' transferred this issue from ' + + p['fromRepository']['name']) ], ), ); @@ -319,14 +321,17 @@ class TimelineItem extends StatelessWidget { textSpan: TextSpan(text: ' pinned this issue '), ); case 'DeployedEvent': - return TimelineEventItem( + return TimelineEventItem( actor: p['actor']['login'], - textSpan: TextSpan(text: ' deployed the pull request ' + p['pullRequest']['name']), + textSpan: TextSpan( + text: ' deployed the pull request ' + p['pullRequest']['name']), ); case 'DeploymentEnvironmentChangedEvent': - return TimelineEventItem( + return TimelineEventItem( actor: p['actor']['login'], - textSpan: TextSpan(text: ' changed the deployment environment to ' + p['deploymentStatus']['deployment']['environment']), + textSpan: TextSpan( + text: ' changed the deployment environment to ' + + p['deploymentStatus']['deployment']['environment']), ); case 'HeadRefDeletedEvent': return TimelineEventItem( @@ -340,17 +345,14 @@ class TimelineItem extends StatelessWidget { p: p, ); case 'HeadRefRestoredEvent': - return TimelineEventItem( + return TimelineEventItem( actor: p['actor']['login'], - textSpan: TextSpan( - children: [ - TextSpan(text: ' restored the '), - WidgetSpan( - child: PrimerBranchName(p['pullRequest']['headRef']['name']) - ), - TextSpan(text: ' branch') - ] - ), + textSpan: TextSpan(children: [ + TextSpan(text: ' restored the '), + WidgetSpan( + child: PrimerBranchName(p['pullRequest']['headRef']['name'])), + TextSpan(text: ' branch') + ]), ); case 'HeadRefForcePushedEvent': return TimelineEventItem( @@ -420,7 +422,7 @@ class TimelineItem extends StatelessWidget { p: p, ); case 'ReviewDismissedEvent': - return TimelineEventItem( + return TimelineEventItem( iconData: Octicons.eye, actor: p['actor']['login'], textSpan: TextSpan(children: [