Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

Indrajit Chakrabarty indyfromoz

🏠
Working from home
View GitHub Profile
@indyfromoz
indyfromoz / PreviewProviderModifier.swift
Created Oct 20, 2020 — forked from davidsteppenbeck/PreviewProviderModifier.swift
A SwiftUI view modifier for simple preview providers.
View PreviewProviderModifier.swift
#if DEBUG
import SwiftUI
struct PreviewProviderModifier: ViewModifier {
/// Whether or not a basic light mode preview is included in the group.
var includeLightMode: Bool
/// Whether or not a basic dark mode preview is included in the group.
var includeDarkMode: Bool
View Color+UIKit.swift
import SwiftUI
import UIKit
private struct ColorConversionError: Swift.Error {
let reason: String
}
extension Color {
var uiColor: UIColor {
View NavigationViewActiveIssue.swift
struct ContentView: View {
@State var tab = 0
@State var selections: [Int:Int] = [:]
var body: some View {
ZStack {
TabView(selection: $tab) {
NavigationView {
PageView(n: 0, selections: $selections)
}.navigationViewStyle(StackNavigationViewStyle()).tabItem { Text("Pages") }.tag(0)
View firstMap.swift
import Cocoa
extension Collection {
func firstMap<T>(_ transform: @escaping (Element) -> T?) -> T? {
for element in self {
if let transformed = transform(element) {
return transformed
}
}
return nil
@indyfromoz
indyfromoz / Example_Complex.swift
Created Jul 30, 2020 — forked from IanKeen/Example_Complex.swift
PropertyWrapper: @transaction binding for SwiftUI to make changes to data supporting commit/rollback
View Example_Complex.swift
struct User: Equatable {
var firstName: String
var lastName: String
}
@main
struct MyApp: App {
@State var value = User(firstName: "", lastName: "")
@State var showEdit = false
View swiftui-utils.swift
import SwiftUI
struct ConditionalContent<TrueContent: View, FalseContent: View>: View {
let value: Bool
let trueContent: () -> TrueContent
let falseContent: () -> FalseContent
var body: some View {
if value {
return AnyView(trueContent())
@indyfromoz
indyfromoz / iPod.swift
Created Jul 28, 2020 — forked from jordansinger/iPod.swift
Swift Playgrounds iPod Classic
View iPod.swift
import SwiftUI
import PlaygroundSupport
struct iPod: View {
var body: some View {
VStack(spacing: 40) {
Screen()
ClickWheel()
Spacer()
}
View Sunset.swift
import SwiftUI
import PlaygroundSupport
struct Sunset: View {
@State var backgroundColor = Color.blue
@State var sunSetted = false
let sunGradient = [Color.yellow, Color.orange]
let moonGradient = [Color.gray, Color.black]
@State var alignment = Alignment.top
@indyfromoz
indyfromoz / iPhone12ProWebsite.swift
Created Jul 15, 2020 — forked from navsing/iPhone12ProWebsite.swift
iPhone 12 Pro Buying Experience
View iPhone12ProWebsite.swift
//
// Apple.swift
// Playground
//
// Created by Navdeep Singh on 7/14/20.
//
import SwiftUI
struct Apple: View {
@indyfromoz
indyfromoz / WheelView.swift
Created Jul 14, 2020 — forked from sturdysturge/WheelView.swift
WheelView Colour Picker Maker
View WheelView.swift
import SwiftUI
struct RGBAWheelView: WheelPickable {
typealias DataType = RGBAData
let data: DataType
@State var thumbOffset = CGPoint()
var _$thumbOffset: Binding<CGPoint> { $thumbOffset }
let angularGradient: Gradient
let radialGradient: Gradient
init(data: DataType) {
You can’t perform that action at this time.