This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { useDispatch, useSelector } from "react-redux"; | |
import React, { Fragment, useEffect, useRef, useState } from "react"; | |
import * as Yup from "yup"; | |
import { useFormik } from "formik"; | |
const validationSchema = Yup.object({ | |
firstName: Yup.string().required("Required"), | |
lastName: Yup.string().required("Required"), | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func addAnimation(node: SCNNode) { | |
let rotateOne = SCNAction.rotateBy(x: 0, y: CGFloat(Float.pi), z: 0, duration: 5.0) | |
let hoverUp = SCNAction.moveBy(x: 0, y: 0.2, z: 0, duration: 2.5) | |
let hoverDown = SCNAction.moveBy(x: 0, y: -0.2, z: 0, duration: 2.5) | |
let hoverSequence = SCNAction.sequence([hoverUp, hoverDown]) | |
let rotateAndHover = SCNAction.group([rotateOne, hoverSequence]) | |
let repeatForever = SCNAction.repeatForever(rotateAndHover) | |
node.runAction(repeatForever) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let pinchGesture = UIPinchGestureRecognizer(target: self, action: #selector(didPinch(_:))) | |
sceneView.addGestureRecognizer(pinchGesture) | |
@objc | |
func didPinch(_ gesture: UIPinchGestureRecognizer) { | |
guard let _ = object else { return } | |
var originalScale = object?.scale | |
switch gesture.state { | |
case .began: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ref.child("users").child(user.uid).setValue(["username": username]) { | |
(error:Error?, ref:DatabaseReference) in | |
if let error = error { | |
print("Data could not be saved: \(error).") | |
} else { | |
print("Data saved successfully!") | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sealed class Response | |
data class Success(val body: String): Response() | |
data class Error(val code: Int, val message: String): Response() | |
object Timeout: Response() | |
fun sugar(response: Response) = when (response) { | |
is Success -> ... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class VenuAdapter(val context: Context,val venueList:List<Venue> , val itemClick: (Venue) -> Unit): RecyclerView.Adapter<VenuAdapter.ViewHolder>() { | |
override fun onCreateViewHolder(parentView: ViewGroup, position: Int):ViewHolder { | |
val inflateview = LayoutInflater.from(context).inflate(R.layout.venue_cell,parentView,false) | |
return ViewHolder(context,itemView = inflateview , itemClick = itemClick ) | |
} | |
override fun getItemCount(): Int { | |
return venueList.count() | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MyClass { | |
fun test() { | |
val str: String = "..." | |
val result = str.xxx { | |
print(this) // Receiver | |
print(it) // Argument | |
42 // Block return value | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- Divider --> | |
<style name="LayoutDivider"> | |
<item name="android:layout_width">match_parent</item> | |
<item name="android:layout_height">1dp</item> | |
<item name="android:background">@color/colorPrimaryDark</item> | |
<item name="android:alpha">0.5</item> | |
</style> | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let rotationGesture = UIRotationGestureRecognizer(target: self, action: #selector(viewRotated)) | |
sceneView.addGestureRecognizer(rotationGesture) | |
@objc private func viewRotated(_ gesture: UIRotationGestureRecognizer) { | |
let location = gesture.location(in: sceneView) | |
guard let node = self.object(at: location) else { return } | |
switch gesture.state { | |
case .began: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// on Tap to reposition the cube | |
@objc func addCubeToSceneView(withGestureRecognizer recognizer: UIGestureRecognizer) { | |
let tapLocation = recognizer.location(in: sceneView) | |
switch recognizer.state { | |
case .began: | |
print("Object began to move") | |
let hitResults = self.sceneView.hitTest(tapLocation, options: nil) | |
if hitResults.isEmpty { return } | |
let hitResult = hitResults.first | |
if let node = hitResult?.node.parent?.parent?.parent { |
NewerOlder