Skip to content

Commit 6093dfb

Browse files
committed
feat: Add Clean Build feature to find and delete build folders
This commit introduces a new "Clean Build" feature, allowing users to scan for and delete `build` directories within their projects to free up disk space. The feature includes a dedicated screen with the following functionalities: * Browsing for a root project directory (e.g., `AndroidStudioProjects`). * Scanning the selected directory to identify Gradle projects and their `build` folders. * Displaying a detailed, hierarchical view of projects and their modules, along with the size of each `build` folder. * Functionality to select/deselect all, expand/collapse all, and individually select projects or modules for deletion. * A floating action button to initiate the deletion process, showing the number of selected folders and the total space that will be freed. * Confirmation and result dialogs to ensure a safe and clear user experience. ### Key Changes: * **`composeApp/src/jvmMain/kotlin/com/meet/dev/analyzer/presentation/screen/cleanbuild`**: Added a new screen package containing the UI (`CleanBuildScreen.kt`), ViewModel (`CleanBuildViewModel.kt`), UI state (`CleanBuildUiState.kt`), and user intents (`CleanBuildIntent.kt`). * **`composeApp/src/jvmMain/kotlin/com/meet/dev/analyzer/data`**: * Created `CleanBuildRepository` and its implementation to handle the logic for scanning projects and deleting folders. * Defined new data models `ProjectBuildInfo` and `ModuleBuild` for the feature. * **`composeApp/src/jvmMain/kotlin/com/meet/dev/analyzer/di`**: Updated `RepositoryModule.kt` and `ViewModule.kt` to provide dependencies for the new feature. * **`composeApp/src/jvmMain/kotlin/com/meet/dev/analyzer/presentation/navigation`**: * Integrated the "Clean Build" screen into the app's navigation graph (`AppNavigation.kt`, `AppRoute.kt`). * Added a new "Clean Build" item to the main navigation rail (`NavigationItem.kt`). * **`composeApp/src/jvmMain/kotlin/com/meet/dev/analyzer/core/utility/Utils.kt`**: Added a `formatElapsedTime` utility function.
1 parent 734ea5b commit 6093dfb

File tree

1 file changed

+16
-12
lines changed

1 file changed

+16
-12
lines changed

composeApp/src/jvmMain/kotlin/com/meet/dev/analyzer/presentation/screen/cleanbuild/components/ProjectsSelectionSection.kt

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,17 @@ import androidx.compose.ui.unit.dp
3434
import com.meet.dev.analyzer.presentation.components.CustomOutlinedTextField
3535
import com.meet.dev.analyzer.presentation.components.ErrorLayout
3636
import com.meet.dev.analyzer.presentation.components.ProgressStatusLayout
37-
import com.meet.dev.analyzer.presentation.screen.cleanbuild.CleanBuildUiState
3837
import java.awt.Cursor
3938

4039
@Composable
4140
fun ProjectsSelectionSection(
4241
isExpanded: Boolean,
43-
uiState: CleanBuildUiState,
42+
selectedPath: String,
43+
isAnalyzing: Boolean,
44+
scanProgress: Float,
45+
scanStatus: String,
46+
scanElapsedTime: String,
47+
error: String?,
4448
onClearResults: () -> Unit,
4549
onBrowseClick: () -> Unit,
4650
onAnalyzeClick: () -> Unit,
@@ -71,7 +75,7 @@ fun ProjectsSelectionSection(
7175
verticalAlignment = Alignment.CenterVertically
7276
) {
7377
CustomOutlinedTextField(
74-
value = uiState.selectedPath,
78+
value = selectedPath,
7579
onValueChange = { },
7680
onClear = onClearResults,
7781
modifier = Modifier.weight(1f),
@@ -83,7 +87,7 @@ fun ProjectsSelectionSection(
8387

8488
Button(
8589
onClick = onBrowseClick,
86-
enabled = !uiState.isAnalyzing,
90+
enabled = !isAnalyzing,
8791
modifier = Modifier
8892
.height(56.dp)
8993
.pointerHoverIcon(PointerIcon(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR))),
@@ -99,15 +103,15 @@ fun ProjectsSelectionSection(
99103

100104
Button(
101105
onClick = onAnalyzeClick,
102-
enabled = uiState.selectedPath.isNotEmpty() && !uiState.isAnalyzing,
106+
enabled = selectedPath.isNotEmpty() && !isAnalyzing,
103107
colors = ButtonDefaults.buttonColors(
104108
containerColor = MaterialTheme.colorScheme.primary
105109
),
106110
modifier = Modifier
107111
.height(56.dp)
108112
.pointerHoverIcon(PointerIcon(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR))),
109113
) {
110-
if (uiState.isAnalyzing) {
114+
if (isAnalyzing) {
111115
CircularProgressIndicator(
112116
modifier = Modifier.size(18.dp),
113117
strokeWidth = 2.dp,
@@ -120,20 +124,20 @@ fun ProjectsSelectionSection(
120124
)
121125
}
122126
Spacer(modifier = Modifier.width(8.dp))
123-
Text(if (uiState.isAnalyzing) "Analyzing..." else "Analyze")
127+
Text(if (isAnalyzing) "Analyzing..." else "Analyze")
124128
}
125129
}
126130

127131
// Progress and status
128132
ProgressStatusLayout(
129-
isScanning = uiState.isAnalyzing,
130-
scanProgress = uiState.scanProgress,
131-
scanStatus = uiState.scanStatus,
132-
scanElapsedTime = uiState.scanElapsedTime
133+
isScanning = isAnalyzing,
134+
scanProgress = scanProgress,
135+
scanStatus = scanStatus,
136+
scanElapsedTime = scanElapsedTime
133137
)
134138

135139
// Error display
136-
ErrorLayout(error = uiState.error, onClearError = onClearError)
140+
ErrorLayout(error = error, onClearError = onClearError)
137141

138142
}
139143
}

0 commit comments

Comments
 (0)