Skip to content

Commit 1730043

Browse files
initial commit
0 parents  commit 1730043

File tree

43 files changed

+983
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+983
-0
lines changed

.gitignore

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
*.iml
2+
.gradle
3+
/local.properties
4+
/.idea/*
5+
.DS_Store
6+
/build
7+
/captures
8+
.externalNativeBuild
9+
.cxx
10+
local.properties

README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
### Jetpack Compose Colorful Customizable Sliders
2+
Colorful sliders that can have Solid or Gradient colors for thumb or track which can have
3+
thumb and track with varying sizes.
4+
5+
### ColorfulSlider
6+
Sliders that can use Color or gradient for track, thumb, or tick colors with custom
7+
thumb and track heights.
8+
9+
### IconSlider
10+
Sliders that can use any Composable for thumb and use Color or gradient for track, thumb, or tick colors with custom
11+
thumb and track heights.

app/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/build

app/build.gradle

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
plugins {
2+
id 'com.android.application'
3+
id 'org.jetbrains.kotlin.android'
4+
}
5+
6+
android {
7+
compileSdk 31
8+
9+
defaultConfig {
10+
applicationId "com.smarttoolfactory.composematerialslider"
11+
minSdk 21
12+
targetSdk 31
13+
versionCode 1
14+
versionName "1.0"
15+
16+
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
17+
vectorDrawables {
18+
useSupportLibrary true
19+
}
20+
}
21+
22+
buildTypes {
23+
release {
24+
minifyEnabled false
25+
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
26+
}
27+
}
28+
compileOptions {
29+
sourceCompatibility JavaVersion.VERSION_1_8
30+
targetCompatibility JavaVersion.VERSION_1_8
31+
}
32+
kotlinOptions {
33+
jvmTarget = '1.8'
34+
}
35+
buildFeatures {
36+
compose true
37+
}
38+
composeOptions {
39+
kotlinCompilerExtensionVersion compose_version
40+
}
41+
packagingOptions {
42+
resources {
43+
excludes += '/META-INF/{AL2.0,LGPL2.1}'
44+
}
45+
}
46+
}
47+
48+
dependencies {
49+
50+
implementation project(':slider')
51+
52+
implementation 'androidx.core:core-ktx:1.7.0'
53+
implementation "androidx.compose.ui:ui:$compose_version"
54+
implementation "androidx.compose.material:material:$compose_version"
55+
implementation "androidx.compose.ui:ui-tooling-preview:$compose_version"
56+
implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.4.1'
57+
implementation 'androidx.activity:activity-compose:1.4.0'
58+
59+
testImplementation 'junit:junit:4.13.2'
60+
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
61+
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
62+
androidTestImplementation "androidx.compose.ui:ui-test-junit4:$compose_version"
63+
debugImplementation "androidx.compose.ui:ui-tooling:$compose_version"
64+
}

app/proguard-rules.pro

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Add project specific ProGuard rules here.
2+
# You can control the set of applied configuration files using the
3+
# proguardFiles setting in build.gradle.
4+
#
5+
# For more details, see
6+
# http://developer.android.com/guide/developing/tools/proguard.html
7+
8+
# If your project uses WebView with JS, uncomment the following
9+
# and specify the fully qualified class name to the JavaScript interface
10+
# class:
11+
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12+
# public *;
13+
#}
14+
15+
# Uncomment this to preserve the line number information for
16+
# debugging stack traces.
17+
#-keepattributes SourceFile,LineNumberTable
18+
19+
# If you keep the line number information, uncomment this to
20+
# hide the original source file name.
21+
#-renamesourcefileattribute SourceFile
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package com.smarttoolfactory.composematerialslider
2+
3+
import androidx.test.platform.app.InstrumentationRegistry
4+
import androidx.test.ext.junit.runners.AndroidJUnit4
5+
6+
import org.junit.Test
7+
import org.junit.runner.RunWith
8+
9+
import org.junit.Assert.*
10+
11+
/**
12+
* Instrumented test, which will execute on an Android device.
13+
*
14+
* See [testing documentation](http://d.android.com/tools/testing).
15+
*/
16+
@RunWith(AndroidJUnit4::class)
17+
class ExampleInstrumentedTest {
18+
@Test
19+
fun useAppContext() {
20+
// Context of the app under test.
21+
val appContext = InstrumentationRegistry.getInstrumentation().targetContext
22+
assertEquals("com.smarttoolfactory.composematerialslider", appContext.packageName)
23+
}
24+
}

