南鑫林 5 vuotta sitten
vanhempi
commit
89e5770a17

+ 60 - 0
RainbowPlanet/RainbowPlanet.xcodeproj/project.pbxproj

@@ -222,6 +222,11 @@
 		A7931E0322AF827600297D0A /* ESTabBarItemBadgeView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A7931DFB22AF827600297D0A /* ESTabBarItemBadgeView.swift */; };
 		A7931E0422AF827600297D0A /* ESTabBar.swift in Sources */ = {isa = PBXBuildFile; fileRef = A7931DFC22AF827600297D0A /* ESTabBar.swift */; };
 		A7931E0522AF827600297D0A /* ESTabBarItemContainer.swift in Sources */ = {isa = PBXBuildFile; fileRef = A7931DFD22AF827600297D0A /* ESTabBarItemContainer.swift */; };
+		A7931E0822AF855E00297D0A /* RegisterLoginModule.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = A7931E0722AF855E00297D0A /* RegisterLoginModule.xcassets */; };
+		A7931E0D22AF874600297D0A /* GenderSelectionViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = A7931E0C22AF874600297D0A /* GenderSelectionViewController.swift */; };
+		A7931E1122AF989B00297D0A /* TopicSelectionViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = A7931E1022AF989B00297D0A /* TopicSelectionViewController.swift */; };
+		A7931E1422AF9E4000297D0A /* TopicSelectionCollectionViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = A7931E1322AF9E4000297D0A /* TopicSelectionCollectionViewCell.swift */; };
+		A7931E1622AFAEF500297D0A /* TopicSelectionModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = A7931E1522AFAEF500297D0A /* TopicSelectionModel.swift */; };
 		A7A17E5F22A0CEF200B7A77E /* SwiftMoyaNetWorkManagerTools.swift in Sources */ = {isa = PBXBuildFile; fileRef = A7A17E5E22A0CEF200B7A77E /* SwiftMoyaNetWorkManagerTools.swift */; };
 		A7A98DFD227E84F4005306E9 /* SwiftMoyaServiceProductApi.swift in Sources */ = {isa = PBXBuildFile; fileRef = A7A98DFC227E84F4005306E9 /* SwiftMoyaServiceProductApi.swift */; };
 		A7A98DFF227E8501005306E9 /* SwiftMoyaNetWorkServiceProduct.swift in Sources */ = {isa = PBXBuildFile; fileRef = A7A98DFE227E8501005306E9 /* SwiftMoyaNetWorkServiceProduct.swift */; };
