Skip to content

Commit dfb66e9

Browse files
author
code3-dev
committed
Fix Layouts
1 parent ec970ff commit dfb66e9

7 files changed

Lines changed: 94 additions & 105 deletions

File tree

app/build.gradle.kts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ android {
1616
applicationId = "com.pira.ccloud"
1717
minSdk = 24
1818
targetSdk = 36
19-
versionCode = 2
20-
versionName = "1.0.1"
19+
versionCode = 3
20+
versionName = "1.0.2"
2121

2222
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
2323
}

app/src/main/java/com/pira/ccloud/screens/MoviesScreen.kt

Lines changed: 22 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -84,30 +84,28 @@ fun MoviesScreen(
8484
}
8585
}
8686

87-
Column(modifier = Modifier.fillMaxSize()) {
88-
when {
89-
isLoading && movies.isEmpty() -> {
90-
// Show modern loading animation when initial movies are loading
91-
LoadingScreen()
92-
}
93-
errorMessage != null && movies.isEmpty() -> {
94-
ErrorScreen(
95-
errorMessage = errorMessage,
96-
onRetry = { viewModel.retry() }
97-
)
98-
}
99-
else -> {
100-
MovieGrid(
101-
movies = movies,
102-
isLoading = isLoading,
103-
isLoadingMore = isLoadingMore,
104-
errorMessage = errorMessage,
105-
onRetry = { viewModel.retry() },
106-
onRefresh = { viewModel.refresh() },
107-
onLoadMore = { viewModel.loadMoreMovies() },
108-
navController = navController
109-
)
110-
}
87+
when {
88+
isLoading && movies.isEmpty() -> {
89+
// Show modern loading animation when initial movies are loading
90+
LoadingScreen()
91+
}
92+
errorMessage != null && movies.isEmpty() -> {
93+
ErrorScreen(
94+
errorMessage = errorMessage,
95+
onRetry = { viewModel.retry() }
96+
)
97+
}
98+
else -> {
99+
MovieGrid(
100+
movies = movies,
101+
isLoading = isLoading,
102+
isLoadingMore = isLoadingMore,
103+
errorMessage = errorMessage,
104+
onRetry = { viewModel.retry() },
105+
onRefresh = { viewModel.refresh() },
106+
onLoadMore = { viewModel.loadMoreMovies() },
107+
navController = navController
108+
)
111109
}
112110
}
113111
}

app/src/main/java/com/pira/ccloud/screens/SettingsScreen.kt

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ import com.pira.ccloud.ui.theme.ThemeSettings
4747
import com.pira.ccloud.ui.theme.ThemeManager
4848
import com.pira.ccloud.ui.theme.colorOptions
4949
import com.pira.ccloud.ui.theme.defaultPrimaryColor
50-
import com.pira.ccloud.ui.theme.defaultSecondaryColor
5150
import com.pira.ccloud.utils.StorageUtils
5251
import androidx.compose.foundation.layout.Arrangement.SpaceBetween
5352
import androidx.compose.foundation.layout.RowScope
@@ -154,23 +153,6 @@ fun SettingsScreen(onThemeSettingsChanged: (ThemeSettings) -> Unit = {}) {
154153
}
155154
}
156155

