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
struct NumberField<T: Numeric & LosslessStringConvertible>: View { | |
let prompt: String | |
@Binding var value: T? | |
@StateObject var viewModel = ViewModel() | |
class ViewModel: ObservableObject { | |
@Published var text = "" | |
var ignoreNextChange = false |
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
// | |
// Author: Chase Wasden | |
// Website: https://gist.github.com/ccwasden | |
// Licensed under MIT license https://opensource.org/licenses/MIT | |
// | |
import Foundation | |
import Combine | |
// Threading |
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
// | |
// Author: Chase Wasden | |
// Website: https://gist.github.com/ccwasden | |
// Licensed under MIT license https://opensource.org/licenses/MIT | |
// | |
import SwiftUI | |
struct Fruit: Selectable { | |
let name: String |
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
// | |
// Author: Chase Wasden | |
// Website: https://gist.github.com/ccwasden | |
// Licensed under MIT license https://opensource.org/licenses/MIT | |
// | |
import SwiftUI | |
struct Fruit: Selectable { | |
let name: String |
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
// | |
// Author: Chase Wasden | |
// Website: https://gist.github.com/ccwasden | |
// Licensed under MIT license https://opensource.org/licenses/MIT | |
// | |
import SwiftUI | |
struct Fruit: Identifiable { | |
let name: String |
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
struct Cheese: Identifiable { | |
let name: String | |
var isSelected: Bool | |
var id: String { name } | |
} | |
class ViewModel: ObservableObject { | |
@Published var cheeses = [ | |
Cheese(name: "Brie", isSelected: false), | |
Cheese(name: "Cheddar", isSelected: true), |
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
// -- Usage | |
struct Content: View { | |
@State var open = false | |
@State var popoverSize = CGSize(width: 300, height: 300) | |
var body: some View { | |
WithPopover( | |
showPopover: $open, | |
popoverSize: popoverSize, |
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
// Steps to use: | |
// 1. Go to itunesConnect > Users & Roles | |
// 2. Select "Testers" under the "Sandbox" header on the left | |
// 2. Open the console on your browser (eg. CMD-OPT-J) | |
// 3. Paste the code below (modified to your liking) into the console and hit enter | |
// 4. enter `createUser('desiredEmailAlias')` into the console and watch the user get created automatically | |
// | |
// NOTE: To create several users rapidly: in the console hit the up arrow, change the alias, and hit enter again. Repeat. | |
// Edit the user here to your liking |
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
func unwrapAndCollapse<T>(array:[T?]) -> [T] { | |
return array.reduce([]) { $1 != nil ? $0 + [$1!] : $0 } | |
} | |
func appendReplacingMatches<T>(first:[T], second:[T], matcher:((T,T)->Bool)) -> [T] { | |
var i = 0 | |
var finalArray = first | |
var appendArray = second | |
while i < first.count && appendArray.count > 0 { | |
let item = appendArray.first! |