Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Newchanges #7

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Example/Podfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
platform :ios, '10.0'
platform :ios, '11.0'
use_frameworks!

target 'WaveTab_Example' do
Expand Down
12 changes: 6 additions & 6 deletions Example/Pods/Pods.xcodeproj/project.pbxproj

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ extension UIBezierPath {
let path = UIBezierPath()
path.move(to: .zero)
path.addLine(to: CGPoint(x: center - (curve * 2), y: 0))
path.addQuadCurve(to: CGPoint(x: center - curve, y: curve / 2), controlPoint: CGPoint(x: center - curve - curve / 7.5, y: 0))
path.addQuadCurve(to: CGPoint(x: center - curve, y: curve / 2), controlPoint: CGPoint(x: center - curve - 13, y: 0))
path.addCurve(to: CGPoint(x: center + curve, y: curve / 2),
controlPoint1: CGPoint(x: center - curve + curve / 4, y: curve + curve / 2),
controlPoint2: CGPoint(x: center + curve - curve / 4, y: curve + curve / 2))
path.addQuadCurve(to: CGPoint(x: center + (curve * 2), y: 0), controlPoint: CGPoint(x: center + curve + curve / 7.5, y: 0))
controlPoint1: CGPoint(x: center - curve + curve / 2, y: curve + curve / 2),
controlPoint2: CGPoint(x: center + curve - curve / 2, y: curve + curve / 1.8))
path.addQuadCurve(to: CGPoint(x: center + (curve * 2), y: 0), controlPoint: CGPoint(x: center + curve + 13, y: 0))
path.addLine(to: CGPoint(x: tabBar.bounds.width, y: 0))
path.addLine(to: CGPoint(x: tabBar.bounds.width, y: tabBar.bounds.height))
path.addLine(to: CGPoint(x: 0, y: tabBar.bounds.height))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ open class WaveTabBarController: UITabBarController, WaveTabBarProtocol {
presenter.viewDidLoad()
}

// open override func viewWillAppear(_ animated: Bool) {
// presenter.viewDidLoad()
// }

open override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)

Expand All @@ -60,6 +64,10 @@ open class WaveTabBarController: UITabBarController, WaveTabBarProtocol {
open override func tabBar(_ tabBar: UITabBar, didSelect item: UITabBarItem) {
presenter.tabBarDidSelectItem(with: item.tag)
}
open func didTapItem(tag:Int){
presenter.tabBarDidSelectItem(with: tag)

}

open override func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator) {
super.viewWillTransition(to: size, with: coordinator)
Expand Down Expand Up @@ -99,14 +107,23 @@ open class WaveTabBarController: UITabBarController, WaveTabBarProtocol {
tabBar.layer.insertSublayer(waveSubLayer, above: tabBar.layer.sublayers?.first)
}

//
func setupCircle(_ width: Float) {
circle?.removeFromSuperview() // ->> Add this line
circle = UIView(frame: CGRect(x: 0.0, y: 0.0, width: CGFloat(width), height: CGFloat(width)))
circle?.layer.cornerRadius = CGFloat(width) / 2
circle?.center = CGPoint(x: tabBarItems[safeSelectedIndex].center.x, y: 0.0)
circle?.layer.borderWidth = Constants.borderWidth
circle?.layer.borderColor = Constants.borderColor
tabBar.addSubview(circle!)
circle?.clipsToBounds = true;
//circle?.backgroundColor = UIColor.white
circle?.layer.shadowColor = UIColor.lightGray.cgColor
circle?.layer.shadowOpacity = 0.8
circle?.layer.shadowOffset = CGSize(width: 0.0, height: 0.0)
circle?.layer.shadowRadius = 6.0
circle?.layer.masksToBounds = false
tabBar.addSubview(circle!)
}



func updateCircleSize(_ radius: Float) {
guard let circle = circle else { return }
Expand Down Expand Up @@ -144,13 +161,16 @@ open class WaveTabBarController: UITabBarController, WaveTabBarProtocol {
}
}

//
func setupImageView(_ center: Float) {
let image = viewControllers?[safeSelectedIndex].tabBarItem.selectedImage?.withRenderingMode(.alwaysTemplate)
imageView = UIImageView(image: image)
imageView?.contentMode = UIView.ContentMode.scaleAspectFit
imageView?.tintColor = tabBar.tintColor
circle?.addSubview(imageView!)
imageView?.center = CGPoint(x: CGFloat(center), y: CGFloat(center))
let image = viewControllers?[safeSelectedIndex].tabBarItem.selectedImage
imageView?.removeFromSuperview() // ->> Add this line
imageView = UIImageView(image: image)
imageView?.tintColor = UIColor.init(red: 0/255, green: 90.0/255, blue: 159.0/255, alpha: 1)
imageView?.contentMode = UIView.ContentMode.scaleAspectFit
circle?.addSubview(imageView!)
imageView?.center = CGPoint(x: CGFloat(center), y: CGFloat(center))
// imageView?.backgroundColor = UIColor.red
}

func updateImageViewSize(_ center: Float) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ class WaveTabBarPresenterBase: WaveTabBarPresenter {

private struct Constants {

static let smallRadius: Float = 25
static let bigRadius: Float = 30
static let smallCircle: Float = 47
static let bigCircle: Float = 57
static let smallRadius: Float = 32//25
static let bigRadius: Float = 37//30
static let smallCircle: Float = 57//47
static let bigCircle: Float = 67//57
static let circleAnimationDuration: TimeInterval = 0.2
static let waveAnimationDuration: TimeInterval = Constants.circleAnimationDuration * 2
static let showHideAnimationDuration: TimeInterval = 0.3
Expand Down Expand Up @@ -46,6 +46,7 @@ class WaveTabBarPresenterBase: WaveTabBarPresenter {
view.setupImageView((isPortrait ? Constants.bigCircle : Constants.smallCircle) / 2)
view.setupTabBarColoring()
view.setupTabBarBackground()

}

func viewDidRotate(portrait portraitOrientation: Bool, at index: Int) {
Expand All @@ -67,6 +68,7 @@ class WaveTabBarPresenterBase: WaveTabBarPresenter {
view.moveCircle(over: Constants.circleAnimationDuration,
offset: isPortrait ? Constants.bigRadius : Constants.smallRadius,
down: true)
view.setupImageView((isPortrait ? Constants.bigCircle : Constants.smallCircle) / 2)
}

func viewWillLayoutSubviews() {
Expand Down