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
NavigationView { | |
List { | |
ForEach(businesses) { business in | |
Text(business.name) | |
} | |
// Swipe actions | |
.swipeActions( | |
edge: .trailing, | |
allowsFullSwipe: true, | |
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
@State var businesses = [Bussiness]() | |
NavigationView { | |
List { | |
ForEach(businesses) { business in | |
Text(business.name ?? "no name") | |
} | |
} | |
.listStyle(.plain) | |
.navigationTitle(Text("Boston")) |
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
NavigationView { | |
List { | |
ForEach(businesses) { business in | |
Text(business.name) | |
} | |
} | |
.listStyle(.plain) | |
.navigationTitle(Text("Boston")) | |
.searchable($searchText) | |
// Receive an update here when the user selects the done button on the keyboard |
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
NavigationView { | |
List { | |
ForEach(viewModel.businesses) { business in | |
Text(business.name) | |
} | |
} | |
.listStyle(.plain) | |
.navigationTitle(Text("Boston")) | |
// Position a gradient at the bottom edge of a list | |
.safeAreaInset(edge: .bottom) { |
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
NavigationView { | |
List { | |
ForEach(businesses, id: \.id) { business in | |
Text(business.name) | |
} | |
} | |
.listStyle(.plain) | |
.navigationTitle(Text("Boston")) | |
// New tool bar modifier and tool bar item | |
.toolbar { |
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
NavigationView { | |
List { | |
ForEach(businesses, id: \.id) { business in | |
Text(business.name) | |
} | |
} | |
.listStyle(.plain) | |
.navigationTitle(Text("Restaurant")) | |
// Add the new searchable modifier on List | |
.searchable(text: $searchText) { |
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
// Grab everything before the cursor | |
var before = textDocumentProxy.documentContextBeforeInput | |
var completePriorString = "" | |
while let beforeInput = before, !beforeInput.isEmpty { | |
completePriorString = beforeInput | |
let length = beforeInput.lengthOfBytes(using: String.Encoding.utf8) | |
textDocumentProxy.adjustTextPosition(byCharacterOffset: -length) |
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
{ | |
"businesses": [ | |
{ | |
"id": "htEuhPBhBgMs6ShlT3G3JA", | |
"alias": "regina-pizzeria-boston-28", | |
"name": "Regina Pizzeria", | |
"image_url": "https://s3-media3.fl.yelpcdn.com/bphoto/rPG03lJzJVlrTJNrQnuQxg/o.jpg", | |
"is_closed": false, | |
"url": "https://www.yelp.com/biz/regina-pizzeria-boston-28?adjust_creative=P9N85ndOnt6FtF1FkbyulA&utm_campaign=yelp_api_v3&utm_medium=api_v3_business_search&utm_source=P9N85ndOnt6FtF1FkbyulA", | |
"review_count": 2099, |
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
[ | |
{ | |
"name": "Gary Tokman", | |
"bio": "iOS dev working with SwiftUI", | |
"imageUrl": "https://pbs.twimg.com/profile_images/1395577843476742144/MOWWQV-V_400x400.jpg", | |
"twitter": "f6ary" | |
}, | |
{ | |
"name": "Elon Musk", | |
"bio": "CEO of Tesla", |
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
["hello world"] | |
.publisher | |
.subscribe(on: DispatchQueue.global(qos: .background)) // 1 | |
.map { string -> String in | |
print("Is main thread in map:", Thread.isMainThread) | |
return string | |
} | |
.breakpoint(receiveOutput: { str in | |
print("current str:", str) | |
return Thread.isMainThread // if main thread, breakpoint |