Skip to content

Commit

Permalink
🎨 Revamped Settings page
Browse files Browse the repository at this point in the history
* Again?
* used ListItem to make everything more material themed
* fixed #54
  • Loading branch information
shub39 committed Dec 7, 2024
1 parent 65b7e71 commit 3bd3b9f
Show file tree
Hide file tree
Showing 8 changed files with 233 additions and 299 deletions.
4 changes: 4 additions & 0 deletions app/src/main/java/com/shub39/rush/app/RushApp.kt
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,13 @@ import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalContext
import androidx.lifecycle.compose.collectAsStateWithLifecycle
import androidx.navigation.compose.NavHost
import androidx.navigation.compose.composable
import androidx.navigation.compose.navigation
import androidx.navigation.compose.rememberNavController
import com.shub39.rush.lyrics.domain.listener.NotificationListener
import com.shub39.rush.lyrics.presentation.search_sheet.SearchSheet
import com.shub39.rush.lyrics.presentation.lyrics.LyricsPage
import com.shub39.rush.lyrics.presentation.saved.SavedPage
Expand All @@ -35,6 +37,7 @@ fun RushApp(
val searchSheetState by rushViewModel.searchState.collectAsStateWithLifecycle()

val navController = rememberNavController()
val context = LocalContext.current

var currentRoute: Route by remember { mutableStateOf(Route.SavedPage) }

Expand Down Expand Up @@ -95,6 +98,7 @@ fun RushApp(
SettingPage(
state = settingsState,
action = rushViewModel::onSettingsPageAction,
notificationAccess = NotificationListener.canAccessNotifications(context),
paddingValues = paddingValues
)
}
Expand Down
18 changes: 0 additions & 18 deletions app/src/main/java/com/shub39/rush/di/RushModules.kt
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
package com.shub39.rush.di

import android.content.Context
import coil.ImageLoader
import coil.disk.DiskCache
import coil.request.CachePolicy
import com.shub39.rush.lyrics.data.database.SongDatabase
import com.shub39.rush.lyrics.presentation.RushViewModel
import com.shub39.rush.lyrics.data.repository.RushRepository
Expand All @@ -22,18 +18,4 @@ val rushModules = module {
viewModelOf(::RushViewModel)

single { provideImageLoader(get()) }
}

fun provideImageLoader(context: Context): ImageLoader {
return ImageLoader.Builder(context)
.crossfade(true)
.memoryCachePolicy(CachePolicy.ENABLED)
.diskCachePolicy(CachePolicy.ENABLED)
.diskCache {
DiskCache.Builder()
.directory(context.cacheDir.resolve("image_cache"))
.maxSizePercent(0.02)
.build()
}
.build()
}
20 changes: 20 additions & 0 deletions app/src/main/java/com/shub39/rush/di/util.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package com.shub39.rush.di

import android.content.Context
import coil.ImageLoader
import coil.disk.DiskCache
import coil.request.CachePolicy

fun provideImageLoader(context: Context): ImageLoader {
return ImageLoader.Builder(context)
.crossfade(true)
.memoryCachePolicy(CachePolicy.ENABLED)
.diskCachePolicy(CachePolicy.ENABLED)
.diskCache {
DiskCache.Builder()
.directory(context.cacheDir.resolve("image_cache"))
.maxSizePercent(0.02)
.build()
}
.build()
}
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.font.Font
import androidx.compose.ui.text.font.FontFamily
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
Expand Down Expand Up @@ -287,6 +288,7 @@ fun LyricsPage(
style = MaterialTheme.typography.titleLarge,
fontWeight = FontWeight.SemiBold,
maxLines = 2,
textAlign = TextAlign.Center,
overflow = TextOverflow.Ellipsis,
)

Expand All @@ -295,6 +297,7 @@ fun LyricsPage(
style = MaterialTheme.typography.bodyMedium,
fontWeight = FontWeight.Bold,
maxLines = 1,
textAlign = TextAlign.Center,
overflow = TextOverflow.Ellipsis,
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ package com.shub39.rush.lyrics.presentation.lyrics
import com.shub39.rush.lyrics.presentation.share.SongDetails

sealed interface LyricsPageAction {
object OnToggleAutoChange: LyricsPageAction
data object OnToggleAutoChange: LyricsPageAction
data class OnUpdateShareLines(val songDetails: SongDetails, val shareLines: Map<Int, String>) :
LyricsPageAction
object OnToggleSearchSheet: LyricsPageAction
data object OnToggleSearchSheet: LyricsPageAction
data class OnLrcSearch(val track: String, val artist: String) : LyricsPageAction
data class OnUpdateSongLyrics(val id: Long, val plainLyrics: String, val syncedLyrics: String?) :
LyricsPageAction
Expand Down
Loading

0 comments on commit 3bd3b9f

Please sign in to comment.