content.tsx 1.3 KB

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