View TCA_CounterDemo.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import SwiftUI | |
import ComposableArchitecture | |
struct State: Equatable { | |
var counter = 0 | |
} | |
enum Action: Equatable { | |
case increaseCounter |
View dependency injection with closures
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import UIKit | |
import XCTest | |
struct LoggedInUser { | |
let name: String | |
} | |
class LoginViewController: UIViewController { | |
var login: (((LoggedInUser) -> Void) -> Void)? | |
var user: String? |
View ContentView.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import SwiftUI | |
import WebKit | |
struct WebView: UIViewRepresentable { | |
class Coordinator: NSObject, WKNavigationDelegate, WKScriptMessageHandler { | |
var webView: WKWebView? | |
func webView(_ webView: WKWebView, didFinish navigation: WKNavigation!) { | |
self.webView = webView | |
} |
View pokemon-fetch-combine.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import UIKit | |
import Combine | |
struct PokemonResponse: Codable{ | |
let results: [Pokemon] | |
} | |
struct Pokemon: Codable{ | |
let name: String |
View DatePickerTextField.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import SwiftUI | |
import UIKit | |
final class DatePickerTextField: UITextField { | |
@Binding var date: Date? | |
private let datePicker = UIDatePicker() | |
init(date: Binding<Date?>, frame: CGRect) { | |
self._date = date | |
super.init(frame: frame) |
View StarPlane.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// A fun little game written in SwiftUI | |
// Copyright (c) John Sundell 2020, MIT license. | |
// This is a hacky implementation written just for fun. | |
// It's only verified to work on iPhones in portrait mode. | |
import SwiftUI | |
final class GameController: ObservableObject { | |
@Published var plane = GameObject.plane() | |
@Published private(set) var clouds = [GameObject]() |
View LockScreen.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import SwiftUI | |
import PlaygroundSupport | |
struct Screen: View { | |
var body: some View { | |
ScrollView { | |
VStack { | |
Text("5:45").font(.system(size: 64, weight: .thin)) | |
Text("Monday, May 11").font(.system(size: 24)) | |
}.padding(.vertical, 32) |
View Calendar.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import SwiftUI | |
extension Calendar { | |
func generateDates( | |
inside interval: DateInterval, | |
matching components: DateComponents | |
) -> [Date] { | |
var dates: [Date] = [] | |
dates.append(interval.start) |
View example.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'dart:async'; | |
import 'package:flutter/cupertino.dart'; | |
import 'package:flutter/material.dart'; | |
import 'package:flutter/services.dart'; | |
import 'package:video_player/video_player.dart'; | |
import 'package:orientation/orientation.dart'; | |
import 'package:chewie/chewie.dart'; |
View DateField.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// DateField.swift | |
// | |
// Created by Szymon Lorenz on 22/2/20. | |
// Copyright © 2020 Szymon Lorenz. All rights reserved. | |
// | |
import SwiftUI | |
struct DateTextField: UIViewRepresentable { |
NewerOlder