@@ -646,6 +651,11 @@
 		A7931DFB22AF827600297D0A /* ESTabBarItemBadgeView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ESTabBarItemBadgeView.swift; sourceTree = "<group>"; };
 		A7931DFC22AF827600297D0A /* ESTabBar.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ESTabBar.swift; sourceTree = "<group>"; };
 		A7931DFD22AF827600297D0A /* ESTabBarItemContainer.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ESTabBarItemContainer.swift; sourceTree = "<group>"; };
+		A7931E0722AF855E00297D0A /* RegisterLoginModule.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = RegisterLoginModule.xcassets; sourceTree = "<group>"; };
+		A7931E0C22AF874600297D0A /* GenderSelectionViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GenderSelectionViewController.swift; sourceTree = "<group>"; };
+		A7931E1022AF989B00297D0A /* TopicSelectionViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TopicSelectionViewController.swift; sourceTree = "<group>"; };
+		A7931E1322AF9E4000297D0A /* TopicSelectionCollectionViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TopicSelectionCollectionViewCell.swift; sourceTree = "<group>"; };
+		A7931E1522AFAEF500297D0A /* TopicSelectionModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TopicSelectionModel.swift; sourceTree = "<group>"; };
 		A7A17E5E22A0CEF200B7A77E /* SwiftMoyaNetWorkManagerTools.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SwiftMoyaNetWorkManagerTools.swift; sourceTree = "<group>"; };
 		A7A59A7722363CCB00417FA4 /* RainbowPlanet.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = RainbowPlanet.entitlements; sourceTree = "<group>"; };
 		A7A98DFC227E84F4005306E9 /* SwiftMoyaServiceProductApi.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SwiftMoyaServiceProductApi.swift; sourceTree = "<group>"; };
@@ -2210,6 +2220,8 @@
 		A77F2CAE2232010F001BD3F6 /* RegisterLoginModule */ = {
 			isa = PBXGroup;
 			children = (
+				A7931E0922AF86D900297D0A /* GenderSelection */,
+				A7931E0E22AF929B00297D0A /* TopicSelection */,
 				A7778CAC2244BC2600C7C47A /* RegisterLogin */,
 				A7778CB52244E93E00C7C47A /* BindPhoneNumber */,
 				A75414F9224B5EFC002480B5 /* MobileLogin */,
@@ -2245,6 +2257,7 @@
 				A7CC74DD22703B4A003C4F38 /* MineModule.xcassets */,
 				A70B2C2C2286E29900B2449F /* ProductModule.xcassets */,
 				A7FF1576228C824300A85748 /* OrderModule.xcassets */,
+				A7931E0722AF855E00297D0A /* RegisterLoginModule.xcassets */,
 				A729B5A92266F6FD004AE098 /* Launch Screen.storyboard */,
 				A77F2C6C2231FB4A001BD3F6 /* Info.plist */,
 			);
@@ -2354,6 +2367,48 @@
 			path = "ESTabBarController-swift";
 			sourceTree = "<group>";
 		};
