/
MainActivity.kt
57 lines (48 loc) · 2.1 KB
/
MainActivity.kt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
package com.etebarian.meowbottomnavigaion
import android.graphics.Typeface
import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import com.etebarian.meowbottomnavigation.MeowBottomNavigation
import kotlinx.android.synthetic.main.activity_main.*
class MainActivity : AppCompatActivity() {
companion object {
private const val ID_HOME = 1
private const val ID_EXPLORE = 2
private const val ID_MESSAGE = 3
private const val ID_NOTIFICATION = 4
private const val ID_ACCOUNT = 5
}
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
tv_selected.typeface = Typeface.createFromAsset(assets, "fonts/SourceSansPro-Regular.ttf")
bottomNavigation.add(MeowBottomNavigation.Model(ID_HOME, R.drawable.ic_home))
bottomNavigation.add(MeowBottomNavigation.Model(ID_EXPLORE, R.drawable.ic_explore))
bottomNavigation.add(MeowBottomNavigation.Model(ID_MESSAGE, R.drawable.ic_message))
bottomNavigation.add(MeowBottomNavigation.Model(ID_NOTIFICATION, R.drawable.ic_notification))
bottomNavigation.add(MeowBottomNavigation.Model(ID_ACCOUNT, R.drawable.ic_account))
bottomNavigation.setCount(ID_NOTIFICATION, "3")
bottomNavigation.setOnShowListener {
val name = when (it.id) {
ID_HOME -> "HOME"
ID_EXPLORE -> "EXPLORE"
ID_MESSAGE -> "MESSAGE"
ID_NOTIFICATION -> "NOTIFICATION"
ID_ACCOUNT -> "ACCOUNT"
else -> ""
}
tv_selected.text = "$name page is selected"
}
bottomNavigation.setOnClickMenuListener {
val name = when (it.id) {
ID_HOME -> "HOME"
ID_EXPLORE -> "EXPLORE"
ID_MESSAGE -> "MESSAGE"
ID_NOTIFICATION -> "NOTIFICATION"
ID_ACCOUNT -> "ACCOUNT"
else -> ""
}
// Toast.makeText(this, "$name is clicked", Toast.LENGTH_SHORT).show()
}
}
}