Skip to content

Commit

Permalink
Updating compose!
Browse files Browse the repository at this point in the history
  • Loading branch information
jakepurple13 committed Feb 8, 2024
1 parent ab7c239 commit 6745afe
Show file tree
Hide file tree
Showing 9 changed files with 34 additions and 51 deletions.
2 changes: 1 addition & 1 deletion UIViews/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ dependencies {
implementation(libs.gson)

implementation(libs.recyclerview)
implementation(libs.palette)
//implementation(libs.palette)
implementation(libs.bundles.roomLibs)

implementation(libs.showMoreLess)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ import androidx.compose.ui.draw.drawWithContent
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.toArgb
import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.semantics.semantics
import androidx.compose.ui.text.style.TextOverflow
Expand Down Expand Up @@ -110,7 +111,7 @@ internal fun DetailsHeader(
GlideImage(
imageModel = { imageUrl },
imageOptions = ImageOptions(contentScale = ContentScale.Fit),
previewPlaceholder = R.drawable.ic_baseline_battery_alert_24,
previewPlaceholder = painterResource(id = R.drawable.ic_baseline_battery_alert_24),
modifier = Modifier
.scaleRotateOffsetReset()
.defaultMinSize(ComposableUtils.IMAGE_WIDTH, ComposableUtils.IMAGE_HEIGHT)
Expand Down Expand Up @@ -140,7 +141,7 @@ internal fun DetailsHeader(
GlideImage(
imageModel = { imageUrl },
imageOptions = ImageOptions(contentScale = ContentScale.Crop),
previewPlaceholder = R.drawable.ic_baseline_battery_alert_24,
previewPlaceholder = painterResource(id = R.drawable.ic_baseline_battery_alert_24),
modifier = Modifier
.matchParentSize()
.blur(4.dp)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ fun OtakuListScreen(
.showListDetail
.collectAsStateWithLifecycle(true)

val state = rememberListDetailPaneScaffoldNavigator(
val state = rememberListDetailPaneScaffoldNavigator<Int>(
scaffoldDirective = calculateStandardPaneScaffoldDirective(currentWindowAdaptiveInfo())
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ fun ExtensionList(
)
}

val navigator = rememberListDetailPaneScaffoldNavigator(
val navigator = rememberListDetailPaneScaffoldNavigator<Int>(
scaffoldDirective = calculateStandardPaneScaffoldDirective(currentWindowAdaptiveInfo())
)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
package com.programmersbox.uiviews.utils

import android.graphics.Bitmap
import android.graphics.Canvas
import android.graphics.Color
import android.graphics.drawable.ColorDrawable
import android.graphics.drawable.Drawable
import androidx.core.graphics.drawable.toBitmap
import androidx.palette.graphics.Palette
import androidx.recyclerview.widget.RecyclerView
import com.bumptech.glide.ListPreloader
import com.bumptech.glide.RequestBuilder
Expand Down Expand Up @@ -52,7 +48,7 @@ abstract class DragSwipeGlideAdapter<T, VH : RecyclerView.ViewHolder, Model : An
override fun getPreloadRequestBuilder(item: Model): RequestBuilder<Drawable?>? = fullRequest.thumbnail(thumbRequest.load(item)).load(item)
}

fun Drawable.getPalette() = Palette.from(toBitmap()).generate()
/*fun Drawable.getPalette() = Palette.from(toBitmap()).generate()
fun Bitmap.getPalette() = Palette.from(this).generate()
fun Int.getPaletteFromColor(): Palette {
Expand All @@ -61,7 +57,7 @@ fun Int.getPaletteFromColor(): Palette {
return b.getPalette()
}
fun String.getPaletteFromHexColor(): Palette = Color.parseColor(this@getPaletteFromHexColor).getPaletteFromColor()
fun String.getPaletteFromHexColor(): Palette = Color.parseColor(this@getPaletteFromHexColor).getPaletteFromColor()*/

fun Int.toColorDrawable() = ColorDrawable(this)
fun String.toColorDrawable() = ColorDrawable(Color.parseColor(this))
Original file line number Diff line number Diff line change
@@ -1,28 +1,12 @@
package com.programmersbox.uiviews.utils.components

import android.content.Context
import android.util.LruCache
import androidx.compose.animation.animateColorAsState
import androidx.compose.animation.core.Spring
import androidx.compose.animation.core.spring
import androidx.compose.material.icons.filled.Palette
import androidx.compose.material3.ColorScheme
import androidx.compose.material3.MaterialTheme
import androidx.compose.runtime.*
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.platform.LocalContext
import androidx.core.graphics.drawable.toBitmap
import androidx.palette.graphics.Palette
import coil.Coil
import coil.imageLoader
import coil.request.ImageRequest
import coil.request.SuccessResult
import coil.size.Scale
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.withContext


@Composable
/*@Composable
fun rememberDominantColorState(
context: Context = LocalContext.current,
defaultColor: Color = MaterialTheme.colorScheme.primary,
Expand All @@ -40,7 +24,7 @@ fun rememberDynamicColorState(
cacheSize: Int = 12
): DynamicColorState = remember {
DynamicColorState(context, defaultColorScheme, cacheSize)
}
}*/

//TODO: Try converting DetailsFragment to use this

Expand All @@ -66,7 +50,7 @@ DynamicThemePrimaryColorsFromImage(dominantColor) {
/**
* A composable which allows dynamic theming of the [androidx.compose.material.Colors.primary]
* color from an image.
*/
*//*
@Composable
fun DynamicThemePrimaryColorsFromImage(
dominantColorState: DominantColorState = rememberDominantColorState(),
Expand Down Expand Up @@ -125,7 +109,7 @@ fun FullDynamicThemePrimaryColorsFromImage(
).value,
)
MaterialTheme(colorScheme = colors, content = content)
}
}*/

/**
* A class which stores and caches the result of any calculated dominant colors
Expand All @@ -138,7 +122,7 @@ fun FullDynamicThemePrimaryColorsFromImage(
* @param cacheSize The size of the [LruCache] used to store recent results. Pass `0` to
* disable the cache.
* @param isColorValid A lambda which allows filtering of the calculated image colors.
*/
*//*
@Stable
class DominantColorState(
private val context: Context,
Expand Down Expand Up @@ -187,9 +171,10 @@ class DominantColorState(
?.also { result -> cache?.put(url, result) }
}
/**
*/
/**
* Reset the color values to [defaultColor].
*/
*//*
fun reset() {
color = defaultColor
onColor = defaultColor
Expand Down Expand Up @@ -238,19 +223,20 @@ class DynamicColorState(
// Then we want to find the first valid color
//.firstOrNull { swatch -> isColorValid(Color(swatch.rgb)) }
// If we found a valid swatch, wrap it in a [DominantColors]
/*?.let { swatch ->
*//*?.let { swatch ->
DominantColors(
color = Color(swatch.rgb),
onColor = Color(swatch.bodyTextColor).copy(alpha = 1f)
)
}*/
}*//*
// Cache the resulting [DominantColors]
?.also { result -> cache?.put(url, result) }
}
/**
*/
/**
* Reset the color values to [defaultColor].
*/
*//*
fun reset() {
colorScheme = defaultColorScheme
}
Expand All @@ -259,9 +245,10 @@ class DynamicColorState(
@Immutable
private data class DominantColors(val color: Color, val onColor: Color)
*/
/**
* Fetches the given [imageUrl] with [Coil], then uses [Palette] to calculate the dominant color.
*/
*//*
private suspend fun calculateSwatchesInImage(
context: Context,
imageUrl: String
Expand Down Expand Up @@ -333,4 +320,4 @@ private suspend fun calculateAllSwatchesInImage(
palette
}
}
}
}*/
1 change: 0 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,5 @@ android.enableJetifier=true
kotlin.code.style=official
android.nonTransitiveRClass=false
android.nonFinalResIds=false
android.experimental.lint.version=8.3.0-alpha10
kotlin.experimental.tryK2=true
android.lint.useK2Uast=true
18 changes: 9 additions & 9 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,38 +1,38 @@
[versions]
gradle = "8.4.0-alpha07"

androidxBaselineprofileGradlePlugin = "1.2.0"
composeCollapsable = "0.3.0"
dragselect = "2.2.6"
easylauncher = "6.2.0"
firebaseCrashlyticsGradle = "2.9.9"
googleServices = "4.4.0"
gradle = "8.3.0-alpha10"
haze = "0.5.0"
haze = "0.5.1"
kamelImage = "0.9.1"
kotlin = "1.9.22"
latestAboutLibsRelease = "10.10.0"
coroutinesVersion = "1.7.3"
glideVersion = "4.16.0"
material3AdaptiveNavigationSuite = "1.0.0-alpha02"
pagingVersion = "3.2.1"
roomVersion = "2.6.1"
navVersion = "2.7.6"
navVersion = "2.8.0-alpha02"
koinVersion = "3.5.3"
coil = "2.5.0"
lifecycle = "2.7.0"
jetpack = "1.6.0-alpha03"
jetpackCompiler = "1.5.8"
jetpackCompiler = "1.5.9"
jetbrainsCompiler = "1.5.1"
accompanist = "0.34.0"
okhttpVersion = "4.12.0"
ktorVersion = "2.3.7"
ktorVersion = "2.3.8"
tvCompose = "1.0.0-alpha10"
workVersion = "2.9.0"
ziplineVersion = "1.1.0"
landscapist = "2.2.13"
landscapist = "2.3.0"
protobufVersion = "3.25.2"
sketchVersion = "3.2.5"
activity = "1.8.2"
composeBomVersion = "2024.01.00-alpha03"
composeBomVersion = "2024.02.00-alpha01"

### MangaWorld
piasy = "1.8.1"
Expand Down Expand Up @@ -79,7 +79,7 @@ composeMaterial = { group = "androidx.compose.material", name = "material" }
materialYou = { group = "androidx.compose.material3", name = "material3" }
materialWindow = { group = "androidx.compose.material3", name = "material3-window-size-class" }
materialAdaptive = { group = "androidx.compose.material3", name = "material3-adaptive" }
material-adaptive-navigation-suite = { module = "androidx.compose.material3:material3-adaptive-navigation-suite", version.ref = "material3AdaptiveNavigationSuite" }
material-adaptive-navigation-suite = { group = "androidx.compose.material3", name = "material3-adaptive-navigation-suite" }
composeMaterialIconsCore = { group = "androidx.compose.material", name = "material-icons-core" }
composeMaterialIconsExtended = { group = "androidx.compose.material", name = "material-icons-extended" }
composeViewBinding = { group = "androidx.compose.ui", name = "ui-viewbinding" }
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-rc-1-all.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down

0 comments on commit 6745afe

Please sign in to comment.