Skip to content

Instantly share code, notes, and snippets.

View devs-rootstrap's full-sized avatar

devs-rootstrap

View GitHub Profile
@devs-rootstrap
devs-rootstrap / lazy-stack-example-1
Created March 10, 2023 17:43
Building faster scrollable views using LazyStacks
/* Data Model & Arrray Example */
struct Contact: Identifiable, Hashable {
let id = UUID()
let firstName: String
let lastName: String
let shortName: String
let role: String
let phone: String
@devs-rootstrap
devs-rootstrap / hstack-example
Last active March 13, 2023 17:26
Complex Layouts With Stack Views Examples
var body: some View {
VStack(spacing: 10) {
Text("HStack")
.font(.title)
Text("Spacing & Alignment")
.font(.subheadline)
HStack {
Circle()
@devs-rootstrap
devs-rootstrap / geometry-reader-buttons-example.swift
Last active October 17, 2023 17:00
SwiftUI: GeometryReader examples
import SwiftUI
struct ContentView: View {
var body: some View {
GeometryReader { geometry in
VStack(spacing: 10) {
Text("GeometryReader")
.font(.title)
Text("Buttons example")
.font(.subheadline)
@devs-rootstrap
devs-rootstrap / app-storage.swift
Last active October 17, 2023 17:00
Exploring SwiftUI’s Data Flow
struct ContentView: View {
@AppStorage("username") var username: String = "guest"
var body: some View {
VStack {
Text("Welcome, \(username)!")
TextField("Enter your username", text: $username)
}
}
}
@devs-rootstrap
devs-rootstrap / button-background.swift
Last active October 17, 2023 14:55
SwiftUI Button Example
import SwiftUI
struct ContentView: View {
var body: some View {
VStack(spacing: 20) {
Text("SwiftUI Button")
.font(.largeTitle)
Text("With Backgroud")
.font(.title)
.foregroundColor(.gray)
@devs-rootstrap
devs-rootstrap / swiftui_picker_custom_style.swift
Last active November 30, 2023 16:45
SwiftUI Picker Example
import SwiftUI
struct ContentView: View {
@State private var favoriteFruit = 1
var body: some View {
VStack(spacing: 20) {
Text("SwiftUI Picker")
.font(.largeTitle)
@devs-rootstrap
devs-rootstrap / DeletePet.swift
Last active June 27, 2024 15:47
SwiftUI List
import SwiftUI
struct Pet: Identifiable, Hashable {
let id = UUID()
let name: String
}
struct PetCustomRow: View {
let pet: Pet