app/src/main/AndroidManifest.xml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3+
package="com.smarttoolfactory.composematerialslider">
4+
5+
<application
6+
android:allowBackup="true"
7+
android:icon="@mipmap/ic_launcher"
8+
android:label="@string/app_name"
9+
android:roundIcon="@mipmap/ic_launcher_round"
10+
android:supportsRtl="true"
11+
android:theme="@style/Theme.ComposeMaterialSlider">
12+
<activity
13+
android:name=".MainActivity"
14+
android:exported="true"
15+
android:label="@string/app_name"
16+
android:theme="@style/Theme.ComposeMaterialSlider">
17+
<intent-filter>
18+
<action android:name="android.intent.action.MAIN" />
19+
20+
<category android:name="android.intent.category.LAUNCHER" />
21+
</intent-filter>
22+
</activity>
23+
</application>
24+
25+
</manifest>
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package com.smarttoolfactory.composematerialslider.ui.theme
2+
3+
import androidx.compose.ui.graphics.Color
4+
5+
val Purple200 = Color(0xFFBB86FC)
6+
val Purple500 = Color(0xFF6200EE)
7+
val Purple700 = Color(0xFF3700B3)
8+
val Teal200 = Color(0xFF03DAC5)
9+
10+
val Orange400 = Color(0xffFFA726)
11+
val Blue400 = Color(0xff42A5F5)
12+
val Pink400 = Color(0xffEC407A)
13+
val Green400 = Color(0xff66BB6A)
14+
val Red400 = Color(0xffEF5350)
15+
val Yellow400 = Color(0xffFFEE58)
16+
val Purple400 = Color(0xffAB47BC)
17+
val Brown400 = Color(0xff8D6E63)
18+
val BlueGrey400 = Color(0xff78909C)
19+
val Grey400 = Color(0xffBDBDBD)
20+
21+
val Grey600 = Color(0xff757575)
22+
val Grey800 = Color(0xff424242)
23+
val Grey900 = Color(0xff212121)
24+
25+
val Gray = Color(0xff808080)
26+
val WhiteTransparent = Color(0x00ffffff)
27+
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package com.smarttoolfactory.composematerialslider.ui.theme
2+
3+
import androidx.compose.foundation.shape.RoundedCornerShape
4+
import androidx.compose.material.Shapes
5+
import androidx.compose.ui.unit.dp
6+
7+
val Shapes = Shapes(
8+
small = RoundedCornerShape(4.dp),
9+
medium = RoundedCornerShape(4.dp),
10+
large = RoundedCornerShape(0.dp)
11+
)
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
package com.smarttoolfactory.composematerialslider.ui.theme
2+
3+
import androidx.compose.foundation.isSystemInDarkTheme
4+
import androidx.compose.material.MaterialTheme
5+
import androidx.compose.material.darkColors
6+
import androidx.compose.material.lightColors
7+
import androidx.compose.runtime.Composable
8+
9+
private val DarkColorPalette = darkColors(
10+
primary = Purple200,
11+
primaryVariant = Purple700,
12+
secondary = Teal200
13+
)
14+
15+
private val LightColorPalette = lightColors(
16+
primary = Purple500,
17+
primaryVariant = Purple700,
18+
secondary = Teal200
19+
20+
/* Other default colors to override
21+
background = Color.White,
22+
surface = Color.White,
23+
onPrimary = Color.White,
24+
onSecondary = Color.Black,
25+
onBackground = Color.Black,
26+
onSurface = Color.Black,
27+
*/
28+
)
29+
30+
@Composable
31+
fun ComposeMaterialSliderTheme(
32+
darkTheme: Boolean = isSystemInDarkTheme(),
33+
content: @Composable () -> Unit
34+
) {
35+
val colors = if (darkTheme) {
36+
DarkColorPalette
37+
} else {
38+
LightColorPalette
39+
}
40+
41+
MaterialTheme(
42+
colors = colors,
43+
typography = Typography,
44+
shapes = Shapes,
45+
content = content
46+
)
47+
}

0 commit comments

Comments
 (0)