Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/tangem-master' into tangem-master
Browse files Browse the repository at this point in the history
# Conflicts:
#	vico/core/src/main/java/com/patrykandpatrick/vico/core/cartesian/axis/VerticalAxis.kt
  • Loading branch information
MasterBin committed Jun 2, 2024
2 parents 8a11e6f + ac44341 commit f3fa901
Show file tree
Hide file tree
Showing 55 changed files with 354 additions and 190 deletions.
4 changes: 4 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,7 @@ plugins {
apply("versions.gradle")

tasks.register<Delete>("clean") { delete(rootProject.layout.buildDirectory) }

subprojects.forEach { project ->
project.tasks.withType<Test>().configureEach { useJUnitPlatform() }
}
10 changes: 6 additions & 4 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,16 @@ activity = "1.9.0"
agp = "8.4.1"
androidXAnnotation = "1.8.0"
androidXCore = "1.13.1"
appcompat = "1.6.1"
appcompat = "1.7.0"
composeBom = "2024.05.00"
composeNavigation = "2.7.7"
coroutines = "1.8.1"
dokka = "1.9.20"
jUnit = "4.13.2"
jUnitExt = "1.1.5"
jupiter = "5.10.2"
kotlin = "2.0.0"
lifecycle = "2.8.0"
lifecycle = "2.8.1"
material = "1.12.0"
mockK = "1.13.11"
paparazziGradlePlugin = "1.3.4"
Expand All @@ -34,8 +35,9 @@ composeUI = { group = "androidx.compose.ui", name = "ui" }
composeUITooling = { group = "androidx.compose.ui", name = "ui-tooling" }
composeViewBinding = { group = "androidx.compose.ui", name = "ui-viewbinding" }
coroutinesCore = { group = "org.jetbrains.kotlinx", name = "kotlinx-coroutines-core", version.ref = "coroutines" }
jUnit = { group = "junit", name = "junit", version.ref = "jUnit" }
jUnitExt = { group = "androidx.test.ext", name = "junit", version.ref = "jUnitExt" }
jUnit = { module = "junit:junit", version.ref = "jUnit" }
jupiter = { module = "org.junit.jupiter:junit-jupiter", version.ref = "jupiter" }
jupiterParams = { module = "org.junit.jupiter:junit-jupiter-params", version.ref = "jupiter" }
kotlinGradlePlugin = { group = "org.jetbrains.kotlin", name = "kotlin-gradle-plugin", version.ref = "kotlin" }
kotlinStdLib = { group = "org.jetbrains.kotlin", name = "kotlin-stdlib", version.ref = "kotlin" }
kotlinTest = { group = "org.jetbrains.kotlin", name = "kotlin-test", version.ref = "kotlin" }
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.7-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
2 changes: 1 addition & 1 deletion gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
# Darwin, MinGW, and NonStop.
#
# (3) This script is generated from the Groovy template
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# within the Gradle project.
#
# You can find Gradle at https://github.com/gradle/gradle/.
Expand Down
3 changes: 3 additions & 0 deletions renovate.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
{
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
"extends": ["config:base"],
"automerge": true,
"automergeType": "branch",
"baseBranches": ["master", "v1"],
"dependencyDashboard": false
}
2 changes: 0 additions & 2 deletions sample/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,5 @@ dependencies {
implementation libs.systemUIController
implementation libs.viewModelCompose
debugImplementation libs.composeUITooling
testImplementation libs.JUnit
testImplementation libs.JUnitExt
testImplementation libs.kotlinTest
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,17 @@ internal fun VicoApp() {
NavHost(navController = navController, startDestination = "chartList") {
composable("chartList") { ChartListScreen(navController) }
composable(
"chart/{initialChartID}/{uiSystemID}",
"chart/{initialChartID}/{uiFrameworkID}",
listOf(
navArgument("initialChartID") { type = NavType.IntType },
navArgument("uiSystemID") { type = NavType.IntType },
navArgument("uiFrameworkID") { type = NavType.IntType },
),
) { backStackEntry ->
val arguments = requireNotNull(backStackEntry.arguments)
ChartScreen(
navController,
arguments.getInt("initialChartID"),
arguments.getInt("uiSystemID"),
arguments.getInt("uiFrameworkID"),
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ import com.patrykandpatrick.vico.R
@OptIn(ExperimentalMaterial3Api::class)
@Composable
internal fun ChartListScreen(navController: NavController) {
var uiSystem by rememberSaveable { mutableStateOf(UISystem.Compose) }
var uiFramework by rememberSaveable { mutableStateOf(UIFramework.Compose) }
val scrollBehavior = TopAppBarDefaults.pinnedScrollBehavior()
Scaffold(
Modifier.nestedScroll(scrollBehavior.nestedScrollConnection),
Expand All @@ -60,21 +60,21 @@ internal fun ChartListScreen(navController: NavController) {
SingleChoiceSegmentedButtonRow(
Modifier.fillMaxWidth().padding(start = 16.dp, end = 16.dp, bottom = 8.dp)
) {
UISystem.entries.forEachIndexed { index, segmentUISystem ->
UIFramework.entries.forEachIndexed { index, segmentUIFramework ->
SegmentedButton(
selected = uiSystem == segmentUISystem,
onClick = { uiSystem = segmentUISystem },
shape = SegmentedButtonDefaults.itemShape(index, UISystem.entries.size),
selected = uiFramework == segmentUIFramework,
onClick = { uiFramework = segmentUIFramework },
shape = SegmentedButtonDefaults.itemShape(index, UIFramework.entries.size),
) {
Text(stringResource(segmentUISystem.labelResourceID))
Text(stringResource(segmentUIFramework.labelResourceID))
}
}
}
}
items(charts.size) { chartID ->
ListItem(
{ Text(stringResource(R.string.chart_x, chartID + 1)) },
Modifier.clickable { navController.navigate("chart/$chartID/${uiSystem.ordinal}") },
Modifier.clickable { navController.navigate("chart/$chartID/${uiFramework.ordinal}") },
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ import com.patrykandpatrick.vico.R

@OptIn(ExperimentalMaterial3Api::class)
@Composable
internal fun ChartScreen(navController: NavController, initialChartID: Int, uiSystemID: Int) {
internal fun ChartScreen(navController: NavController, initialChartID: Int, uiFrameworkID: Int) {
val scrollBehavior = TopAppBarDefaults.pinnedScrollBehavior()
val nestedNavController = rememberNavController()
val chartID =
Expand Down Expand Up @@ -113,7 +113,7 @@ internal fun ChartScreen(navController: NavController, initialChartID: Int, uiSy
BackHandler(onBack = navigateBack)
val arguments = requireNotNull(backStackEntry.arguments)
charts[arguments.getInt("chartID")](
UISystem.entries[uiSystemID],
UIFramework.entries[uiFrameworkID],
Modifier.padding(horizontal = 16.dp),
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,15 @@ import com.patrykandpatrick.vico.sample.showcase.charts.Chart8
import com.patrykandpatrick.vico.sample.showcase.charts.Chart9

internal val charts =
listOf<@Composable (UISystem, Modifier) -> Unit>(
{ uiSystem, modifier -> Chart1(uiSystem, modifier) },
{ uiSystem, modifier -> Chart2(uiSystem, modifier) },
{ uiSystem, modifier -> Chart3(uiSystem, modifier) },
{ uiSystem, modifier -> Chart4(uiSystem, modifier) },
{ uiSystem, modifier -> Chart5(uiSystem, modifier) },
{ uiSystem, modifier -> Chart6(uiSystem, modifier) },
{ uiSystem, modifier -> Chart7(uiSystem, modifier) },
{ uiSystem, modifier -> Chart8(uiSystem, modifier) },
{ uiSystem, modifier -> Chart9(uiSystem, modifier) },
{ uiSystem, modifier -> Chart10(uiSystem, modifier) },
listOf<@Composable (UIFramework, Modifier) -> Unit>(
{ uiFramework, modifier -> Chart1(uiFramework, modifier) },
{ uiFramework, modifier -> Chart2(uiFramework, modifier) },
{ uiFramework, modifier -> Chart3(uiFramework, modifier) },
{ uiFramework, modifier -> Chart4(uiFramework, modifier) },
{ uiFramework, modifier -> Chart5(uiFramework, modifier) },
{ uiFramework, modifier -> Chart6(uiFramework, modifier) },
{ uiFramework, modifier -> Chart7(uiFramework, modifier) },
{ uiFramework, modifier -> Chart8(uiFramework, modifier) },
{ uiFramework, modifier -> Chart9(uiFramework, modifier) },
{ uiFramework, modifier -> Chart10(uiFramework, modifier) },
)
Original file line number Diff line number Diff line change
Expand Up @@ -104,16 +104,10 @@ internal fun rememberMarker(
) {
with(context) {
super.getInsets(context, outInsets, horizontalDimensions)
val shadowInset =
(CLIPPING_FREE_SHADOW_RADIUS_MULTIPLIER * LABEL_BACKGROUND_SHADOW_RADIUS_DP -
LABEL_BACKGROUND_SHADOW_DY_DP)
.pixels
when (labelPosition) {
LabelPosition.Top,
LabelPosition.AroundPoint,
LabelPosition.AbovePoint -> outInsets.top += shadowInset
LabelPosition.Bottom -> outInsets.bottom += shadowInset
}
val baseShadowInsetDp =
CLIPPING_FREE_SHADOW_RADIUS_MULTIPLIER * LABEL_BACKGROUND_SHADOW_RADIUS_DP
outInsets.top += (baseShadowInsetDp - LABEL_BACKGROUND_SHADOW_DY_DP).pixels
outInsets.bottom += (baseShadowInsetDp + LABEL_BACKGROUND_SHADOW_DY_DP).pixels
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ package com.patrykandpatrick.vico.sample.showcase
import androidx.annotation.StringRes
import com.patrykandpatrick.vico.R

internal enum class UISystem(@StringRes val labelResourceID: Int) {
internal enum class UIFramework(@StringRes val labelResourceID: Int) {
Compose(R.string.compose),
Views(R.string.views),
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,25 +35,27 @@ import com.patrykandpatrick.vico.core.cartesian.data.CartesianChartModelProducer
import com.patrykandpatrick.vico.core.cartesian.data.lineSeries
import com.patrykandpatrick.vico.core.common.shader.DynamicShader
import com.patrykandpatrick.vico.databinding.Chart1Binding
import com.patrykandpatrick.vico.sample.showcase.UISystem
import com.patrykandpatrick.vico.sample.showcase.UIFramework
import com.patrykandpatrick.vico.sample.showcase.rememberMarker
import kotlin.random.Random
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.withContext

@Composable
internal fun Chart1(uiSystem: UISystem, modifier: Modifier) {
internal fun Chart1(uiFramework: UIFramework, modifier: Modifier) {
val modelProducer = remember { CartesianChartModelProducer.build() }
LaunchedEffect(Unit) {
withContext(Dispatchers.Default) {
modelProducer.tryRunTransaction {
/* Learn more:
https://patrykandpatrick.com/vico/wiki/cartesian-charts/layers/line-layer#data. */
lineSeries { series(x, x.map { Random.nextFloat() * 15 }) }
}
}
}
when (uiSystem) {
UISystem.Compose -> ComposeChart1(modelProducer, modifier)
UISystem.Views -> ViewChart1(modelProducer, modifier)
when (uiFramework) {
UIFramework.Compose -> ComposeChart1(modelProducer, modifier)
UIFramework.Views -> ViewChart1(modelProducer, modifier)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,29 +33,31 @@ import com.patrykandpatrick.vico.core.cartesian.data.CartesianChartModelProducer
import com.patrykandpatrick.vico.core.cartesian.data.RandomCartesianModelGenerator
import com.patrykandpatrick.vico.databinding.Chart10Binding
import com.patrykandpatrick.vico.sample.showcase.Defaults
import com.patrykandpatrick.vico.sample.showcase.UISystem
import com.patrykandpatrick.vico.sample.showcase.UIFramework
import com.patrykandpatrick.vico.sample.showcase.rememberMarker
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.delay
import kotlinx.coroutines.isActive
import kotlinx.coroutines.withContext

@Composable
internal fun Chart10(uiSystem: UISystem, modifier: Modifier) {
internal fun Chart10(uiFramework: UIFramework, modifier: Modifier) {
val modelProducer = remember { CartesianChartModelProducer.build() }
LaunchedEffect(key1 = Unit) {
withContext(Dispatchers.Default) {
while (isActive) {
modelProducer.tryRunTransaction {
/* Learn more:
https://patrykandpatrick.com/vico/wiki/cartesian-charts/layers/candlestick-layer#data. */
add(RandomCartesianModelGenerator.getRandomCandlestickLayerModelPartial())
}
delay(Defaults.TRANSACTION_INTERVAL_MS)
}
}
}
when (uiSystem) {
UISystem.Compose -> ComposeChart10(modelProducer, modifier)
UISystem.Views -> ViewChart10(modelProducer, modifier)
when (uiFramework) {
UIFramework.Compose -> ComposeChart10(modelProducer, modifier)
UIFramework.Views -> ViewChart10(modelProducer, modifier)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ import com.patrykandpatrick.vico.core.common.component.TextComponent
import com.patrykandpatrick.vico.core.common.shape.Shape
import com.patrykandpatrick.vico.databinding.Chart2Binding
import com.patrykandpatrick.vico.sample.showcase.Defaults
import com.patrykandpatrick.vico.sample.showcase.UISystem
import com.patrykandpatrick.vico.sample.showcase.UIFramework
import com.patrykandpatrick.vico.sample.showcase.rememberMarker
import java.text.DateFormatSymbols
import java.util.Locale
Expand All @@ -61,21 +61,23 @@ import kotlinx.coroutines.isActive
import kotlinx.coroutines.withContext

@Composable
internal fun Chart2(uiSystem: UISystem, modifier: Modifier) {
internal fun Chart2(uiFramework: UIFramework, modifier: Modifier) {
val modelProducer = remember { CartesianChartModelProducer.build() }
LaunchedEffect(Unit) {
withContext(Dispatchers.Default) {
while (isActive) {
modelProducer.tryRunTransaction {
/* Learn more:
https://patrykandpatrick.com/vico/wiki/cartesian-charts/layers/column-layer#data. */
columnSeries { series(List(47) { 2 + Random.nextFloat() * 18 }) }
}
delay(Defaults.TRANSACTION_INTERVAL_MS)
}
}
}
when (uiSystem) {
UISystem.Compose -> ComposeChart2(modelProducer, modifier)
UISystem.Views -> ViewChart2(modelProducer, modifier)
when (uiFramework) {
UIFramework.Compose -> ComposeChart2(modelProducer, modifier)
UIFramework.Views -> ViewChart2(modelProducer, modifier)
}
}

Expand Down Expand Up @@ -158,8 +160,8 @@ private fun getViewHorizontalLine() =
background = ShapeComponent(Shape.Pill, HORIZONTAL_LINE_COLOR)
padding =
Dimensions(
HORIZONTAL_LINE_LABEL_VERTICAL_PADDING_DP,
HORIZONTAL_LINE_LABEL_HORIZONTAL_PADDING_DP,
HORIZONTAL_LINE_LABEL_VERTICAL_PADDING_DP,
)
margins = Dimensions(HORIZONTAL_LINE_LABEL_MARGIN_DP)
typeface = Typeface.MONOSPACE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ import com.patrykandpatrick.vico.core.common.shader.DynamicShader
import com.patrykandpatrick.vico.core.common.shape.Shape
import com.patrykandpatrick.vico.databinding.Chart3Binding
import com.patrykandpatrick.vico.sample.showcase.Defaults
import com.patrykandpatrick.vico.sample.showcase.UISystem
import com.patrykandpatrick.vico.sample.showcase.UIFramework
import com.patrykandpatrick.vico.sample.showcase.rememberMarker
import kotlin.random.Random
import kotlinx.coroutines.Dispatchers
Expand All @@ -60,21 +60,23 @@ import kotlinx.coroutines.isActive
import kotlinx.coroutines.withContext

@Composable
internal fun Chart3(uiSystem: UISystem, modifier: Modifier) {
internal fun Chart3(uiFramework: UIFramework, modifier: Modifier) {
val modelProducer = remember { CartesianChartModelProducer.build() }
LaunchedEffect(Unit) {
withContext(Dispatchers.Default) {
while (isActive) {
modelProducer.tryRunTransaction {
/* Learn more:
https://patrykandpatrick.com/vico/wiki/cartesian-charts/layers/line-layer#data. */
lineSeries { series(List(Defaults.ENTRY_COUNT) { Random.nextFloat() * 20 }) }
}
delay(Defaults.TRANSACTION_INTERVAL_MS)
}
}
}
when (uiSystem) {
UISystem.Compose -> ComposeChart3(modelProducer, modifier)
UISystem.Views -> ViewChart3(modelProducer, modifier)
when (uiFramework) {
UIFramework.Compose -> ComposeChart3(modelProducer, modifier)
UIFramework.Views -> ViewChart3(modelProducer, modifier)
}
}

Expand Down
Loading

0 comments on commit f3fa901

Please sign in to comment.