Skip to content

Instantly share code, notes, and snippets.

@prafullakumar
prafullakumar / SecretView.swift
Created May 11, 2022 16:26
Blocks screen grab and recordings
//
// ViewController.swift
// TextField
//
// Created by Prafulla Singh on 11/5/22.
//
import UIKit
class ViewController: UIViewController {
lazy var secretBaseView: UIView? = {
@prafullakumar
prafullakumar / subScriptSuperScript.swift
Created May 3, 2021 15:31
SwiftUI: Adding sub and super scripts
import SwiftUI
//Rule:
//_{} subscript
//^{} superscript
//mainFont
//script font
//
struct SubSuperScriptText: View {
let inputString: String
struct FormTextField: UIViewRepresentable {
let placeholder: String
@Binding var text: String
var returnKeyType: UIReturnKeyType = .next
var autocapitalizationType: UITextAutocapitalizationType = .none
var keyboardType: UIKeyboardType = .default
var tag: Int
func makeUIView(context: Context) -> UITextField {
let textField = UITextField(frame: .zero)
textField.delegate = context.coordinator
@prafullakumar
prafullakumar / DemoFormKeyboardIssueFix.swift
Last active April 30, 2021 08:11
This is a demo to Show form as SwiftUI View with ability to move from x text field to x+1 text field. It also have interactive keyboard dismiss
//Allow to move next text field on Next Tap
//Adds next in toolbar if keypad is number pad
//Allow interactive keyboard dismiss
import SwiftUI
import Introspect
@main
struct DemoFormKeyboardIssueFix: App {
@State var name: String = ""
@State var profession: String = ""
extension View {
func addButtonActions(leadingButtons: [CellButtons], trailingButton: [CellButtons], onClick: @escaping (CellButtons) -> Void) -> some View {
self.modifier(SwipeContainerCell(leadingButtons: leadingButtons, trailingButton: trailingButton, onClick: onClick))
}
}
import SwiftUI
struct SwipeContainerCell: ViewModifier {
enum VisibleButton {
case none
case left
case right
}
@State private var offset: CGFloat = 0
@State private var oldOffset: CGFloat = 0
struct ContentView: View {
var body: some View {
NavigationView {
ScrollView {
LazyVStack.init(spacing: 0, pinnedViews: [.sectionHeaders], content: {
Section.init(header:
HStack {
Text("Section 1")
Spacer()
import SwiftUI
let buttonWidth: CGFloat = 60
enum CellButtons: Identifiable {
case edit
case delete
case save
case info
import SwiftUI
let buttonWidth: CGFloat = 60
enum CellButtons: Identifiable {
case edit
case delete
case save
case info
import SwiftUI
import Introspect
@main
struct DemoApp: App {
let tabBarControllerDelegate = TabBarControllerDelegate()
var body: some Scene {
WindowGroup {
TabView {
NavigationView {