Commit 748eb3de authored by David黄金龙's avatar David黄金龙

Merge branch 'youhua-dev' of http://gitlab.galaxy-immi.com/mobile-group/galaxy-iOS into youhua-dev

* 'youhua-dev' of http://gitlab.galaxy-immi.com/mobile-group/galaxy-iOS:
  // 刷新组件
  // 更改刷新方式
  文件添加
  //  新增自定义刷新组件
  点赞动画添加
parents 246a4000 f7329d56
......@@ -81,6 +81,10 @@ target 'galaxy' do
pod 'BMPlayer', '1.3.0'
#高斯模糊
pod 'VisualEffectView', '4.1.5'
#GIF图播放
pod 'FLAnimatedImage', '1.0.17'
#动画框架
pod 'lottie-ios', '4.4.0'
end
......
This diff is collapsed.
......@@ -146,7 +146,7 @@ private extension YHHomePageViewController {
view.addSubview(homeCollectView)
homeCollectView.snp.makeConstraints { make in
make.left.right.equalToSuperview()
make.top.equalTo(searchView.snp.bottom).offset(6)
make.top.equalTo(searchView.snp.bottom).offset(6+20)
make.bottom.equalToSuperview().offset(-k_Height_TabBar)
}
......@@ -154,7 +154,7 @@ private extension YHHomePageViewController {
homeCollectView.addSubview(homeHeaderView)
homeCollectView.contentInset = UIEdgeInsets(top: YHHomeHeadView.viewH, left: 0, bottom: 0, right: 0)
let tmpHeadView = homeCollectView.es.addPullToRefresh {
let tmpHeadView = homeCollectView.es.addYHPullToRefresh {
self.loadFirstData()
}
......
......@@ -85,7 +85,7 @@ class YHSearchInfomationVC: YHBaseViewController {
tableView.backgroundColor = .white
tableView.backgroundView = emptyDataTipsView
tableView.register(YHSearchInfoCell.self, forCellReuseIdentifier: YHSearchInfoCell.cellReuseIdentifier)
tableView.es.addPullToRefresh {
tableView.es.addYHPullToRefresh {
self.loadFirstData()
}
tableView.es.addInfiniteScrolling {
......
......@@ -10,6 +10,7 @@ import UIKit
import Kingfisher
import AVFoundation
import AVKit
import Lottie
class YHHomeCollectionViewCell: UICollectionViewCell {
static let cellReuseIdentifier = "YHHomeCollectionViewCell"
......@@ -66,7 +67,8 @@ class YHHomeCollectionViewCell: UICollectionViewCell {
label.font = UIFont.PFSC_R(ofSize: 12)
return label
}()
var animationView: LottieAnimationView!
required init?(coder: NSCoder) {
super.init(coder: coder)
}
......@@ -138,6 +140,18 @@ extension YHHomeCollectionViewCell {
make.height.equalTo(16)
}
animationView = {
let view = LottieAnimationView(name: "shouye")
view.isHidden = true
return view
}()
subHoldView.addSubview(animationView)
animationView.snp.makeConstraints { make in
make.right.equalTo(numLable.snp.left).offset(2.5)
make.height.width.equalTo(24)
make.centerY.equalTo(numLable).offset(-0.5)
}
subHoldView.addSubview(heartImageViewBtn)
heartImageViewBtn.snp.makeConstraints { make in
make.right.equalTo(numLable.snp.left).offset(-2)
......@@ -199,6 +213,12 @@ extension YHHomeCollectionViewCell {
if YHLoginManager.shared.isLogin() {
if listModel.is_like == false {
animationView.isHidden = false
animationView.loopMode = .playOnce
animationView.play {[weak self] completed in
guard let self = self else { return }
self.animationView.isHidden = true
}
viewModel.getLike(listModel.id, 1) {[weak self] success, error in
guard let self = self else { return }
if success {
......@@ -208,6 +228,7 @@ extension YHHomeCollectionViewCell {
}
}
} else {
animationView.isHidden = true
viewModel.getLike(listModel.id, 0) {[weak self] success, error in
guard let self = self else { return }
if success {
......
......@@ -8,7 +8,7 @@
import UIKit
class YHHomeHeadView: UIView {
static let viewH : CGFloat = (20 + YHHomeBannerView.viewH) + (20 + YHHkLifeAndIdView.viewH) + (20 + YHHomeKingKongBlockView.viewH) + 20 + 20 + 1
static let viewH : CGFloat = (YHHomeBannerView.viewH) + (20 + YHHkLifeAndIdView.viewH) + (20 + YHHomeKingKongBlockView.viewH) + 20 + 20 + 1
override init(frame: CGRect) {
super.init(frame: frame)
......@@ -44,7 +44,7 @@ private extension YHHomeHeadView {
addSubview(homeBannerView)
homeBannerView.snp.makeConstraints { make in
make.top.equalTo(20)
make.top.equalTo(0)
make.left.right.equalToSuperview()
make.height.equalTo(YHHomeBannerView.viewH)
}
......
......@@ -7,6 +7,7 @@
//
import UIKit
import Lottie
enum YHTintColorMode {
case light
......@@ -22,6 +23,7 @@ class YHHomeWebBottomView: UIView {
var starBlock: Block?
var likeButton: YHHomeWebBottomButton!
var starButton: YHHomeWebBottomButton!
var animationView: LottieAnimationView!
var likeCount: Int = 0
var starCount: Int = 0
var isStar: Bool = false {
......@@ -77,7 +79,18 @@ class YHHomeWebBottomView: UIView {
}
func setUpView() {
animationView = {
let view = LottieAnimationView(name: "zixun")
view.isHidden = true
return view
}()
addSubview(animationView)
animationView.snp.makeConstraints { make in
make.right.equalTo(-72)
make.top.equalTo(2.5)
make.height.equalTo(36)
make.width.equalTo(36)
}
likeButton = {
let button = YHHomeWebBottomButton()
button.setContent(UIImage(named:"home_web_like"), "0")
......@@ -86,7 +99,7 @@ class YHHomeWebBottomView: UIView {
}()
addSubview(likeButton)
likeButton.snp.makeConstraints { make in
make.right.equalTo(-79)
make.centerX.equalTo(animationView.snp.centerX)
make.top.equalTo(10)
make.height.equalTo(39)
make.width.equalTo(24)
......@@ -115,6 +128,16 @@ class YHHomeWebBottomView: UIView {
return
}
isLike = !isLike
if isLike {
animationView.isHidden = false
animationView.loopMode = .playOnce
animationView.play {[weak self] completed in
guard let self = self else { return }
self.animationView.isHidden = true
}
} else {
animationView.isHidden = true
}
if let block = likeBlock {
block(isLike)
}
......
//
// YHRefreshHeaderAnimator.swift
// galaxy
//
// Created by edy on 2024/5/16.
// Copyright © 2024 https://www.galaxy-immi.com. All rights reserved.
//
import UIKit
import ESPullToRefresh
import FLAnimatedImage
public extension ES where Base: UIScrollView {
@discardableResult
func addYHPullToRefresh(handler: @escaping ESRefreshHandler) -> ESRefreshHeaderView {
return self.addPullToRefresh(animator: YHRefreshHeaderAnimator.init(), handler: handler)
}
}
class YHRefreshHeaderAnimator: UIView , ESRefreshProtocol, ESRefreshAnimatorProtocol, ESRefreshImpactProtocol {
static let logoWidth = 62.0
static let logoHeight = 23.0
static let tipsHeight = 18.0
static let topMargin = 17.0
static let bottomMargin = 19.0
static let midGap = 4.0
static let headerHeight = YHRefreshHeaderAnimator.topMargin + YHRefreshHeaderAnimator.logoHeight + YHRefreshHeaderAnimator.midGap + YHRefreshHeaderAnimator.tipsHeight + YHRefreshHeaderAnimator.bottomMargin
open var pullToRefreshDescription = "下拉刷新".local {
didSet {
if pullToRefreshDescription != oldValue {
titleLabel.text = pullToRefreshDescription;
}
}
}
open var releaseToRefreshDescription = "松手开始刷新".local
open var loadingDescription = "加载中...".local
open var view: UIView { return self }
open var insets: UIEdgeInsets = UIEdgeInsets.zero
open var trigger: CGFloat = YHRefreshHeaderAnimator.headerHeight
open var executeIncremental: CGFloat = YHRefreshHeaderAnimator.headerHeight
open var state: ESRefreshViewState = .pullToRefresh
fileprivate let logoImgView: UIImageView = {
let imageView = UIImageView(image: UIImage(named: "galaxy_icon_refresher"))
return imageView
}()
fileprivate let animaitonImgView: FLAnimatedImageView = {
let imgV = FLAnimatedImageView()
imgV.isHidden = true
let url = Bundle.main.url(forResource: "galaxy_refresher", withExtension: "gif")!
if let animatedImage = try? FLAnimatedImage(animatedGIFData: Data(contentsOf: url)) {
imgV.animatedImage = animatedImage
} else {
print("Error loading GIF")
}
return imgV
}()
fileprivate let titleLabel: UILabel = {
let label = UILabel.init(frame: CGRect.zero)
label.font = UIFont.PFSC_R(ofSize: 12)
label.textColor = UIColor.init(hex: 0x0046B4, alpha: 0.4)
label.textAlignment = .left
return label
}()
public override init(frame: CGRect) {
super.init(frame: frame)
titleLabel.text = pullToRefreshDescription
self.addSubview(logoImgView)
self.addSubview(animaitonImgView)
self.addSubview(titleLabel)
}
public required init(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
open func refreshAnimationBegin(view: ESRefreshComponent) {
self.titleLabel.text = loadingDescription
self.animaitonImgView.isHidden = false
}
open func refreshAnimationEnd(view: ESRefreshComponent) {
self.animaitonImgView.isHidden = true
self.titleLabel.text = pullToRefreshDescription
}
open func refresh(view: ESRefreshComponent, progressDidChange progress: CGFloat) {
// Do nothing
}
open func refresh(view: ESRefreshComponent, stateDidChange state: ESRefreshViewState) {
guard self.state != state else {
return
}
self.state = state
switch state {
case .refreshing, .autoRefreshing:
titleLabel.text = loadingDescription
self.setNeedsLayout()
break
case .releaseToRefresh:
titleLabel.text = releaseToRefreshDescription
self.setNeedsLayout()
self.impact()
break
case .pullToRefresh:
titleLabel.text = pullToRefreshDescription
self.setNeedsLayout()
break
default:
break
}
}
open override func layoutSubviews() {
super.layoutSubviews()
let s = self.bounds.size
let w = s.width
UIView.performWithoutAnimation {
titleLabel.sizeToFit()
logoImgView.frame = CGRect.init(x: 0, y: Self.topMargin, width: Self.logoWidth, height: Self.logoHeight)
logoImgView.center = CGPoint.init(x: w / 2.0, y: Self.topMargin+Self.logoHeight / 2.0)
animaitonImgView.frame = logoImgView.frame
titleLabel.center = CGPoint.init(x: w / 2.0, y: logoImgView.frame.maxY + Self.midGap + Self.tipsHeight/2.0)
}
}
}
{
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "Group@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "Group@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
......@@ -15,6 +15,8 @@
#import "JPUSHService.h"
// iOS10注册APNs所需头文件
#ifdef NSFoundationVersionNumber_iOS_9_x_Max
// GIF播放
#import "FLAnimatedImage.h"
#import <UserNotifications/UserNotifications.h>
#endif
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
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