Skip to content

Commit

Permalink
Now the files can be opened directly from the analyze screen
Browse files Browse the repository at this point in the history
  • Loading branch information
D4rK7355608 committed Oct 11, 2024
1 parent 044a67b commit c0dcc45
Show file tree
Hide file tree
Showing 8 changed files with 411 additions and 341 deletions.
68 changes: 39 additions & 29 deletions app/src/main/kotlin/com/d4rk/cleaner/ui/components/Buttons.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.d4rk.cleaner.ui.components

import android.view.SoundEffectConstants
import android.view.View
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
Expand All @@ -21,29 +23,34 @@ import com.d4rk.cleaner.ui.components.animations.bounceClick

@Composable
fun TwoRowButtons(
modifier : Modifier ,
enabled : Boolean ,
onStartButtonClick : () -> Unit ,
onStartButtonIcon : ImageVector ,
onStartButtonText : Int ,
onEndButtonClick : () -> Unit ,
onEndButtonIcon : ImageVector ,
onEndButtonText : Int ,
modifier: Modifier,
enabled: Boolean,
onStartButtonClick: () -> Unit,
onStartButtonIcon: ImageVector,
onStartButtonText: Int,
onEndButtonClick: () -> Unit,
onEndButtonIcon: ImageVector,
onEndButtonText: Int,
view: View
) {

Row(
modifier = modifier.fillMaxWidth() , horizontalArrangement = Arrangement.SpaceAround
modifier = modifier.fillMaxWidth(), horizontalArrangement = Arrangement.SpaceAround
) {
OutlinedButton(enabled = enabled ,
onClick = {
onStartButtonClick()
} ,
modifier = Modifier
.weight(1f)
.bounceClick() ,
colors = ButtonDefaults.outlinedButtonColors(contentColor = Color.Black)) {
OutlinedButton(
enabled = enabled,
onClick = {
view.playSoundEffect(SoundEffectConstants.CLICK)
onStartButtonClick()
},
modifier = Modifier
.weight(1f)
.bounceClick(),
colors = ButtonDefaults.outlinedButtonColors(contentColor = Color.Black)
) {
Icon(
imageVector = onStartButtonIcon ,
contentDescription = "Move to trash" ,
imageVector = onStartButtonIcon,
contentDescription = "Move to trash",
modifier = Modifier.size(ButtonDefaults.IconSize)
)
Spacer(Modifier.size(ButtonDefaults.IconSpacing))
Expand All @@ -52,17 +59,20 @@ fun TwoRowButtons(

Spacer(Modifier.width(8.dp))

Button(enabled = enabled ,
onClick = {
onEndButtonClick()
} ,
modifier = Modifier
.weight(1f)
.bounceClick() ,
colors = ButtonDefaults.buttonColors(contentColor = Color.White)) {
Button(
enabled = enabled,
onClick = {
view.playSoundEffect(SoundEffectConstants.CLICK)
onEndButtonClick()
},
modifier = Modifier
.weight(1f)
.bounceClick(),
colors = ButtonDefaults.buttonColors(contentColor = Color.White)
) {
Icon(
imageVector = onEndButtonIcon ,
contentDescription = "Delete forever" ,
imageVector = onEndButtonIcon,
contentDescription = "Delete forever",
modifier = Modifier.size(ButtonDefaults.IconSize)
)
Spacer(Modifier.size(ButtonDefaults.IconSpacing))
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.d4rk.cleaner.ui.components

import android.view.SoundEffectConstants
import android.view.View
import androidx.compose.animation.animateContentSize
import androidx.compose.animation.core.LinearOutSlowInEasing
import androidx.compose.animation.core.animateFloatAsState
Expand All @@ -21,6 +23,7 @@ import androidx.compose.runtime.getValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.StrokeCap
import androidx.compose.ui.platform.LocalView
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.unit.dp
Expand All @@ -45,6 +48,8 @@ fun CircularDeterminateIndicator(
modifier: Modifier = Modifier,
onClick: () -> Unit = {}
) {
val view: View = LocalView.current

val animatedProgress: Float by animateFloatAsState(
targetValue = progress,
animationSpec = tween(durationMillis = 1000, easing = LinearOutSlowInEasing),
Expand Down Expand Up @@ -77,13 +82,14 @@ fun CircularDeterminateIndicator(
.padding(16.dp)
.bounceClick(),
onClick = {
view.playSoundEffect(SoundEffectConstants.CLICK)
onClick()
},
colors = ButtonDefaults.filledTonalButtonColors()
) {
Text(
text = stringResource(id = R.string.quick_scan) ,
textAlign = TextAlign.Center ,
text = stringResource(id = R.string.quick_scan),
textAlign = TextAlign.Center,
style = MaterialTheme.typography.titleLarge
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@ import androidx.compose.ui.res.stringResource
import androidx.navigation.NavBackStackEntry
import androidx.navigation.NavController
import androidx.navigation.compose.currentBackStackEntryAsState
import com.d4rk.cleaner.ui.components.ads.AdBannerFull
import com.d4rk.cleaner.data.datastore.DataStore
import com.d4rk.cleaner.data.model.ui.navigation.BottomNavigationScreen
import com.d4rk.cleaner.ui.components.ads.AdBannerFull
import com.d4rk.cleaner.ui.components.animations.bounceClick

@Composable
fun BottomNavBar(
navController: NavController ,
dataStore: DataStore ,
fun BottomNavigationBar(
navController: NavController,
dataStore: DataStore,
view: View
) {
val bottomBarItems: List<BottomNavigationScreen> = listOf(
Expand All @@ -34,38 +34,38 @@ fun BottomNavBar(
BottomNavigationScreen.MemoryManager
)
val showLabels: Boolean =
dataStore.getShowBottomBarLabels().collectAsState(initial = true).value
dataStore.getShowBottomBarLabels().collectAsState(initial = true).value

Column {
AdBannerFull(
modifier = Modifier.fillMaxWidth() , dataStore = dataStore
modifier = Modifier.fillMaxWidth(), dataStore = dataStore
)
NavigationBar {
val navBackStackEntry: NavBackStackEntry? by navController.currentBackStackEntryAsState()
val currentRoute: String? = navBackStackEntry?.destination?.route
bottomBarItems.forEach { screen ->
NavigationBarItem(modifier = Modifier.bounceClick(),
icon = {
val iconResource: ImageVector =
if (currentRoute == screen.route) screen.selectedIcon else screen.icon
Icon(
iconResource,
contentDescription = null
)
},
label = {
if (showLabels) Text(
text = stringResource(id = screen.title)
)
},
selected = currentRoute == screen.route,
onClick = {
view.playSoundEffect(SoundEffectConstants.CLICK)
navController.navigate(screen.route) {
popUpTo(navController.graph.startDestinationId)
launchSingleTop = true
}
})
icon = {
val iconResource: ImageVector =
if (currentRoute == screen.route) screen.selectedIcon else screen.icon
Icon(
iconResource,
contentDescription = null
)
},
label = {
if (showLabels) Text(
text = stringResource(id = screen.title)
)
},
selected = currentRoute == screen.route,
onClick = {
view.playSoundEffect(SoundEffectConstants.CLICK)
navController.navigate(screen.route) {
popUpTo(navController.graph.startDestinationId)
launchSingleTop = true
}
})
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,8 @@ fun NavigationDrawer(
Spacer(modifier = Modifier.height(16.dp))
drawerItems.forEachIndexed { index, item ->
val title: String = stringResource(id = item.title)
NavigationDrawerItem(label = { Text(text = title) },
NavigationDrawerItem(
label = { Text(text = title) },
selected = index == selectedItemIndex,
onClick = {
when (item.title) {
Expand Down Expand Up @@ -169,7 +170,8 @@ fun NavigationDrawer(
.padding(
NavigationDrawerItemDefaults.ItemPadding
)
.bounceClick())
.bounceClick()
)
if (item.title == R.string.trash) {
HorizontalDivider(modifier = Modifier.padding(8.dp))
}
Expand Down Expand Up @@ -215,7 +217,7 @@ fun NavigationDrawer(
}
})
}, bottomBar = {
BottomNavBar(navHostController, dataStore, view)
BottomNavigationBar(navHostController, dataStore, view)
}) { paddingValues ->
NavigationHost(
navHostController = navHostController,
Expand Down
Loading

0 comments on commit c0dcc45

Please sign in to comment.