Commit 14de6310 authored by David黄金龙's avatar David黄金龙

tabbar 上view分享逻辑

parent 77005f9f
......@@ -501,6 +501,7 @@
A59B43C92C491FB100B28379 /* YHEvaluationViewVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = A59B43C82C491FB100B28379 /* YHEvaluationViewVC.swift */; };
A59B43CB2C4A151200B28379 /* YHStatusAdvantageVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = A59B43CA2C4A151200B28379 /* YHStatusAdvantageVC.swift */; };
A59B43CD2C4A36DF00B28379 /* YHStatusAdvantageBottomView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A59B43CC2C4A36DF00B28379 /* YHStatusAdvantageBottomView.swift */; };
A59B43CF2C4B5AD100B28379 /* YHShareViewOnTablebarView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A59B43CE2C4B5AD100B28379 /* YHShareViewOnTablebarView.swift */; };
A5A89FD72C256B94005A71DD /* YHHomeLastMessageModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = A5A89FD62C256B94005A71DD /* YHHomeLastMessageModel.swift */; };
A5ACE9282B4564F7002C94D2 /* YHSmsCodeView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A5ACE8DE2B4564F7002C94D2 /* YHSmsCodeView.swift */; };
A5ACE9292B4564F7002C94D2 /* YHSmsCodeInputView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A5ACE8E02B4564F7002C94D2 /* YHSmsCodeInputView.swift */; };
......@@ -1118,6 +1119,7 @@
A59B43C82C491FB100B28379 /* YHEvaluationViewVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHEvaluationViewVC.swift; sourceTree = "<group>"; };
A59B43CA2C4A151200B28379 /* YHStatusAdvantageVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHStatusAdvantageVC.swift; sourceTree = "<group>"; };
A59B43CC2C4A36DF00B28379 /* YHStatusAdvantageBottomView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHStatusAdvantageBottomView.swift; sourceTree = "<group>"; };
A59B43CE2C4B5AD100B28379 /* YHShareViewOnTablebarView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHShareViewOnTablebarView.swift; sourceTree = "<group>"; };
A5A89FD62C256B94005A71DD /* YHHomeLastMessageModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHHomeLastMessageModel.swift; sourceTree = "<group>"; };
A5ACE8DE2B4564F7002C94D2 /* YHSmsCodeView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = YHSmsCodeView.swift; sourceTree = "<group>"; };
A5ACE8E02B4564F7002C94D2 /* YHSmsCodeInputView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = YHSmsCodeInputView.swift; sourceTree = "<group>"; };
......@@ -3071,6 +3073,7 @@
A5ACE9252B4564F7002C94D2 /* YHBasicContentView.swift */,
04A7BC902B6B7B89000E8D47 /* YHTwoOptionAlertView.swift */,
04AAA8DB2BF5E5A200FE9FD5 /* YHEmptyDataView.swift */,
A59B43CE2C4B5AD100B28379 /* YHShareViewOnTablebarView.swift */,
);
path = V;
sourceTree = "<group>";
......@@ -3491,6 +3494,7 @@
A567E5AA2BD7643D00D5D5A0 /* YHGestureTableView.swift in Sources */,
04CE1ADF2C2AD91F001CB80A /* YHActivityListCell.swift in Sources */,
04F5F8642C19460D004A463C /* YHHKLifeViewController.swift in Sources */,
A59B43CF2C4B5AD100B28379 /* YHShareViewOnTablebarView.swift in Sources */,
A5ACE94A2B4564F7002C94D2 /* YHHUDProgressView.swift in Sources */,
04A271232BABFF3200652B1B /* YHCertificateUploadTypeCell.swift in Sources */,
A582B2412BB95998009D098C /* YHHKPlanTipsCell.swift in Sources */,
......
......@@ -8,7 +8,6 @@
import UIKit
import ESTabBarController_swift
class YHTabBarViewController: ESTabBarController {
lazy var viewModel = {
......@@ -16,18 +15,20 @@ class YHTabBarViewController: ESTabBarController {
return model
}()
lazy var testView: UIView = {
let view = UIView()
view.backgroundColor = .purple
lazy var shareView: YHShareViewOnTablebarView = {
let view = YHShareViewOnTablebarView()
view.isHidden = true
return view
}()
private var shareModel : TabBarShareModel?
override func viewDidLayoutSubviews() {
super.viewDidLayoutSubviews()
testView.frame = self.tabBar.frame
testView.bringSubviewToFront(testView)
shareView.frame = self.tabBar.frame
view.bringSubviewToFront(shareView)
}
override func viewDidLoad() {
......@@ -38,9 +39,25 @@ class YHTabBarViewController: ESTabBarController {
reportDeviceInfo()
}
testView.frame = self.tabBar.frame
view.addSubview(testView)
shareView.frame = self.tabBar.frame
view.addSubview(shareView)
shareView.block = { tag in
if let model = self.shareModel {
if tag == 0 {
//分享
YHShareManager.shared.sendLinkContent("Nick哥:我是标题", "Nick哥-这是分享描述", UIImage(named: "AppIcon") ?? UIImage(), link: "https://www.baidu.com/") //todo : for test hjl
// YHShareManager.shared.sendMiniProgram(path: <#T##String#>, name: <#T##String#>
} else {
//预约咨询
let codeUrl = model.codeUrl
let downloadUrl = model.downloadUrl
YHConsultantQRCodeView.codeView(codeUrl, downloadUrl: downloadUrl).show()
}
}
}
}
func addObservers() {
......@@ -71,25 +88,22 @@ extension YHTabBarViewController {
}
@objc func changeShareViewStatus(_ notification: Notification) {
if let dic = notification.object as? [String : Any] {
let show = dic["show"] as? Int ?? 0
if show == 0 {
testView.isHidden = true
testView.layer.opacity = 1.0
UIView.animate(withDuration: 0.25, delay: 0, options: [.curveEaseOut]) {
self.testView.layer.opacity = 0.0
} completion: { finish in }
} else if show == 1 {
self.testView.isHidden = false
self.testView.layer.opacity = 0.0
if let model = notification.object as? TabBarShareModel {
shareModel = model
if model.showFlag {
self.shareView.isHidden = false
self.shareView.layer.opacity = 0.0
UIView.animate(withDuration: 0.25, delay: 0, options: [.curveEaseIn]) {
self.testView.layer.opacity = 1.0
self.shareView.layer.opacity = 1.0
} completion: { finish in }
} else {
testView.isHidden = true
shareView.layer.opacity = 1.0
UIView.animate(withDuration: 0.25, delay: 0, options: [.curveEaseOut]) {
self.shareView.layer.opacity = 0.0
} completion: { finish in
self.shareView.isHidden = true
}
}
}
}
......
//
// YHShareViewOnTablebarView.swift
// galaxy
//
// Created by davidhuangA on 2024/7/20.
// Copyright © 2024 https://www.galaxy-immi.com. All rights reserved.
//
import UIKit
/*
导航栏上的 分享、咨询 按钮
*/
//tabbar上view 的参数对象
struct TabBarShareModel {
var showFlag : Bool = false //是否展示tabbar上的分享view
var shareUrl : String = "" //分享到小程序上的url
var codeUrl : String = "" //用于展示的二维码图片
var downloadUrl : String = ""//用于下载的二维码图片
}
class YHShareViewOnTablebarView: UIView {
static let viewH : CGFloat = 98.0
override init(frame: CGRect) {
super.init(frame: CGRect(x: 0, y: 0, width: KScreenWidth, height: YHBasicInfoFillBottomView.viewH))
setupUI()
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
typealias Block = (Int) -> () //0-快速测评 1-资讯顾问 2-分享有礼
var block: Block?
lazy var topLine: UIView = {
let line = UIView()
line.backgroundColor = UIColor.separatorColor
return line
}()
//分享按钮
lazy var shareBtn: UIButton = {
let button = UIButton(type: .custom)
button.titleLabel?.font = UIFont.PFSC_R(ofSize: 11)
// button.contentHorizontalAlignment = .center
button.setTitle("分享", for: .normal)
button.setTitle("分享", for: .highlighted)
button.setTitleColor(UIColor.mainTextColor, for: .normal)
button.setTitleColor(UIColor.mainTextColor, for: .highlighted)
button.setImage(UIImage(named: "share_item"), for: .normal)
button.setImage(UIImage(named: "share_item"), for: .highlighted)
button.addTarget(self, action: #selector(clickShareBtn), for: .touchUpInside)
return button
}()
//预约咨询
lazy var consultantBtn: UIButton = {
let button = UIButton(type: .custom)
button.titleLabel?.font = UIFont.PFSC_M(ofSize: 15)
button.contentHorizontalAlignment = .center
button.setTitle("预约咨询", for: .normal)
button.setTitleColor(UIColor.white, for: .normal)
button.layer.cornerRadius = kCornerRadius3
button.clipsToBounds = true
button.addTarget(self, action: #selector(clickConsultantBtn), for: .touchUpInside)
button.backgroundColor = UIColor.brandMainColor
return button
}()
override func layoutSubviews() {
super.layoutSubviews()
// if YHLoginManager.shared.isLogin() {
// quickEvaluationBtn.isHidden = true
// consultantBtn.isHidden = true
// rewardBtn.isHidden = false
// } else {
// quickEvaluationBtn.isHidden = false
// consultantBtn.isHidden = false
// rewardBtn.isHidden = true
// }
shareBtn.iconInTop(spacing: 0)
}
}
private extension YHShareViewOnTablebarView {
func setupUI() {
backgroundColor = .white
addSubview(topLine)
addSubview(shareBtn)
addSubview(consultantBtn)
topLine.snp.makeConstraints { make in
make.left.right.top.equalToSuperview()
make.height.equalTo(0.5)
}
shareBtn.snp.makeConstraints { make in
make.top.equalToSuperview().offset(13)
make.left.equalTo(14)
make.right.equalTo(consultantBtn.snp.left).offset(-14)
make.height.equalTo(40)
make.width.equalTo(60)
}
consultantBtn.snp.makeConstraints { make in
make.top.equalTo(shareBtn.snp.top).offset(-5)
make.left.equalTo(shareBtn.snp.right).offset(14)
make.right.equalTo(-20)
make.height.equalTo(44)
}
}
@objc func clickShareBtn() {
block?(0)
}
@objc func clickConsultantBtn() {
block?(1)
}
}
......@@ -100,14 +100,33 @@ class YHMessageBellView: UIView {
// UIViewController.current?.navigationController?.pushViewController(vc)
//todo: for test hjl
//TODO: - for test hjl
testNumber = testNumber + 1
let shareUrl = "https://www.baidu.com"
let codeUrl = "https://public-resuorces.oss-cn-shenzhen.aliyuncs.com/app/article_clue_default_user_code1.png"
let downloadUrl = "https://public-resuorces.oss-cn-shenzhen.aliyuncs.com/app/article_clue_default_user_code.png"
if testNumber % 2 == 0 {
let dic = ["show":0,"other":"https://www.baidu.com"] as [String : Any]
NotificationCenter.default.post(name: YhConstant.YhNotification.changeShareViewStatusOnTabBarNotifiction, object: dic)
//隐藏
// let dic = ["show":0] as [String : Any]
var model = TabBarShareModel()
model.showFlag = false
NotificationCenter.default.post(name: YhConstant.YhNotification.changeShareViewStatusOnTabBarNotifiction, object: model)
} else {
let dic = ["show":1,"other":"https://www.baidu.com"] as [String : Any]
NotificationCenter.default.post(name: YhConstant.YhNotification.changeShareViewStatusOnTabBarNotifiction, object: dic)
//展示
// let dic = ["show":1,
// "shareUrl":shareUrl,
// "codeUrl":codeUrl,
// "downloadUrl":downloadUrl] as [String : Any]
var model = TabBarShareModel()
model.showFlag = true
model.shareUrl = shareUrl
model.codeUrl = codeUrl
model.downloadUrl = downloadUrl
NotificationCenter.default.post(name: YhConstant.YhNotification.changeShareViewStatusOnTabBarNotifiction, object: model)
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment