Skip to content

Instantly share code, notes, and snippets.

@oliverspryn
Created April 25, 2023 22:49
Show Gist options
  • Save oliverspryn/f9b0594ec0c28daa1c48f311275d4901 to your computer and use it in GitHub Desktop.
Save oliverspryn/f9b0594ec0c28daa1c48f311275d4901 to your computer and use it in GitHub Desktop.
A prompt for Google Bard used to build ToDo Bard for Android using Jetpack Compose
I am going to build an native Android app using Kotlin and Jetpack Compose. I already have a new project created in Android Studio but would like your help for the rest. I don't have any screens, just an empty activity with a setContext() function inside of it, ready for Jetpack Compose to take over. My next prompt will explain what the app is for and what I want it to do.
This app should be a todo list app. It should have the following features:
- One screen with a list of all of your tasks.
- That screen should have an empty state saying "No Tasks" when there aren't any tasks stored in the app.
- The screen should have a FAB that allows you to add a new task to that list.
- Pressing that FAB should open a pop-up dialog with a text field, allowing you to enter the name of the task to complete. It should also have an OK button that adds the task to the list on the screen and a Cancel button that closes the dialog without saving the task.
- Each task in the list should have a checkbox. That task can be completed by checking the associated checkbox. A task can be uncompleted by unchecking the associated checkbox.
- Long-pressing on a task should bring up another dialog asking if the user wants to delete that task. It should also have an OK button that deletes the relevant task from the list and a Cancel button that closes the dialog without changing the list.
- The tasks should be saved in a Room database
Can you help me create a new room database for TodoDatabase?
Show me how to build a Todo object for the database.
Show me how to implement the TodoViewModel
The tasks property on the view model doesn't have an collectAsState() function. So the code does not compile. Can you help me fix that?
I want the Button in the main UI composable to be a FAB not a button. How do I fix that?
How do I implement the onClick handler in the FAB to open a dialog with a text field asking me for the task to add to the list?
How do I implement a long-press in the list to show a dialog asking if I want to delete a task in the list?
The TodoDatabase class doesn't create a database. Can you show me how to implement the database instance creation?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment