Skip to content

Instantly share code, notes, and snippets.

import SwiftUI
@main
struct ios14_demoApp: App {
@UIApplicationDelegateAdaptor private var appDelegate: AppDelegate
var body: some Scene {
WindowGroup {
ContentView()
//
// ios14_demoApp.swift
// ios14-demo
//
// Created by Prafulla Singh on 23/6/20.
//
import SwiftUI
@main
struct ios14_demoApp: App {
import SwiftUI
public struct CirclerPercentageProgressViewStyle : ProgressViewStyle {
public func makeBody(configuration: LinearProgressViewStyle.Configuration) -> some View {
VStack(spacing: 10) {
configuration.label
.foregroundColor(Color.secondary)
ZStack {
Circle()
.stroke(lineWidth: 15.0)
.opacity(0.3)
public struct CirclerPercentageProgressViewStyle : ProgressViewStyle {
public func makeBody(configuration: LinearProgressViewStyle.Configuration) -> some View {
VStack(spacing: 10) {
configuration.label
.foregroundColor(Color.secondary)
ZStack {
Circle()
.stroke(lineWidth: 15.0)
.opacity(0.3)
.foregroundColor(Color.accentColor.opacity(0.5))
//
// keyboardToolBar.swift
// ios14-demo
//
// Created by Prafulla Singh on 4/10/20.
//
import SwiftUI
final class KeyboardResponder: ObservableObject {
struct KeyboardView<Content, ToolBar> : View where Content : View, ToolBar: View {
@StateObject private var keyboard: KeyboardResponder = KeyboardResponder()
let toolbarFrame: CGSize = CGSize(width: UIScreen.main.bounds.width, height: 40.0)
var content: () -> Content
var toolBar: () -> ToolBar
var body: some View {
ZStack {
content()
.padding(.bottom, (keyboard.currentHeight == 0) ? 0 : toolbarFrame.height)
final class KeyboardResponder: ObservableObject {
private var notificationCenter: NotificationCenter
@Published private(set) var currentHeight: CGFloat = 0
init(center: NotificationCenter = .default) {
notificationCenter = center
notificationCenter.addObserver(self, selector: #selector(keyBoardWillShow(notification:)), name: UIResponder.keyboardWillShowNotification, object: nil)
notificationCenter.addObserver(self, selector: #selector(keyBoardWillHide(notification:)), name: UIResponder.keyboardWillHideNotification, object: nil)
}
import SwiftUI
struct PreviewsDemo: View {
var body: some View {
ZStack {
Color(UIColor.systemBackground)
Text("Hello, World!")
}.ignoresSafeArea()
}
}
import SwiftUI
struct FloatingTextField: View {
let textFieldHeight: CGFloat = 50
private let placeHolderText: String
@Binding var text: String
@State private var isEditing = false
public init(placeHolder: String,
text: Binding<String>) {
self._text = text
self.placeHolderText = placeHolder
@prafullakumar
prafullakumar / Marque.swift
Last active September 24, 2020 05:02
Demo to create Marque Labels
//
// Marque.swift
// ios14-demo
//
// Created by Prafulla Singh on 23/9/20.
//
import SwiftUI
struct Marque: View {