Skip to content

Instantly share code, notes, and snippets.

View mohitnandwani's full-sized avatar
🎯
Focusing

Mohit Nandwani mohitnandwani

🎯
Focusing
View GitHub Profile
@mohitnandwani
mohitnandwani / RandomColor.swift
Created March 15, 2022 18:07
Generating random color in SwiftUI
// Based on this gist: https://gist.github.com/EnesKaraosman/efb9c2d989e51d20253976c8fb1aa734
// This particular gist is made to prefer iOS system colors over any random color
#if canImport(UIKit)
import UIKit
extension UIColor {
public static func random() -> UIColor {
let colors: [UIColor]
if #available(iOS 15.0, *) {
@mohitnandwani
mohitnandwani / DetailViewPresentationController.swift
Created September 19, 2021 22:28
A presentation controller which changes the container view size when the trait collection changes
class DetailViewPresentationController: UIPresentationController {
override var frameOfPresentedViewInContainerView: CGRect {
guard let containerView = containerView else {
return super.frameOfPresentedViewInContainerView
}
if traitCollection.verticalSizeClass == .compact {
return CGRect(x: 72, y: 64, width: containerView.frame.width - 144, height: containerView.frame.height)
} else {
@mohitnandwani
mohitnandwani / index.html
Last active March 15, 2022 18:11
Tribute to Dr. Kalam
<link href="https://fonts.googleapis.com/css?family=Ubuntu" rel="stylesheet" type="text/css">
<div class= "container">
<div class= "jumbotron">
<div class= "row">
<div class= "col-xs-12">
<h1 class= "text-center white-text">Dr. APJ Abdul Kalam </h1>
<h2 class= "text-center white-text"><em>The People's President</em></h2>
<div class= "thumbnail"><img class="img-responsive thick-border img-size" src="https://upload.wikimedia.org/wikipedia/commons/thumb/6/6e/A._P._J._Abdul_Kalam.jpg/440px-A._P._J._Abdul_Kalam.jpg">
<div class= "caption text-center white-text">Dr. Kalam during an interview.</div>
</div>