Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lī-iōng context menu lâi hok-tsè tshâ-tio̍h ē jī #5

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions ChhoeTaigi_iOS/ChhoeTaigi.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@
87DADC922155544F004D39C5 /* Bundle+Versions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 87DADC912155544F004D39C5 /* Bundle+Versions.swift */; };
87E16F942184BE4B00618A86 /* CustomBackButtonTableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 87E16F932184BE4B00618A86 /* CustomBackButtonTableViewController.swift */; };
A096747619DF0A61D2CA5814 /* Pods_ChhoeTaigi.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 732FE640379CF98043F9719E /* Pods_ChhoeTaigi.framework */; };
B555C67C251FA57600FCC316 /* ContentLabelContainer.swift in Sources */ = {isa = PBXBuildFile; fileRef = B555C67A251F9EDC00FCC316 /* ContentLabelContainer.swift */; };
B555C67D251FA62900FCC316 /* ContextMenuInteractable.swift in Sources */ = {isa = PBXBuildFile; fileRef = B555C678251F9E0E00FCC316 /* ContextMenuInteractable.swift */; };
/* End PBXBuildFile section */

/* Begin PBXFileReference section */
Expand Down Expand Up @@ -192,6 +194,8 @@
87DADC8F2155326F004D39C5 /* zh-Hant */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "zh-Hant"; path = "zh-Hant.lproj/LaunchScreen.strings"; sourceTree = "<group>"; };
87DADC912155544F004D39C5 /* Bundle+Versions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Bundle+Versions.swift"; sourceTree = "<group>"; };
87E16F932184BE4B00618A86 /* CustomBackButtonTableViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CustomBackButtonTableViewController.swift; sourceTree = "<group>"; };
B555C678251F9E0E00FCC316 /* ContextMenuInteractable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContextMenuInteractable.swift; sourceTree = "<group>"; };
B555C67A251F9EDC00FCC316 /* ContentLabelContainer.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ContentLabelContainer.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand Down Expand Up @@ -292,6 +296,7 @@
8763EACF214508EC00FD040B /* SearchResult */ = {
isa = PBXGroup;
children = (
B555C675251F8BD900FCC316 /* Extension */,
8782DF69214E4139009211EE /* EmbreeTaigiSutian */,
8782DF6B214E4154009211EE /* ITaigiHoataiSutian */,
8782DF6A214E4143009211EE /* KamJitian */,
Expand Down Expand Up @@ -471,6 +476,15 @@
path = Utils;
sourceTree = "<group>";
};
B555C675251F8BD900FCC316 /* Extension */ = {
isa = PBXGroup;
children = (
B555C678251F9E0E00FCC316 /* ContextMenuInteractable.swift */,
B555C67A251F9EDC00FCC316 /* ContentLabelContainer.swift */,
);
path = Extension;
sourceTree = "<group>";
};
B5647765C643AA37BD4328AB /* Pods */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -523,7 +537,9 @@
developmentRegion = en;
hasScannedForEncodings = 0;
knownRegions = (
en,
Base,
"zh-Hant",
);
mainGroup = 87C0E4182131E45900F26C32;
productRefGroup = 87C0E4222131E45900F26C32 /* Products */;
Expand Down Expand Up @@ -660,6 +676,7 @@
8774048F2153CE1000577D89 /* MaryknollTaiengSutianWordTableViewCell.swift in Sources */,
877404772152CCC300577D89 /* ITaigiHoataiSutianWordTableViewController.swift in Sources */,
8782DF84214E4265009211EE /* TaijitToaSutianResultTableViewController.swift in Sources */,
B555C67D251FA62900FCC316 /* ContextMenuInteractable.swift in Sources */,
877404972153CE7600577D89 /* EmbreeTaigiSutianWordTableViewCell.swift in Sources */,
877404932153CE4A00577D89 /* KamJitianWordTableViewCell.swift in Sources */,
87D479CE214A6E1B00ED5A40 /* Results+ToArray.swift in Sources */,
Expand Down Expand Up @@ -687,6 +704,7 @@
87C0E4252131E45900F26C32 /* AppDelegate.swift in Sources */,
87BB2938213435680073D126 /* MainViewController.swift in Sources */,
877404872152D2E800577D89 /* TaioanSitbutMialuiWordTableViewCell.swift in Sources */,
B555C67C251FA57600FCC316 /* ContentLabelContainer.swift in Sources */,
874C10192148B7D600D26024 /* SearchAllTableViewCell.swift in Sources */,
8782DF74214E41CC009211EE /* KamJitianResultTableViewCell.swift in Sources */,
877404792152CCD200577D89 /* KamJitianWordTableViewController.swift in Sources */,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ class SearchAllViewController: UIViewController, UITableViewDataSource, UITableV
textfield.clipsToBounds = true
textfield.textColor = #colorLiteral(red: 0.2745098174, green: 0.4862745106, blue: 0.1411764771, alpha: 1)

if let label = textfield.value(forKey: "_placeholderLabel") as? UILabel {
if let label = textfield.value(forKey: "placeholderLabel") as? UILabel {
label.minimumScaleFactor = 0.8
label.adjustsFontSizeToFitWidth = true
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,5 @@ class EmbreeTaigiSutianWordTableViewCell: UITableViewCell {
}
}
}

extension EmbreeTaigiSutianWordTableViewCell: ContentLabelContainer {}
Original file line number Diff line number Diff line change
Expand Up @@ -97,3 +97,12 @@ class EmbreeTaigiSutianWordTableViewController: CustomBackButtonTableViewControl
*/

}

@available(iOS 13.0, *)
extension EmbreeTaigiSutianWordTableViewController: ContextMenuInteractable {

override func tableView(_ tableView: UITableView, contextMenuConfigurationForRowAt indexPath: IndexPath, point: CGPoint) -> UIContextMenuConfiguration? {
return contextMenuConfiguration(for: self, at: indexPath)
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
//
// ContentLabelContainer.swift
// ChhoeTaigi
//
// Created by bcylin on 26/09/2020.
//

import UIKit

/// A shared interface for the table view cells with a content label.
protocol ContentLabelContainer {
var columnContentLabel: UILabel! { get }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
//
// ContextMenuInteractable.swift
// ChhoeTaigi
//
// Created by bcylin on 26/09/2020.
//

import UIKit

/// A protocol that provides context menu configuration for table view controllers.
protocol ContextMenuInteractable {}

@available(iOS 13.0, *)
extension ContextMenuInteractable where Self: UITableViewController {

func contextMenuConfiguration(for dataSource: UITableViewDataSource, at indexPath: IndexPath) -> UIContextMenuConfiguration? {
let cell = dataSource.tableView(tableView, cellForRowAt: indexPath) as? ContentLabelContainer
guard let copiableText = cell?.columnContentLabel?.text else {
return nil
}

return UIContextMenuConfiguration(identifier: nil, previewProvider: nil) { _ in
let copy = UIAction(title: "Hok-tsè", image: UIImage(systemName: "doc.on.doc")) { _ in
UIPasteboard.general.string = copiableText
}
return UIMenu(title: "", children: [copy])
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,5 @@ class ITaigiHoataiSutianWordTableViewCell: UITableViewCell {
}
}
}

extension ITaigiHoataiSutianWordTableViewCell: ContentLabelContainer {}
Original file line number Diff line number Diff line change
Expand Up @@ -97,3 +97,12 @@ class ITaigiHoataiSutianWordTableViewController: CustomBackButtonTableViewContro
*/

}

@available(iOS 13.0, *)
extension ITaigiHoataiSutianWordTableViewController: ContextMenuInteractable {

override func tableView(_ tableView: UITableView, contextMenuConfigurationForRowAt indexPath: IndexPath, point: CGPoint) -> UIContextMenuConfiguration? {
return contextMenuConfiguration(for: self, at: indexPath)
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -77,3 +77,5 @@ class KamJitianWordTableViewCell: UITableViewCell {
}
}
}

extension KamJitianWordTableViewCell: ContentLabelContainer {}
Original file line number Diff line number Diff line change
Expand Up @@ -97,3 +97,12 @@ class KamJitianWordTableViewController: CustomBackButtonTableViewController {
*/

}

@available(iOS 13.0, *)
extension KamJitianWordTableViewController: ContextMenuInteractable {

override func tableView(_ tableView: UITableView, contextMenuConfigurationForRowAt indexPath: IndexPath, point: CGPoint) -> UIContextMenuConfiguration? {
return contextMenuConfiguration(for: self, at: indexPath)
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -95,3 +95,5 @@ class KauiokpooTaigiDictWordTableViewCell: UITableViewCell {
}
}
}

extension KauiokpooTaigiDictWordTableViewCell: ContentLabelContainer {}
Original file line number Diff line number Diff line change
Expand Up @@ -97,3 +97,12 @@ class KauiokpooTaigiDictWordTableViewController: CustomBackButtonTableViewContro
*/

}

@available(iOS 13.0, *)
extension KauiokpooTaigiDictWordTableViewController: ContextMenuInteractable {

override func tableView(_ tableView: UITableView, contextMenuConfigurationForRowAt indexPath: IndexPath, point: CGPoint) -> UIContextMenuConfiguration? {
return contextMenuConfiguration(for: self, at: indexPath)
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,5 @@ class MaryknollTaiengSutianWordTableViewCell: UITableViewCell {
}
}
}

extension MaryknollTaiengSutianWordTableViewCell: ContentLabelContainer {}
Original file line number Diff line number Diff line change
Expand Up @@ -97,3 +97,12 @@ class MaryknollTaiengSutianWordTableViewController: CustomBackButtonTableViewCon
*/

}

@available(iOS 13.0, *)
extension MaryknollTaiengSutianWordTableViewController: ContextMenuInteractable {

override func tableView(_ tableView: UITableView, contextMenuConfigurationForRowAt indexPath: IndexPath, point: CGPoint) -> UIContextMenuConfiguration? {
return contextMenuConfiguration(for: self, at: indexPath)
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -71,3 +71,5 @@ class TaihoaSoanntengSutianWordTableViewCell: UITableViewCell {
}
}
}

extension TaihoaSoanntengSutianWordTableViewCell: ContentLabelContainer {}
Original file line number Diff line number Diff line change
Expand Up @@ -97,3 +97,12 @@ class TaihoaSoanntengSutianWordTableViewController: CustomBackButtonTableViewCon
*/

}

