dizyaa / budget-control-android

Android app for controlling your budgets
GNU Affero General Public License v3.0
0 stars 0 forks source link

Sweep: rewrite all fragments to composable functions by Jetpack Compose and add dependensies if requeire #2

Open dizyaa opened 1 year ago

dizyaa commented 1 year ago
Checklist - [X] `app/build.gradle` > • Add Jetpack Compose dependencies to the dependencies block. > • Update the compileOptions and kotlinOptions to use Java 11, as required by Jetpack Compose. - [X] `app/src/main/java/dizel/budget_control/budget/view/MainActivity.kt` > • Replace the setContentView call with setContent and define the UI using Composable functions. > • Update the navigation logic to use navigation-compose if necessary. - [X] `app/src/main/java/dizel/budget_control/budget/view/budget_list/BudgetListFragment.kt` > • Refactor the BudgetListFragment to a Composable function. > • Update the UI definition to use Compose. - [X] `app/src/main/java/dizel/budget_control/auth/view/SplashAuthFragment.kt` > • Refactor the SplashAuthFragment to a Composable function. > • Update the UI definition to use Compose. - [X] `app/src/main/java/dizel/budget_control/budget/view/create_budget/CreateBudgetFragment.kt` > • Refactor the CreateBudgetFragment to a Composable function. > • Update the UI definition to use Compose.
sweep-ai[bot] commented 1 year ago

Here's the PR! https://github.com/dizyaa/budget-control-android/pull/4.

⚡ Sweep Free Trial: I used GPT-4 to create this ticket. You have 4 GPT-4 tickets left for the month and 1 for the day. For more GPT-4 tickets, visit our payment portal. To retrigger Sweep, edit the issue.


Step 1: 🔍 Code Search

I found the following snippets in your repository. I will now analyze these snippets and come up with a plan.

Some code snippets I looked at (click to expand). If some file is missing from here, you can mention the path in the ticket description. https://github.com/dizyaa/budget-control-android/blob/0fd6fb810341b5ef44b95120a53390f1fa63674e/app/src/main/java/dizel/budget_control/budget/view/budget_list/BudgetListAdapter.kt#L1-L75 https://github.com/dizyaa/budget-control-android/blob/0fd6fb810341b5ef44b95120a53390f1fa63674e/app/src/main/java/dizel/budget_control/budget/view/MainActivity.kt#L1-L18 https://github.com/dizyaa/budget-control-android/blob/0fd6fb810341b5ef44b95120a53390f1fa63674e/app/build.gradle#L1-L66 https://github.com/dizyaa/budget-control-android/blob/0fd6fb810341b5ef44b95120a53390f1fa63674e/app/src/main/java/dizel/budget_control/auth/view/SplashAuthFragment.kt#L1-L18 https://github.com/dizyaa/budget-control-android/blob/0fd6fb810341b5ef44b95120a53390f1fa63674e/app/src/main/res/layout/activity_main.xml#L1-L8

Step 2: 🧐 Snippet Analysis

From looking through the relevant snippets, I decided to make the following modifications:

File Path Proposed Changes
app/build.gradle Modify app/build.gradle with contents:
• Add Jetpack Compose dependencies to the dependencies block.
• Update the compileOptions and kotlinOptions to use Java 11, as required by Jetpack Compose.
app/src/main/java/dizel/budget_control/budget/view/MainActivity.kt Modify app/src/main/java/dizel/budget_control/budget/view/MainActivity.kt with contents:
• Replace the setContentView call with setContent and define the UI using Composable functions.
• Update the navigation logic to use navigation-compose if necessary.
app/src/main/java/dizel/budget_control/budget/view/budget_list/BudgetListFragment.kt Modify app/src/main/java/dizel/budget_control/budget/view/budget_list/BudgetListFragment.kt with contents:
• Refactor the BudgetListFragment to a Composable function.
• Update the UI definition to use Compose.
app/src/main/java/dizel/budget_control/auth/view/SplashAuthFragment.kt Modify app/src/main/java/dizel/budget_control/auth/view/SplashAuthFragment.kt with contents:
• Refactor the SplashAuthFragment to a Composable function.
• Update the UI definition to use Compose.
app/src/main/java/dizel/budget_control/budget/view/create_budget/CreateBudgetFragment.kt Modify app/src/main/java/dizel/budget_control/budget/view/create_budget/CreateBudgetFragment.kt with contents:
• Refactor the CreateBudgetFragment to a Composable function.
• Update the UI definition to use Compose.