157-
item {
158-
AnimatedVisibility(
159-
visible = true,
160-
enter = fadeIn(animationSpec = tween(800)) + slideInVertically(animationSpec = tween(800, delayMillis = 500)),
161-
exit = fadeOut(animationSpec = tween(800)) + slideOutVertically(animationSpec = tween(800))
162-
) {
163-
ColorSelectionSection(
164-
title = "Secondary Color",
165-
selectedColor = themeSettings.secondaryColor,
166-
onColorSelected = { color ->
167-
val newSettings = themeSettings.copy(secondaryColor = color)
168-
updateThemeSettings(newSettings)
169-
}
170-
)
171-
}
172-
}
173-
174156
item {
175157
AnimatedVisibility(
176158
visible = true,
@@ -214,6 +196,9 @@ fun SettingsScreen(onThemeSettingsChanged: (ThemeSettings) -> Unit = {}) {
214196
onClick = {
215197
val defaultSettings = ThemeSettings()
216198
updateThemeSettings(defaultSettings)
199+
// Reset subtitle settings to default as well
200+
val defaultSubtitleSettings = SubtitleSettings.DEFAULT
201+
updateSubtitleSettings(defaultSubtitleSettings)
217202
}
218203
)
219204
}
@@ -339,7 +324,7 @@ fun ColorSelectionSection(
339324
.padding(vertical = 4.dp),
340325
horizontalArrangement = Arrangement.Start
341326
) {
342-
val defaultColor = if (title == "Primary Color") defaultPrimaryColor else defaultSecondaryColor
327+
val defaultColor = defaultPrimaryColor
343328
Box(modifier = Modifier.weight(1f), contentAlignment = Alignment.Center) {
344329
ColorOption(
345330
color = defaultColor,

app/src/main/java/com/pira/ccloud/screens/SingleMovieScreen.kt

Lines changed: 55 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ import androidx.compose.foundation.layout.height
1717
import androidx.compose.foundation.layout.padding
1818
import androidx.compose.foundation.layout.size
1919
import androidx.compose.foundation.layout.width
20+
import androidx.compose.foundation.lazy.LazyRow
21+
import androidx.compose.foundation.lazy.items
2022
import androidx.compose.foundation.rememberScrollState
2123
import androidx.compose.foundation.shape.RoundedCornerShape
2224
import androidx.compose.foundation.verticalScroll
@@ -75,42 +77,40 @@ fun SingleMovieScreen(
7577
movie = StorageUtils.loadMovieFromFile(context, movieId)
7678
}
7779

78-
// Using Scaffold without topBar to avoid conflicts with the main app's navigation
79-
Scaffold { innerPadding ->
80-
if (movie != null) {
81-
MovieDetailsContent(
82-
movie = movie!!,
83-
onBackClick = { navController.popBackStack() },
84-
onPlayClick = { source ->
85-
// Launch video player activity
86-
VideoPlayerActivity.start(context, source.url)
87-
},
88-
modifier = Modifier.padding(innerPadding)
89-
)
90-
} else {
91-
// Show loading or error state
92-
Box(
93-
modifier = Modifier
94-
.fillMaxSize()
95-
.padding(innerPadding),
96-
contentAlignment = Alignment.Center
80+
// Directly render content without Scaffold since it's already in MainScreen's Scaffold
81+
if (movie != null) {
82+
MovieDetailsContent(
83+
movie = movie!!,
84+
onBackClick = { navController.popBackStack() },
85+
onPlayClick = { source ->
86+
// Launch video player activity
87+
VideoPlayerActivity.start(context, source.url)
88+
},
89+
// Remove any padding from parent Scaffold to use full screen
90+
modifier = Modifier.fillMaxSize()
91+
)
92+
} else {
93+
// Show loading or error state
94+
Box(
95+
modifier = Modifier
96+
.fillMaxSize(),
97+
contentAlignment = Alignment.Center
98+
) {
99+
Column(
100+
horizontalAlignment = Alignment.CenterHorizontally
97101
) {
98-
Column(
99-
horizontalAlignment = Alignment.CenterHorizontally
100-
) {
101-
IconButton(onClick = { navController.popBackStack() }) {
102-
Icon(
103-
imageVector = Icons.AutoMirrored.Filled.ArrowBack,
104-
contentDescription = "Back"
105-
)
106-
}
107-
Text(
108-
text = "Movie not found",
109-
style = MaterialTheme.typography.headlineSmall,
110-
color = MaterialTheme.colorScheme.onSurface,
111-
modifier = Modifier.padding(top = 16.dp)
102+
IconButton(onClick = { navController.popBackStack() }) {
103+
Icon(
104+
imageVector = Icons.AutoMirrored.Filled.ArrowBack,
105+
contentDescription = "Back"
112106
)
113107
}
108+
Text(
109+
text = "Movie not found",
110+
style = MaterialTheme.typography.headlineSmall,
111+
color = MaterialTheme.colorScheme.onSurface,
112+
modifier = Modifier.padding(top = 16.dp)
113+
)
114114
}
115115
}
116116
}
@@ -272,26 +272,32 @@ fun MovieDetailsContent(
272272
modifier = Modifier.padding(start = 16.dp, top = 16.dp, end = 16.dp)
273273
)
274274

275-
// Set layout direction to RTL for the genres
276-
CompositionLocalProvider(LocalLayoutDirection provides LayoutDirection.Rtl) {
277-
Row(
278-
horizontalArrangement = Arrangement.spacedBy(8.dp),
279-
modifier = Modifier
280-
.padding(start = 16.dp, end = 16.dp)
281-
.fillMaxWidth(),
282-
) {
283-
movie.genres.forEach { genre ->
284-
Card(
285-
colors = CardDefaults.cardColors(
286-
containerColor = MaterialTheme.colorScheme.primaryContainer
287-
),
288-
shape = RoundedCornerShape(16.dp)
275+
// Improved genres display with better wrapping and styling
276+
LazyRow(
277+
modifier = Modifier
278+
.padding(start = 16.dp, end = 16.dp, top = 8.dp)
279+
.fillMaxWidth(),
280+
horizontalArrangement = Arrangement.spacedBy(8.dp)
281+
) {
282+
items(movie.genres) { genre ->
283+
Card(
284+
colors = CardDefaults.cardColors(
285+
containerColor = MaterialTheme.colorScheme.primaryContainer
286+
),
287+
shape = RoundedCornerShape(50.dp), // More rounded corners
288+
modifier = Modifier
289+
.height(32.dp) // Fixed height for consistency
290+
) {
291+
Box(
292+
contentAlignment = Alignment.Center,
293+
modifier = Modifier
294+
.padding(horizontal = 16.dp)
289295
) {
290296
Text(
291297
text = genre.title,
292-
modifier = Modifier.padding(horizontal = 12.dp, vertical = 6.dp),
293298
style = MaterialTheme.typography.bodyMedium,
294-
color = MaterialTheme.colorScheme.onPrimaryContainer
299+
color = MaterialTheme.colorScheme.onPrimaryContainer,
300+
fontWeight = FontWeight.Medium
295301
)
296302
}
297303
}

app/src/main/java/com/pira/ccloud/ui/theme/Theme.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,12 +68,12 @@ fun CCloudTheme(
6868
}
6969

7070
val colorScheme = when {
71-
themeSettings.primaryColor != defaultPrimaryColor || themeSettings.secondaryColor != defaultSecondaryColor -> {
72-
// Custom colors
71+
themeSettings.primaryColor != defaultPrimaryColor -> {
72+
// Custom colors - using the same color for primary and secondary since we removed secondary color setting
7373
if (darkTheme) {
7474
darkColorScheme(
7575
primary = themeSettings.primaryColor,
76-
secondary = themeSettings.secondaryColor,
76+
secondary = themeSettings.primaryColor,
7777
tertiary = Pink80,
7878
background = Color(0xFF121212),
7979
surface = Color(0xFF1E1E1E),
@@ -88,7 +88,7 @@ fun CCloudTheme(
8888
} else {
8989
lightColorScheme(
9090
primary = themeSettings.primaryColor,
91-
secondary = themeSettings.secondaryColor,
91+
secondary = themeSettings.primaryColor,
9292
tertiary = Pink40,
9393
background = Color(0xFFFFFBFE),
9494
surface = Color(0xFFFFFBFE),

app/src/main/java/com/pira/ccloud/ui/theme/ThemeManager.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class ThemeManager(private val context: Context) {
1717
prefs.edit {
1818
putString("theme_mode", settings.themeMode.name)
1919
putInt("primary_color", settings.primaryColor.toArgb())
20-
putInt("secondary_color", settings.secondaryColor.toArgb())
20+
// Removed secondary_color as it's no longer used
2121
}
2222
}
2323

@@ -30,12 +30,12 @@ class ThemeManager(private val context: Context) {
3030
}
3131

3232
val primaryColor = prefs.getInt("primary_color", defaultPrimaryColor.toArgb())
33-
val secondaryColor = prefs.getInt("secondary_color", defaultSecondaryColor.toArgb())
33+
// Removed secondary_color as it's no longer used
3434

3535
return ThemeSettings(
3636
themeMode = themeMode,
37-
primaryColor = Color(primaryColor),
38-
secondaryColor = Color(secondaryColor)
37+
primaryColor = Color(primaryColor)
38+
// Removed secondaryColor as it's no longer used
3939
)
4040
}
4141
}

app/src/main/java/com/pira/ccloud/ui/theme/ThemeSettings.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ import androidx.compose.ui.graphics.Color
77

88
data class ThemeSettings(
99
val themeMode: ThemeMode = ThemeMode.SYSTEM,
10-
val primaryColor: Color = defaultPrimaryColor,
11-
val secondaryColor: Color = defaultSecondaryColor
10+
val primaryColor: Color = defaultPrimaryColor
11+
// Removed secondaryColor as it's no longer used
1212
)
1313

1414
enum class ThemeMode {
@@ -17,7 +17,7 @@ enum class ThemeMode {
1717

1818
// Default colors
1919
val defaultPrimaryColor = Color(0xFF6650a4) // Purple40
20-
val defaultSecondaryColor = Color(0xFF625b71) // PurpleGrey40
20+
// Removed defaultSecondaryColor as it's no longer used
2121

2222
// Predefined color options
2323
val colorOptions = listOf(

0 commit comments

Comments
 (0)