Skip to content

Instantly share code, notes, and snippets.

View michael94ellis's full-sized avatar

Michael Ellis michael94ellis

View GitHub Profile
@michael94ellis
michael94ellis / SegmentedPicker.swift
Last active July 19, 2024 23:56
SwiftUI Simple Customizable Custom Segmented Picker
// Demo: https://imgur.com/a/NsexCm2
/// This SegmentedPicker will take some Equatable array(Int, String, etc.)
public struct SegmentedPicker<T: Equatable, Content: View>: View {
// Tells SwiftUI which views can be animated together
@Namespace private var selectionAnimation
/// The currently selected item, if there is one
@Binding var selectedItem: T?
/// The list of options available in this picker
private let items: [T]
//
// UDPListener.swift
//
// Created by Michael Robert Ellis on 12/16/21.
//
import Foundation
import Network
import Combine
@michael94ellis
michael94ellis / TextFieldFocus.swift
Last active April 14, 2024 15:03
TextField FocusState Demo for iOS 15 SwiftUI
//
// Focus State Example
//
// Created by Michael Robert Ellis on 12/7/21.
//
import SwiftUI
struct MyObject: Identifiable, Equatable {
var id: String
//
// UDPClient.swift
//
import Network
import Foundation
protocol UDPListener {
func handleResponse(_ client: UDPClient, data: Data)
}
@michael94ellis
michael94ellis / UDPClient.swift
Created June 1, 2020 14:41
iOS 12 Network Framework UDP Client Example
import Network
import Foundation
class UDPClient {
var connection: NWConnection
var address: NWEndpoint.Host
var port: NWEndpoint.Port