+		A7931E0922AF86D900297D0A /* GenderSelection */ = {
+			isa = PBXGroup;
+			children = (
+				A7931E0B22AF872000297D0A /* ViewController */,
+			);
+			path = GenderSelection;
+			sourceTree = "<group>";
+		};
+		A7931E0B22AF872000297D0A /* ViewController */ = {
+			isa = PBXGroup;
+			children = (
+				A7931E0C22AF874600297D0A /* GenderSelectionViewController.swift */,
+			);
+			path = ViewController;
+			sourceTree = "<group>";
+		};
+		A7931E0E22AF929B00297D0A /* TopicSelection */ = {
+			isa = PBXGroup;
+			children = (
+				A7931E1222AF9E2500297D0A /* View */,
+				A7931E0F22AF988900297D0A /* ViewController */,
+			);
+			path = TopicSelection;
+			sourceTree = "<group>";
+		};
+		A7931E0F22AF988900297D0A /* ViewController */ = {
+			isa = PBXGroup;
+			children = (
+				A7931E1022AF989B00297D0A /* TopicSelectionViewController.swift */,
+				A7931E1522AFAEF500297D0A /* TopicSelectionModel.swift */,
+			);
+			path = ViewController;
+			sourceTree = "<group>";
+		};
+		A7931E1222AF9E2500297D0A /* View */ = {
+			isa = PBXGroup;
+			children = (
+				A7931E1322AF9E4000297D0A /* TopicSelectionCollectionViewCell.swift */,
+			);
+			path = View;
+			sourceTree = "<group>";
+		};
 		A7A98DFB227E84D0005306E9 /* SwiftMoyaServiceProduct */ = {
 			isa = PBXGroup;
 			children = (
@@ -3369,6 +3424,7 @@
 				BD108C9B22A60C3300837DAB /* HGImage.storyboard in Resources */,
 				A7FF1577228C824300A85748 /* OrderModule.xcassets in Resources */,
 				BD20F1D82283D2AA00677D8E /* ShoppingCartModule.xcassets in Resources */,
+				A7931E0822AF855E00297D0A /* RegisterLoginModule.xcassets in Resources */,
 				A7778C9922438F5D00C7C47A /* README.txt in Resources */,
 				BD108C9A22A60C3300837DAB /* HGImage.xcassets in Resources */,
 				A729B5AA2266F6FD004AE098 /* Launch Screen.storyboard in Resources */,
@@ -3481,6 +3537,7 @@
 				A7B4E7352281907A0012914A /* CMSModel.swift in Sources */,
 				A72A72BE22321DE000B21995 /* Extension+RxTimer.swift in Sources */,
 				A7CC74EA22706ACD003C4F38 /* MessageViewController.swift in Sources */,
+				A7931E1622AFAEF500297D0A /* TopicSelectionModel.swift in Sources */,
 				BDF47D7E22827C3F00941AB9 /* ProductSlidingTopBottomCollectionViewCell.swift in Sources */,
 				BD108C9522A60C2100837DAB /* HGImageCollectionViewCell.swift in Sources */,
 				A7FF1589228C854900A85748 /* OrderDetailBottomView.swift in Sources */,
@@ -3495,6 +3552,7 @@
 				A7CC74D4226FF1AA003C4F38 /* MineView.swift in Sources */,
 				A71AA5152272160A008FF1A5 /* ExpressAddressListTableViewCell.swift in Sources */,
 				A72A72B722321DE000B21995 /* Extension+NSMutableAttributedString.swift in Sources */,
+				A7931E0D22AF874600297D0A /* GenderSelectionViewController.swift in Sources */,
 				A7BB6857226965C100AB07A2 /* SelfRecommendationHeaderCollectionReusableView.swift in Sources */,
 				BDE3045F228554CA001D050F /* ProductCartAmountModel.swift in Sources */,
 				A7BB68672269B1DD00AB07A2 /* AddressPOIViewController.swift in Sources */,
@@ -3507,6 +3565,7 @@
 				BD3AA45F22AE6F2500EF4F20 /* MessagePlanetTableCell.swift in Sources */,
 				A7284404224DBFBD00F82F30 /* UserModel.swift in Sources */,
 				A7CC74D822700359003C4F38 /* MineTableViewHeaderView.swift in Sources */,
+				A7931E1122AF989B00297D0A /* TopicSelectionViewController.swift in Sources */,
 				A71D2A602265673A00A55D16 /* RegisterLoginView.swift in Sources */,
 				A73D7C682268A032002A4CE3 /* SwiftyStarRatingView.swift in Sources */,
 				A7931E0122AF827600297D0A /* ESTabBarItemContentView.swift in Sources */,
@@ -3681,6 +3740,7 @@
 				A7274C5C228EE636000E3A07 /* LBXScanLineAnimation.swift in Sources */,
 				A739121A229F75F50033177E /* JXPagingMainTableView.swift in Sources */,
 				A7CC7524227190FB003C4F38 /* AccountSecurityView.swift in Sources */,
+				A7931E1422AF9E4000297D0A /* TopicSelectionCollectionViewCell.swift in Sources */,
 				BD1DC6CB228D157000B89C57 /* OrderCreateBackModel.swift in Sources */,
 				A72A72BD22321DE000B21995 /* Extension+UIColor.swift in Sources */,
 				A7FF1596228CFA8100A85748 /* OrderListViewController.swift in Sources */,

+ 2 - 1
RainbowPlanet/RainbowPlanet/Base/BaseTabbarViewController/BaseTabbarViewController.swift

@@ -40,7 +40,8 @@ class BaseTabbarViewController: ESTabBarController {
         }
         
         /// 社区
-        let v1 = CommunityViewController()
+//        let v1 = CommunityViewController()
+        let v1 = GenderSelectionViewController()
         /// 商城
         let v2 = ShoppingMallViewController()
         /// 发布

+ 8 - 0
RainbowPlanet/RainbowPlanet/Macro/ColorMacro.swift

@@ -25,8 +25,16 @@ let kEnabledTitleColor = UIColor(hexString: "FFFFFF")
 
 let k333333Color = UIColor(hexString: "333333")
 
+let k313334Color = UIColor(hexString: "313334")
+
 let k666666Color = UIColor(hexString: "666666")
 
+let kFFF9F0Color = UIColor(hexString: "FFF9F0")
+
+let kFFEDD3Color = UIColor(hexString: "FFEDD3")
+
+
+
 let k999999Color = UIColor(hexString: "999999")
 
 let kffffffColor = UIColor(hexString: "ffffff")

+ 1 - 0
RainbowPlanet/RainbowPlanet/Macro/FontMacro.swift

@@ -79,6 +79,7 @@ let kScaleMediumFont16 = UIFont(name: "PingFang-SC-Medium", size: kScaleValue(va
 let kScaleMediumFont17 = UIFont(name: "PingFang-SC-Medium", size: kScaleValue(value: 17))
 let kScaleMediumFont18 = UIFont(name: "PingFang-SC-Medium", size: kScaleValue(value: 18))
 let kScaleMediumFont20 = UIFont(name: "PingFang-SC-Medium", size: kScaleValue(value: 20))
+let kScaleMediumFont22 = UIFont(name: "PingFang-SC-Medium", size: kScaleValue(value: 22))
 let kScaleMediumFont24 = UIFont(name: "PingFang-SC-Medium", size: kScaleValue(value: 24))
 let kScaleMediumFont25 = UIFont(name: "PingFang-SC-Medium", size: kScaleValue(value: 25))
 let kScaleMediumFont27 = UIFont(name: "PingFang-SC-Medium", size: kScaleValue(value: 27))

+ 137 - 0
RainbowPlanet/RainbowPlanet/Modules/RegisterLoginModule/GenderSelection/ViewController/GenderSelectionViewController.swift

@@ -0,0 +1,137 @@
+//
+//  GenderSelectionViewController.swift
+//  RainbowPlanet
+//
+//  Created by 南鑫林 on 2019/6/11.
+//  Copyright © 2019 RainbowPlanet. All rights reserved.
+//
+
+import UIKit
+
+class GenderSelectionViewController: BaseViewController {
+
+    override func viewDidLoad() {
+        super.viewDidLoad()
+        setupViews()
+        setupLayouts()
+    }
+    
+    override func setupViews() {
+        navigationBar.isHidden = true
+        view.addSubview(titleLable)
+        view.addSubview(subtitleLable)
+        view.addSubview(maleButton)
+        view.addSubview(femaleButton)
+        view.addSubview(maleTitleButton)
+        view.addSubview(femaleTitleButton)
+    }
+    
+    override func setupLayouts() {
+        titleLable.snp.makeConstraints { (make) in
+            make.top.equalTo(kNavBarTotalHeight + 75 * kScaleWidth)
+            make.left.equalTo(38 * kScaleWidth)
+            make.height.equalTo(31 * kScaleWidth)
+        }
+        subtitleLable.snp.makeConstraints { (make) in
+            make.top.equalTo(titleLable.snp.bottom).offset(6 * kScaleWidth)
+            make.left.equalTo(titleLable)
+            make.height.equalTo(17 * kScaleWidth)
+        }
+        maleButton.snp.makeConstraints { (make) in
+            make.top.equalTo(subtitleLable.snp.bottom).offset(50 * kScaleWidth)
+            make.left.equalTo(38 * kScaleWidth)
+            make.size.equalTo(120 * kScaleWidth)
+        }
+        
+        femaleButton.snp.makeConstraints { (make) in
+            make.top.equalTo(subtitleLable.snp.bottom).offset(50 * kScaleWidth)
+            make.right.equalTo(-38 * kScaleWidth)
+            make.size.equalTo(120 * kScaleWidth)
+        }
+        
+        maleTitleButton.snp.makeConstraints { (make) in
+            make.top.equalTo(maleButton.snp_bottom).offset(15 * kScaleWidth)
+            make.centerX.equalTo(maleButton)
+        }
+        
+        femaleTitleButton.snp.makeConstraints { (make) in
+            make.top.equalTo(femaleButton.snp_bottom).offset(15 * kScaleWidth)
+            make.centerX.equalTo(femaleButton)
+        }
+    }
+    
+    private lazy var titleLable: UILabel = {
+        let titleLable = UILabel()
+        titleLable.text = "欢迎登陆彩虹星球"
+        titleLable.textColor = k313334Color
+        titleLable.font = kScaleMediumFont22
+        return titleLable
+    }()
+    
+    private lazy var subtitleLable: UILabel = {
+        let subtitleLable = UILabel()
+        subtitleLable.text = "选择您的星球身份,开启个性化内容定制"
+        subtitleLable.textColor = k666666Color
+        subtitleLable.font = kScaleRegularFont12
+        return subtitleLable
+    }()
+    
+    private lazy var maleButton: UIButton = {
+        let maleButton = UIButton(type: UIButton.ButtonType.custom)
+        maleButton.setBackgroundImage(UIImage.imageWithColor(color: kFFF9F0Color), for: UIControl.State.normal)
+        maleButton.setBackgroundImage(UIImage.imageWithColor(color: kFFEDD3Color), for: UIControl.State.highlighted)
+        maleButton.setImage(kImage(name: "pic_preload"), for: UIControl.State.normal)
+        maleButton.cornerRadius = 10
+        maleButton.masksToBounds = true
+        maleButton.rx.tap.subscribe(onNext: {
+            [weak self] (data) in
+            self?.presentVC()
+        }).disposed(by: disposeBag)
+        return maleButton
+    }()
+    
+    private lazy var femaleButton: UIButton = {
+        let femaleButton = UIButton(type: UIButton.ButtonType.custom)
+        femaleButton.setBackgroundImage(UIImage.imageWithColor(color: kFFF9F0Color), for: UIControl.State.normal)
+        femaleButton.setBackgroundImage(UIImage.imageWithColor(color: kFFEDD3Color), for: UIControl.State.highlighted)
+        femaleButton.setImage(kImage(name: "pic_preload"), for: UIControl.State.normal)
+        femaleButton.cornerRadius = 10
+        femaleButton.masksToBounds = true
+        femaleButton.rx.tap.subscribe(onNext: {
+            [weak self] (data) in
+            self?.presentVC()
+        }).disposed(by: disposeBag)
+        return femaleButton
+    }()
+    
+    private lazy var maleTitleButton: UIButton = {
+        let maleTitleButton = UIButton(type: UIButton.ButtonType.custom)
+        maleTitleButton.setTitle("男生", for: UIControl.State.normal)
+        maleTitleButton.setTitleColor(k333333Color, for: UIControl.State.normal)
+        maleTitleButton.titleLabel?.font = kScaleRegularFont16
+        maleTitleButton.rx.tap.subscribe(onNext: {
+            [weak self] (data) in
+            self?.presentVC()
+        }).disposed(by: disposeBag)
+        return maleTitleButton
+    }()
+    
+    private lazy var femaleTitleButton: UIButton = {
+        let femaleTitleButton = UIButton(type: UIButton.ButtonType.custom)
+        femaleTitleButton.setTitle("女生", for: UIControl.State.normal)
+        femaleTitleButton.setTitleColor(k333333Color, for: UIControl.State.normal)
+        femaleTitleButton.titleLabel?.font = kScaleRegularFont16
+        femaleTitleButton.rx.tap.subscribe(onNext: {
+            [weak self] (data) in
+            self?.presentVC()
+        }).disposed(by: disposeBag)
+        return femaleTitleButton
+    }()
+}
+
+extension GenderSelectionViewController {
+    func presentVC() {
+        let vc = TopicSelectionViewController()
+        self.present(vc, animated: true, completion: nil)
+    }
+}

+ 93 - 0
RainbowPlanet/RainbowPlanet/Modules/RegisterLoginModule/TopicSelection/View/TopicSelectionCollectionViewCell.swift

@@ -0,0 +1,93 @@
+//
+//  TopicSelectionCollectionViewCell.swift
+//  RainbowPlanet
+//
+//  Created by 南鑫林 on 2019/6/11.
+//  Copyright © 2019 RainbowPlanet. All rights reserved.
+//
+
+import UIKit
+
+class TopicSelectionCollectionViewCell: UICollectionViewCell {
+    class func cellWith(collectionView:UICollectionView,indexPath:IndexPath) -> TopicSelectionCollectionViewCell {
+        let ID = "TopicSelectionCollectionViewCell"
+        collectionView.register(TopicSelectionCollectionViewCell.self, forCellWithReuseIdentifier: ID)
+        let cell : TopicSelectionCollectionViewCell = collectionView.dequeueReusableCell(withReuseIdentifier: ID, for: indexPath) as! TopicSelectionCollectionViewCell
+        cell.indexPath = indexPath
+        return cell
+    }
+    //MARK: - indexPath
+    var indexPath: IndexPath?{
+        didSet {
+            
+        }
+    }
+    //MARK: - 初始化
+    override init(frame: CGRect) {
+        super.init(frame: frame)
+        setupViews()
+        setupLayouts()
+    }
+    
+    required init?(coder aDecoder: NSCoder) {
+        fatalError("init(coder:) has not been implemented")
+    }
+    
+    //MARK: - 设置view
+    private func setupViews() {
+        self.cornerRadius = 8 * kScaleWidth
+        self.masksToBounds = true
+        addSubview(iconImageView)
+        addSubview(selectionButton)
+        addSubview(titleLabel)
+    }
+    
+    private func setupLayouts() {
+        selectionButton.snp.makeConstraints { (make) in
+            make.top.equalTo(5 * kScaleWidth)
+            make.right.equalTo(-5 * kScaleWidth)
+            make.size.equalTo(22 * kScaleWidth)
+        }
+        titleLabel.snp.makeConstraints { (make) in
+            make.bottom.equalTo(5 * kScaleWidth)
+            make.left.equalTo(5 * kScreenWidth)
+            make.right.equalTo(-5 * kScreenWidth)
+        }
+    }
+    
+    private lazy var iconImageView: UIImageView = {
+        let iconImageView = UIImageView(frame: CGRect(x: 0, y: 0, width: self.width, height: self.height))
+        let bgLayer1 = CAGradientLayer()
+        bgLayer1.rainbowLayer(gradientColors: [UIColor(hexString: "000000", alpha: 0).cgColor,UIColor(hexString: "000000", alpha: 0.4).cgColor], gradientLocations: [0,1], gradientDisplayType: .vertical, startPoint: CGPoint(x: 0.5, y: 0), endPoint: CGPoint(x: 1, y: 1))
+        iconImageView.image = kImage(name: "pic_preload")
+        iconImageView.layer.addSublayer(bgLayer1)
+        iconImageView.contentMode = .scaleAspectFit
+        iconImageView.isUserInteractionEnabled = true
+        return iconImageView
+    }()
+    
+    private lazy var selectionButton: UIButton = {
+        let selectionButton = UIButton(type: UIButton.ButtonType.custom)
+        selectionButton.setImage(kImage(name: "hg_image_not_selected"), for: UIControl.State.normal)
+        selectionButton.setImage(kImage(name: "hg_image_selected"), for: UIControl.State.selected)
+        return selectionButton
+    }()
+    
+    private lazy var titleLabel: UILabel = {
+        let titleLabel = UILabel()
+        titleLabel.text = "生活方式"
+        titleLabel.textColor = kffffffColor
+        titleLabel.font = kScaleRegularFont14
+        titleLabel.textAlignment = .center
+        titleLabel.adjustsFontSizeToFitWidth = true
+        return titleLabel
+    }()
+    
+    var topicSelectionModel: TopicSelectionModel? {
+        didSet {
+            selectionButton.isSelected = topicSelectionModel?.isSelected ?? false
+        }
+    }
+    
+    
+}

+ 13 - 0
RainbowPlanet/RainbowPlanet/Modules/RegisterLoginModule/TopicSelection/ViewController/TopicSelectionModel.swift

@@ -0,0 +1,13 @@
+//
+//  TopicSelectionModel.swift
+//  RainbowPlanet
+//
+//  Created by 南鑫林 on 2019/6/11.
+//  Copyright © 2019 RainbowPlanet. All rights reserved.
+//
+
+import UIKit
+
+class TopicSelectionModel: NSObject {
+    var isSelected : Bool = false    
+}

+ 141 - 0
RainbowPlanet/RainbowPlanet/Modules/RegisterLoginModule/TopicSelection/ViewController/TopicSelectionViewController.swift

@@ -0,0 +1,141 @@
+//
+//  TopicSelectionViewController.swift
+//  RainbowPlanet
+//
+//  Created by 南鑫林 on 2019/6/11.
+//  Copyright © 2019 RainbowPlanet. All rights reserved.
+//
+
+import UIKit
+
+class TopicSelectionViewController: BaseViewController {
+    
+    var indexPathDict = Dictionary<Int, Any>()
+    
+    var TopicSelectionModels = Array<TopicSelectionModel>()
+    
+    override func viewDidLoad() {
+        super.viewDidLoad()
+        setupViews()
+        setupLayouts()
+        setupData()
+    }
+    
+    override func setupViews() {
+        navigationBar.isHidden = true
+        view.addSubview(titleLable)
+        view.addSubview(subtitleLable)
+        view.addSubview(collectionView)
+        view.addSubview(goButton)
+    }
+    
+    override func setupLayouts() {
+        titleLable.snp.makeConstraints { (make) in
+            make.top.equalTo(kNavBarTotalHeight + 75 * kScaleWidth)
+            make.left.equalTo(38 * kScaleWidth)
+            make.height.equalTo(31 * kScaleWidth)
+        }
+        subtitleLable.snp.makeConstraints { (make) in
+            make.top.equalTo(titleLable.snp.bottom).offset(6 * kScaleWidth)
+            make.left.equalTo(titleLable)
+            make.height.equalTo(17 * kScaleWidth)
+        }
+        collectionView.snp.makeConstraints { (make) in
+            make.top.equalTo(subtitleLable.snp.bottom).offset(50 * kScaleWidth)
+            make.left.equalTo(38 * kScaleWidth)
+            make.right.equalTo(-38 * kScaleWidth)
+            make.height.equalTo(kScreenWidth - (38 * kScaleWidth * 2))
+        }
+        goButton.snp.makeConstraints { (make) in
+            make.top.equalTo(collectionView.snp.bottom).offset(22 * kScaleWidth)
+            make.left.right.equalTo(collectionView)
+            make.height.equalTo(44 * kScaleWidth)
+        }
+    }
+    
+    override func setupData() {
+        for _ in 0...11 {
+            TopicSelectionModels.append(TopicSelectionModel())
+        }
+        collectionView.reloadData()
+    }
+    
+    private lazy var titleLable: UILabel = {
+        let titleLable = UILabel()
+        titleLable.text = "请选择您关注的生活方式"
+        titleLable.textColor = k313334Color
+        titleLable.font = kScaleMediumFont22
+        return titleLable
+    }()
+    
+    private lazy var subtitleLable: UILabel = {
+        let subtitleLable = UILabel()
+        subtitleLable.text = "选择想看的内容吧,至少选择三个内容哦~"
+        subtitleLable.textColor = k666666Color
+        subtitleLable.font = kScaleRegularFont12
+        return subtitleLable
+    }()
+    
+    private lazy var collectionView: UICollectionView = {
+        let collectionView = UICollectionView.init(frame: CGRect.zero, collectionViewLayout: collectionViewLayout)
+        collectionView.backgroundColor = UIColor.white
+        collectionView.delegate = self;
+        collectionView.dataSource = self;
+        collectionView.showsVerticalScrollIndicator = false
+        collectionView.showsHorizontalScrollIndicator = false
+        return collectionView
+    }()
+    
+    private lazy var collectionViewLayout: UICollectionViewFlowLayout = {
+        let collectionViewLayout = UICollectionViewFlowLayout.init()
+        collectionViewLayout.minimumLineSpacing = 18 * kScaleWidth
+        collectionViewLayout.minimumInteritemSpacing = 18 * kScaleWidth
+        collectionViewLayout.itemSize = CGSize(width: (kScreenWidth-(38*kScaleWidth*2)-(18.5*kScaleWidth*2))/3, height: (kScreenWidth-(38*kScaleWidth*2)-(18.5*kScaleWidth*2))/3)
+        return collectionViewLayout
+    }()
+    
+    private lazy var goButton: UIButton = {
+        let goButton = UIButton(type: UIButton.ButtonType.custom)
+        goButton.setBackgroundImage(UIImage.imageWithColor(color: kDisabledButtonColor), for: UIControl.State.disabled)
+        goButton.setBackgroundImage(UIImage.imageWithColor(color: kEnabledButtonColor), for: UIControl.State.normal)
+        goButton.setTitleColor(kDisabledTitleColor, for: UIControl.State.disabled)
+        goButton.setTitleColor(kEnabledTitleColor, for: UIControl.State.normal)
+        goButton.setTitle("进入星球", for: UIControl.State.normal)
+        goButton.titleLabel?.font = kScaleMediumFont18
+        goButton.isEnabled = false
+        goButton.cornerRadius = 22 * kScaleWidth
+        goButton.masksToBounds = true
+        return goButton
+    }()
+
+}
+
+extension TopicSelectionViewController: UICollectionViewDelegateFlowLayout,UICollectionViewDataSource {
+    func numberOfSections(in collectionView: UICollectionView) -> Int {
+        
+        return 1
+    }
+    
+    func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
+        return TopicSelectionModels.count
+    }
+    
+    func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
+        let cell = TopicSelectionCollectionViewCell.cellWith(collectionView: collectionView, indexPath: indexPath)
+        cell.topicSelectionModel = TopicSelectionModels[indexPath.row]
+        return cell
+        
+    }
+    
+    func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
+        let cell = collectionView.cellForItem(at: indexPath) as! TopicSelectionCollectionViewCell
+        cell.topicSelectionModel?.isSelected = !(cell.topicSelectionModel?.isSelected ?? false)
+        if cell.topicSelectionModel?.isSelected ?? false {
+            indexPathDict.updateValue(indexPath, forKey: indexPath.row)
+        }else {
+            indexPathDict.removeValue(forKey: indexPath.row)
+        }
+        goButton.isEnabled = indexPathDict.count >= 3 ? true : false
+    }
+    
+}

+ 2 - 2
RainbowPlanet/RainbowPlanet/Tools/Extension/Extension+UIColor.swift

@@ -9,7 +9,7 @@
 import UIKit
 
 extension UIColor {
-    convenience init(hexString:String){
+    convenience init(hexString:String,alpha:CGFloat = 1.0){
         //处理数值
         var cString = hexString.uppercased().trimmingCharacters(in: CharacterSet.whitespacesAndNewlines)
         
@@ -45,6 +45,6 @@ extension UIColor {
         Scanner(string: gString).scanHexInt32(&g)
         Scanner(string: bString).scanHexInt32(&b)
         //根据颜色值创建UIColor
-        self.init(red: CGFloat(r)/255.0, green: CGFloat(g)/255.0, blue: CGFloat(b)/255.0, alpha: 1.0)
+        self.init(red: CGFloat(r)/255.0, green: CGFloat(g)/255.0, blue: CGFloat(b)/255.0, alpha: alpha)
     }
 }

+ 1 - 1
RainbowPlanet/RainbowPlanet/Tools/Extension/Extension+UIView.swift

@@ -8,7 +8,7 @@
 
 import UIKit
 
-public extension UIView {
+extension UIView {
     
     var x:CGFloat{
         get{