Skip to content

Instantly share code, notes, and snippets.

##############################
## Java
##############################
*.class
*.jar
*.war
*.ear
*.nar
hs_err_pid*
// Run any SwiftUI view as a Mac app.
import Cocoa
import SwiftUI
public func run<V: View>(view: V) {
let delegate = AppDelegate(view)
let app = NSApplication.shared
NSApp.setActivationPolicy(.regular)
app.mainMenu = app.customMenu
import SwiftUI
import PlaygroundSupport
struct ShareSheet: View {
var body: some View {
VStack(spacing: 0) {
SheetHeaderView()
.padding()
Divider()
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
import SwiftUI
import PlaygroundSupport
struct ContentView: View {
@State var gradientAngle: Double = 0
var colors = [
Color(UIColor.systemRed),
Color(UIColor.systemOrange),
Color(UIColor.systemYellow),
Color(UIColor.systemGreen),
@wb-towa
wb-towa / EnumPicker.swift
Created July 18, 2020 13:31 — forked from magnuskahr/EnumPicker.swift
A simple picker to pick a enum.
import SwiftUI
struct EnumPicker<T: Hashable & CaseIterable, V: View>: View {
@Binding var selected: T
var title: String? = nil
let mapping: (T) -> V
var body: some View {
@wb-towa
wb-towa / Frost.swift
Created July 20, 2020 10:25 — forked from Clarko/Frost.swift
SwiftUI live-blur materials
//
// Frost.swift
//
// Created by Clarko on 7/19/20.
//
// A SwiftUI representation of UIVisualEffectView
// and UIBlurEffect, that handles mostly like a
// SwiftUI Color view. Use it as a background.
//
// Comes with styles like Frost.thin and Frost.thick
@wb-towa
wb-towa / ExampleView.swift
Created August 19, 2020 17:19 — forked from larsaugustin/ExampleView.swift
Conditional view modifiers in SwiftUI
struct ExampleView: View {
var body: some View {
Text("Example")
.if(true) { $0.foregroundColor(.red) }
}
}
import SwiftUI
import PlaygroundSupport
struct app: View {
var appTitle: String
var appDesc: String
var appColor: Color
var body: some View {
HStack (alignment: .center, spacing: 14) {
VStack {
@wb-towa
wb-towa / SearchBar.swift
Created December 30, 2020 17:43 — forked from jstheoriginal/SearchBar.swift
A simple SwiftUI search bar
struct SearchBar : View {
@Binding var searchText: String
var body: some View {
HStack {
Image(systemName: "magnifyingglass").foregroundColor(.secondary)
TextField(
$searchText,
placeholder: Text("Search")) {
UIApplication.shared.keyWindow?.endEditing(true)