diff --git a/README.md b/README.md index 1495de7e..7aaf72b6 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@
The library contains several chart composables for usage in Kotlin Multiplatform projects and Android Native. -Currently supported platforms are Desktop Android and soon IOS +Currently supported platforms are Desktop Android and IOS
  diff --git a/build.gradle.kts b/build.gradle.kts index f0079a7e..c19b1f7e 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -9,7 +9,6 @@ allprojects { plugins { kotlin("multiplatform") apply false - kotlin("native.cocoapods") version "1.8.0" kotlin("android") apply false id("com.android.application") apply false id("com.android.library") apply false diff --git a/chart/build.gradle.kts b/chart/build.gradle.kts index 30e234df..29863a65 100644 --- a/chart/build.gradle.kts +++ b/chart/build.gradle.kts @@ -1,35 +1,38 @@ - plugins { kotlin("multiplatform") id("org.jetbrains.compose") id("com.android.library") id("org.jetbrains.dokka") version "1.5.0" id("convention.publication") - id ("org.jetbrains.kotlin.native.cocoapods") version "1.8.0" + kotlin("native.cocoapods") } group = "io.github.thechance101" -version = "Beta-0.0.1" +version = "Beta-0.0.5" kotlin { android { - publishLibraryVariants("release","debug") + publishLibraryVariants("release", "debug") } jvm("desktop") { jvmToolchain(11) } + ios{} iosX64() iosArm64() iosSimulatorArm64() - cocoapods { - version = "1.0.0" - summary = "Some description for the chart Module" - homepage = "Link to the chart Module homepage" - ios.deploymentTarget = "14.1" - podfile = project.file("../iosApp/Podfile") - framework { - baseName = "chart" - isStatic = true + + js(IR) { + browser { + testTask { + useKarma { + useChromeHeadless() + webpackConfig.cssSupport { + enabled.set(true) + } + } + } } + binaries.executable() } sourceSets { @@ -40,42 +43,30 @@ kotlin { api(compose.material) } } - val commonTest by getting { - dependencies { - implementation(kotlin("test")) - } - } + val androidMain by getting { dependencies { api("androidx.appcompat:appcompat:1.5.1") api("androidx.core:core-ktx:1.9.0") } } - val androidTest by getting { - dependencies { - implementation("junit:junit:4.13.2") - } - } + val desktopMain by getting { dependencies { api(compose.preview) } } - val desktopTest by getting - - val iosX64Main by getting val iosArm64Main by getting val iosSimulatorArm64Main by getting - val iosMain by creating { + val iosMain by getting { dependsOn(commonMain) iosX64Main.dependsOn(this) iosArm64Main.dependsOn(this) iosSimulatorArm64Main.dependsOn(this) - dependencies { - implementation("io.ktor:ktor-client-darwin:2.3.3") - } + } + val jsMain by getting } } @@ -91,16 +82,4 @@ android { sourceCompatibility = JavaVersion.VERSION_1_8 targetCompatibility = JavaVersion.VERSION_1_8 } - buildTypes { - getByName("release") { - isMinifyEnabled = true - proguardFiles(getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro") - } - create("staging") { - initWith(getByName("release")) - manifestPlaceholders["TheChance101"] = "io.github.thechance101" - } - } -} - - +} \ No newline at end of file diff --git a/chart/chart.podspec b/chart/chart.podspec deleted file mode 100644 index f315f14c..00000000 --- a/chart/chart.podspec +++ /dev/null @@ -1,39 +0,0 @@ -Pod::Spec.new do |spec| - spec.name = 'chart' - spec.version = '1.0.0' - spec.homepage = 'Link to the chart Module homepage' - spec.source = { :http=> ''} - spec.authors = '' - spec.license = '' - spec.summary = 'Some description for the chart Module' - spec.vendored_frameworks = 'build/cocoapods/framework/chart.framework' - spec.libraries = 'c++' - spec.ios.deployment_target = '14.1' - - - spec.pod_target_xcconfig = { - 'KOTLIN_PROJECT_PATH' => ':chart', - 'PRODUCT_MODULE_NAME' => 'chart', - } - - spec.script_phases = [ - { - :name => 'Build chart', - :execution_position => :before_compile, - :shell_path => '/bin/sh', - :script => <<-SCRIPT - if [ "YES" = "$OVERRIDE_KOTLIN_BUILD_IDE_SUPPORTED" ]; then - echo "Skipping Gradle build task invocation due to OVERRIDE_KOTLIN_BUILD_IDE_SUPPORTED environment variable set to \"YES\"" - exit 0 - fi - set -ev - REPO_ROOT="$PODS_TARGET_SRCROOT" - "$REPO_ROOT/../gradlew" -p "$REPO_ROOT" $KOTLIN_PROJECT_PATH:syncFramework \ - -Pkotlin.native.cocoapods.platform=$PLATFORM_NAME \ - -Pkotlin.native.cocoapods.archs="$ARCHS" \ - -Pkotlin.native.cocoapods.configuration="$CONFIGURATION" - SCRIPT - } - ] - -end \ No newline at end of file diff --git a/chart/src/commonMain/kotlin/com/aay/compose/baseComponents/XAxisDrawing.kt b/chart/src/commonMain/kotlin/com/aay/compose/baseComponents/XAxisDrawing.kt index b0a31323..addead6b 100644 --- a/chart/src/commonMain/kotlin/com/aay/compose/baseComponents/XAxisDrawing.kt +++ b/chart/src/commonMain/kotlin/com/aay/compose/baseComponents/XAxisDrawing.kt @@ -26,9 +26,10 @@ internal fun DrawScope.xAxisDrawing( val yTextLayoutResult = textMeasure.measure( text = AnnotatedString(upperValue.formatToThousandsMillionsBillions()), ).size.width + val textSpace = yTextLayoutResult - (yTextLayoutResult/4) xAxisData.forEachIndexed { index, dataPoint -> - val xLength = (yTextLayoutResult.toDp()) + (index * xRegionWidth) + val xLength = (textSpace.toDp()) + (index * xRegionWidth) drawContext.canvas.nativeCanvas.apply { drawText( diff --git a/chart/src/commonMain/kotlin/com/aay/compose/baseComponents/grid.kt b/chart/src/commonMain/kotlin/com/aay/compose/baseComponents/grid.kt index d756b397..7b4e6dee 100644 --- a/chart/src/commonMain/kotlin/com/aay/compose/baseComponents/grid.kt +++ b/chart/src/commonMain/kotlin/com/aay/compose/baseComponents/grid.kt @@ -35,7 +35,7 @@ internal fun DrawScope.grid( val yTextLayoutResult = textMeasurer.measure( text = AnnotatedString(upperValue.formatToThousandsMillionsBillions()), ).size.width - + val textSpace = yTextLayoutResult - (yTextLayoutResult/4) if (isShowGrid) { when (gridOrientation) { @@ -45,7 +45,7 @@ internal fun DrawScope.grid( gridColor = gridColor, backgroundLineWidth = backgroundLineWidth, showGridWithSpacer = showGridWithSpacer, - yTextLayoutResult = yTextLayoutResult + yTextLayoutResult = textSpace ) GridOrientation.VERTICAL -> drawVerticalGrid( @@ -54,7 +54,7 @@ internal fun DrawScope.grid( gridColor = gridColor, backgroundLineWidth = backgroundLineWidth, showGridWithSpacer = showGridWithSpacer, - yTextLayoutResult = yTextLayoutResult + yTextLayoutResult = textSpace ) else -> { @@ -65,7 +65,7 @@ internal fun DrawScope.grid( xEndLength = 38.dp.toPx(), backgroundLineWidth = backgroundLineWidth, showGridWithSpacer = showGridWithSpacer, - yTextLayoutResult = yTextLayoutResult + yTextLayoutResult = textSpace ) drawVerticalGrid( @@ -75,7 +75,7 @@ internal fun DrawScope.grid( yEndLength = 9f.toDp(), backgroundLineWidth = backgroundLineWidth, showGridWithSpacer = showGridWithSpacer, - yTextLayoutResult = yTextLayoutResult + yTextLayoutResult = textSpace ) } @@ -90,12 +90,14 @@ private fun DrawScope.drawHorizontalGrid( xEndLength: Float = 0f, backgroundLineWidth: Float, showGridWithSpacer: Boolean, - yTextLayoutResult: Int + yTextLayoutResult: Int, ) { val xAxisMaxValue = size.width val yAxisList = mutableListOf() + val textSpace = yTextLayoutResult - (yTextLayoutResult/4) + (0..yAxisRange).forEach { i -> yAxisList.add( size.height.toDp() @@ -107,7 +109,7 @@ private fun DrawScope.drawHorizontalGrid( gridColor = gridColor, xStart = (yTextLayoutResult * 1.5.toFloat().toDp()).toPx(), yStart = yAlignmentValue, - xEnd = xAxisMaxValue - xEndLength, + xEnd = xAxisMaxValue - (textSpace/0.9.toFloat().toDp().toPx()), yEnd = yAlignmentValue, backgroundLineWidth = backgroundLineWidth, showGridWithSpacer = showGridWithSpacer diff --git a/chart/src/commonMain/kotlin/com/aay/compose/donutChart/component/PiePedigreeChart.kt b/chart/src/commonMain/kotlin/com/aay/compose/donutChart/component/PiePedigreeChart.kt index bbe3b18a..812c79ba 100644 --- a/chart/src/commonMain/kotlin/com/aay/compose/donutChart/component/PiePedigreeChart.kt +++ b/chart/src/commonMain/kotlin/com/aay/compose/donutChart/component/PiePedigreeChart.kt @@ -45,12 +45,12 @@ internal fun DrawScope.drawPedigreeChart( val angleInRadians = (startArcWithoutAnimation + arcWithoutAnimation / 2).degreeToAngle if (pieChart == ChartTypes.PIE_CHART) { val lineStart = Offset( - center.x + (outerCircularRadius * 1.18f) * cos(angleInRadians) * 0.8f, - center.y + (outerCircularRadius * 1.18f) * sin(angleInRadians) * 0.8f + (center.x + (outerCircularRadius * 1.18f) * cos(angleInRadians) * 0.8f).toFloat(), + (center.y + (outerCircularRadius * 1.18f) * sin(angleInRadians) * 0.8f).toFloat() ) val lineEnd = Offset( - center.x + (outerCircularRadius * 1.18f) * cos(angleInRadians) * 1.1f, - center.y + (outerCircularRadius * 1.18f) * sin(angleInRadians) * 1.1f + (center.x + (outerCircularRadius * 1.18f) * cos(angleInRadians) * 1.1f).toFloat(), + (center.y + (outerCircularRadius * 1.18f) * sin(angleInRadians) * 1.1f).toFloat() ) val arcOffset = Offset(center.x - (minValue / 2), center.y - (minValue / 2)) val region = pieValueWithRatio.subList(0, index).sum() @@ -88,12 +88,12 @@ internal fun DrawScope.drawPedigreeChart( } else { val lineStart = Offset( - center.x + (outerCircularRadius * 1.18f) * cos(angleInRadians) * 0.8f, - center.y + (outerCircularRadius * 1.18f) * sin(angleInRadians) * 0.8f + (center.x + (outerCircularRadius * 1.18f) * cos(angleInRadians) * 0.8f).toFloat(), + (center.y + (outerCircularRadius * 1.18f) * sin(angleInRadians) * 0.8f).toFloat() ) val lineEnd = Offset( - center.x + (outerCircularRadius * 1.18f) * cos(angleInRadians) * 1.1f, - center.y + (outerCircularRadius * 1.18f) * sin(angleInRadians) * 1.1f + (center.x + (outerCircularRadius * 1.18f) * cos(angleInRadians) * 1.1f).toFloat(), + (center.y + (outerCircularRadius * 1.18f) * sin(angleInRadians) * 1.1f).toFloat() ) val arcOffset = Offset(center.x - (minValue / 2), center.y - (minValue / 2)) val region = pieValueWithRatio.subList(0, index).sum() @@ -132,7 +132,7 @@ internal fun DrawScope.drawPedigreeChart( } private val Float.degreeToAngle - get() = (this * Math.PI / 180f).toFloat() + get() = (this * (22/7) / 180f) private fun calculateAngle(dataLength: Float, totalLength: Float, progress: Float): Float = -360F * dataLength * progress / totalLength diff --git a/chart/src/commonMain/kotlin/com/aay/compose/lineChart/components/DefaultLines.kt b/chart/src/commonMain/kotlin/com/aay/compose/lineChart/components/DefaultLines.kt index 3af75193..e625b302 100644 --- a/chart/src/commonMain/kotlin/com/aay/compose/lineChart/components/DefaultLines.kt +++ b/chart/src/commonMain/kotlin/com/aay/compose/lineChart/components/DefaultLines.kt @@ -82,10 +82,10 @@ private fun DrawScope.drawLineAsDefault( val yTextLayoutResult = textMeasure.measure( text = AnnotatedString(upperValue.formatToThousandsMillionsBillions()), ).size.width - + val textSpace = yTextLayoutResult - (yTextLayoutResult/4) val info = lineParameter.data[index] val ratio = (info - lowerValue) / (upperValue - lowerValue) - val startXPoint = (yTextLayoutResult * 1.5.toFloat().toDp()) + (index * xRegionWidth) + val startXPoint = (textSpace * 1.5.toFloat().toDp()) + (index * xRegionWidth) val startYPoint = (height.toPx() + 8.dp.toPx() - spacingY.toPx() - (ratio * (height.toPx() - spacingY.toPx()))) diff --git a/chart/src/commonMain/kotlin/com/aay/compose/lineChart/components/QuadraticLines.kt b/chart/src/commonMain/kotlin/com/aay/compose/lineChart/components/QuadraticLines.kt index 79070bec..b7816106 100644 --- a/chart/src/commonMain/kotlin/com/aay/compose/lineChart/components/QuadraticLines.kt +++ b/chart/src/commonMain/kotlin/com/aay/compose/lineChart/components/QuadraticLines.kt @@ -87,16 +87,16 @@ fun DrawScope.drawLineAsQuadratic( val yTextLayoutResult = textMeasurer.measure( text = AnnotatedString(upperValue.formatToThousandsMillionsBillions()), ).size.width - + val textSpace = yTextLayoutResult - (yTextLayoutResult/4) val info = lineParameter.data[index] val nextInfo = lineParameter.data.getOrNull(index + 1) ?: lineParameter.data.last() val firstRatio = (info - lowerValue) / (upperValue - lowerValue) val secondRatio = (nextInfo - lowerValue) / (upperValue - lowerValue) - val xFirstPoint = (yTextLayoutResult * 1.5.toFloat().toDp()) + index * xRegionWidth + val xFirstPoint = (textSpace * 1.5.toFloat().toDp()) + index * xRegionWidth val xSecondPoint = - (yTextLayoutResult * 1.5.toFloat().toDp()) + (index + checkLastIndex( + (textSpace * 1.5.toFloat().toDp()) + (index + checkLastIndex( lineParameter.data, index )) * xRegionWidth diff --git a/chart/src/commonMain/kotlin/com/aay/compose/radarChart/CalculateRadarConfig.kt b/chart/src/commonMain/kotlin/com/aay/compose/radarChart/CalculateRadarConfig.kt index 04ebf1c3..10b5f6e9 100644 --- a/chart/src/commonMain/kotlin/com/aay/compose/radarChart/CalculateRadarConfig.kt +++ b/chart/src/commonMain/kotlin/com/aay/compose/radarChart/CalculateRadarConfig.kt @@ -18,7 +18,7 @@ internal fun calculateRadarConfig( val netCornersPoints = mutableListOf() val stepsStartPoints = mutableListOf() val stepsEndPoints = mutableListOf() - val polygonPoints = mutableListOf() + val scalarValuesPoints = mutableListOf() val labelsPoints = mutableListOf() val center = Offset(size.width / 2, size.height / 2) @@ -42,12 +42,12 @@ internal fun calculateRadarConfig( val nextEndPoint = getCircumferencePointOffset(center, value * step, nextAngle) stepsStartPoints.add(startEndPoint) stepsEndPoints.add(nextEndPoint) - if (lineIndex == 0) polygonPoints.add(startEndPoint) + if (lineIndex == 0) scalarValuesPoints.add(startEndPoint) } } return RadarChartConfig( - center, netCornersPoints, stepsEndPoints, stepsStartPoints, polygonPoints, labelsPoints + center, netCornersPoints, stepsEndPoints, stepsStartPoints, scalarValuesPoints, labelsPoints ) } diff --git a/chart/src/commonMain/kotlin/com/aay/compose/radarChart/DrawAxisData.kt b/chart/src/commonMain/kotlin/com/aay/compose/radarChart/DrawRadarLabels.kt similarity index 50% rename from chart/src/commonMain/kotlin/com/aay/compose/radarChart/DrawAxisData.kt rename to chart/src/commonMain/kotlin/com/aay/compose/radarChart/DrawRadarLabels.kt index 89b9b68a..24399950 100644 --- a/chart/src/commonMain/kotlin/com/aay/compose/radarChart/DrawAxisData.kt +++ b/chart/src/commonMain/kotlin/com/aay/compose/radarChart/DrawRadarLabels.kt @@ -2,47 +2,18 @@ package com.aay.compose.radarChart import androidx.compose.ui.geometry.Offset import androidx.compose.ui.graphics.drawscope.DrawScope -import androidx.compose.ui.text.AnnotatedString -import androidx.compose.ui.text.ExperimentalTextApi -import androidx.compose.ui.text.TextMeasurer -import androidx.compose.ui.text.TextStyle -import androidx.compose.ui.text.drawText +import androidx.compose.ui.text.* import com.aay.compose.radarChart.model.RadarChartConfig @OptIn(ExperimentalTextApi::class) -internal fun DrawScope.drawAxisData( - labelsStyle: TextStyle, - scalarValuesStyle: TextStyle, +internal fun DrawScope.drawRadarLabels( textMeasurer: TextMeasurer, radarChartConfig: RadarChartConfig, radarLabels: List, - scalarValue: Double, - scalarSteps: Int, - unit: String + labelsStyle: TextStyle, ) { - val labelsEndPoints = radarChartConfig.labelsPoints - val nextStartPoints = radarChartConfig.polygonPoints.toMutableList() - nextStartPoints.add(0, center) - nextStartPoints.removeAt(nextStartPoints.size - 1) - - val scalarStep = scalarValue / (scalarSteps - 1) - val textVerticalOffset = 20.toDp().toPx() val labelHeight = textMeasurer.measure(AnnotatedString("M")).size.height - - - for (step in 0 until scalarSteps) { - drawText( - textMeasurer = textMeasurer, - text = (scalarStep * step).toString() + " " + unit, - style = scalarValuesStyle, - topLeft = Offset( - nextStartPoints[step].x + 5.toDp().toPx(), - nextStartPoints[step].y - textVerticalOffset - ) - ) - } - for (line in labelsEndPoints.indices) { drawText( textMeasurer = textMeasurer, @@ -58,5 +29,4 @@ internal fun DrawScope.drawAxisData( ) ) } - } \ No newline at end of file diff --git a/chart/src/commonMain/kotlin/com/aay/compose/radarChart/DrawRadarNets.kt b/chart/src/commonMain/kotlin/com/aay/compose/radarChart/DrawRadarNets.kt index 76b3d346..57df6ecb 100644 --- a/chart/src/commonMain/kotlin/com/aay/compose/radarChart/DrawRadarNets.kt +++ b/chart/src/commonMain/kotlin/com/aay/compose/radarChart/DrawRadarNets.kt @@ -31,7 +31,5 @@ internal fun DrawScope.drawRadarNet( cap = netLinesStyle.netLinesStrokeCap, ) } - } - } \ No newline at end of file diff --git a/chart/src/commonMain/kotlin/com/aay/compose/radarChart/DrawScalarValues.kt b/chart/src/commonMain/kotlin/com/aay/compose/radarChart/DrawScalarValues.kt new file mode 100644 index 00000000..b64d121f --- /dev/null +++ b/chart/src/commonMain/kotlin/com/aay/compose/radarChart/DrawScalarValues.kt @@ -0,0 +1,40 @@ +package com.aay.compose.radarChart + +import androidx.compose.ui.geometry.Offset +import androidx.compose.ui.graphics.drawscope.DrawScope +import androidx.compose.ui.text.ExperimentalTextApi +import androidx.compose.ui.text.TextMeasurer +import androidx.compose.ui.text.TextStyle +import androidx.compose.ui.text.drawText +import com.aay.compose.radarChart.model.RadarChartConfig + +private const val SCALAR_VALUES_VERTICAL_DISPLACEMENT = 20 +private const val SCALAR_VALUES_HORIZONTAL_DISPLACEMENT = 5 + +@OptIn(ExperimentalTextApi::class) +internal fun DrawScope.drawScalarValues( + scalarValuesStyle: TextStyle, + textMeasurer: TextMeasurer, + radarChartConfig: RadarChartConfig, + scalarValue: Double, + scalarSteps: Int, + unit: String +) { + val scalarStep = scalarValue / (scalarSteps - 1) + val nextStartPoints = radarChartConfig.scalarValuesPoints.toMutableList() + nextStartPoints.add(0, center) + nextStartPoints.removeAt(nextStartPoints.size - 1) + + for (step in 0 until scalarSteps) { + drawText( + textMeasurer = textMeasurer, + text = (scalarStep * step).toString() + " " + unit, + style = scalarValuesStyle, + topLeft = Offset( + nextStartPoints[step].x + SCALAR_VALUES_HORIZONTAL_DISPLACEMENT.toDp().toPx(), + nextStartPoints[step].y - SCALAR_VALUES_VERTICAL_DISPLACEMENT.toDp().toPx() + ) + ) + } + +} \ No newline at end of file diff --git a/chart/src/commonMain/kotlin/com/aay/compose/radarChart/RadarChart.kt b/chart/src/commonMain/kotlin/com/aay/compose/radarChart/RadarChart.kt index cb4a9b7d..167de324 100644 --- a/chart/src/commonMain/kotlin/com/aay/compose/radarChart/RadarChart.kt +++ b/chart/src/commonMain/kotlin/com/aay/compose/radarChart/RadarChart.kt @@ -1,10 +1,11 @@ package com.aay.compose.radarChart import androidx.compose.foundation.Canvas +import androidx.compose.foundation.layout.* import androidx.compose.runtime.Composable +import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.geometry.Offset -import androidx.compose.ui.graphics.drawscope.DrawScope import androidx.compose.ui.text.AnnotatedString import androidx.compose.ui.text.ExperimentalTextApi import androidx.compose.ui.text.TextMeasurer @@ -12,6 +13,7 @@ import androidx.compose.ui.text.TextStyle import androidx.compose.ui.text.rememberTextMeasurer import com.aay.compose.radarChart.model.NetLinesStyle import com.aay.compose.radarChart.model.Polygon + /** * Composable function to render a radar chart with configurable radar labels, net lines, and polygons. * @@ -43,40 +45,39 @@ fun RadarChart( val textMeasurer = rememberTextMeasurer() validateRadarChartConfiguration(radarLabels, scalarValue, polygons, scalarSteps) + Column(modifier.fillMaxSize()) { + Canvas(modifier = Modifier.weight(1f).aspectRatio(1f).align(Alignment.CenterHorizontally)) { + val labelWidth = measureMaxLabelWidth(radarLabels, labelsStyle, textMeasurer) + val radius = size.minDimension / 2 - (labelWidth + 10.toDp().toPx()) + val labelRadius = size.minDimension / 2 - (labelWidth / 2) + val numLines = radarLabels.size + val radarChartConfig = + calculateRadarConfig(labelRadius, radius, size, numLines, scalarSteps) + + drawRadarNet(netLinesStyle, radarChartConfig) + + polygons.forEach { + drawPolygonShape( + this, + it, + radius, + scalarValue, + Offset(size.width / 2, size.height / 2), + scalarSteps + ) + } - Canvas(modifier = modifier) { - - val labelWidth = measureMaxLabelWidth(radarLabels, labelsStyle, textMeasurer) - val radius = (size.minDimension / 2) - (labelWidth + 10.toDp().toPx()) - val labelRadius = (size.minDimension / 2) - (labelWidth / 2) - val numLines = radarLabels.size - val radarChartConfig = - calculateRadarConfig(labelRadius, radius, size, numLines, scalarSteps) - - drawRadarNet(netLinesStyle, radarChartConfig) - - polygons.forEach { - drawPolygonShape( - this, - it, - radius, + drawRadarLabels(textMeasurer, radarChartConfig, radarLabels, labelsStyle) + drawScalarValues( + scalarValuesStyle, + textMeasurer, + radarChartConfig, scalarValue, - Offset(size.width / 2, size.height / 2), - scalarSteps + scalarSteps, + polygons[0].unit ) } - drawAxisData( - labelsStyle, - scalarValuesStyle, - textMeasurer, - radarChartConfig, - radarLabels, - scalarValue, - scalarSteps, - polygons[0].unit - ) - } } @@ -104,17 +105,16 @@ private fun validateRadarChartConfiguration( } @OptIn(ExperimentalTextApi::class) -private fun DrawScope.measureMaxLabelWidth( +private fun measureMaxLabelWidth( radarLabels: List, labelsStyle: TextStyle, textMeasurer: TextMeasurer -): Float { - return textMeasurer.measure( - AnnotatedString( - text = radarLabels.maxByOrNull { it.length } ?: "", - ), style = labelsStyle - ).size.width.toDp().toPx() +): Int { + return radarLabels.maxOf { + textMeasurer.measure(AnnotatedString(text = it), style = labelsStyle).size.width + } } + diff --git a/chart/src/commonMain/kotlin/com/aay/compose/radarChart/model/RadarChartConfig.kt b/chart/src/commonMain/kotlin/com/aay/compose/radarChart/model/RadarChartConfig.kt index fa3dae47..33de31e1 100644 --- a/chart/src/commonMain/kotlin/com/aay/compose/radarChart/model/RadarChartConfig.kt +++ b/chart/src/commonMain/kotlin/com/aay/compose/radarChart/model/RadarChartConfig.kt @@ -7,6 +7,6 @@ internal data class RadarChartConfig( val netCornersPoints: List, val stepsEndPoints: List, val stepsStartPoints: List, - val polygonPoints: List, + val scalarValuesPoints: List, val labelsPoints: List ) \ No newline at end of file diff --git a/chart/src/commonMain/kotlin/com/aay/compose/utils/FormatText.kt b/chart/src/commonMain/kotlin/com/aay/compose/utils/FormatText.kt index d146eea2..cb13a759 100644 --- a/chart/src/commonMain/kotlin/com/aay/compose/utils/FormatText.kt +++ b/chart/src/commonMain/kotlin/com/aay/compose/utils/FormatText.kt @@ -1,22 +1,22 @@ package com.aay.compose.utils -import java.math.BigDecimal +import kotlin.math.abs + +fun Float.format(status:String): String { + val intValue = this.toInt() + val floatValue = this - intValue + val decimalPart = (floatValue * 10).toInt() + return "$intValue.$decimalPart$status" +} internal fun Float.formatToThousandsMillionsBillions(): String { - val value = BigDecimal(this.toDouble()) - val absValue = value.abs() + val absValue = abs(this) return when { - absValue < BigDecimal.valueOf(1000) -> String.format("%.1f", value) - absValue < BigDecimal.valueOf(1000000) -> "${String.format("%.1f", value.divide(BigDecimal.valueOf(1000)))}k" - absValue < BigDecimal.valueOf(1000000000) -> "${String.format("%.1f", value.divide(BigDecimal.valueOf(1000000)))}M" - absValue < BigDecimal.valueOf(1000000000000) -> "${String.format("%.1f", value.divide(BigDecimal.valueOf(1000000000)))}B" - absValue < BigDecimal.valueOf(1000000000000000) -> "${String.format("%.1f", value.divide(BigDecimal.valueOf(1000000000000)))}T" - absValue < BigDecimal.valueOf(1e18) -> "${String.format("%.1f", value.divide(BigDecimal.valueOf(1e15)))}Q" - absValue < BigDecimal.valueOf(1e21) -> "${String.format("%.1f", value.divide(BigDecimal.valueOf(1e18)))}KQ" - absValue < BigDecimal.valueOf(1e24) -> "${String.format("%.1f", value.divide(BigDecimal.valueOf(1e21)))}MQ" - absValue < BigDecimal.valueOf(1e27) -> "${String.format("%.1f", value.divide(BigDecimal.valueOf(1e24)))}BQ" - absValue < BigDecimal.valueOf(1e30) -> "${String.format("%.1f", value.divide(BigDecimal.valueOf(1e27)))}TQ" - absValue < BigDecimal.valueOf(1e33) -> "${String.format("%.1f", value.divide(BigDecimal.valueOf(1e30)))}QQ" + absValue < 1000 -> this.format("") + absValue < 1_000_000 -> (this / 1_000).format("K") + absValue < 1_000_000_000 -> (this / 1_000_000).format("M") + absValue < 1_000_000_000_000 -> (this / 1_000_000_000).format("B") else -> "Infinity" } } + diff --git a/chart/src/iosMain/kotlin/com/aay/compose/Platform.kt b/chart/src/iosMain/kotlin/com/aay/compose/Platform.kt new file mode 100644 index 00000000..623f7308 --- /dev/null +++ b/chart/src/iosMain/kotlin/com/aay/compose/Platform.kt @@ -0,0 +1,4 @@ +package com.aay.compose +actual fun getPlatformName(): String { + return "ios" +} \ No newline at end of file diff --git a/chart/src/jsMain/kotlin/com/aay/compose/Platform.kt b/chart/src/jsMain/kotlin/com/aay/compose/Platform.kt new file mode 100644 index 00000000..f90b945e --- /dev/null +++ b/chart/src/jsMain/kotlin/com/aay/compose/Platform.kt @@ -0,0 +1,5 @@ +package com.aay.compose + +actual fun getPlatformName(): String { + return "Web" +} diff --git a/common/build.gradle.kts b/common/build.gradle.kts index 9b742657..90c1b573 100644 --- a/common/build.gradle.kts +++ b/common/build.gradle.kts @@ -1,3 +1,4 @@ +import org.jetbrains.compose.compose plugins { kotlin("multiplatform") @@ -16,34 +17,26 @@ kotlin { sourceSets { val commonMain by getting { dependencies { - implementation("io.github.thechance101:chart:Beta-0.0.1") + implementation(project(":chart")) api(compose.runtime) api(compose.foundation) api(compose.material) } } - val commonTest by getting { - dependencies { - implementation(kotlin("test")) - } - } + val androidMain by getting { dependencies { api("androidx.appcompat:appcompat:1.5.1") api("androidx.core:core-ktx:1.9.0") } } - val androidTest by getting { - dependencies { - implementation("junit:junit:4.13.2") - } - } + val desktopMain by getting { dependencies { api(compose.preview) } } - val desktopTest by getting + } } @@ -58,4 +51,4 @@ android { sourceCompatibility = JavaVersion.VERSION_1_8 targetCompatibility = JavaVersion.VERSION_1_8 } -} +} \ No newline at end of file diff --git a/common/src/commonMain/kotlin/com/aay/common/App.kt b/common/src/commonMain/kotlin/com/aay/common/App.kt index 9b6e6132..81da440a 100644 --- a/common/src/commonMain/kotlin/com/aay/common/App.kt +++ b/common/src/commonMain/kotlin/com/aay/common/App.kt @@ -6,7 +6,7 @@ import androidx.compose.runtime.Composable fun App() { /** Sample of Line Chart **/ - LineChartSample() +// LineChartSample() /** Sample of Bar Chart **/ diff --git a/common/src/commonMain/kotlin/com/aay/common/LineChartSample.kt b/common/src/commonMain/kotlin/com/aay/common/LineChartSample.kt index 487a2284..5fdd6df7 100644 --- a/common/src/commonMain/kotlin/com/aay/common/LineChartSample.kt +++ b/common/src/commonMain/kotlin/com/aay/common/LineChartSample.kt @@ -22,21 +22,21 @@ fun LineChartSample() { val testLineParameters: List = listOf( LineParameters( label = "revenue", - data = listOf(70.0, 00.0, 50.33, 40.0, 100.500, 50.0), + data = listOf(7000000.0, 00.0, 50000000.33, 40000000.0, 100000000.500, 50000000.0), lineColor = Color.Gray, lineType = LineType.CURVED_LINE, lineShadow = true, ), LineParameters( label = "Earnings", - data = listOf(60.0, 80.6, 40.33, 86.232, 88.0, 90.0), + data = listOf(60000000.0, 80000000.6, 40000000.33, 86000000.232, 88000000.0, 90000000.0), lineColor = Color(0xFFFF7F50), lineType = LineType.DEFAULT_LINE, lineShadow = true ), LineParameters( label = "Earnings", - data = listOf(1.0, 40.0, 11.33, 55.23, 1.0, 100.0), + data = listOf(1000000.0, 40000000.0, 11000000.33, 55000000.23, 1000000.0, 100000000.0), lineColor = Color(0xFF81BE88), lineType = LineType.CURVED_LINE, lineShadow = false, @@ -51,7 +51,7 @@ fun LineChartSample() { gridColor = Color.Gray, xAxisData = listOf("2015", "2016", "2017", "2018", "2019", "2020"), animateChart = true, - showGridWithSpacer = true, + showGridWithSpacer = false, yAxisStyle = TextStyle( fontSize = 14.sp, color = Color.Gray, diff --git a/common/src/commonMain/kotlin/com/aay/common/RadarChartSample.kt b/common/src/commonMain/kotlin/com/aay/common/RadarChartSample.kt index acdf0abd..9a590e5c 100644 --- a/common/src/commonMain/kotlin/com/aay/common/RadarChartSample.kt +++ b/common/src/commonMain/kotlin/com/aay/common/RadarChartSample.kt @@ -17,7 +17,7 @@ import com.aay.compose.radarChart.model.Polygon import com.aay.compose.radarChart.model.PolygonStyle @Composable -fun RadarChartSample() { +fun RadarChartSample(modifier: Modifier = Modifier) { val radarLabels = listOf( @@ -48,7 +48,7 @@ fun RadarChartSample() { ) RadarChart( - modifier = Modifier.fillMaxSize(), + modifier = modifier, radarLabels = radarLabels, labelsStyle = labelsStyle, netLinesStyle = NetLinesStyle( diff --git a/desktop/build.gradle.kts b/desktop/build.gradle.kts index 50a5d7fb..436591e0 100644 --- a/desktop/build.gradle.kts +++ b/desktop/build.gradle.kts @@ -14,11 +14,30 @@ kotlin { jvmToolchain(11) withJava() } + + val osName = System.getProperty("os.name") + val targetOs = when { + osName == "Mac OS X" -> "macos" + osName.startsWith("Win") -> "windows" + osName.startsWith("Linux") -> "linux" + else -> error("Unsupported OS: $osName") + } + + val targetArch = when (val osArch = System.getProperty("os.arch")) { + "x86_64", "amd64" -> "x64" + "aarch64" -> "arm64" + else -> error("Unsupported arch: $osArch") + } + + val version = "0.7.77" // or any more recent version + val target = "${targetOs}-${targetArch}" + sourceSets { val jvmMain by getting { dependencies { implementation(project(":common")) implementation(compose.desktop.currentOs) + implementation("org.jetbrains.skiko:skiko-awt-runtime-$target:$version") } } val jvmTest by getting diff --git a/gradle.properties b/gradle.properties index 58742979..fafb552c 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,7 +1,9 @@ kotlin.code.style=official kotlin.native.enableDependencyPropagation=false android.useAndroidX=true -kotlin.version=1.8.0 +kotlin.version=1.9.0 agp.version=7.4.1 -compose.version=1.3.0 +compose.version=1.4.3 org.jetbrains.compose.experimental.uikit.enabled=true +xcodeproj=./iosApp +org.jetbrains.compose.experimental.jscanvas.enabled=true \ No newline at end of file diff --git a/iosApp/Configuration/Config.xcconfig b/iosApp/Configuration/Config.xcconfig new file mode 100644 index 00000000..f3915978 --- /dev/null +++ b/iosApp/Configuration/Config.xcconfig @@ -0,0 +1,3 @@ +TEAM_ID= +BUNDLE_ID=com.myapplication.MyApplication +APP_NAME=My application diff --git a/iosApp/Podfile b/iosApp/Podfile new file mode 100644 index 00000000..aff9c517 --- /dev/null +++ b/iosApp/Podfile @@ -0,0 +1,5 @@ +target 'iosApp' do + use_frameworks! + platform :ios, '14.1' + pod 'shared', :path => '../shared' +end \ No newline at end of file diff --git a/iosApp/iosApp.xcodeproj/project.pbxproj b/iosApp/iosApp.xcodeproj/project.pbxproj new file mode 100644 index 00000000..fe548043 --- /dev/null +++ b/iosApp/iosApp.xcodeproj/project.pbxproj @@ -0,0 +1,418 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 51; + objects = { + +/* Begin PBXBuildFile section */ + 058557BB273AAA24004C7B11 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 058557BA273AAA24004C7B11 /* Assets.xcassets */; }; + 058557D9273AAEEB004C7B11 /* Preview Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 058557D8273AAEEB004C7B11 /* Preview Assets.xcassets */; }; + 2152FB042600AC8F00CF470E /* iOSApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2152FB032600AC8F00CF470E /* iOSApp.swift */; }; + 7555FF83242A565900829871 /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7555FF82242A565900829871 /* ContentView.swift */; }; + CFDB58B53BB94DE262B13C24 /* Pods_iosApp.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6B1049432C0C2B312090ABF6 /* Pods_iosApp.framework */; }; +/* End PBXBuildFile section */ + +/* Begin PBXFileReference section */ + 058557BA273AAA24004C7B11 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; + 058557D8273AAEEB004C7B11 /* Preview Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = "Preview Assets.xcassets"; sourceTree = ""; }; + 2152FB032600AC8F00CF470E /* iOSApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = iOSApp.swift; sourceTree = ""; }; + 4FF3202A603A284706412EDC /* Pods-iosApp.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-iosApp.debug.xcconfig"; path = "Target Support Files/Pods-iosApp/Pods-iosApp.debug.xcconfig"; sourceTree = ""; }; + 6B1049432C0C2B312090ABF6 /* Pods_iosApp.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_iosApp.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + 7555FF7B242A565900829871 /* My application.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "My application.app"; sourceTree = BUILT_PRODUCTS_DIR; }; + 7555FF82242A565900829871 /* ContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentView.swift; sourceTree = ""; }; + 7555FF8C242A565B00829871 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + AB3632DC29227652001CCB65 /* Config.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = Config.xcconfig; sourceTree = ""; }; + FF8CA3F5360CEAB49D74065F /* Pods-iosApp.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-iosApp.release.xcconfig"; path = "Target Support Files/Pods-iosApp/Pods-iosApp.release.xcconfig"; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + F85CB1118929364A9C6EFABC /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + CFDB58B53BB94DE262B13C24 /* Pods_iosApp.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 058557D7273AAEEB004C7B11 /* Preview Content */ = { + isa = PBXGroup; + children = ( + 058557D8273AAEEB004C7B11 /* Preview Assets.xcassets */, + ); + path = "Preview Content"; + sourceTree = ""; + }; + 42799AB246E5F90AF97AA0EF /* Frameworks */ = { + isa = PBXGroup; + children = ( + 6B1049432C0C2B312090ABF6 /* Pods_iosApp.framework */, + ); + name = Frameworks; + sourceTree = ""; + }; + 7555FF72242A565900829871 = { + isa = PBXGroup; + children = ( + AB1DB47929225F7C00F7AF9C /* Configuration */, + 7555FF7D242A565900829871 /* iosApp */, + 7555FF7C242A565900829871 /* Products */, + FEFF387C0A8D172AA4D59CAE /* Pods */, + 42799AB246E5F90AF97AA0EF /* Frameworks */, + ); + sourceTree = ""; + }; + 7555FF7C242A565900829871 /* Products */ = { + isa = PBXGroup; + children = ( + 7555FF7B242A565900829871 /* My application.app */, + ); + name = Products; + sourceTree = ""; + }; + 7555FF7D242A565900829871 /* iosApp */ = { + isa = PBXGroup; + children = ( + 058557BA273AAA24004C7B11 /* Assets.xcassets */, + 7555FF82242A565900829871 /* ContentView.swift */, + 7555FF8C242A565B00829871 /* Info.plist */, + 2152FB032600AC8F00CF470E /* iOSApp.swift */, + 058557D7273AAEEB004C7B11 /* Preview Content */, + ); + path = iosApp; + sourceTree = ""; + }; + AB1DB47929225F7C00F7AF9C /* Configuration */ = { + isa = PBXGroup; + children = ( + AB3632DC29227652001CCB65 /* Config.xcconfig */, + ); + path = Configuration; + sourceTree = ""; + }; + FEFF387C0A8D172AA4D59CAE /* Pods */ = { + isa = PBXGroup; + children = ( + 4FF3202A603A284706412EDC /* Pods-iosApp.debug.xcconfig */, + FF8CA3F5360CEAB49D74065F /* Pods-iosApp.release.xcconfig */, + ); + path = Pods; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 7555FF7A242A565900829871 /* iosApp */ = { + isa = PBXNativeTarget; + buildConfigurationList = 7555FFA5242A565B00829871 /* Build configuration list for PBXNativeTarget "iosApp" */; + buildPhases = ( + 98D614C51D2DA07C614CC46E /* [CP] Check Pods Manifest.lock */, + 7555FF77242A565900829871 /* Sources */, + 7555FF79242A565900829871 /* Resources */, + F85CB1118929364A9C6EFABC /* Frameworks */, + EAC8183F4304B90579867D0C /* [CP] Copy Pods Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = iosApp; + productName = iosApp; + productReference = 7555FF7B242A565900829871 /* My application.app */; + productType = "com.apple.product-type.application"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 7555FF73242A565900829871 /* Project object */ = { + isa = PBXProject; + attributes = { + LastSwiftUpdateCheck = 1130; + LastUpgradeCheck = 1130; + ORGANIZATIONNAME = orgName; + TargetAttributes = { + 7555FF7A242A565900829871 = { + CreatedOnToolsVersion = 11.3.1; + }; + }; + }; + buildConfigurationList = 7555FF76242A565900829871 /* Build configuration list for PBXProject "iosApp" */; + compatibilityVersion = "Xcode 9.3"; + developmentRegion = en; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = 7555FF72242A565900829871; + productRefGroup = 7555FF7C242A565900829871 /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 7555FF7A242A565900829871 /* iosApp */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + 7555FF79242A565900829871 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 058557D9273AAEEB004C7B11 /* Preview Assets.xcassets in Resources */, + 058557BB273AAA24004C7B11 /* Assets.xcassets in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXShellScriptBuildPhase section */ + 98D614C51D2DA07C614CC46E /* [CP] Check Pods Manifest.lock */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + ); + inputPaths = ( + "${PODS_PODFILE_DIR_PATH}/Podfile.lock", + "${PODS_ROOT}/Manifest.lock", + ); + name = "[CP] Check Pods Manifest.lock"; + outputFileListPaths = ( + ); + outputPaths = ( + "$(DERIVED_FILE_DIR)/Pods-iosApp-checkManifestLockResult.txt", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; + showEnvVarsInLog = 0; + }; + EAC8183F4304B90579867D0C /* [CP] Copy Pods Resources */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + "${PODS_ROOT}/Target Support Files/Pods-iosApp/Pods-iosApp-resources-${CONFIGURATION}-input-files.xcfilelist", + ); + name = "[CP] Copy Pods Resources"; + outputFileListPaths = ( + "${PODS_ROOT}/Target Support Files/Pods-iosApp/Pods-iosApp-resources-${CONFIGURATION}-output-files.xcfilelist", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-iosApp/Pods-iosApp-resources.sh\"\n"; + showEnvVarsInLog = 0; + }; +/* End PBXShellScriptBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + 7555FF77242A565900829871 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 2152FB042600AC8F00CF470E /* iOSApp.swift in Sources */, + 7555FF83242A565900829871 /* ContentView.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin XCBuildConfiguration section */ + 7555FFA3242A565B00829871 /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = AB3632DC29227652001CCB65 /* Config.xcconfig */; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 14.1; + MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; + MTL_FAST_MATH = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = iphoneos; + SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + }; + name = Debug; + }; + 7555FFA4242A565B00829871 /* Release */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = AB3632DC29227652001CCB65 /* Config.xcconfig */; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 14.1; + MTL_ENABLE_DEBUG_INFO = NO; + MTL_FAST_MATH = YES; + SDKROOT = iphoneos; + SWIFT_COMPILATION_MODE = wholemodule; + SWIFT_OPTIMIZATION_LEVEL = "-O"; + VALIDATE_PRODUCT = YES; + }; + name = Release; + }; + 7555FFA6242A565B00829871 /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 4FF3202A603A284706412EDC /* Pods-iosApp.debug.xcconfig */; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CODE_SIGN_IDENTITY = "Apple Development"; + CODE_SIGN_STYLE = Automatic; + DEVELOPMENT_ASSET_PATHS = "\"iosApp/Preview Content\""; + DEVELOPMENT_TEAM = "${TEAM_ID}"; + ENABLE_PREVIEWS = YES; + INFOPLIST_FILE = iosApp/Info.plist; + IPHONEOS_DEPLOYMENT_TARGET = 14.1; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + PRODUCT_BUNDLE_IDENTIFIER = "${BUNDLE_ID}${TEAM_ID}"; + PRODUCT_NAME = "${APP_NAME}"; + PROVISIONING_PROFILE_SPECIFIER = ""; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Debug; + }; + 7555FFA7242A565B00829871 /* Release */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = FF8CA3F5360CEAB49D74065F /* Pods-iosApp.release.xcconfig */; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CODE_SIGN_IDENTITY = "Apple Development"; + CODE_SIGN_STYLE = Automatic; + DEVELOPMENT_ASSET_PATHS = "\"iosApp/Preview Content\""; + DEVELOPMENT_TEAM = "${TEAM_ID}"; + ENABLE_PREVIEWS = YES; + INFOPLIST_FILE = iosApp/Info.plist; + IPHONEOS_DEPLOYMENT_TARGET = 14.1; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + PRODUCT_BUNDLE_IDENTIFIER = "${BUNDLE_ID}${TEAM_ID}"; + PRODUCT_NAME = "${APP_NAME}"; + PROVISIONING_PROFILE_SPECIFIER = ""; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 7555FF76242A565900829871 /* Build configuration list for PBXProject "iosApp" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 7555FFA3242A565B00829871 /* Debug */, + 7555FFA4242A565B00829871 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 7555FFA5242A565B00829871 /* Build configuration list for PBXNativeTarget "iosApp" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 7555FFA6242A565B00829871 /* Debug */, + 7555FFA7242A565B00829871 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = 7555FF73242A565900829871 /* Project object */; +} diff --git a/iosApp/iosApp/Assets.xcassets/AccentColor.colorset/Contents.json b/iosApp/iosApp/Assets.xcassets/AccentColor.colorset/Contents.json new file mode 100644 index 00000000..ee7e3ca0 --- /dev/null +++ b/iosApp/iosApp/Assets.xcassets/AccentColor.colorset/Contents.json @@ -0,0 +1,11 @@ +{ + "colors" : [ + { + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} \ No newline at end of file diff --git a/iosApp/iosApp/Assets.xcassets/AppIcon.appiconset/Contents.json b/iosApp/iosApp/Assets.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 00000000..8edf56e7 --- /dev/null +++ b/iosApp/iosApp/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -0,0 +1,14 @@ +{ + "images" : [ + { + "filename" : "app-icon-1024.png", + "idiom" : "universal", + "platform" : "ios", + "size" : "1024x1024" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/iosApp/iosApp/Assets.xcassets/AppIcon.appiconset/app-icon-1024.png b/iosApp/iosApp/Assets.xcassets/AppIcon.appiconset/app-icon-1024.png new file mode 100644 index 00000000..53fc536f Binary files /dev/null and b/iosApp/iosApp/Assets.xcassets/AppIcon.appiconset/app-icon-1024.png differ diff --git a/iosApp/iosApp/Assets.xcassets/Contents.json b/iosApp/iosApp/Assets.xcassets/Contents.json new file mode 100644 index 00000000..73c00596 --- /dev/null +++ b/iosApp/iosApp/Assets.xcassets/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/iosApp/iosApp/ContentView.swift b/iosApp/iosApp/ContentView.swift new file mode 100644 index 00000000..64e70568 --- /dev/null +++ b/iosApp/iosApp/ContentView.swift @@ -0,0 +1,21 @@ +import UIKit +import SwiftUI +import shared + +struct ComposeView: UIViewControllerRepresentable { + func makeUIViewController(context: Context) -> UIViewController { + Main_iosKt.MainViewController() + } + + func updateUIViewController(_ uiViewController: UIViewController, context: Context) {} +} + +struct ContentView: View { + var body: some View { + ComposeView() + .ignoresSafeArea(.all, edges: .bottom) // Compose has own keyboard handler + } +} + + + diff --git a/iosApp/iosApp/Info.plist b/iosApp/iosApp/Info.plist new file mode 100644 index 00000000..08c2bb2e --- /dev/null +++ b/iosApp/iosApp/Info.plist @@ -0,0 +1,55 @@ + + + + + CFBundleDevelopmentRegion + $(DEVELOPMENT_LANGUAGE) + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + $(PRODUCT_BUNDLE_PACKAGE_TYPE) + CFBundleShortVersionString + 1.0 + CFBundleVersion + 1 + LSRequiresIPhoneOS + + CADisableMinimumFrameDurationOnPhone + + UIApplicationSceneManifest + + UIApplicationSupportsMultipleScenes + + + UILaunchScreen + + UIRequiredDeviceCapabilities + + armv7 + + UISupportedInterfaceOrientations + + UIInterfaceOrientationPortrait + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + UISupportedInterfaceOrientations~ipad + + UIInterfaceOrientationPortrait + UIInterfaceOrientationPortraitUpsideDown + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + UIAppFonts + + roboto_medium.ttf + roboto_regular.ttf + + + diff --git a/iosApp/iosApp/Preview Content/Preview Assets.xcassets/Contents.json b/iosApp/iosApp/Preview Content/Preview Assets.xcassets/Contents.json new file mode 100644 index 00000000..4aa7c535 --- /dev/null +++ b/iosApp/iosApp/Preview Content/Preview Assets.xcassets/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "author" : "xcode", + "version" : 1 + } +} \ No newline at end of file diff --git a/iosApp/iosApp/iOSApp.swift b/iosApp/iosApp/iOSApp.swift new file mode 100644 index 00000000..f5f6c561 --- /dev/null +++ b/iosApp/iosApp/iOSApp.swift @@ -0,0 +1,19 @@ +import SwiftUI +import shared + + +@main +struct iOSApp: App { + init(){ + HelperKt.doInitKoin() + } + + var body: some Scene { + WindowGroup { + ZStack { + Color.white.ignoresSafeArea(.all) // status bar color + ContentView() + }.preferredColorScheme(.light) + } + } +} diff --git a/iosApp/iosApp/roboto_medium.ttf b/iosApp/iosApp/roboto_medium.ttf new file mode 100644 index 00000000..87983419 Binary files /dev/null and b/iosApp/iosApp/roboto_medium.ttf differ diff --git a/iosApp/iosApp/roboto_regular.ttf b/iosApp/iosApp/roboto_regular.ttf new file mode 100644 index 00000000..7d9a6c4c Binary files /dev/null and b/iosApp/iosApp/roboto_regular.ttf differ diff --git a/local.properties b/local.properties deleted file mode 100644 index ff3ca4b1..00000000 --- a/local.properties +++ /dev/null @@ -1,13 +0,0 @@ -## This file must *NOT* be checked into Version Control Systems, -# as it contains information specific to your local configuration. -# -# Location of the SDK. This is only used by Gradle. -# For customization when using a Version Control System, please read the -# header note. -#Thu Sep 07 21:37:46 AST 2023 -ossrhPassword=Andro0123\#*. -ossrhUsername=AndrewAboAlhana -sdk.dir=/Users/amnah.a/Library/Android/sdk -signing.keyId=A4125214 -signing.password=/8/2i7m0aLYbPLe6rL4K6Sn1g4nM9tNg1X4UCIDya5rtTRJcRxuBi/VUt1bhHh8m -signing.secretKeyRingFile=secret-key.asc.gpg diff --git a/settings.gradle.kts b/settings.gradle.kts index f99ec765..0aeecc8b 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -15,7 +15,7 @@ pluginManagement { } } -rootProject.name = "AAY-Chart" +rootProject.name = "AAY-chart" include(":android", ":desktop", ":common", ":chart") includeBuild("convention-plugins")