Skip to content

Instantly share code, notes, and snippets.

@appfrosch
appfrosch / FocusView.swift
Created November 1, 2021 17:45
Controlling the focus on textfields
struct FocusView: View {
enum FocusField {
case username, password
}
@State private var username = ""
@State private var password = ""
@FocusState private var focusedField: FocusField?
var body: some View {
@appfrosch
appfrosch / MdToHtmlWebView.swift
Created November 15, 2021 13:54
Display markdown string in a WebView in SiwftUI
import SwiftUI
import WebKit
import Ink
@main
struct poc_MarkdownToHtmlApp: App {
var body: some Scene {
WindowGroup {
ContentView()
}
@appfrosch
appfrosch / poc-TCA-stackBasedNav.swift
Last active September 18, 2023 09:12
TCA - Stack-based navigation - child to parent communication for value mutation
import ComposableArchitecture
import SwiftUI
@main
struct poc_TCA_NavStack_multilevelApp: App {
var body: some Scene {
WindowGroup {
RootView(
store: Store(
initialState: RootFeature.State(
@appfrosch
appfrosch / BoulderBoard.swift
Last active November 11, 2023 08:34
Simple square grid showing coloured circles depending on their type
//
// ContentView.swift
// poc-bolderGrid
//
// Created by Andreas Seeger on 10.11.2023.
//
import SwiftUI
struct ContentView: View {
@appfrosch
appfrosch / TCA-StackNavigation-with-updates-from-child-to-parent.swift
Last active January 21, 2024 21:55
TCA StackNavigation w/ updates from child to parent
import ComposableArchitecture
import SwiftUI
@main
struct so_tca_StackNavigationUpdateParentFromChildApp: App {
var body: some Scene {
WindowGroup {
ParentView(
store: Store(
initialState: ParentFeature.State(),
@appfrosch
appfrosch / ScrollViewApp.swift
Last active May 24, 2024 06:41
When scrolling in a SwiftUI app, there might be two features a user would want to have: keep track of where the user is scrolling to and move the scroll position programmatically.
import SwiftUI
@main
struct so_ScrollViewWithPositionApp: App {
var body: some Scene {
WindowGroup {
ScrollContentView()
}
}
}
@appfrosch
appfrosch / poc_tca_Child_Parent_Child_CommunicationApp.swift
Last active June 5, 2024 15:31
TCA poc with Child-to-Parent (working) and Parent-to-Child (open question) communication
import SwiftUI
@main
struct poc_tca_Child_Parent_Child_CommunicationApp: App {
var body: some Scene {
WindowGroup {
ParentView(
store: Store(
initialState: ParentFeature.State(),
reducer: { ParentFeature() }
@appfrosch
appfrosch / TCA-dismissal-issue.swift
Created July 24, 2024 06:25
Simplified project showing the issue of a sheet being dismissed upon first drill down (tree-navigation) while a detail screen is shown (stack-navigation)
import ComposableArchitecture
import SwiftUI
@main
struct ItemBrainApp: App {
var body: some Scene {
WindowGroup {
RootFeatureView(
store: Store(
initialState: RootFeature.State(
@appfrosch
appfrosch / Sharing_GRDB_in_TCAApp.swift
Last active June 16, 2025 08:45
Use `TCA`, `GRDB` and the `swift-dependencies` together
//
// Sharing_GRDB_in_TCAApp.swift
// Sharing-GRDB-in-TCA
//
// Created by Andreas Seeger on 15.06.2025.
//
import ComposableArchitecture
import OSLog
import SharingGRDB