Skip to content

Instantly share code, notes, and snippets.

struct PhotoPickerDemo: View {
@State private var isPresented: Bool = false
@State var pickerResult: [UIImage] = []
var config: PHPickerConfiguration {
var config = PHPickerConfiguration(photoLibrary: PHPhotoLibrary.shared())
config.filter = .images //videos, livePhotos...
config.selectionLimit = 0 //0 => any, set 1-2-3 for hard limit
return config
}
struct PhotoPicker: UIViewControllerRepresentable {
let configuration: PHPickerConfiguration
@Binding var pickerResult: [UIImage]
@Binding var isPresented: Bool
func makeUIViewController(context: Context) -> PHPickerViewController {
let controller = PHPickerViewController(configuration: configuration)
controller.delegate = context.coordinator
return controller
}
func updateUIViewController(_ uiViewController: PHPickerViewController, context: Context) { }
import SwiftUI
import PhotosUI
struct PhotoPickerDemo: View {
@State private var isPresented: Bool = false
@State var pickerResult: [UIImage] = []
var config: PHPickerConfiguration {
var config = PHPickerConfiguration(photoLibrary: PHPhotoLibrary.shared())
config.filter = .images //videos, livePhotos...
config.selectionLimit = 0 //0 => any, set 1-2-3 for har limit
import SwiftUI
import UIKit
struct ContentView: View {
var body: some View {
NoSepratorList {
Text("Message 1")
Text("Message 1")
Text("Message 1")
Text("Message 1")
struct ChatBubbleShape: Shape {
enum Direction {
case left
case right
}
let direction: Direction
func path(in rect: CGRect) -> Path {
return (direction == .left) ? getLeftBubblePath(in: rect) : getRightBubblePath(in: rect)
struct ChatBubble<Content>: View where Content: View {
let direction: ChatBubbleShape.Direction
let content: () -> Content
init(direction: ChatBubbleShape.Direction, @ViewBuilder content: @escaping () -> Content) {
self.content = content
self.direction = direction
}
var body: some View {
HStack {
//
// ChatBubble.swift
// ios14-demo
//
// Created by Prafulla Singh on 25/7/20.
//
import SwiftUI
struct ChatBubble<Content>: View where Content: View {
let direction: ChatBubbleShape.Direction
struct FloatingMenu: View {
let buttonArray: [String]
let onClick: (String)->()
@State var showButtons = false
var body: some View {
HStack {
Spacer()
VStack {
Spacer()
if showButtons {
//
// FloatingMenu.swift
// ios14-demo
//
// Created by Prafulla Singh on 24/7/20.
//
import SwiftUI
struct FloatingMenu: View {
struct ChatUI : View {
var body: some View {
NavigationView {
Text("")
.navigationBarTitleDisplayMode(.inline)
.toolbar(items: {
ToolbarItem(placement: .principal) {
HStack {
Image(systemName: "person.circle.fill")
Text("User Name")