Skip to content

Commit 94ecbed

Browse files
authored
Merge pull request #26 from menubar-apps/custom-gh-api-url
Custom gh api url
2 parents 4b37531 + 49cb893 commit 94ecbed

File tree

8 files changed

+76
-12
lines changed

8 files changed

+76
-12
lines changed

pullBar.xcodeproj/project.pbxproj

+5-1
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@
164164
attributes = {
165165
BuildIndependentTargetsInParallel = 1;
166166
LastSwiftUpdateCheck = 1300;
167-
LastUpgradeCheck = 1310;
167+
LastUpgradeCheck = 1410;
168168
TargetAttributes = {
169169
8CECBBDE2742AAF800A2802D = {
170170
CreatedOnToolsVersion = 13.0;
@@ -299,6 +299,7 @@
299299
CLANG_WARN_UNREACHABLE_CODE = YES;
300300
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
301301
COPY_PHASE_STRIP = NO;
302+
DEAD_CODE_STRIPPING = YES;
302303
DEBUG_INFORMATION_FORMAT = dwarf;
303304
ENABLE_STRICT_OBJC_MSGSEND = YES;
304305
ENABLE_TESTABILITY = YES;
@@ -360,6 +361,7 @@
360361
CLANG_WARN_UNREACHABLE_CODE = YES;
361362
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
362363
COPY_PHASE_STRIP = NO;
364+
DEAD_CODE_STRIPPING = YES;
363365
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
364366
ENABLE_NS_ASSERTIONS = NO;
365367
ENABLE_STRICT_OBJC_MSGSEND = YES;
@@ -391,6 +393,7 @@
391393
CODE_SIGN_STYLE = Automatic;
392394
COMBINE_HIDPI_IMAGES = YES;
393395
CURRENT_PROJECT_VERSION = 11;
396+
DEAD_CODE_STRIPPING = YES;
394397
DEVELOPMENT_TEAM = UV3HUS49VJ;
395398
ENABLE_HARDENED_RUNTIME = YES;
396399
GENERATE_INFOPLIST_FILE = YES;
@@ -420,6 +423,7 @@
420423
CODE_SIGN_STYLE = Automatic;
421424
COMBINE_HIDPI_IMAGES = YES;
422425
CURRENT_PROJECT_VERSION = 11;
426+
DEAD_CODE_STRIPPING = YES;
423427
DEVELOPMENT_TEAM = UV3HUS49VJ;
424428
ENABLE_HARDENED_RUNTIME = YES;
425429
GENERATE_INFOPLIST_FILE = YES;

pullBar.xcodeproj/xcshareddata/xcschemes/pullBar.xcscheme

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<Scheme
3-
LastUpgradeVersion = "1310"
3+
LastUpgradeVersion = "1410"
44
version = "1.3">
55
<BuildAction
66
parallelizeBuildables = "YES"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"images" : [
3+
{
4+
"filename" : "bmc-logo-no-background.png",
5+
"idiom" : "universal",
6+
"scale" : "1x"
7+
},
8+
{
9+
"idiom" : "universal",
10+
"scale" : "2x"
11+
},
12+
{
13+
"idiom" : "universal",
14+
"scale" : "3x"
15+
}
16+
],
17+
"info" : {
18+
"author" : "xcode",
19+
"version" : 1
20+
}
21+
}
Loading

pullBar/Extensions/DefaultsExtensions.swift

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import Foundation
99
import Defaults
1010

1111
extension Defaults.Keys {
12+
static let githubApiBaseUrl = Key<String>("githubApiBaseUrl", default: "https://api.github.com")
1213
static let githubUsername = Key<String>("githubUsername", default: "")
1314

1415
static let showAssigned = Key<Bool>("showAssigned", default: false)

pullBar/GitHub/GitHubClient.swift

+5-4
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import KeychainAccess
1212

1313
public class GitHubClient {
1414

15+
@Default(.githubApiBaseUrl) var githubApiBaseUrl
1516
@Default(.githubUsername) var githubUsername
1617
@FromKeychain(.githubToken) var githubToken
1718

@@ -35,7 +36,7 @@ public class GitHubClient {
3536
"variables":[]
3637
] as [String: Any]
3738

38-
AF.request("https://api.github.com/graphql", method: .post, parameters: parameters, encoding: JSONEncoding.default, headers: headers)
39+
AF.request(githubApiBaseUrl + "/graphql", method: .post, parameters: parameters, encoding: JSONEncoding.default, headers: headers)
3940
.validate(statusCode: 200..<300)
4041
.responseDecodable(of: GraphQlSearchResp.self, decoder: GithubDecoder()) { response in
4142
switch response.result {
@@ -66,7 +67,7 @@ public class GitHubClient {
6667
"variables":[]
6768
] as [String: Any]
6869

69-
AF.request("https://api.github.com/graphql", method: .post, parameters: parameters, encoding: JSONEncoding.default, headers: headers)
70+
AF.request(githubApiBaseUrl + "/graphql", method: .post, parameters: parameters, encoding: JSONEncoding.default, headers: headers)
7071
.validate(statusCode: 200..<300)
7172
.responseDecodable(of: GraphQlSearchResp.self, decoder: GithubDecoder()) { response in
7273
switch response.result {
@@ -96,7 +97,7 @@ public class GitHubClient {
9697
"variables":[]
9798
] as [String: Any]
9899

99-
AF.request("https://api.github.com/graphql", method: .post, parameters: parameters, encoding: JSONEncoding.default, headers: headers)
100+
AF.request(githubApiBaseUrl + "/graphql", method: .post, parameters: parameters, encoding: JSONEncoding.default, headers: headers)
100101
.validate(statusCode: 200..<300)
101102
.responseDecodable(of: GraphQlSearchResp.self, decoder: GithubDecoder()) { response in
102103
switch response.result {
@@ -231,7 +232,7 @@ public class GitHubClient {
231232
.accept("application/json")
232233
]
233234

234-
AF.request("https://api.github.com/user",
235+
AF.request(githubApiBaseUrl + "/user",
235236
method: .get,
236237
headers: headers)
237238
.validate(statusCode: 200..<300)

pullBar/Views/AboutView.swift

+32-4
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,47 @@
77

88
import SwiftUI
99

10-
import SwiftUI
11-
1210
struct AboutView: View {
11+
@Environment(\.openURL) var openURL
12+
1313
let currentVersion = Bundle.main.object(forInfoDictionaryKey: "CFBundleShortVersionString") as! String
14-
14+
1515
var body: some View {
1616
VStack {
1717
Image(nsImage: NSImage(named: "AppIcon")!)
1818
Text("PullBar").font(.title)
1919
Text("by Pavel Makhov").font(.caption)
2020
Text("version " + currentVersion).font(.footnote)
2121
Divider()
22-
Link("PullBar on GitHub", destination: URL(string: "https://github.com/menubar-apps/PullBar")!)
22+
23+
Button(action: {
24+
openURL(URL(string:"https://github.com/menubar-apps/PullBar/issues/new?assignees=&labels=enhancement&projects=&template=feature_request.md&title=")!)
25+
}) {
26+
HStack {
27+
Image(systemName: "star.fill")
28+
Text("Feature Request")
29+
}
30+
}
31+
Button(action: {
32+
openURL(URL(string:"https://github.com/menubar-apps/PullBar/issues/new?assignees=&labels=bug&projects=&template=bug_report.md&title=")!)
33+
}) {
34+
HStack {
35+
Image(systemName: "ladybug.fill")
36+
Text("Bug Report")
37+
}
38+
}
39+
Divider()
40+
Button(action: {
41+
openURL(URL(string: "https://www.buymeacoffee.com/streetturtle")!)
42+
}) {
43+
HStack {
44+
Image("bmc-logo-no-background")
45+
.resizable()
46+
.scaledToFit()
47+
.padding(.top, 2)
48+
Text("Buy me a coffee")
49+
}
50+
}
2351
}.padding()
2452
}
2553
}

pullBar/Views/PreferencesView.swift

+11-2
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import LaunchAtLogin
1212

1313
struct PreferencesView: View {
1414

15+
@Default(.githubApiBaseUrl) var githubApiBaseUrl
1516
@Default(.githubUsername) var githubUsername
1617
@FromKeychain(.githubToken) var githubToken
1718

@@ -36,7 +37,15 @@ struct PreferencesView: View {
3637
TabView {
3738
Form {
3839
HStack(alignment: .center) {
39-
Text("GitHub username:").frame(width: 120, alignment: .trailing)
40+
Text("API Base URL:").frame(width: 120, alignment: .trailing)
41+
TextField("", text: $githubApiBaseUrl)
42+
.textFieldStyle(RoundedBorderTextFieldStyle())
43+
.disableAutocorrection(true)
44+
.textContentType(.password)
45+
.frame(width: 200)
46+
}
47+
HStack(alignment: .center) {
48+
Text("Username:").frame(width: 120, alignment: .trailing)
4049
TextField("", text: $githubUsername)
4150
.textFieldStyle(RoundedBorderTextFieldStyle())
4251
.disableAutocorrection(true)
@@ -45,7 +54,7 @@ struct PreferencesView: View {
4554
}
4655

4756
HStack(alignment: .center) {
48-
Text("GitHub token:").frame(width: 120, alignment: .trailing)
57+
Text("Token:").frame(width: 120, alignment: .trailing)
4958
VStack(alignment: .leading) {
5059
HStack() {
5160
SecureField("", text: $githubToken)

0 commit comments

Comments
 (0)