content.tsx70 lines · main
| 1 | import { MultipleCodeBlock } from 'ui-patterns/MultipleCodeBlock' |
| 2 | |
| 3 | import type { StepContentProps } from '@/components/interfaces/ConnectSheet/Connect.types' |
| 4 | |
| 5 | const ContentFile = ({ projectKeys }: StepContentProps) => { |
| 6 | const files = [ |
| 7 | { |
| 8 | name: 'Briven.swift', |
| 9 | language: 'swift', |
| 10 | code: ` |
| 11 | import Foundation |
| 12 | import Briven |
| 13 | |
| 14 | let briven = BrivenClient( |
| 15 | brivenURL: URL(string: "${projectKeys.apiUrl ?? 'your-project-url'}")!, |
| 16 | brivenKey: "${projectKeys.publishableKey ?? '<prefer publishable key for native apps instead of anon key>'}" |
| 17 | ) |
| 18 | `, |
| 19 | }, |
| 20 | { |
| 21 | name: 'Todo.swift', |
| 22 | language: 'swift', |
| 23 | code: ` |
| 24 | import Foundation |
| 25 | |
| 26 | struct Todo: Identifiable, Decodable { |
| 27 | var id: Int |
| 28 | var name: String |
| 29 | } |
| 30 | `, |
| 31 | }, |
| 32 | { |
| 33 | name: 'ContentView.swift', |
| 34 | language: 'swift', |
| 35 | code: ` |
| 36 | import Briven |
| 37 | import SwiftUI |
| 38 | |
| 39 | struct ContentView: View { |
| 40 | @State var todos: [Todo] = [] |
| 41 | |
| 42 | var body: some View { |
| 43 | NavigationStack { |
| 44 | List(todos) { todo in |
| 45 | Text(todo.name) |
| 46 | } |
| 47 | .navigationTitle("Todos") |
| 48 | .task { |
| 49 | do { |
| 50 | todos = try await briven.from("todos").select().execute().value |
| 51 | } catch { |
| 52 | debugPrint(error) |
| 53 | } |
| 54 | } |
| 55 | } |
| 56 | } |
| 57 | } |
| 58 | |
| 59 | #Preview { |
| 60 | ContentView() |
| 61 | } |
| 62 | |
| 63 | `, |
| 64 | }, |
| 65 | ] |
| 66 | |
| 67 | return <MultipleCodeBlock files={files} /> |
| 68 | } |
| 69 | |
| 70 | export default ContentFile |