Skip to content

Instantly share code, notes, and snippets.

View badrinathvm's full-sized avatar

Badarinath Venkatnarayansetty badrinathvm

View GitHub Profile
fileprivate func performAnimation() {
let screenSize = UIScreen.main.bounds
let stackedButtons = self.buttonStackView.arrangedSubviews
let animation = UIViewPropertyAnimator(duration: 0.3, curve: .easeOut) {
//hide or show the stackview.
self.buttonStackView.isHidden = self.buttonsAreHidden
@badrinathvm
badrinathvm / Animate.swift
Created September 2, 2019 05:06
Animate by considering the height Constraint
func animate() {
let screenSize = UIScreen.main.bounds
let heightValue = screenSize.size.height / 2
self.view.layoutIfNeeded()
UIView.animate(withDuration: 1.0, delay: 0, usingSpringWithDamping: 1.0, initialSpringVelocity: 1.0, options: UIView.AnimationOptions.curveEaseIn, animations: {
self.notchBottomConstraint.constant = -heightValue
self.heightConstraint.constant = heightValue
self.view.layoutIfNeeded()
}, completion: nil)
}
@badrinathvm
badrinathvm / AddBlurEffectView.swift
Last active September 2, 2019 18:09
Adding a blur Effect View
let blurredEffectView:UIVisualEffectView = {
let blurEffect = UIBlurEffect(style: .dark)
let blurredEffectView = UIVisualEffectView(effect: blurEffect)
blurredEffectView.translatesAutoresizingMaskIntoConstraints = false
return blurredEffectView
}()
func setupBlurView() {
self.view.addSubview(blurredEffectView)
@badrinathvm
badrinathvm / Container.swift
Last active September 2, 2019 05:00
Setting up Container View Controller
func setupContainerView() {
[containerVC,notchVC].forEach { (viewController) in
self.view.addSubview(viewController.view)
}
heightConstraint = containerVC.view.heightAnchor.constraint(equalToConstant: 0)
notchBottomConstraint = notchVC.view.bottomAnchor.constraint(equalTo: self.view.bottomAnchor)
NSLayoutConstraint.activate([
containerVC.view.leadingAnchor.constraint(equalTo: self.view.leadingAnchor),
containerVC.view.trailingAnchor.constraint(equalTo: self.view.trailingAnchor),
@badrinathvm
badrinathvm / DynamicHeight.swift
Created July 26, 2019 17:56
dynamic height of the collectionView
public func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {
let height = calculateDynamicHeightOftheCell(index: indexPath.row)
return CGSize(width: self.collectionView.bounds.width, height: height)
}
/**
Calculates the height of the card based on the content inside the view.
- parameters:
- index = identifies which cell it is.
*/
//
// CreditCardListViewController.swift
// BUPNative
//
// Created by Venkatnarayansetty, Badarinath on 7/24/19.
//
import Foundation
import UIKit
{
"user_data": {
"full_name": "John Sundell",
"user_age": 31
}
}
@badrinathvm
badrinathvm / sample.json
Created January 6, 2019 01:48
sample.json
[
{ "uid": 1, "name": "Avengers: Infinity War", "shortDesc": "Lorem Ipsum", "duration": 120, "thumbnailUrl": "https://s3.amazonaws.com/mobile.scribd.com/ios-interview-test/avg.jpg", "category": 1, "venue": 1 },
]
[
{ "uid": 1, "name": "Avengers: Infinity War", "shortDesc": "Lorem Ipsum", "duration": 120, "thumbnailUrl": "https://s3.amazonaws.com/mobile.scribd.com/ios-interview-test/avg.jpg", "category": 1, "venue": 1 },
{ "uid": 2, "name": "Deadpool 2", "shortDesc": "Lorem Ipsum", "duration": 120, "thumbnailUrl": "https://s3.amazonaws.com/mobile.scribd.com/ios-interview-test/deadpool.jpg", "category": 1, "venue": 2 },
{ "uid": 3, "name": "Solo: A Star Wars Movie", "shortDesc": "Lorem Ipsum", "duration": 120, "thumbnailUrl": "https://s3.amazonaws.com/mobile.scribd.com/ios-interview-test/solo.jpg", "category": 1, "venue": 3 },
{ "uid": 4, "name": "Game Night", "shortDesc": "Lorem Ipsum", "duration": 120, "thumbnailUrl": "https://s3.amazonaws.com/mobile.scribd.com/ios-interview-test/gamenight.jpg", "category": 2, "venue": 1 },
{ "uid": 5, "name": "Blockers", "shortDesc": "Lorem Ipsum", "duration": 120, "thumbnailUrl": "https://s3.amazonaws.com/mobile.scribd.com/ios-interview-test/blockers.jpg", "category": 2, "
@badrinathvm
badrinathvm / PriceExpects.swift
Last active October 14, 2017 23:33
Price Validations
it("Price validations"){
expect(watch.price).toNot(beNil())
expect(watch.price).to(beTruthy())
//evaluating boundary cases
expect(watch.price).toNot(beLessThan(0))
expect(watch.price).to(beCloseTo(11, within: 0.69))
expect(watch.price).to(beLessThanOrEqualTo(11.69))
expect(watch.price).to(beGreaterThan(Double.pi))
expect(watch.price).toNot(beGreaterThan(11.69))