This library is now deprecated in favour of a more complete and SwiftUI friendly TextEditor
backport:
https://github.com/shaps80/SwiftUIBackports
See it in action here: https://twitter.com/shaps/status/1654972428286668800?s=20
// Bigger iPhones = any Max, any Plus, iPhone XR, iPhone 11 | |
switch (UITraitCollection.current.horizontalSizeClass, UITraitCollection.current.verticalSizeClass) { | |
case (.compact, .compact): | |
// Smaller iPhones in landscape | |
case (.compact, .regular): | |
// iPhones in portrait | |
// iPads in portrait during any split screen, |
// Author: The SwiftUI-Lab | |
// This code is part of the tutorial: https://swiftui-lab.com/swiftui-animations-part4/ | |
import SwiftUI | |
// Sample usage | |
struct ContentView: View { | |
var body: some View { | |
VStack { | |
GifImage(url: URL(string: "https://media.giphy.com/media/YAlhwn67KT76E/giphy.gif?cid=790b7611b26260b2ad23535a70e343e67443ff80ef623844&rid=giphy.gif&ct=g")!) | |
.padding(10) |
This library is now deprecated in favour of a more complete and SwiftUI friendly TextEditor
backport:
https://github.com/shaps80/SwiftUIBackports
See it in action here: https://twitter.com/shaps/status/1654972428286668800?s=20
import SwiftUI | |
#if os(macOS) | |
public typealias Font = NSFont | |
public typealias FontDescriptor = NSFontDescriptor | |
#else | |
public typealias Font = UIFont | |
public typealias FontDescriptor = UIFontDescriptor | |
#endif |
// | |
// Color+UIColor.swift | |
// Swatches | |
// | |
// Created by Timothy Sanders on 2019-11-15. | |
import Foundation | |
import SwiftUI | |
import UIKit |
// SwiftUI Custom Styles (TripleToggleStyle) | |
// https://swiftui-lab.com | |
// https://swiftui-lab.com/custom-styling | |
import SwiftUI | |
// MARK: - TripleToggle View | |
public struct TripleToggle: View { | |
@Environment(\.tripleToggleStyle) var style: AnyTripleToggleStyle | |
// | |
// ContentView.swift | |
// DeleteMe | |
// | |
// Created by Chris Eidhof on 02.02.21. | |
// | |
import SwiftUI | |
/* |
UICollectionViewDiffableDataSource
does an excellent job of handling changes to data and updating the items accordingly. However, there seems to be no good way to handle updates to existing items. If you follow the samples that Apple provides and define Equatable
and Hashable
to use an id instead of the complete models value, value changes won't cause the collection view to update those cells. If you leave Equatable
as it should be and have it compare all values of a model, the cell will update, but it will completely replace the old cell, causing an undesirable "flash".
UICollectionViewComparableDataSource
wraps a UICollectionViewDiffableDataSource
and will check for items that have been updated, but not removed or added.
This allows us to make updates to a cell without completely reloading it. This is especially usefull if your cells have some sort of temporary state.
This is just an expirement. Use at your own risk.
// UICollectionView Objective-C example | |
- (void)viewWillAppear:(BOOL)animated { | |
[super viewWillAppear:animated]; | |
NSIndexPath *selectedIndexPath = [[self.collectionView indexPathsForSelectedItems] firstObject]; | |
if (selectedIndexPath != nil) { | |
id<UIViewControllerTransitionCoordinator> coordinator = self.transitionCoordinator; | |
if (coordinator != nil) { | |
[coordinator animateAlongsideTransition:^(id<UIViewControllerTransitionCoordinatorContext> context) { |