Skip to content

Commit

Permalink
Added 'playground' to demo app
Browse files Browse the repository at this point in the history
  • Loading branch information
Droppers committed Mar 19, 2020
1 parent 62c0c79 commit 5f87378
Show file tree
Hide file tree
Showing 27 changed files with 777 additions and 67 deletions.
9 changes: 9 additions & 0 deletions .idea/misc.xml

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

27 changes: 16 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,9 @@ Download the app showcasing the examples: [demo.apk](./media/demo.apk)
## Getting started
<img src="./media/getting-started-demo.gif" width="400" />


Add the following dependency to your <b>build.gradle</b>:

```gradle
implementation 'nl.joery.animatedbottombar:library:1.0.4'
implementation 'nl.joery.animatedbottombar:library:1.0.5'
```

Define `AnimatedBottomBar` in your XML layout with custom attributes.
Expand Down Expand Up @@ -211,6 +209,17 @@ An overview of all configuration options. All options can also be accessed and s
<th>Description</th>
<th>Default</th>
</tr>
<tr>
<td><b>abb_selectedTabType</b></td>
<td>
Determines whether the icon or text should be shown when a tab has been selected.<br><br>
<b>icon</b><br>
<img src="./media/static/type-icon.png" width="240" /><br>
<b>text</b><br>
<img src="./media/static/type-text.png" width="240" /><br>
</td>
<td>icon</td>
</tr>
<tr>
<td><b>abb_tabColor</b></td>
<td>The color of the icon or text when the tab is not selected.</td>
Expand Down Expand Up @@ -258,15 +267,11 @@ An overview of all configuration options. All options can also be accessed and s
<th>Default</th>
</tr>
<tr>
<td><b>abb_selectedTabType</b></td>
<td><b>abb_animationDuration</b></td>
<td>
Determines whether the icon or text should be shown when a tab has been selected.<br><br>
<b>icon</b><br>
<img src="./media/static/type-icon.png" width="240" /><br>
<b>text</b><br>
<img src="./media/static/type-text.png" width="240" /><br>
The duration of all animations, including the indicator animation.
</td>
<td>icon</td>
<td>400</td>
</tr>
<tr>
<td><b>abb_tabAnimation</b></td>
Expand All @@ -287,7 +292,7 @@ An overview of all configuration options. All options can also be accessed and s
The enter and exit animation style of the selected tab.<br><br>
<b>none</b><br>
<img src="./media/anim-active-none.gif" width="240" /><br>
<b>slide</b<br><br>
<b>slide</b><br>
<img src="./media/anim-active-slide.gif" width="240" /><br>
<b>fade</b><br>
<img src="./media/anim-active-fade.gif" width="240" /><br>
Expand Down
2 changes: 1 addition & 1 deletion demo/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ dependencies {
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'androidx.navigation:navigation-fragment-ktx:2.2.1'
implementation 'androidx.navigation:navigation-ui-ktx:2.2.1'
implementation 'com.google.android:flexbox:2.0.1'
implementation 'com.jaredrummler:colorpicker:1.1.0'
implementation project(path: ':library')
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
Expand Down
5 changes: 5 additions & 0 deletions demo/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@
android:name=".ViewPagerActivity"
android:label="ViewPagerActivity"
android:theme="@style/AppTheme.NoActionBar" />

<activity
android:name=".playground.PlaygroundActivity"
android:label="ConfiguratorActivity"
android:theme="@style/AppTheme.NoActionBar" />
</application>

</manifest>
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package nl.joery.demo.animatedbottombar

import android.content.res.Resources
import kotlin.math.roundToInt

internal val Int.dp: Int
get() = (this / Resources.getSystem().displayMetrics.density).roundToInt()
internal val Int.px: Int
get() = (this * Resources.getSystem().displayMetrics.density).roundToInt()
15 changes: 13 additions & 2 deletions demo/src/main/java/nl/joery/demo/animatedbottombar/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,23 @@ import android.util.Log
import androidx.appcompat.app.AppCompatActivity
import kotlinx.android.synthetic.main.activity_main.*
import nl.joery.animatedbottombar.AnimatedBottomBar
import nl.joery.demo.animatedbottombar.playground.PlaygroundActivity
import java.lang.reflect.Type


class MainActivity : AppCompatActivity() {

private fun setProperty(instance: Any, property: String, value: Any) {
val methodName = "set" + property.capitalize()
val method = instance.javaClass.methods.toList().find { it.name == methodName }
method?.invoke(instance, value)
}

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)

val bottomBars = arrayOf(bottom_bar, bottom_bar2, bottom_bar3, bottom_bar4)
val bottomBars = arrayOf(bottom_bar, bottom_bar2, bottom_bar3, bottom_bar4, bottom_bar5)

bottom_bar.setOnTabSelectListener(object : AnimatedBottomBar.OnTabSelectListener {
override fun onTabSelected(
Expand Down Expand Up @@ -61,11 +69,14 @@ class MainActivity : AppCompatActivity() {
for (bottomBar in bottomBars) {
bottomBar.selectTabAt(bottom_bar.tabCount - 1)
}
bottom_bar.tabColor = Color.RED
}

open_view_pager.setOnClickListener {
startActivity(Intent(this, ViewPagerActivity::class.java))
}

open_playground.setOnClickListener {
startActivity(Intent(this, PlaygroundActivity::class.java))
}
}
}
15 changes: 15 additions & 0 deletions demo/src/main/java/nl/joery/demo/animatedbottombar/Utils.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package nl.joery.demo.animatedbottombar

internal object Utils {
fun getProperty(instance: Any, property: String): Any? {
val methodName = "get" + property.capitalize()
val method = instance.javaClass.methods.toList().find { it.name == methodName }
return method?.invoke(instance)
}

fun setProperty(instance: Any, property: String, value: Any) {
val methodName = "set" + property.capitalize()
val method = instance.javaClass.methods.toList().find { it.name == methodName }
method?.invoke(instance, value)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
package nl.joery.demo.animatedbottombar.playground

import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import androidx.recyclerview.widget.LinearLayoutManager
import kotlinx.android.synthetic.main.activity_playground.*
import nl.joery.animatedbottombar.AnimatedBottomBar
import nl.joery.demo.animatedbottombar.R
import nl.joery.demo.animatedbottombar.playground.properties.*


class PlaygroundActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_playground)

val properties = ArrayList<Property>()
properties.add(
CategoryProperty(
"General"
)
)
properties.add(
ColorProperty(
"backgroundColor"
)
)
properties.add(
CategoryProperty(
"Tab appearance"
)
)
properties.add(
EnumProperty(
"selectedTabType",
AnimatedBottomBar.TabType::class.java
)
)
properties.add(
ColorProperty(
"tabColor"
)
)
properties.add(
ColorProperty(
"tabColorSelected"
)
)
properties.add(
BooleanProperty(
"rippleEnabled"
)
)
properties.add(
ColorProperty(
"rippleColor"
)
)

properties.add(
CategoryProperty(
"Animations"
)
)
properties.add(
IntegerProperty(
"animationDuration"
)
)
properties.add(
EnumProperty(
"tabAnimation",
AnimatedBottomBar.TabAnimation::class.java
)
)
properties.add(
EnumProperty(
"tabAnimationSelected",
AnimatedBottomBar.TabAnimation::class.java
)
)

properties.add(
CategoryProperty(
"Indicator appearance"
)
)
properties.add(
ColorProperty(
"indicatorColor"
)
)
properties.add(
IntegerProperty(
"indicatorHeight",
true
)
)
properties.add(
IntegerProperty(
"indicatorMargin",
true
)
)
properties.add(
EnumProperty(
"indicatorAppearance",
AnimatedBottomBar.IndicatorAppearance::class.java
)
)
properties.add(
EnumProperty(
"indicatorLocation",
AnimatedBottomBar.IndicatorLocation::class.java
)
)
properties.add(
EnumProperty(
"indicatorAnimation",
AnimatedBottomBar.IndicatorAnimation::class.java
)
)

recycler.layoutManager =
LinearLayoutManager(applicationContext, LinearLayoutManager.VERTICAL, false)
recycler.adapter = PropertyAdapter(bottom_bar, properties)
}
}
Loading

0 comments on commit 5f87378

Please sign in to comment.