Skip to content

Instantly share code, notes, and snippets.

extension View {
func navigationBarColor(backgroundColor: UIColor, tintColor: UIColor) -> some View {
self.modifier(NavigationBarColor(backgroundColor: backgroundColor, tintColor: tintColor))
}
}
import SwiftUI
struct ContentView: View {
var body: some View {
NavigationView {
List {
ForEach(0..<25, id: \.self, content: { i in
NavigationLink("(\(i)) Hello, world!", destination: EmptyView())
})
}
var body: some View {
NavigationView {
List {
ForEach(0..<10, content: { i in
Text("\(i): 🥳")
.font(.largeTitle)
.padding([.top, .bottom])
})
}
.foregroundColor(.black)
import Foundation
public struct EmojiDetails {
public let emoji: String
public let name: String
public let description: String
}
// MARK: - Identifiable
import Foundation
public struct EmojiProvider {
/// Creates a list of emoji details that includes an emoji along with its name and description.
/// - Returns: The list of `EmojiDetail`s
/// - Note: Emoji descriptions obtained from [Empojipedia](https://emojipedia.org/).
static func all() -> [EmojiDetails] {
return [
EmojiDetails(
struct EmojibookListView: View {
// ...
}
struct EmojiItemView: View {
let emoji: String
let emojiName: String
var body: some View {
Text("\(emoji) \(emojiName)")
struct EmojibookListView: View {
let emojiData: [EmojiDetails] = EmojiProvider.all()
var body: some View {
NavigationView {
List {
ForEach(emojiData, content: { emojiDetails in
EmojiItemView(emoji: emojiDetails.emoji, emojiName: emojiDetails.name)
})
struct EmojibookListView: View {
// ...
}
struct EmojiItemView: View {
// ...
}
struct EmojiDetailsView: View {
var emojiDetails: EmojiDetails
struct EmojibookListView: View {
let emojiData: [EmojiDetails] = EmojiProvider.all()
@State private var showingDetail: Bool = false
var body: some View {
NavigationView {
List {
ForEach(emojiData, content: { emojiDetails in
Button(action: {
import SwiftUI
struct EmojiWidgetView: View {
let emojiDetails: EmojiDetails
var body: some View {
ZStack {
Color(UIColor.systemIndigo)
VStack {