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 logo from "./logo.svg"; | |
import "./App.css"; | |
import styled from "styled-components"; | |
function App() { | |
return ( | |
<Container> | |
<WrapperCard> | |
<Card></Card> | |
<Card></Card> |
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 ContentView: View { | |
@State var isPresented: Bool = false | |
var body: some View { | |
Button(action: {}, label: { | |
Text("Present Bottom Sheet") | |
.padding() | |
}) | |
.background(Color.blue) | |
.foregroundColor(.white) |
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 SwiftUIX | |
import Introspect | |
var body: some View { | |
NavigationView { | |
// ... | |
.onTapGesture { | |
print(friend.name) | |
Keyboard.main.dismiss() // inactive | |
} |
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
typealias Predicate<Element> = (Element) -> Bool | |
func ==<Element>(lhs: KeyPath<Element, String>, rhs: String) -> Predicate<Element> { // overload == | |
return { element in | |
guard !rhs.isEmpty else { return true } // make sure not empty | |
return search( | |
needle: rhs.lowercased(), // search | |
haystack: element[keyPath: lhs].lowercased() // value for keypath | |
) | |
} |
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
// ... | |
List(friends | |
.filter { | |
search( | |
needle: searchText.lowercased(), | |
haystack: $0.name.lowercased() | |
) | |
} | |
) | |
// ... |
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 SwiftUIX | |
struct Friend: Identifiable { // Example model | |
let id: UUID = .init() | |
let name: String | |
} | |
struct ContentView: View { | |
@State var friends: [Friend] = [ | |
.init(name: "Gary"), |
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 search(needle: String, haystack: String) -> Bool { | |
guard needle.count <= haystack.count else { | |
return false | |
} | |
if needle == haystack { | |
return true | |
} | |
var needleIdx = needle.startIndex |
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 ContentView: View { | |
let colors: [Color] = [ | |
.red, .green, .blue, .gray | |
] | |
var body: some View { | |
GeometryReader { proxy in | |
TabView { | |
ForEach(colors, id: \.self) { color in | |
color // Your cell content |
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 ContentView: View { | |
let colors: [Color] = [ | |
.red, .green, .blue, .gray | |
] | |
var body: some View { | |
GeometryReader { proxy in | |
TabView { | |
ForEach(colors, id: \.self) { color in | |
color // Your cell content |
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
// swiftlint:disable all | |
// Generated using SwiftGen — https://github.com/SwiftGen/SwiftGen | |
{% if catalogs %} | |
{% set enumName %}{{param.enumName|default:"Asset"}}{% endset %} | |
{% set colorType %}{{param.colorTypeName|default:"ColorAsset"}}{% endset %} | |
{% set imageType %}{{param.imageTypeName|default:"ImageAsset"}}{% endset %} | |
{% set forceNamespaces %}{{param.forceProvidesNamespaces|default:"false"}}{% endset %} | |
{% set accessModifier %}{% if param.publicAccess %}public{% else %}internal{% endif %}{% endset %} | |
import SwiftUI |