Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 28 additions & 24 deletions app/src/main/java/com/sayanthrock/freeairock/ui/AboutScreen.kt
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ import androidx.compose.material3.ButtonDefaults
import androidx.compose.material3.HorizontalDivider
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.OutlinedButton
import androidx.compose.material3.RadioButton
import androidx.compose.material3.RadioButtonDefaults
import androidx.compose.material3.Surface
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
Expand Down Expand Up @@ -73,28 +73,31 @@ fun AboutScreen(
Spacer(modifier = Modifier.height(16.dp))

val themeOptions = listOf(ThemeMode.SYSTEM, ThemeMode.LIGHT, ThemeMode.DARK)
val themeLabels = listOf("System Auto Color", "Light Mode", "Dark Mode")
val themeLabels = listOf("System", "Light", "Dark")

themeOptions.forEachIndexed { index, themeMode ->
Row(
verticalAlignment = Alignment.CenterVertically,
modifier = Modifier
.fillMaxWidth()
.clickable { onThemeChange(themeMode) }
.padding(vertical = 8.dp)
) {
RadioButton(
selected = currentTheme == themeMode,
onClick = { onThemeChange(themeMode) },
colors = RadioButtonDefaults.colors(
selectedColor = MaterialTheme.colorScheme.primary
Row(
modifier = Modifier.fillMaxWidth(),
horizontalArrangement = Arrangement.SpaceBetween
) {
themeOptions.forEachIndexed { index, themeMode ->
Surface(
shape = MaterialTheme.shapes.large,
color = if (currentTheme == themeMode) MaterialTheme.colorScheme.primary else MaterialTheme.colorScheme.surface,
contentColor = if (currentTheme == themeMode) MaterialTheme.colorScheme.onPrimary else MaterialTheme.colorScheme.onSurface,
modifier = Modifier
.weight(1f)
.padding(horizontal = 4.dp)
.clickable { onThemeChange(themeMode) },
Comment thread
SayanthRock marked this conversation as resolved.
shadowElevation = if (currentTheme == themeMode) 4.dp else 0.dp
) {
Text(
text = themeLabels[index],
style = MaterialTheme.typography.bodyLarge,
fontFamily = FontFamily.Monospace,
modifier = Modifier.padding(vertical = 12.dp, horizontal = 8.dp),
textAlign = androidx.compose.ui.text.style.TextAlign.Center
)
)
Spacer(modifier = Modifier.width(8.dp))
Text(
text = themeLabels[index],
style = MaterialTheme.typography.bodyLarge
)
}
Comment thread
SayanthRock marked this conversation as resolved.
}
}

Expand All @@ -121,8 +124,9 @@ fun AboutScreen(

Text(
text = "FREE-AI-ROCK",
style = MaterialTheme.typography.bodyLarge,
fontFamily = FontFamily.Monospace
style = MaterialTheme.typography.titleLarge,
fontFamily = FontFamily.Monospace,
color = MaterialTheme.colorScheme.primary
)
Text(
text = "Designed and developed by @SayanthRock in Kerala, India.",
Expand Down
51 changes: 34 additions & 17 deletions app/src/main/java/com/sayanthrock/freeairock/ui/HomeScaffold.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,11 @@ package com.sayanthrock.freeairock.ui
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.padding
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.NavigationBar
import androidx.compose.material3.NavigationBarItem
import androidx.compose.material3.Surface
import androidx.compose.material3.Tab
import androidx.compose.material3.TabRow
import androidx.compose.material3.TabRowDefaults
import androidx.compose.material3.TabRowDefaults.tabIndicatorOffset
import androidx.compose.material3.Scaffold
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
Expand All @@ -29,24 +32,38 @@ fun HomeScaffold(
val screens = listOf(Screen.ImageStudio, Screen.About)

Scaffold(
bottomBar = {
NavigationBar(containerColor = MaterialTheme.colorScheme.surface) {
topBar = {
Surface(shadowElevation = 4.dp) {
val navBackStackEntry by navController.currentBackStackEntryAsState()
val currentDestination = navBackStackEntry?.destination
val currentRoute = currentDestination?.route
val selectedTabIndex = screens.indexOfFirst { it.route == currentRoute }.takeIf { it >= 0 } ?: 0

screens.forEach { screen ->
NavigationBarItem(
icon = { Text(screen.shortLabel, fontFamily = FontFamily.Monospace) },
label = { Text(screen.title, fontFamily = FontFamily.Monospace) },
selected = currentDestination?.hierarchy?.any { it.route == screen.route } == true,
onClick = {
navController.navigate(screen.route) {
popUpTo(navController.graph.findStartDestination().id) { saveState = true }
launchSingleTop = true
restoreState = true
}
}
)
TabRow(
selectedTabIndex = selectedTabIndex,
containerColor = MaterialTheme.colorScheme.surface,
contentColor = MaterialTheme.colorScheme.onSurface,
indicator = { tabPositions ->
TabRowDefaults.SecondaryIndicator(
Modifier.tabIndicatorOffset(tabPositions[selectedTabIndex]),
color = MaterialTheme.colorScheme.primary
)
}
) {
screens.forEachIndexed { index, screen ->
Tab(
selected = selectedTabIndex == index,
onClick = {
navController.navigate(screen.route) {
popUpTo(navController.graph.findStartDestination().id) { saveState = true }
launchSingleTop = true
restoreState = true
}
},
text = { Text(screen.title, fontFamily = FontFamily.Monospace) },
icon = { Text(screen.shortLabel, fontFamily = FontFamily.Monospace, style = MaterialTheme.typography.titleLarge) }
)
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ import androidx.compose.foundation.verticalScroll
import androidx.compose.material3.Button
import androidx.compose.material3.CircularProgressIndicator
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.OutlinedButton
import androidx.compose.material3.OutlinedTextField
import androidx.compose.material3.OutlinedTextFieldDefaults
import androidx.compose.material3.Surface
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
Expand Down Expand Up @@ -74,12 +76,17 @@ fun ImageStudioScreen(
label = { Text("Describe the image you want") },
modifier = Modifier.fillMaxWidth(),
singleLine = false,
maxLines = 5
maxLines = 5,
shape = MaterialTheme.shapes.extraLarge,
colors = OutlinedTextFieldDefaults.colors(
unfocusedBorderColor = MaterialTheme.colorScheme.primary.copy(alpha = 0.5f),
focusedBorderColor = MaterialTheme.colorScheme.primary
)
)

Spacer(modifier = Modifier.height(16.dp))

Button(
OutlinedButton(
onClick = {
if (prompt.isNotBlank()) {
val seed = (0..1000000).random()
Expand All @@ -90,15 +97,16 @@ fun ImageStudioScreen(
modifier = Modifier.fillMaxWidth(),
enabled = prompt.isNotBlank() && !isGenerating
) {
Text(if (isGenerating) "Generating..." else "Generate Image")
Text(if (isGenerating) "Generating..." else "Generate Image", fontFamily = FontFamily.Monospace)
}

Spacer(modifier = Modifier.height(32.dp))

imageUrl?.let { url ->
Surface(
color = MaterialTheme.colorScheme.surface,
shape = MaterialTheme.shapes.medium,
shape = MaterialTheme.shapes.extraLarge,
shadowElevation = 8.dp,
modifier = Modifier.fillMaxWidth().height(300.dp)
) {
SubcomposeAsyncImage(
Expand Down Expand Up @@ -126,7 +134,7 @@ fun ImageStudioScreen(

Spacer(modifier = Modifier.height(16.dp))

Button(
OutlinedButton(
onClick = {
if (!isDownloading) {
isDownloading = true
Expand All @@ -153,7 +161,7 @@ fun ImageStudioScreen(
modifier = Modifier.fillMaxWidth(),
enabled = !isDownloading && !isGenerating
) {
Text(if (isDownloading) "Downloading..." else "Download [↓]")
Text(if (isDownloading) "Downloading..." else "Download [↓]", fontFamily = FontFamily.Monospace)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ sealed class Screen(
data object ImageStudio : Screen(
route = "image_studio",
title = "Image Studio",
shortLabel = "IMG"
shortLabel = ""
)

data object About : Screen(
route = "about",
title = "Settings",
shortLabel = "SET"
shortLabel = ""
)
}
Loading