Skip to content

Instantly share code, notes, and snippets.

@brunogb
brunogb / SwiftUIDragDrop.swift
Last active Jul 1, 2020
Drag'n'Drop with SwiftUI
View SwiftUIDragDrop.swift
import SwiftUI
import PlaygroundSupport
struct MyView: View {
@State var viewOffset: CGSize = .zero {
didSet {
let newFrame = viewFrame.offsetBy(dx: self.viewOffset.width, dy: self.viewOffset.height)
self.canDrop = containerFrame.intersects(newFrame)
@ohayon
ohayon / DraggableView.swift
Last active Sep 15, 2021
Example of making a reusable `draggable()` modifier for SwiftUI Views
View DraggableView.swift
struct DraggablePita: View {
var body: some View {
Image(uiImage: UIImage(named: "pita.png")!)
.draggable() // Add the new, custom modifier to make this draggable
}
}
// Handle dragging
struct DraggableView: ViewModifier {
@State var offset = CGPoint(x: 0, y: 0)
@JosiasSena
JosiasSena / DeCryptor.java
Last active Dec 6, 2021
Encryptor and Decryptor for data encryption.decryption using the Android KeyStore.
View DeCryptor.java
/**
_____ _____ _
| __ \ / ____| | |
| | | | ___| | _ __ _ _ _ __ | |_ ___ _ __
| | | |/ _ \ | | '__| | | | '_ \| __/ _ \| '__|
| |__| | __/ |____| | | |_| | |_) | || (_) | |
|_____/ \___|\_____|_| \__, | .__/ \__\___/|_|
__/ | |
|___/|_|
*/