Step 3: 📝 Planning

I have created a plan for writing the pull request. I am now working my plan and coding the required changes to address this issue. Here is the planned pull request:

Refactor Fragments to Jetpack Compose sweep/refactor-fragments-to-compose

Description

This PR refactors the existing fragments in the budget-control-android app to use Jetpack Compose, a modern toolkit for building native Android UI. The following changes were made:

  • Added Jetpack Compose dependencies to the build.gradle file.
  • Refactored the MainActivity to use setContent method instead of setting a layout resource.
  • Refactored the BudgetListFragment, SplashAuthFragment, and CreateBudgetFragment to Composable functions.
  • Updated the UI definition in the fragments to use Compose.

Summary of Changes

  • Added Jetpack Compose dependencies to the build.gradle file.
  • Updated compileOptions and kotlinOptions to use Java 11.
  • Refactored MainActivity to use setContent and updated navigation logic.
  • Refactored BudgetListFragment to a Composable function and updated UI definition.
  • Refactored SplashAuthFragment to a Composable function and updated UI definition.
  • Refactored CreateBudgetFragment to a Composable function and updated UI definition.

Please review and merge these changes. Thank you!


Step 4: ⌨️ Coding

File Instructions Progress Error logs
app/build.gradle Modify app/build.gradle with contents:
• Add Jetpack Compose dependencies to the dependencies block.
• Update the compileOptions and kotlinOptions to use Java 11, as required by Jetpack Compose.
✅ Commit 9ffd8d4 No errors.
app/src/main/java/dizel/budget_control/budget/view/MainActivity.kt Modify app/src/main/java/dizel/budget_control/budget/view/MainActivity.kt with contents:
• Replace the setContentView call with setContent and define the UI using Composable functions.
• Update the navigation logic to use navigation-compose if necessary.
✅ Commit 9ffd8d4 No errors.
app/src/main/java/dizel/budget_control/budget/view/budget_list/BudgetListFragment.kt Modify app/src/main/java/dizel/budget_control/budget/view/budget_list/BudgetListFragment.kt with contents:
• Refactor the BudgetListFragment to a Composable function.
• Update the UI definition to use Compose.
✅ Commit 1acfc9d No errors.
app/src/main/java/dizel/budget_control/auth/view/SplashAuthFragment.kt Modify app/src/main/java/dizel/budget_control/auth/view/SplashAuthFragment.kt with contents:
• Refactor the SplashAuthFragment to a Composable function.
• Update the UI definition to use Compose.
✅ Commit d15cbd1 No errors.
app/src/main/java/dizel/budget_control/budget/view/create_budget/CreateBudgetFragment.kt Modify app/src/main/java/dizel/budget_control/budget/view/create_budget/CreateBudgetFragment.kt with contents:
• Refactor the CreateBudgetFragment to a Composable function.
• Update the UI definition to use Compose.
✅ Commit d15cbd1 No errors. I have finished coding the issue. I am now reviewing it for completeness.

Step 5: 🔁 Code Review

Here are my self-reviews of my changes at sweep/refactor-fragments-to-compose.

Here is the 1st review

Great job on starting to implement Jetpack Compose in the project! Here are a few things that need to be addressed:

  • In app/build.gradle, you've added new dependencies for Jetpack Compose. Please ensure that you've imported these dependencies in the files where they are used.
  • In app/src/main/java/dizel/budget_control/auth/view/SplashAuthFragment.kt, you've replaced the fragment with composable functions. Make sure that the "signIn" and "signUp" destinations are defined in the navigation graph.
  • In app/src/main/java/dizel/budget_control/budget/view/MainActivity.kt, you've replaced the fragment container setup with setContent. Ensure that the BudgetListScreen composable function is properly implemented.
  • In app/src/main/java/dizel/budget_control/budget/view/budget_list/BudgetListFragment.kt, you've replaced the fragment with a composable function. Make sure that the navigation functions and the BudgetListViewModel are properly implemented.
  • In app/src/main/java/dizel/budget_control/budget/view/create_budget/CreateBudgetFragment.kt, you've replaced the fragment with a composable function. Ensure that the CreateBudgetViewModel is properly implemented.

Keep up the good work!

I finished incorporating these changes.


🎉 Latest improvements to Sweep:


💡 To recreate the pull request edit the issue title or description. Join Our Discord