Skip to content

Commit

Permalink
Code improvements.
Browse files Browse the repository at this point in the history
  • Loading branch information
sergstav committed May 15, 2018
1 parent 7985720 commit 718fa33
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 35 deletions.
Binary file added HakawaiDemoSwift/.DS_Store
Binary file not shown.
4 changes: 2 additions & 2 deletions HakawaiDemoSwift/HakawaiDemoSwift.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_STYLE = Automatic;
DEVELOPMENT_TEAM = HLS658NRU7;
INFOPLIST_FILE = HakawaiDemoSwift/Info.plist;
INFOPLIST_FILE = "$(SRCROOT)/HakawaiDemoSwift/Supporting Files/Info.plist";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.linkedin.HakawaiDemoSwift;
PRODUCT_NAME = "$(TARGET_NAME)";
Expand All @@ -414,7 +414,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_STYLE = Automatic;
DEVELOPMENT_TEAM = HLS658NRU7;
INFOPLIST_FILE = HakawaiDemoSwift/Info.plist;
INFOPLIST_FILE = "$(SRCROOT)/HakawaiDemoSwift/Supporting Files/Info.plist";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.linkedin.HakawaiDemoSwift;
PRODUCT_NAME = "$(TARGET_NAME)";
Expand Down

This file was deleted.

Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,12 @@ class MentionsDemoViewController: UIViewController {
@IBOutlet weak var textView: HKWTextView!
@IBOutlet weak var mentionsListButton: UIButton!

//
private var plugin: HKWMentionsPlugin!
private var plugin: HKWMentionsPlugin?

override func viewDidLoad() {
super.viewDidLoad()
setupUI()
}


}

// MARK: -
Expand All @@ -54,10 +51,9 @@ extension MentionsDemoViewController {
// Add edge insets so chooser view doesn't overlap the text view's cosmetic grey border
mentionsPlugin?.chooserViewEdgeInsets = UIEdgeInsetsMake(2, 0.5, 0.5, 0.5)
plugin = mentionsPlugin
plugin.chooserViewBackgroundColor = .lightGray
plugin?.chooserViewBackgroundColor = .lightGray
// The mentions plug-in requires a delegate, which provides it with mentions entities in response to a query string
mentionsPlugin?.delegate = MentionsManager.shared
// mentionsPlugin?.stateChangeDelegate =
textView.controlFlowPlugin = mentionsPlugin
}
}
Expand All @@ -66,7 +62,7 @@ extension MentionsDemoViewController {
extension MentionsDemoViewController {

@IBAction func listMentionsButtonTapped(_ sender: UIButton) {
print("There are mention(s): \(plugin.mentions().count) @% \(plugin.mentions())")
print("There are mention(s): \(String(describing: plugin?.mentions().count)) @% \(String(describing: plugin?.mentions()))")
}

@IBAction func doneEditingButtonTapped(_ sender: UIButton) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import Hakawai

class MentionsEntity: NSObject {

private var name: String!
private var name: String?
private var id: String!

init(name: String, id: String) {
Expand Down
13 changes: 8 additions & 5 deletions HakawaiDemoSwift/HakawaiDemoSwift/Mentions/MentionsManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ class MentionsManager: NSObject {

static let shared = MentionsManager()

private let mentionsCellId = "mentionsCell"
private let mentionsCellHeight: CGFloat = 44.0
private var fakeData = [MentionsEntity]()

private func setupFakeData() {
Expand All @@ -42,8 +44,9 @@ extension MentionsManager: HKWMentionsDelegate {
// perform whatever work is necessary to get the entities for that search string (network call, database query, etc),
// and then to call the completion block with an array of entity objects corresponding to the search string. See the
// documentation for the method for more details.
func asyncRetrieveEntities(forKeyString keyString: String!, searchType type: HKWMentionsSearchType, controlCharacter character: unichar, completion completionBlock: (([Any]?, Bool, Bool) -> Void)!) {
if completionBlock == nil {
func asyncRetrieveEntities(forKeyString keyString: String!, searchType type: HKWMentionsSearchType, controlCharacter character: unichar,
completion completionBlock: (([Any]?, Bool, Bool) -> Void)!) {
guard completionBlock != nil else {
return
}
setupFakeData()
Expand All @@ -66,9 +69,9 @@ extension MentionsManager: HKWMentionsDelegate {
// In this method, the plug-in gives us a mentions entity (one we previously returned in response to a query), and asks
// us to provide a table view cell corresponding to that entity to be presented to the user.
func cell(forMentionsEntity entity: HKWMentionsEntityProtocol!, withMatch matchString: String!, tableView: UITableView!) -> UITableViewCell! {
var cell = tableView.dequeueReusableCell(withIdentifier: "mentionsCell")
var cell = tableView.dequeueReusableCell(withIdentifier: mentionsCellId)
if cell == nil {
cell = UITableViewCell(style: .subtitle, reuseIdentifier: "mentionsCell")
cell = UITableViewCell(style: .subtitle, reuseIdentifier: mentionsCellId)
cell?.backgroundColor = .lightGray
}
cell?.textLabel?.text = entity.entityName()
Expand All @@ -77,7 +80,7 @@ extension MentionsManager: HKWMentionsDelegate {
}

func heightForCell(forMentionsEntity entity: HKWMentionsEntityProtocol!, tableView: UITableView!) -> CGFloat {
return 44
return mentionsCellHeight
}


Expand Down
12 changes: 6 additions & 6 deletions HakawaiDemoSwift/Podfile.lock
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
PODS:
- Hakawai (5.1.1):
- Hakawai/Core (= 5.1.1)
- Hakawai/Mentions (= 5.1.1)
- Hakawai/Core (5.1.1)
- Hakawai/Mentions (5.1.1):
- Hakawai (5.1.4):
- Hakawai/Core (= 5.1.4)
- Hakawai/Mentions (= 5.1.4)
- Hakawai/Core (5.1.4)
- Hakawai/Mentions (5.1.4):
- Hakawai/Core

DEPENDENCIES:
- Hakawai

SPEC CHECKSUMS:
Hakawai: 98dfeb08fce7c1ae9310089020c358a98acf29b5
Hakawai: b525498fdef6485445127d615a65cbee5f0cfea2

PODFILE CHECKSUM: 8afb544880f2856932d1fd9950c29e8e1627c5ba

Expand Down

0 comments on commit 718fa33

Please sign in to comment.