This PR contains all the work related to setting up this project as required to implement the [Assignment](https://repo.rock-n-code.com/rock-n-code/deep-linking-assignment/wiki/Assignment) on top, as intended. To summarise this work: - [x] created a new **Xcode** project; - [x] cloned the `Wikipedia` app and inserted it into the **Xcode** project; - [x] created the `Locations` app and also, its `Libraries` package; - [x] created the `Shared` package to share dependencies between the apps; - [x] added a `Makefile` file and implemented some **environment** and **help** commands. Co-authored-by: Javier Cicchelli <javier@rock-n-code.com> Reviewed-on: rock-n-code/deep-linking-assignment#1
32 lines
1.5 KiB
Swift
32 lines
1.5 KiB
Swift
extension ArticleViewController {
|
|
func updateMenuItems() {
|
|
let shareMenuItemTitle = CommonStrings.shareMenuTitle
|
|
let shareMenuItem = UIMenuItem(title: shareMenuItemTitle, action: #selector(shareMenuItemTapped))
|
|
let editMenuItemTitle = WMFLocalizedString("edit-menu-item", value: "Edit", comment: "Button label for text selection 'Edit' menu item")
|
|
let editMenuItem = UIMenuItem(title: editMenuItemTitle, action: #selector(editMenuItemTapped))
|
|
|
|
UIMenuController.shared.menuItems = [editMenuItem, shareMenuItem]
|
|
}
|
|
|
|
@objc func shareMenuItemTapped() {
|
|
self.shareArticle()
|
|
}
|
|
|
|
@objc func editMenuItemTapped() {
|
|
webView.wmf_getSelectedTextEditInfo { (editInfo, error) in
|
|
guard let editInfo = editInfo else {
|
|
self.showError(error ?? RequestError.unexpectedResponse)
|
|
return
|
|
}
|
|
|
|
if editInfo.isSelectedTextInTitleDescription, let descriptionSource = editInfo.descriptionSource, descriptionSource == .central {
|
|
// Only show the description editor if the description is from Wikidata (descriptionSource == .central)
|
|
self.showTitleDescriptionEditor(with: .unknown, funnelSource: .highlight)
|
|
} else {
|
|
// Otherwise it needs to be changed in the section editor by editing the {{Short description}} template
|
|
self.showEditorForSection(with: editInfo.sectionID, selectedTextEditInfo: editInfo, funnelSource: .highlight)
|
|
}
|
|
}
|
|
}
|
|
}
|