This file contains hidden or 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
app.post("books") { req -> Book in | |
let book = try req.content.decode(Book.self) | |
return book | |
} |
This file contains hidden or 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 routes(_ app: Application) throws { | |
app.get("books") { req -> [Book] in | |
let books = [Book(name: "Atomic Habits", isbn: "1234"), Book(name: "Peek Performance", isbn: "3456"), Book(name: "How Not to Die", isbn: "6567")] | |
return books | |
} | |
} |
This file contains hidden or 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
// | |
// ContentView.swift | |
// Shared | |
// | |
// Created by Mohammad Azam on 6/30/20. | |
// | |
import SwiftUI | |
struct ListItem: Identifiable { |
This file contains hidden or 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
// | |
// ContentView.swift | |
// Shared | |
// | |
// Created by Mohammad Azam on 6/30/20. | |
// | |
import SwiftUI | |
struct Category: Identifiable { |
This file contains hidden or 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
// | |
// ContentView.swift | |
// Shared | |
// | |
// Created by Mohammad Azam on 6/27/20. | |
// | |
import SwiftUI |
This file contains hidden or 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 headerView(_ index: Int) -> some View { | |
Section { | |
Text("Section \(index)") | |
.padding() | |
.foregroundColor(Color.white) | |
.font(.title) | |
.frame(maxWidth: .infinity) | |
.background(Color.blue) | |
} | |
} |
This file contains hidden or 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 { | |
ScrollView { | |
LazyVGrid(columns: columns, spacing: 10, pinnedViews: [.sectionHeaders]) { | |
ForEach(1..<11) { index in | |
Section(header: headerView(index)) { | |
ForEach(0..<20) { _ in | |
Rectangle() |
This file contains hidden or 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
var columns: [GridItem] = [ | |
GridItem(.flexible()), | |
GridItem(.flexible()), | |
GridItem(.flexible()) | |
] |
This file contains hidden or 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
var columns: [GridItem] = [ | |
GridItem(.adaptive(minimum: 100)) | |
] |
This file contains hidden or 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
var columns: [GridItem] = [ | |
GridItem(.flexible()), | |
GridItem(.flexible()), | |
GridItem(.flexible()), | |
GridItem(.flexible()), | |
GridItem(.flexible()) | |
] |