Skip to content

Commit d0a33c1

Browse files
feat: open URL (#70)
1 parent 7b1a245 commit d0a33c1

File tree

4 files changed

+28
-4
lines changed

4 files changed

+28
-4
lines changed

GoMoney/Base/GMViewController.swift

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,4 +113,17 @@ class GMViewController: UIViewController {
113113
func hideKeyboard() {
114114
view.endEditing(true)
115115
}
116+
117+
func openURL(_ url: String) {
118+
guard let url = URL(string: url) else {
119+
errorAlert(message: "Can't open \(url)")
120+
return
121+
}
122+
123+
if #available(iOS 10.0, *) {
124+
UIApplication.shared.open(url, options: [:], completionHandler: nil)
125+
} else {
126+
UIApplication.shared.openURL(url)
127+
}
128+
}
116129
}

GoMoney/Constants/Constant.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,4 +52,9 @@ struct K {
5252
enum Animation {
5353
static let calculator = "calculator"
5454
}
55+
56+
enum URL {
57+
static let github = "https://github.com/paul-nguyen-goldenowl/Go-Money"
58+
static let testFlight = "https://testflight.apple.com/join/FQgdoKR0"
59+
}
5560
}

GoMoney/Scences/Profile/ProfileViewController.swift

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,13 +59,19 @@ class ProfileViewController: GMMainViewController {
5959

6060
private lazy var aboutActionView: GMLabelActionView = .init(
6161
text: Content.aboutUs,
62-
icLeft: UIImage(systemName: "info.circle")
62+
icLeft: UIImage(systemName: "info.circle"),
63+
action: { [weak self] in
64+
self?.openURL(K.URL.github)
65+
}
6366
)
6467

6568
private lazy var helpActionView: GMLabelActionView = .init(
6669
text: Content.help,
6770
icLeft: UIImage(systemName: "questionmark.circle"),
68-
icRight: nil
71+
icRight: nil,
72+
action: { [weak self] in
73+
self?.openURL(K.URL.github)
74+
}
6975
)
7076

7177
private lazy var stackActions: UIStackView = {

GoMoney/Scences/Setting/SettingsViewController.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -385,9 +385,9 @@ extension SettingsViewController: UITableViewDelegate, UITableViewDataSource {
385385
case .about:
386386
switch indexPath.row {
387387
case 0:
388-
print("About us")
388+
openURL(K.URL.github)
389389
default:
390-
print("Rate us")
390+
openURL(K.URL.testFlight)
391391
}
392392
}
393393
}

0 commit comments

Comments
 (0)