Skip to content

Instantly share code, notes, and snippets.

@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
@jboullianne
jboullianne / AlignmentControl.swift
Created August 28, 2020 22:40
Text Alignment Control made in SwiftUI
//
// AlignmentControl.swift
// MicroAnimations_Test
//
// Created by Jean-Marc Boullianne on 8/18/20.
//
import SwiftUI
struct AlignmentControl: View {
@jboullianne
jboullianne / ImageToggleStyle.swift
Created August 18, 2020 02:21
Custom SwiftUI ToggleStyle - Image Toggle
import SwiftUI
struct ImageToggleStyle: ToggleStyle {
var onImageName: String
var offImageName: String
func makeBody(configuration: Configuration) -> some View {
HStack {
configuration.label
@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 / CheckmarkToggleStyle.swift
Created August 18, 2020 02:19
Custom SwiftUI ToggleStyle - Checkmark
import SwiftUI
struct CheckmarkToggleStyle: ToggleStyle {
func makeBody(configuration: Configuration) -> some View {
HStack {
configuration.label
Spacer()
Rectangle()
.foregroundColor(configuration.isOn ? .green : .gray)
//
// ContentView.swift
// ScrollView_Tests
//
// Created by Jean-Marc Boullianne on 7/30/20.
//
import SwiftUI
struct ContentView: 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 {
//
// SideMenuTest.swift
// CardEffectsTest
//
// Created by Jean-Marc Boullianne on 7/3/20.
//
import SwiftUI
struct SideMenuTest: View {
struct SideMenu: View {
@Binding var selected: Int
var options: [String]
var body: some View {
Text("Placeholder")
}
}
import SwiftUI
struct SideMenu: View {
@Binding var selected: Int
var options: [String]
var body: some View {
HStack {
ForEach(options.indices) { i in