Skip to content

Instantly share code, notes, and snippets.

@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()
}
}
@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 / 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 / ProductCard.swift
Last active February 13, 2023 11:45
SwiftUI Card designed for Food Products
//
// ProductCard.swift
// FoodProductCard
//
// Created by Jean-Marc Boullianne on 11/17/19.
// Copyright © 2019 Jean-Marc Boullianne. All rights reserved.
//
import SwiftUI
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 / ScrollingHStackModifier.swift
Last active March 22, 2023 05:31
Implement Snap to Item scrolling in SwiftUI using this custom ViewModifier technique.
/
// ScrollingStackModifier.swift
// ScrollView_Tests
//
// Created by Jean-Marc Boullianne on 8/7/20.
//
import SwiftUI
struct ScrollingHStackModifier: ViewModifier {
//
// ContentView.swift
// ScrollView_Tests
//
// Created by Jean-Marc Boullianne on 7/30/20.
//
import SwiftUI
struct ContentView: View {