Skip to content

Commit 7868d89

Browse files
author
Junshuo
committed
1.1
Bump to 1.1
1 parent aad8e7f commit 7868d89

29 files changed

+1009
-741
lines changed

.gitignore

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
JSPopoverMenuDemo/JSPopoverMenu.xcodeproj/project.pbxproj
2+
JSPopoverMenuDemo/JSPopoverMenu.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist
3+
xcuserdata/
4+
JSPopoverMenuDemo/JSPopoverMenu.xcodeproj/project.pbxproj

JSMenu.podspec

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
Pod::Spec.new do |s|
22

33
s.name = "JSMenu"
4-
s.version = "1.0.2"
4+
s.version = "1.1"
55
s.summary = "Popover Menu View"
66
s.description = "It's a popover view for managing tags."
7-
s.homepage = "https://github.com/DevNewbee/JSPopoverMenu"
7+
s.homepage = "https://github.com/JunsW/JSMenu"
88
s.license = { :type => "MIT", :file => "LICENSE" }
99

1010

11-
s.author = { "DevNewbee" => "[email protected]" }
11+
s.author = { "JunsW" => "[email protected]" }
1212

13-
s.ios.deployment_target = '8.0'
14-
s.source = { :git => "https://github.com/DevNewbee/JSMenu.git", :tag => "1.0.2" }
15-
s.source_files = "Source/*.swift"
13+
s.ios.deployment_target = '9.0'
14+
s.source = { :git => "https://github.com/JunsW/JSMenu.git", :tag => "1.1" }
15+
s.source_files = "Source/*/*.swift"
1616

1717

1818
s.requires_arc = true

JSPopoverMenuDemo/JSPopoverMenu.xcodeproj/project.pbxproj

+6
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
objects = {
88

99
/* Begin PBXBuildFile section */
10+
4B6DF830230E54CC00DC746F /* JSTag.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4B6DF82F230E54CC00DC746F /* JSTag.swift */; };
1011
E81163471FAE0B28006FD738 /* GlobalExtensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = E81163461FAE0B28006FD738 /* GlobalExtensions.swift */; };
1112
E81DC09E1FB3EB86007D8D22 /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = E81DC0A01FB3EB86007D8D22 /* Localizable.strings */; };
1213
E825841B1FAF00250048B66C /* PMGestureHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = E825841A1FAF00250048B66C /* PMGestureHandler.swift */; };
@@ -47,6 +48,7 @@
4748
/* End PBXContainerItemProxy section */
4849

4950
/* Begin PBXFileReference section */
51+
4B6DF82F230E54CC00DC746F /* JSTag.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = JSTag.swift; sourceTree = "<group>"; };
5052
E81163461FAE0B28006FD738 /* GlobalExtensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GlobalExtensions.swift; sourceTree = "<group>"; };
5153
E81DC09F1FB3EB86007D8D22 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/Localizable.strings; sourceTree = "<group>"; };
5254
E81DC0A11FB3EBB3007D8D22 /* zh-Hans */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "zh-Hans"; path = "zh-Hans.lproj/Localizable.strings"; sourceTree = "<group>"; };
@@ -122,6 +124,7 @@
122124
isa = PBXGroup;
123125
children = (
124126
E8287B1C1FAFF70C00FF364C /* JSButtonState.swift */,
127+
4B6DF82F230E54CC00DC746F /* JSTag.swift */,
125128
);
126129
path = Models;
127130
sourceTree = "<group>";
@@ -380,6 +383,7 @@
380383
E81163471FAE0B28006FD738 /* GlobalExtensions.swift in Sources */,
381384
E8287B1D1FAFF70C00FF364C /* JSButtonState.swift in Sources */,
382385
E86C8E541FADCCE600BBCA3D /* PMBasicSetting.swift in Sources */,
386+
4B6DF830230E54CC00DC746F /* JSTag.swift in Sources */,
383387
E8DC08CD1FAEBE1E00241F2F /* JSHeaderButton.swift in Sources */,
384388
E8ADFEAF1FADFC4B00821FB1 /* PMCollectionViewProtocals.swift in Sources */,
385389
E86DC3C51FACA67B003DF80A /* AppDelegate.swift in Sources */,
@@ -566,6 +570,7 @@
566570
CODE_SIGN_STYLE = Automatic;
567571
DEVELOPMENT_TEAM = 3DQ777MDT3;
568572
INFOPLIST_FILE = JSPopoverMenu/Info.plist;
573+
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
569574
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
570575
PRODUCT_BUNDLE_IDENTIFIER = wjunshuo.JSPopoverMenu;
571576
PRODUCT_NAME = "$(TARGET_NAME)";
@@ -581,6 +586,7 @@
581586
CODE_SIGN_STYLE = Automatic;
582587
DEVELOPMENT_TEAM = 3DQ777MDT3;
583588
INFOPLIST_FILE = JSPopoverMenu/Info.plist;
589+
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
584590
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
585591
PRODUCT_BUNDLE_IDENTIFIER = wjunshuo.JSPopoverMenu;
586592
PRODUCT_NAME = "$(TARGET_NAME)";

JSPopoverMenuDemo/JSPopoverMenu/Controllers/MainView/MVPopoverMenuDelegate.swift

+3-4
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,14 @@ import UIKit
1010

1111
extension MainViewController: JSPopoverMenuViewDelegate {
1212
var baseView: UIView { return self.view }
13-
1413

1514
func popoverMenu(_ popoverMenu: JSPopoverMenuView, didSelectedAt indexPath: IndexPath) {
1615
print("Don't mess up with me: \(indexPath)")
1716
}
18-
func popoverMenu(_ popoverMenu: JSPopoverMenuView, updatedData data: [String]) {
19-
displayerLabel.text = reduceArray(data)
17+
func popoverMenu(_ popoverMenu: JSPopoverMenuView, updatedData data: [JSTag]) {
18+
displayerLabel.text = reduceArray(data.map(){ $0.title} )
2019
}
21-
func popoverMenu(_ popoverMenu: JSPopoverMenuView, newTag value: String) {
20+
func popoverMenu(_ popoverMenu: JSPopoverMenuView, newTag value: JSTag) {
2221
print(value)
2322
}
2423
}

JSPopoverMenuDemo/JSPopoverMenu/Controllers/MainView/MainViewController.swift

+3-2
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ class MainViewController: UIViewController {
2626

2727
setupDisplayer()
2828
view.addSubview(displayerLabel)
29-
popoverView = JSPopoverMenuView(height: 120, data: defaultData)
29+
popoverView = JSPopoverMenuView(tags: defaultData)
30+
JSPopoverMenuView(data: defaultData.enumerated().map(){ JSDefaultTag(id: $0, title: $1) })
3031
popoverView.delegate = self
3132
}
3233

@@ -42,7 +43,7 @@ class MainViewController: UIViewController {
4243
displayerLabel.numberOfLines = 1
4344
displayerLabel.textAlignment = .center
4445
}
45-
// Mark: - Button in the middle of header
46+
// MARK: - Button in the middle of header
4647

4748
func setupMidButton() {
4849
navigationController?.navigationBar.isTranslucent = false

JSPopoverMenuDemo/JSPopoverMenu/Info.plist

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
<key>CFBundlePackageType</key>
1616
<string>APPL</string>
1717
<key>CFBundleShortVersionString</key>
18-
<string>1.0</string>
18+
<string>1.1</string>
1919
<key>CFBundleVersion</key>
2020
<string>1</string>
2121
<key>LSRequiresIPhoneOS</key>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
//
2+
// JSTag.swift
3+
// JSPopoverMenu
4+
//
5+
// Created by Junshuo on 2019/8/22.
6+
// Copyright © 2019 王俊硕. All rights reserved.
7+
//
8+
9+
import UIKit
10+
11+
protocol JSTag {
12+
var title: String { get set }
13+
var id: Int { get set }
14+
}
15+
16+
class JSDefaultTag: JSTag {
17+
18+
var title: String
19+
var id: Int
20+
21+
init(id: Int, title: String) {
22+
self.id = id
23+
self.title = title
24+
}
25+
}
26+
class JSImageTag: JSDefaultTag {
27+
28+
var image: UIImage?
29+
30+
init(id: Int, image name: String) {
31+
image = UIImage(named: name)
32+
super.init(id: id, title: "")
33+
}
34+
35+
static var addButton: JSImageTag {
36+
return JSImageTag(id: Int.max-2, image: "cross")
37+
}
38+
39+
static var deleteButton: JSImageTag {
40+
return JSImageTag(id: Int.max-1, image: "dustbin")
41+
}
42+
}
43+
func ==(lhs: JSTag, rhs: JSTag) -> Bool {
44+
return lhs.id == rhs.id
45+
}

JSPopoverMenuDemo/JSPopoverMenu/Views/JSModalTextField/JSModalTextField.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ extension JSModalTextField {
116116
dismissA() { self.confirmed?(self.textField.text ?? "") }
117117
}
118118
}
119-
// Mark: - Presentation
119+
// MARK: - Presentation
120120
extension JSModalTextField {
121121
public func show(onView view: UIView, completion: (()->Void)?) {
122122
view.addSubview(backMask)

JSPopoverMenuDemo/JSPopoverMenu/Views/PopoverView/CollectionView/JSMenuCell.swift

+6-4
Original file line numberDiff line numberDiff line change
@@ -22,35 +22,37 @@ class JSMenuCell: UICollectionViewCell {
2222
label!.textAlignment = .center
2323

2424
label!.attributedText = NSAttributedString(string: title, attributes: [NSAttributedStringKey.foregroundColor: UIColor.from(hex: 0x363636), NSAttributedStringKey.font: UIFont.systemFont(ofSize: 13)])
25-
// label.tag = 100013
2625
contentView.addSubview(label!)
2726
}
28-
public func setupImage(name: String) {
27+
public func setupImage(image: UIImage?) {
2928
contentView.subviews.forEach() { $0.removeFromSuperview() }
3029

3130
layer.cornerRadius = 3
3231
clipsToBounds = true
3332

34-
imageView = UIImageView(image: UIImage(named: name))
33+
imageView = UIImageView(image: image)
3534
imageView!.frame = bounds
3635
imageView!.contentMode = .scaleAspectFit
3736
contentView.addSubview(imageView!)
3837
}
39-
/// Turn backgroud to gray. Called when the cell is draging.
38+
/// Turn cell style to moving. Called when the cell is draging.
4039
public func moving() {
4140
guard (label != nil) else { return }
4241
label!.textColor = .from(hex: 0xffffff)
4342
backgroundColor = .from(hex: 0xFD8B15) //Orange
4443
}
44+
/// Turn cell style to halt.
4545
public func halt() {
4646
guard (label != nil) else { return }
4747
label!.textColor = .from(hex: 0x363636) //Black
4848
backgroundColor = .from(hex: 0xe6e6e6) //Gray
4949
}
50+
/// Turn cell style to detain. Called when the cell is dragged to deleted area but not confirmed.
5051
public func detained() {
5152
guard (label != nil) else { return }
5253
label!.alpha = 0.3
5354
}
55+
/// Restore cell style to normal.
5456
public func discharged() {
5557
guard (label != nil) else { return }
5658
label!.alpha = 1

JSPopoverMenuDemo/JSPopoverMenu/Views/PopoverView/CollectionView/PMCollectionViewProtocals.swift

+6-7
Original file line numberDiff line numberDiff line change
@@ -46,21 +46,20 @@ extension JSPopoverMenuView: UICollectionViewDelegate {
4646
}
4747

4848
extension JSPopoverMenuView: UICollectionViewDataSource {
49+
4950
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
5051
return dynamicData.count
5152
}
5253
func numberOfSections(in collectionView: UICollectionView) -> Int {
5354
return 1
5455
}
55-
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
56+
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
5657
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "Cell", for: indexPath) as! JSMenuCell
57-
58-
if dynamicData[indexPath.row] == "add" {
59-
cell.setupImage(name: "cross")
60-
} else if dynamicData[indexPath.row] == "delete" {
61-
cell.setupImage(name: "dustbin")
58+
let item = dynamicData[indexPath.row]
59+
if let item = item as? JSImageTag {
60+
cell.setupImage(image: item.image)
6261
} else {
63-
cell.setup(title: dynamicData[indexPath.row])
62+
cell.setup(title: item.title)
6463
}
6564
return cell
6665
}

0 commit comments

Comments
 (0)