Skip to content

Instantly share code, notes, and snippets.

@jboullianne
jboullianne / swift_design_patterns_singleton.swift
Created May 9, 2019 01:34
Singleton Design Pattern in Swift
// Singleton Design Pattern Example
// Author: Jean-Marc Boullianne
class Singleton {
static let instance = Singleton()
private init() {
// Initialize class variable here
}
@jboullianne
jboullianne / swift_design_patterns_observer.swift
Last active May 11, 2019 20:53
Observer Design Pattern in Swift
// Observer pattern in Swift
// Author: Jean-Marc Boullianne
class Subject<T> {
var val:T {
didSet {
notifyObservers()
}
}
import SwiftUI
struct SideMenu: View {
@Binding var selected: Int
var options: [String]
var body: some View {
GeometryReader { geo in
HStack {
import SwiftUI
struct SideMenu: View {
@Binding var selected: Int
var options: [String]
var body: some View {
HStack {
ForEach(options.indices) { i in
struct SideMenu: View {
@Binding var selected: Int
var options: [String]
var body: some View {
Text("Placeholder")
}
}
//
// SideMenuTest.swift
// CardEffectsTest
//
// Created by Jean-Marc Boullianne on 7/3/20.
//
import SwiftUI
struct SideMenuTest: View {
@jboullianne
jboullianne / STSegmentedView.swift
Created July 8, 2019 21:43
Custom UISegmentedControl with Icons and Animations
//
// STSegmentedView.swift
//
//
// Created by Jean-Marc Boullianne on 6/16/19.
// Copyright © 2019 Jean-Marc Boullianne. All rights reserved.
//
import UIKit
@jboullianne
jboullianne / PowerToggleStyle.swift
Created August 18, 2020 02:20
Custom SwiftUI ToggleStyle - Power Button
import SwiftUI
struct PowerToggleStyle: ToggleStyle {
func makeBody(configuration: Configuration) -> some View {
HStack {
configuration.label
Spacer()
Rectangle()
.foregroundColor(configuration.isOn ? .green : .gray)
@jboullianne
jboullianne / SlidingSheetModifier.swift
Created September 17, 2020 02:58
SwiftUI Custom Sliding Sheet
//
// SheetBase.swift
// PopoverSheet_Tests
//
// Created by Jean-Marc Boullianne on 9/13/20.
// Copyright © 2020 TrailingClosure. All rights reserved.
//
import SwiftUI
//
// ContentView.swift
// ScrollView_Tests
//
// Created by Jean-Marc Boullianne on 7/30/20.
//
import SwiftUI
struct ContentView: View {