From e570ca923f2c7cc21bc7a71422d8912f64fa2027 Mon Sep 17 00:00:00 2001
From: Gowtham <68514286+a914-gowtham@users.noreply.github.com>
Date: Mon, 6 Nov 2023 03:11:12 +0000
Subject: [PATCH] test: android only library removed for jitpack publish
---
ratingbar/.gitignore | 1 -
ratingbar/build.gradle | 79 -----
ratingbar/consumer-rules.pro | 0
ratingbar/proguard-rules.pro | 21 --
ratingbar/src/main/AndroidManifest.xml | 4 -
.../ratingbar/FractionalRectangleShape.kt | 32 --
.../java/com/gowtham/ratingbar/LogMessage.kt | 17 -
.../com/gowtham/ratingbar/PathExtensions.kt | 49 ---
.../java/com/gowtham/ratingbar/RatingBar.kt | 303 ------------------
.../com/gowtham/ratingbar/RatingBarUtils.kt | 36 ---
.../java/com/gowtham/ratingbar/RatingStar.kt | 180 -----------
.../com/gowtham/ratingbar/ExampleUnitTest.kt | 10 -
settings.gradle | 2 +-
13 files changed, 1 insertion(+), 733 deletions(-)
delete mode 100644 ratingbar/.gitignore
delete mode 100644 ratingbar/build.gradle
delete mode 100644 ratingbar/consumer-rules.pro
delete mode 100644 ratingbar/proguard-rules.pro
delete mode 100644 ratingbar/src/main/AndroidManifest.xml
delete mode 100644 ratingbar/src/main/java/com/gowtham/ratingbar/FractionalRectangleShape.kt
delete mode 100644 ratingbar/src/main/java/com/gowtham/ratingbar/LogMessage.kt
delete mode 100644 ratingbar/src/main/java/com/gowtham/ratingbar/PathExtensions.kt
delete mode 100644 ratingbar/src/main/java/com/gowtham/ratingbar/RatingBar.kt
delete mode 100644 ratingbar/src/main/java/com/gowtham/ratingbar/RatingBarUtils.kt
delete mode 100644 ratingbar/src/main/java/com/gowtham/ratingbar/RatingStar.kt
delete mode 100644 ratingbar/src/test/java/com/gowtham/ratingbar/ExampleUnitTest.kt
diff --git a/ratingbar/.gitignore b/ratingbar/.gitignore
deleted file mode 100644
index 42afabf..0000000
--- a/ratingbar/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-/build
\ No newline at end of file
diff --git a/ratingbar/build.gradle b/ratingbar/build.gradle
deleted file mode 100644
index a4e01c7..0000000
--- a/ratingbar/build.gradle
+++ /dev/null
@@ -1,79 +0,0 @@
-plugins {
- id 'com.android.library'
- id 'kotlin-android'
-// id 'com.vanniktech.maven.publish'
- id 'maven-publish'
-}
-
-afterEvaluate {
- println("Components: RatingBar: " + components*.name)
- publishing {
- publications {
- // Creates a Maven publication called "release".
- release(MavenPublication) {
- from components.release
- groupId = 'com.gowtham.composeratingbar'
- artifactId = 'compose-ratingbar'
- version = '1.3.7'
- }
- }
- }
-}
-
-/*
-allprojects {
- plugins.withId("com.vanniktech.maven.publish") {
- mavenPublish {
- sonatypeHost = "S01"
- }
- }
-}
-*/
-
-android {
- compileSdk rootProject.compileSdk
-
- defaultConfig {
- minSdk rootProject.minSdk
- targetSdk rootProject.targetSdk
-
- consumerProguardFiles "consumer-rules.pro"
- }
-
- buildTypes {
- release {
- minifyEnabled false
- proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
- }
- }
- compileOptions {
- sourceCompatibility JavaVersion.VERSION_17
- targetCompatibility JavaVersion.VERSION_17
- }
-
- kotlinOptions {
- jvmTarget = JavaVersion.VERSION_17.toString()
- }
- buildFeatures {
- buildConfig false
- compose true
- }
- composeOptions {
- kotlinCompilerExtensionVersion compose_compiler
- }
- namespace 'com.gowtham.ratingbar'
-
-}
-
-dependencies {
- implementation 'androidx.appcompat:appcompat:1.5.1'
- implementation "androidx.compose.foundation:foundation:$compose_version"
- implementation "androidx.compose.ui:ui:$compose_version"
- implementation "androidx.compose.material:material:$compose_version"
- implementation "androidx.compose.ui:ui-tooling:$compose_version"
-
- implementation "androidx.compose.runtime:runtime:$compose_version"
- implementation "androidx.compose.compiler:compiler:$compose_compiler"
-
-}
-
diff --git a/ratingbar/consumer-rules.pro b/ratingbar/consumer-rules.pro
deleted file mode 100644
index e69de29..0000000
diff --git a/ratingbar/proguard-rules.pro b/ratingbar/proguard-rules.pro
deleted file mode 100644
index 481bb43..0000000
--- a/ratingbar/proguard-rules.pro
+++ /dev/null
@@ -1,21 +0,0 @@
-# Add project specific ProGuard rules here.
-# You can control the set of applied configuration files using the
-# proguardFiles setting in build.gradle.
-#
-# For more details, see
-# http://developer.android.com/guide/developing/tools/proguard.html
-
-# If your project uses WebView with JS, uncomment the following
-# and specify the fully qualified class name to the JavaScript interface
-# class:
-#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
-# public *;
-#}
-
-# Uncomment this to preserve the line number information for
-# debugging stack traces.
-#-keepattributes SourceFile,LineNumberTable
-
-# If you keep the line number information, uncomment this to
-# hide the original source file name.
-#-renamesourcefileattribute SourceFile
\ No newline at end of file
diff --git a/ratingbar/src/main/AndroidManifest.xml b/ratingbar/src/main/AndroidManifest.xml
deleted file mode 100644
index a5918e6..0000000
--- a/ratingbar/src/main/AndroidManifest.xml
+++ /dev/null
@@ -1,4 +0,0 @@
-
-
-
-
\ No newline at end of file
diff --git a/ratingbar/src/main/java/com/gowtham/ratingbar/FractionalRectangleShape.kt b/ratingbar/src/main/java/com/gowtham/ratingbar/FractionalRectangleShape.kt
deleted file mode 100644
index 1731d7a..0000000
--- a/ratingbar/src/main/java/com/gowtham/ratingbar/FractionalRectangleShape.kt
+++ /dev/null
@@ -1,32 +0,0 @@
-package com.gowtham.ratingbar
-
-import androidx.annotation.FloatRange
-import androidx.compose.runtime.Stable
-import androidx.compose.ui.geometry.Rect
-import androidx.compose.ui.geometry.Size
-import androidx.compose.ui.graphics.Outline
-import androidx.compose.ui.graphics.Shape
-import androidx.compose.ui.unit.Density
-import androidx.compose.ui.unit.LayoutDirection
-
-@Stable
-class FractionalRectangleShape(
- @FloatRange(from = 0.0, to = 1.0) private val startFraction: Float,
- @FloatRange(from = 0.0, to = 1.0) private val endFraction: Float
-) : Shape {
- override fun createOutline(
- size: Size,
- layoutDirection: LayoutDirection,
- density: Density
- ): Outline {
- return Outline.Rectangle(
- Rect(
- left = (startFraction * size.width).coerceAtMost(size.width - 1f),
- top = 0f,
- right = (endFraction * size.width).coerceAtLeast(1f),
- bottom = size.height
- )
- )
- }
-
-}
diff --git a/ratingbar/src/main/java/com/gowtham/ratingbar/LogMessage.kt b/ratingbar/src/main/java/com/gowtham/ratingbar/LogMessage.kt
deleted file mode 100644
index ce0b0ce..0000000
--- a/ratingbar/src/main/java/com/gowtham/ratingbar/LogMessage.kt
+++ /dev/null
@@ -1,17 +0,0 @@
-package com.gowtham.ratingbar
-
-import android.util.Log
-
-object LogMessage {
-
- private const val logVisible = false
-
- internal fun v(msg: String) {
- if (logVisible) Log.v("Compose-Ratingbar :", msg)
- }
-
- internal fun e(msg: String) {
- if (logVisible) Log.e("Compose-Ratingbar", msg)
- }
-
-}
\ No newline at end of file
diff --git a/ratingbar/src/main/java/com/gowtham/ratingbar/PathExtensions.kt b/ratingbar/src/main/java/com/gowtham/ratingbar/PathExtensions.kt
deleted file mode 100644
index 5b3456d..0000000
--- a/ratingbar/src/main/java/com/gowtham/ratingbar/PathExtensions.kt
+++ /dev/null
@@ -1,49 +0,0 @@
-package com.gowtham.ratingbar
-
-import androidx.annotation.FloatRange
-import androidx.compose.ui.geometry.Size
-import androidx.compose.ui.graphics.Path
-import kotlin.math.PI
-import kotlin.math.cos
-import kotlin.math.sin
-
-fun Path.addStar(
- size: Size,
- spikes: Int = 5,
- @FloatRange(from = 0.0, to = 0.5) outerRadiusFraction: Float = 0.5f,
- @FloatRange(from = 0.0, to = 0.5) innerRadiusFraction: Float = 0.2f
-): Path {
- val outerRadius = size.minDimension * outerRadiusFraction
- val innerRadius = size.minDimension * innerRadiusFraction
-
- val centerX = size.width / 2
- val centerY = size.height / 2
-
- var totalAngle = PI / 2 // Since we start at the top center, the initial angle will be 90°
- val degreesPerSection = (2 * PI) / spikes
-
- moveTo(centerX, 0f) // Starts at the top center of the bounds
-
- var x: Double
- var y: Double
-
- for (i in 1..spikes) {
- // Line going inwards from outerCircle to innerCircle
- totalAngle += degreesPerSection / 2
- x = centerX + cos(totalAngle) * innerRadius
- y = centerY - sin(totalAngle) * innerRadius
- lineTo(x.toFloat(), y.toFloat())
-
-
- // Line going outwards from innerCircle to outerCircle
- totalAngle += degreesPerSection / 2
- x = centerX + cos(totalAngle) * outerRadius
- y = centerY - sin(totalAngle) * outerRadius
- lineTo(x.toFloat(), y.toFloat())
- }
-
- // Path should be closed to ensure it's not an open shape
- close()
-
- return this
-}
diff --git a/ratingbar/src/main/java/com/gowtham/ratingbar/RatingBar.kt b/ratingbar/src/main/java/com/gowtham/ratingbar/RatingBar.kt
deleted file mode 100644
index a3f4e37..0000000
--- a/ratingbar/src/main/java/com/gowtham/ratingbar/RatingBar.kt
+++ /dev/null
@@ -1,303 +0,0 @@
-package com.gowtham.ratingbar
-
-import android.util.Log
-import androidx.compose.foundation.gestures.detectHorizontalDragGestures
-import androidx.compose.foundation.gestures.detectTapGestures
-import androidx.compose.foundation.layout.Row
-import androidx.compose.foundation.layout.padding
-import androidx.compose.foundation.layout.size
-import androidx.compose.runtime.*
-import androidx.compose.ui.ExperimentalComposeUiApi
-import androidx.compose.ui.Modifier
-import androidx.compose.ui.geometry.Size
-import androidx.compose.ui.graphics.Color
-import androidx.compose.ui.graphics.painter.Painter
-import androidx.compose.ui.input.pointer.pointerInput
-import androidx.compose.ui.layout.onSizeChanged
-import androidx.compose.ui.platform.LocalDensity
-import androidx.compose.ui.platform.LocalLayoutDirection
-import androidx.compose.ui.platform.testTag
-import androidx.compose.ui.semantics.SemanticsPropertyKey
-import androidx.compose.ui.semantics.SemanticsPropertyReceiver
-import androidx.compose.ui.semantics.semantics
-import androidx.compose.ui.tooling.preview.Preview
-import androidx.compose.ui.unit.Dp
-import androidx.compose.ui.unit.LayoutDirection
-import androidx.compose.ui.unit.dp
-import androidx.compose.ui.unit.toSize
-
-sealed interface StepSize {
- object ONE : StepSize
- object HALF : StepSize
-}
-
-sealed class RatingBarStyle(open val activeColor: Color) {
- companion object {
- val Default = Stroke()
- }
-
- open class Fill(
- override val activeColor: Color = Color(0xFFFFCA00),
- val inActiveColor: Color = Color(0x66FFCA00),
- ) : RatingBarStyle(activeColor)
-
- /**
- * @param width width for each star
- * @param color A border [Color] shown on inactive star.
- */
- class Stroke(
- val width: Float = 1f,
- override val activeColor: Color = Color(0xFFFFCA00),
- val strokeColor: Color = Color(0xFF888888)
- ) : RatingBarStyle(activeColor)
-}
-
-//For ui testing
-val StarRatingKey = SemanticsPropertyKey("StarRating")
-var SemanticsPropertyReceiver.starRating by StarRatingKey
-
-
-/**
- * @param value is current selected rating count
- * @param numOfStars count of stars to be shown.
- * @param size size for each star
- * @param spaceBetween padding between each star.
- * @param isIndicator isIndicator Whether this rating bar is only an indicator or the value is changeable on user interaction.
- * @param stepSize Can be [StepSize.ONE] or [StepSize.HALF]
- * @param hideInactiveStars Whether the inactive stars should be hidden.
- * @param style the different style applied to the Rating Bar.
- * @param onRatingChanged A function to be called when the click or drag is released and rating value is passed
- */
-@OptIn(ExperimentalComposeUiApi::class)
-@Composable
-internal fun RatingBar(
- value: Float,
- modifier: Modifier = Modifier,
- numOfStars: Int = 5,
- size: Dp = 32.dp,
- spaceBetween: Dp = 6.dp,
- isIndicator: Boolean = false,
- stepSize: StepSize = StepSize.ONE,
- hideInactiveStars: Boolean = false,
- style: RatingBarStyle = RatingBarStyle.Default,
- painterEmpty: Painter? = null,
- painterFilled: Painter? = null,
- onValueChange: (Float) -> Unit,
- onRatingChanged: (Float) -> Unit
-) {
- var rowSize by remember { mutableStateOf(Size.Zero) }
- var lastDraggedValue by remember { mutableStateOf(0f) }
- val direction = LocalLayoutDirection.current
- val density = LocalDensity.current
-
-
- val paddingInPx = remember {
- with(density) { spaceBetween.toPx() }
- }
- val starSizeInPx = remember() {
- with(density) { size.toPx() }
- }
-
- Row(modifier = modifier
- .onSizeChanged { rowSize = it.toSize() }
- .pointerInput(
- onValueChange
- ) {
- //handling dragging events
- detectHorizontalDragGestures(
- onDragEnd = {
- if (isIndicator || hideInactiveStars)
- return@detectHorizontalDragGestures
- onRatingChanged(lastDraggedValue)
- },
- onDragCancel = {
-
- },
- onDragStart = {
-
- },
- onHorizontalDrag = { change, _ ->
- if (isIndicator || hideInactiveStars)
- return@detectHorizontalDragGestures
- change.consume()
- val dragX = change.position.x.coerceIn(-1f, rowSize.width)
- var calculatedStars =
- RatingBarUtils.calculateStars(
- dragX,
- paddingInPx,
- numOfStars, stepSize, starSizeInPx
- )
- if (direction == LayoutDirection.Rtl) {
- // calculatedStars -> reversed
- // 1 -> 5, 2 -> 4, 3 -> 3, 4 -> 2,5 -> 1
- calculatedStars = (numOfStars - calculatedStars)
- }
- onValueChange(calculatedStars)
- lastDraggedValue = calculatedStars
- }
- )
- }
- .pointerInput(onValueChange) {
- //handling when click events
- detectTapGestures(onTap = {
- if (isIndicator || hideInactiveStars)
- return@detectTapGestures
- val dragX = it.x.coerceIn(-1f, rowSize.width)
- var calculatedStars =
- RatingBarUtils.calculateStars(
- dragX,
- paddingInPx,
- numOfStars, stepSize, starSizeInPx
- )
- if (direction == LayoutDirection.Rtl) {
- // calculatedStars -> reversed
- // 1 -> 5, 2 -> 4, 3 -> 3, 4 -> 2,5 -> 1
- calculatedStars = (numOfStars - calculatedStars) + 1
- }
- onValueChange(calculatedStars)
- onRatingChanged(calculatedStars)
- })
- }) {
- ComposeStars(
- value,
- numOfStars,
- size,
- spaceBetween,
- hideInactiveStars,
- style = style,
- painterEmpty,
- painterFilled
- )
- }
-}
-
-@Composable
-fun RatingBar(
- value: Float,
- modifier: Modifier = Modifier,
- numOfStars: Int = 5,
- size: Dp = 32.dp,
- spaceBetween: Dp = 6.dp,
- isIndicator: Boolean = false,
- stepSize: StepSize = StepSize.ONE,
- hideInactiveStars: Boolean = false,
- style: RatingBarStyle,
- onValueChange: (Float) -> Unit,
- onRatingChanged: (Float) -> Unit
-) {
- RatingBar(
- value = value,
- modifier = modifier,
- numOfStars = numOfStars,
- size = size,
- spaceBetween = spaceBetween,
- isIndicator = isIndicator,
- stepSize = stepSize,
- hideInactiveStars = hideInactiveStars,
- style = style,
- painterEmpty = null,
- painterFilled = null,
- onValueChange = onValueChange,
- onRatingChanged = onRatingChanged
- )
-}
-
-@Composable
-fun RatingBar(
- value: Float,
- modifier: Modifier = Modifier,
- numOfStars: Int = 5,
- size: Dp = 32.dp,
- spaceBetween: Dp = 6.dp,
- isIndicator: Boolean = false,
- stepSize: StepSize = StepSize.ONE,
- hideInactiveStars: Boolean = false,
- painterEmpty: Painter,
- painterFilled: Painter,
- onValueChange: (Float) -> Unit,
- onRatingChanged: (Float) -> Unit
-) {
- RatingBar(
- value = value,
- modifier = modifier,
- numOfStars = numOfStars,
- size = size,
- spaceBetween = spaceBetween,
- isIndicator = isIndicator,
- stepSize = stepSize,
- hideInactiveStars = hideInactiveStars,
- style = RatingBarStyle.Default,
- painterEmpty = painterEmpty,
- painterFilled = painterFilled,
- onValueChange = onValueChange,
- onRatingChanged = onRatingChanged
- )
-}
-
-@Composable
-fun ComposeStars(
- value: Float,
- numOfStars: Int,
- size: Dp,
- spaceBetween: Dp,
- hideInactiveStars: Boolean,
- style: RatingBarStyle,
- painterEmpty: Painter?,
- painterFilled: Painter?
-) {
-
- val ratingPerStar = 1f
- var remainingRating = value
-
- Row(modifier = Modifier
- .semantics { starRating = value }) {
- for (i in 1..numOfStars) {
- val starRating = when {
- remainingRating == 0f -> {
- 0f
- }
-
- remainingRating >= ratingPerStar -> {
- remainingRating -= ratingPerStar
- 1f
- }
-
- else -> {
- val fraction = remainingRating / ratingPerStar
- remainingRating = 0f
- fraction
- }
- }
- if (hideInactiveStars && starRating == 0.0f)
- break
-
- RatingStar(
- fraction = starRating,
- style = style,
- modifier = Modifier
- .padding(
- start = if (i > 1) spaceBetween else 0.dp,
- end = if (i < numOfStars) spaceBetween else 0.dp
- )
- .size(size = size)
- .testTag("RatingStar"),
- painterEmpty = painterEmpty, painterFilled = painterFilled
- )
- }
- }
-}
-
-@Preview(showBackground = true)
-@Composable
-fun RatingBarPreview() {
- var rating by remember { mutableStateOf(3.3f) }
- RatingBar(
- value = rating,
- style = RatingBarStyle.Fill(),
- onValueChange = {
- rating = it
- }
- ) {
- Log.d("TAG", "RatingBarPreview: $it")
- }
-}
\ No newline at end of file
diff --git a/ratingbar/src/main/java/com/gowtham/ratingbar/RatingBarUtils.kt b/ratingbar/src/main/java/com/gowtham/ratingbar/RatingBarUtils.kt
deleted file mode 100644
index efe1362..0000000
--- a/ratingbar/src/main/java/com/gowtham/ratingbar/RatingBarUtils.kt
+++ /dev/null
@@ -1,36 +0,0 @@
-package com.gowtham.ratingbar
-
-object RatingBarUtils {
-
- fun calculateStars(
- draggedX: Float,
- horizontalPaddingInPx: Float,
- numOfStars: Int,
- stepSize: StepSize,
- starSizeInPx: Float,
- ): Float {
-
- if(draggedX<=0){
- return 0f
- }
-
- val starWidthWithRightPadding = starSizeInPx + (2 * horizontalPaddingInPx)
- val halfStarWidth = starSizeInPx / 2
- for (i in 1..numOfStars) {
- if (draggedX < (i * starWidthWithRightPadding)) {
- return if (stepSize is StepSize.ONE) {
- i.toFloat()
- } else {
- val crossedStarsWidth = (i - 1) * starWidthWithRightPadding
- val remainingWidth = draggedX - crossedStarsWidth
- if (remainingWidth <= halfStarWidth) {
- i.toFloat().minus(0.5f)
- } else {
- i.toFloat()
- }
- }
- }
- }
- return 0f
- }
-}
\ No newline at end of file
diff --git a/ratingbar/src/main/java/com/gowtham/ratingbar/RatingStar.kt b/ratingbar/src/main/java/com/gowtham/ratingbar/RatingStar.kt
deleted file mode 100644
index 9a580a0..0000000
--- a/ratingbar/src/main/java/com/gowtham/ratingbar/RatingStar.kt
+++ /dev/null
@@ -1,180 +0,0 @@
-package com.gowtham.ratingbar
-
-import androidx.annotation.FloatRange
-import androidx.compose.foundation.Canvas
-import androidx.compose.foundation.layout.Box
-import androidx.compose.foundation.layout.fillMaxSize
-import androidx.compose.foundation.layout.size
-import androidx.compose.runtime.Composable
-import androidx.compose.ui.Modifier
-import androidx.compose.ui.draw.clip
-import androidx.compose.ui.geometry.Size
-import androidx.compose.ui.graphics.Color
-import androidx.compose.ui.graphics.Path
-import androidx.compose.ui.graphics.drawscope.Fill
-import androidx.compose.ui.graphics.drawscope.Stroke
-import androidx.compose.ui.graphics.painter.Painter
-import androidx.compose.ui.platform.LocalLayoutDirection
-import androidx.compose.ui.tooling.preview.Preview
-import androidx.compose.ui.unit.LayoutDirection
-import androidx.compose.ui.unit.dp
-
-@Composable
-fun RatingStar(
- @FloatRange(from = 0.0, to = 1.0) fraction: Float,
- modifier: Modifier = Modifier,
- style: RatingBarStyle,
- painterEmpty: Painter?,
- painterFilled: Painter?
-) {
- val isRtl = LocalLayoutDirection.current == LayoutDirection.Rtl
- Box(modifier = modifier) {
- FilledStar(
- fraction,
- style,
- isRtl,
- painterFilled
- )
- EmptyStar(fraction, style, isRtl, painterEmpty)
- }
-}
-
-@Composable
-private fun FilledStar(
- fraction: Float, style: RatingBarStyle, isRtl: Boolean, painterFilled: Painter?
-) = Canvas(
- modifier = Modifier
- .fillMaxSize()
- .clip(
- if (isRtl) rtlFilledStarFractionalShape(fraction = fraction)
- else FractionalRectangleShape(0f, fraction)
- )
-) {
-
- if (painterFilled != null) {
- with(painterFilled) {
- draw(
- size = Size(size.height, size.height),
- )
- }
- } else {
- val path = Path().addStar(size)
-
- drawPath(path, color = style.activeColor, style = Fill) // Filled Star
- drawPath(
- path,
- color = style.activeColor,
- style = Stroke(width = if (style is RatingBarStyle.Stroke) style.width else 1f)
- ) // Border
- }
-
-
-}
-
-@Composable
-private fun EmptyStar(
- fraction: Float,
- style: RatingBarStyle,
- isRtl: Boolean,
- painterEmpty: Painter?
-) =
- Canvas(
- modifier = Modifier
- .fillMaxSize()
- .clip(
- if (isRtl) rtlEmptyStarFractionalShape(fraction = fraction)
- else FractionalRectangleShape(fraction, 1f)
- )
- ) {
-
- if (painterEmpty != null) {
- with(painterEmpty) {
- draw(
- size = Size(size.height, size.height),
- )
- }
- } else {
- val path = Path().addStar(size)
- if (style is RatingBarStyle.Fill) drawPath(
- path,
- color = style.inActiveColor,
- style = Fill
- ) // Border
- else if (style is RatingBarStyle.Stroke) drawPath(
- path, color = style.strokeColor, style = Stroke(width = style.width)
- ) // Border
- }
-
- }
-
-@Preview(showBackground = true)
-@Composable
-fun EmptyRatingStarPreview() {
- RatingStar(
- fraction = 0f,
- style = RatingBarStyle.Fill(
- activeColor = Color(0xffffd740),
- inActiveColor = Color.Gray
- ),
- modifier = Modifier.size(20.dp),
- painterEmpty = null,
- painterFilled = null
- )
-}
-
-@Preview(showBackground = true)
-@Composable
-fun HighlightedWithBorderColorPreview() {
- RatingStar(
- fraction = 0.8f,
- style = RatingBarStyle.Stroke(
- activeColor = Color(0xffffd740),
- strokeColor = Color.Blue
- ),
- modifier = Modifier.size(20.dp),
- painterEmpty = null,
- painterFilled = null
- )
-}
-
-@Preview(showBackground = true)
-@Composable
-fun PartialRatingStarPreview() {
- RatingStar(
- fraction = 0.8f,
- style = RatingBarStyle.Fill(
- activeColor = Color(0xffffd740),
- inActiveColor = Color(0x66FFD740)
- ),
- modifier = Modifier.size(20.dp),
- painterEmpty = null,
- painterFilled = null
- )
-}
-
-@Preview(showBackground = true)
-@Composable
-fun FullRatingStarPreview() {
- RatingStar(
- fraction = 1f,
- style = RatingBarStyle.Fill(
- activeColor = Color(0xffffd740),
- inActiveColor = Color(0x66FFD740)
- ),
- modifier = Modifier.size(20.dp),
- painterEmpty = null,
- painterFilled = null
- )
-}
-
-fun rtlEmptyStarFractionalShape(fraction: Float): FractionalRectangleShape {
- return if (fraction == 1f || fraction == 0f)
- FractionalRectangleShape(fraction, 1f)
- else FractionalRectangleShape(0f, 1f - fraction)
-}
-
-fun rtlFilledStarFractionalShape(fraction: Float): FractionalRectangleShape {
- return if (fraction == 0f || fraction == 1f)
- FractionalRectangleShape(0f, fraction)
- else FractionalRectangleShape(1f - fraction, 1f)
-}
\ No newline at end of file
diff --git a/ratingbar/src/test/java/com/gowtham/ratingbar/ExampleUnitTest.kt b/ratingbar/src/test/java/com/gowtham/ratingbar/ExampleUnitTest.kt
deleted file mode 100644
index 920da10..0000000
--- a/ratingbar/src/test/java/com/gowtham/ratingbar/ExampleUnitTest.kt
+++ /dev/null
@@ -1,10 +0,0 @@
-package com.gowtham.ratingbar
-
-
-/**
- * Example local unit test, which will execute on the development machine (host).
- *
- * See [testing documentation](http://d.android.com/tools/testing).
- */
-class ExampleUnitTest {
-}
\ No newline at end of file
diff --git a/settings.gradle b/settings.gradle
index 670d68c..4afd13b 100644
--- a/settings.gradle
+++ b/settings.gradle
@@ -18,7 +18,7 @@ dependencyResolutionManagement {
rootProject.name = "Compose-RatingBar"
include ':app'
-include ':ratingbar'
+// include ':ratingbar'
/*
signing.keyId=AEAEDCCC
signing.password=Gowthamsj10