diff --git a/iphone/Maps/UI/Help/AboutController.swift b/iphone/Maps/UI/Help/AboutController.swift index 1a7ce6c6b1..72aee4e1c2 100644 --- a/iphone/Maps/UI/Help/AboutController.swift +++ b/iphone/Maps/UI/Help/AboutController.swift @@ -17,9 +17,17 @@ final class AboutController: MWMViewController, UITableViewDataSource, UITableVi return String(format: L("data_version"), df.string(from:mapsDate), mapsVersionInt) } + private func isDonateEnabled() -> Bool { + return Settings.donateUrl() != nil + } + override func loadView() { super.loadView() + if isDonateEnabled() { + labels[0][kDonateCellIndex] = "donate" + } + title = L("about_menu_title") // Menu items. @@ -115,11 +123,13 @@ final class AboutController: MWMViewController, UITableViewDataSource, UITableVi // MARK: - UITableView data source // Update didSelect... delegate and tools/python/clean_strings_txt.py after modifying this list. - private let labels = [ + private var labels = [ ["news", "faq", "report_a_bug", "how_to_support_us", "rate_the_app"], ["telegram", "github", "website", "email", "matrix", "mastodon", "facebook", "twitter", "instagram", "openstreetmap"], ["privacy_policy", "terms_of_use", "copyright"], ] + // Replaces "how_to_support_us" above. + private let kDonateCellIndex = 3 // Additional section is used to properly resize the header view by putting it in the table cell. func numberOfSections(in tableView: UITableView) -> Int { return labels.count + 1 } @@ -171,7 +181,7 @@ final class AboutController: MWMViewController, UITableViewDataSource, UITableVi case 0: self.openUrl(L("translated_om_site_url") + "news/") case 1: self.navigationController?.pushViewController(FaqController(), animated: true) case 2: sendEmailWith(header: "Organic Maps Bugreport", toRecipients: [kiOSEmail]) - case 3: self.openUrl(L("translated_om_site_url") + "support-us/") + case kDonateCellIndex: self.openUrl(isDonateEnabled() ? Settings.donateUrl() : L("translated_om_site_url") + "support-us/") case 4: UIApplication.shared.rateApp() default: fatalError("Invalid cell0 \(indexPath)") }