Skip to content

Commit

Permalink
Merge pull request #6 from kareemradwan/number-stepper-view
Browse files Browse the repository at this point in the history
Create Number stepper view
  • Loading branch information
kareemradwan authored Jul 4, 2020
2 parents 22d7e09 + c82ff2b commit c74bdcc
Show file tree
Hide file tree
Showing 22 changed files with 589 additions and 38 deletions.
2 changes: 1 addition & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ You can Register The Activity as Controller to Notifiy When `SteeoerView` Finish
- [X] Save State of View When Device Rotate.
- [X] Custmaize Color for `unChecked` and `Checked` status (Indicator)
- [X] Custmaize Image Drawable for `unChecked` and `Checked` status (Step Icon)
- [X] Create Number Stepper View
- [ ] Add Animation for `CheckBox` When be Selected


Expand Down
12 changes: 8 additions & 4 deletions app/src/main/java/com/kareemradwan/stepeer/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import android.annotation.SuppressLint
import android.os.Bundle
import android.widget.Toast
import androidx.appcompat.app.AppCompatActivity
import com.kradwan.stepeer.view.SteeperView
import com.kradwan.stepeer.view.verticalStepper.SteeperView
import kotlinx.android.synthetic.main.activity_main.*


Expand All @@ -15,7 +15,7 @@ class MainActivity : AppCompatActivity(), SteeperView.SteeperHandler {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)

val order1 = Order(1, "Step1" , true)
val order1 = Order(1, "Step1", true)
order1.setChecked(true)
val adapter = OrderAdapter(
this, listOf(
Expand All @@ -26,9 +26,13 @@ class MainActivity : AppCompatActivity(), SteeperView.SteeperHandler {
)
)
steeper.setAdapter(adapter)
steeper2.setAdapter(adapter)
// Assign Controller
steeper.setController(this)
nextStep.setOnClickListener { steeper.nextStep() }
// steeper.setController(this)
nextStep.setOnClickListener {
steeper.nextStep()
steeper2.nextStep()
}

}

Expand Down
5 changes: 5 additions & 0 deletions app/src/main/res/drawable/ic_signal_wifi_0_bar_black_24dp.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<vector android:height="24dp" android:tint="#E92C3C"
android:viewportHeight="24.0" android:viewportWidth="24.0"
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillAlpha=".3" android:fillColor="#FF000000" android:pathData="M12.01,21.49L23.64,7c-0.45,-0.34 -4.93,-4 -11.64,-4C5.28,3 0.81,6.66 0.36,7l11.63,14.49 0.01,0.01 0.01,-0.01z"/>
</vector>
5 changes: 5 additions & 0 deletions app/src/main/res/drawable/ic_signal_wifi_4_bar_black_24dp.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<vector android:height="24dp" android:tint="#E92C3C"
android:viewportHeight="24.0" android:viewportWidth="24.0"
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#FF000000" android:pathData="M12.01,21.49L23.64,7c-0.45,-0.34 -4.93,-4 -11.64,-4C5.28,3 0.81,6.66 0.36,7l11.63,14.49 0.01,0.01 0.01,-0.01z"/>
</vector>
17 changes: 16 additions & 1 deletion app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,25 @@
tools:context=".MainActivity">


<com.kradwan.stepeer.view.SteeperView
<com.kradwan.stepeer.view.numberStepper.NumberStepperView
android:id="@+id/steeper"
android:layout_width="match_parent"
android:layout_height="wrap_content"

app:divider_color_checked="@color/colorAccent"
app:divider_color_unchecked="@android:color/black"
app:num_text_color_checked="#fffff2"
app:num_text_color_unchecked="@android:color/black"
android:padding="20dp"
/>



<com.kradwan.stepeer.view.verticalStepper.SteeperView
android:id="@+id/steeper2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:checked_color="@android:color/white"
android:padding="20dp"
/>

Expand Down
4 changes: 3 additions & 1 deletion app/src/main/res/layout/order_step.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@
android:layout_height="match_parent"
android:layout_marginStart="20dp"
android:layout_marginLeft="20dp"
android:paddingStart="20dp"
android:orientation="vertical"
android:paddingBottom="4dp">
android:paddingBottom="4dp"
android:paddingLeft="20dp">

<LinearLayout
android:layout_width="match_parent"
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/colors.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@
<color name="colorPrimary">#6200EE</color>
<color name="colorPrimaryDark">#3700B3</color>
<color name="colorAccent">#03DAC5</color>
<color name="ww">#ffffff</color>
</resources>
9 changes: 8 additions & 1 deletion stepeer/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ android {
buildToolsVersion "29.0.3"

defaultConfig {
minSdkVersion 15
minSdkVersion 16
targetSdkVersion 29
versionCode 1
versionName "1.0"
Expand All @@ -22,6 +22,13 @@ android {
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = "1.8"
}

}

Expand Down
2 changes: 1 addition & 1 deletion stepeer/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.kradwan.stepeer" />
package="com.kradwan.stepeer" />
21 changes: 21 additions & 0 deletions stepeer/src/main/java/com/kradwan/stepeer/model/Constants.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package com.kradwan.stepeer.model


class Constants {
companion object {
const val COLOR_CHECKED = "checked_color"
const val COLOR_UNCHECKED = "unchecked_color"

// For Number Step View

const val NUM_TEXT_COLOR_CHECKED = "NUM_TEXt_COLOR_CHECKED"
const val NUM_TEXT_COLOR_UNCHECKED = "NUM_TEXt_COLOR_UNCHECKED"

const val STEP_ICON_CHECKED = "STEP_ICON_CHECKED"
const val STEP_ICON_UNCHECKED = "STEP_ICON_UNCHECKED"

const val DIVIDER_COLOR_CHECKED = "DIVIDER_COLOR_CHECKED"
const val DIVIDER_COLOR_UNCHECKED = "DIVIDER_COLOR_UNCHECKED"

}
}
7 changes: 3 additions & 4 deletions stepeer/src/main/java/com/kradwan/stepeer/model/StepColor.kt
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,14 @@ import android.graphics.Color
data class StepColor(var color: Int) {

companion object {
const val COLOR_CHECKED = "checked_color"
const val COLOR_UNCHECKED = "unchecked_color"


val defaultColor = Color.parseColor("#1C8AFF")

fun default(): HashMap<String, StepColor> {
return hashMapOf(
Pair(COLOR_CHECKED, StepColor(defaultColor)),
Pair(COLOR_CHECKED, StepColor(defaultColor))
Pair(Constants.COLOR_CHECKED, StepColor(defaultColor)),
Pair(Constants.COLOR_CHECKED, StepColor(defaultColor))
)
}
}
Expand Down
10 changes: 9 additions & 1 deletion stepeer/src/main/java/com/kradwan/stepeer/model/StepDrawable.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@ import com.kradwan.stepeer.R
class StepDrawable(var drawable: Drawable) {

companion object {

const val DRAWABLE_CHECKED = "checked_drawable"
const val DRAWABLE_UNCHECKED = "unchecked_drawable"


private val defaultIconId = R.drawable.ic_star_black_24dp

fun default(context: Context): HashMap<String, StepDrawable> {
Expand All @@ -20,5 +22,11 @@ class StepDrawable(var drawable: Drawable) {
Pair(DRAWABLE_UNCHECKED, StepDrawable(drawable))
)
}

fun fromId(context: Context , id: Int) : StepDrawable{
return StepDrawable(ContextCompat.getDrawable(context , id)!!)
}
}
}
}

class StepResource(var id: Int)
Loading

0 comments on commit c74bdcc

Please sign in to comment.