| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071 |
- import { MultipleCodeBlock } from 'ui-patterns/MultipleCodeBlock'
- import type { StepContentProps } from '@/components/interfaces/ConnectSheet/Connect.types'
- const ContentFile = ({ projectKeys }: StepContentProps) => {
- const files = [
- {
- name: 'MainActivity.kt',
- language: 'kotlin',
- code: `
- val briven = createBrivenClient(
- brivenUrl = "${projectKeys.apiUrl ?? 'your-project-url'}",
- brivenKey = "${projectKeys.publishableKey ?? '<prefer publishable key instead of anon key for mobile apps>'}"
- ) {
- install(Postgrest)
- }
- class MainActivity : ComponentActivity() {
- override fun onCreate(savedInstanceState: Bundle?) {
- super.onCreate(savedInstanceState)
- setContent {
- MaterialTheme {
- // A surface container using the 'background' color from the theme
- Surface(
- modifier = Modifier.fillMaxSize(),
- color = MaterialTheme.colorScheme.background
- ) {
- TodoList()
- }
- }
- }
- }
- }
- @Composable
- fun TodoList() {
- var items by remember { mutableStateOf<List<TodoItem>>(listOf()) }
- LaunchedEffect(Unit) {
- withContext(Dispatchers.IO) {
- items = briven.from("todos")
- .select().decodeList<TodoItem>()
- }
- }
- LazyColumn {
- items(
- items,
- key = { item -> item.id },
- ) { item ->
- Text(
- item.name,
- modifier = Modifier.padding(8.dp),
- )
- }
- }
- }
- `,
- },
- {
- name: 'TodoItem.kt',
- language: 'kotlin',
- code: `
- @Serializable
- data class TodoItem(val id: Int, val name: String)
- `,
- },
- ]
- return <MultipleCodeBlock files={files} />
- }
- export default ContentFile
|