Skip to content

Instantly share code, notes, and snippets.

View azurast's full-sized avatar
⁉️
merging conflicts 24/7

Azura Sakan Taufik azurast

⁉️
merging conflicts 24/7
View GitHub Profile
@swiftui-lab
swiftui-lab / grid-trainer.swift
Last active October 21, 2024 15:24
A grid trainer for Grid views
// Author: SwiftUI-Lab (swiftui-lab.com)
// Description: this learning tool is designed to showcase the different
// Grid and GridRow view options, added in SwiftUI 2022. It is part of the
// blog article: https://swiftui-lab.com/eager-grids
//
import SwiftUI
import UniformTypeIdentifiers
// The root view of the application
struct ContentView: View {
@nurmaj
nurmaj / TabViewRotationFix.swift
Last active September 20, 2022 05:18
SwiftUI TabView Orientation change fix
import SwiftUI
struct TabViewRotationFix: View {
@State
private var selectedTab = Int.zero
@State
private var isLandscape = false
var body: some View {
GeometryReader { proxy in
ScrollView {
@koher
koher / ContentView.swift
Created April 3, 2021 16:10
An example how to use onReceive with @published
import SwiftUI
struct ContentView: View {
@StateObject private var state: ContentViewState = .init()
var body: some View {
VStack {
Text(state.count.description)
Button("Count Up") { state.countUp() }
Button("Reset") { state.reset() }
}
@neilsmithdesign
neilsmithdesign / swift-ui-protocol-view-models.swift
Last active June 18, 2024 15:24
SwiftUI views with protocol interfaces to view models.
import SwiftUI
/// View model protocol
protocol ViewModel: ObservableObject {
var count: Int { get }
func increase()
}
/// Concrete implementation
class MyViewModel: ViewModel {