@available(iOS 13.0, *)
extension TaihoaSoanntengSutianWordTableViewController: ContextMenuInteractable {

override func tableView(_ tableView: UITableView, contextMenuConfigurationForRowAt indexPath: IndexPath, point: CGPoint) -> UIContextMenuConfiguration? {
return contextMenuConfiguration(for: self, at: indexPath)
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -83,3 +83,5 @@ class TaijitToaSutianWordTableViewCell: UITableViewCell {
}
}
}

extension TaijitToaSutianWordTableViewCell: ContentLabelContainer {}
Original file line number Diff line number Diff line change
Expand Up @@ -97,3 +97,12 @@ class TaijitToaSutianWordTableViewController: CustomBackButtonTableViewControlle
*/

}

@available(iOS 13.0, *)
extension TaijitToaSutianWordTableViewController: ContextMenuInteractable {

override func tableView(_ tableView: UITableView, contextMenuConfigurationForRowAt indexPath: IndexPath, point: CGPoint) -> UIContextMenuConfiguration? {
return contextMenuConfiguration(for: self, at: indexPath)
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,5 @@ class TaioanPehoeKichhooGikuWordTableViewCell: UITableViewCell {
}
}
}

extension TaioanPehoeKichhooGikuWordTableViewCell: ContentLabelContainer {}
Original file line number Diff line number Diff line change
Expand Up @@ -97,3 +97,12 @@ class TaioanPehoeKichhooGikuWordTableViewController: CustomBackButtonTableViewCo
*/

}

@available(iOS 13.0, *)
extension TaioanPehoeKichhooGikuWordTableViewController: ContextMenuInteractable {

override func tableView(_ tableView: UITableView, contextMenuConfigurationForRowAt indexPath: IndexPath, point: CGPoint) -> UIContextMenuConfiguration? {
return contextMenuConfiguration(for: self, at: indexPath)
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,5 @@ class TaioanSitbutMialuiWordTableViewCell: UITableViewCell {
}
}
}

extension TaioanSitbutMialuiWordTableViewCell: ContentLabelContainer {}
Original file line number Diff line number Diff line change
Expand Up @@ -87,3 +87,12 @@ class TaioanSitbutMialuiWordTableViewController: CustomBackButtonTableViewContro
*/

}

@available(iOS 13.0, *)
extension TaioanSitbutMialuiWordTableViewController: ContextMenuInteractable {

override func tableView(_ tableView: UITableView, contextMenuConfigurationForRowAt indexPath: IndexPath, point: CGPoint) -> UIContextMenuConfiguration? {
return contextMenuConfiguration(for: self, at: indexPath)
}

}