diff --git a/raionratingstar/.gitignore b/raionratingstar/.gitignore deleted file mode 100644 index 42afabf..0000000 --- a/raionratingstar/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/build \ No newline at end of file diff --git a/raionratingstar/build.gradle b/raionratingstar/build.gradle deleted file mode 100644 index 1d51c5b..0000000 --- a/raionratingstar/build.gradle +++ /dev/null @@ -1,40 +0,0 @@ -plugins { - id 'com.android.library' - id 'org.jetbrains.kotlin.android' -} - -android { - compileSdk 32 - - defaultConfig { - minSdk 21 - targetSdk 32 - - testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" - consumerProguardFiles "consumer-rules.pro" - } - - buildTypes { - release { - minifyEnabled false - proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' - } - } - compileOptions { - sourceCompatibility JavaVersion.VERSION_1_8 - targetCompatibility JavaVersion.VERSION_1_8 - } - kotlinOptions { - jvmTarget = '1.8' - } -} - -dependencies { - - implementation 'androidx.core:core-ktx:1.7.0' - implementation 'androidx.appcompat:appcompat:1.4.1' - implementation 'com.google.android.material:material:1.5.0' - testImplementation 'junit:junit:4.13.2' - androidTestImplementation 'androidx.test.ext:junit:1.1.3' - androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0' -} \ No newline at end of file diff --git a/raionratingstar/consumer-rules.pro b/raionratingstar/consumer-rules.pro deleted file mode 100644 index e69de29..0000000 diff --git a/raionratingstar/proguard-rules.pro b/raionratingstar/proguard-rules.pro deleted file mode 100644 index 481bb43..0000000 --- a/raionratingstar/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/raionratingstar/rating_stars.dart b/raionratingstar/rating_stars.dart new file mode 100644 index 0000000..0cf349a --- /dev/null +++ b/raionratingstar/rating_stars.dart @@ -0,0 +1,122 @@ +import 'package:flutter/material.dart'; + +class RatingStars extends StatelessWidget { + double rating; + + // named constructor with scale 0-maxValue scores to the 5 stars range + RatingStars.withDivider(double _rating, double _maxValue) { + this.rating = _rating * (5 / _maxValue); + } + + // default constructor with scale 0-5 scores to the 5 stars range + RatingStars(this.rating); + + Row _rate(double _rating) { + if (_rating < 1) { + return Row( + children: [ + Icon(Icons.star_half_outlined), + Icon(Icons.star_outline_outlined), + Icon(Icons.star_outline_outlined), + Icon(Icons.star_outline_outlined), + Icon(Icons.star_outline_outlined), + ], + ); + } else if (_rating == 1) { + return Row( + children: [ + Icon(Icons.star_outlined), + Icon(Icons.star_outline_outlined), + Icon(Icons.star_outline_outlined), + Icon(Icons.star_outline_outlined), + Icon(Icons.star_outline_outlined), + ], + ); + } else if (_rating < 2) { + return Row( + children: [ + Icon(Icons.star_outlined), + Icon(Icons.star_half_outlined), + Icon(Icons.star_outline_outlined), + Icon(Icons.star_outline_outlined), + Icon(Icons.star_outline_outlined), + ], + ); + } else if (_rating == 2) { + return Row( + children: [ + Icon(Icons.star_outlined), + Icon(Icons.star_outlined), + Icon(Icons.star_outline_outlined), + Icon(Icons.star_outline_outlined), + Icon(Icons.star_outline_outlined), + ], + ); + } else if (_rating < 3) { + return Row( + children: [ + Icon(Icons.star_outlined), + Icon(Icons.star_outlined), + Icon(Icons.star_half_outlined), + Icon(Icons.star_outline_outlined), + Icon(Icons.star_outline_outlined), + ], + ); + } else if (_rating == 3) { + return Row( + children: [ + Icon(Icons.star_outlined), + Icon(Icons.star_outlined), + Icon(Icons.star_outlined), + Icon(Icons.star_outline_outlined), + Icon(Icons.star_outline_outlined), + ], + ); + } else if (_rating < 4) { + return Row( + children: [ + Icon(Icons.star_outlined), + Icon(Icons.star_outlined), + Icon(Icons.star_outlined), + Icon(Icons.star_half_outlined), + Icon(Icons.star_outline_outlined), + ], + ); + } else if (_rating == 4) { + return Row( + children: [ + Icon(Icons.star_outlined), + Icon(Icons.star_outlined), + Icon(Icons.star_outlined), + Icon(Icons.star_outlined), + Icon(Icons.star_outline_outlined), + ], + ); + } else if (_rating < 5) { + return Row( + children: [ + Icon(Icons.star_outlined), + Icon(Icons.star_outlined), + Icon(Icons.star_outlined), + Icon(Icons.star_outlined), + Icon(Icons.star_half_outlined), + ], + ); + } else { + return Row( + children: [ + Icon(Icons.star_outlined), + Icon(Icons.star_outlined), + Icon(Icons.star_outlined), + Icon(Icons.star_outlined), + Icon(Icons.star_outlined), + ], + ); + } + } + + @override + Widget build(BuildContext context) { + return _rate(rating); + } +} diff --git a/raionratingstar/src/androidTest/java/com/raion/raionratingstar/ExampleInstrumentedTest.kt b/raionratingstar/src/androidTest/java/com/raion/raionratingstar/ExampleInstrumentedTest.kt deleted file mode 100644 index f1afea7..0000000 --- a/raionratingstar/src/androidTest/java/com/raion/raionratingstar/ExampleInstrumentedTest.kt +++ /dev/null @@ -1,24 +0,0 @@ -package com.raion.raionratingstar - -import androidx.test.platform.app.InstrumentationRegistry -import androidx.test.ext.junit.runners.AndroidJUnit4 - -import org.junit.Test -import org.junit.runner.RunWith - -import org.junit.Assert.* - -/** - * Instrumented test, which will execute on an Android device. - * - * See [testing documentation](http://d.android.com/tools/testing). - */ -@RunWith(AndroidJUnit4::class) -class ExampleInstrumentedTest { - @Test - fun useAppContext() { - // Context of the app under test. - val appContext = InstrumentationRegistry.getInstrumentation().targetContext - assertEquals("com.raion.raionratingstar.test", appContext.packageName) - } -} \ No newline at end of file diff --git a/raionratingstar/src/main/AndroidManifest.xml b/raionratingstar/src/main/AndroidManifest.xml deleted file mode 100644 index 5b776ff..0000000 --- a/raionratingstar/src/main/AndroidManifest.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - - \ No newline at end of file diff --git a/raionratingstar/src/test/java/com/raion/raionratingstar/ExampleUnitTest.kt b/raionratingstar/src/test/java/com/raion/raionratingstar/ExampleUnitTest.kt deleted file mode 100644 index 9781074..0000000 --- a/raionratingstar/src/test/java/com/raion/raionratingstar/ExampleUnitTest.kt +++ /dev/null @@ -1,17 +0,0 @@ -package com.raion.raionratingstar - -import org.junit.Test - -import org.junit.Assert.* - -/** - * Example local unit test, which will execute on the development machine (host). - * - * See [testing documentation](http://d.android.com/tools/testing). - */ -class ExampleUnitTest { - @Test - fun addition_isCorrect() { - assertEquals(4, 2 + 2) - } -} \ No newline at end of file