Last active
August 29, 2015 14:02
-
-
Save stanch/3f60216b4495d80b28bd to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// -- in the activity: | |
var navSlot = slot[ListView] | |
var drawerSlot = slot[DrawerLayout] | |
// -- in onCreate: | |
// ListView tweaks | |
def checkItem(pos: Int) = Tweak[ListView](_.setItemChecked(pos, true)) | |
val singleNoDivider = Tweak[ListView] { lv ⇒ | |
lv.setDividerHeight(0) | |
lv.setChoiceMode(AbsListView.CHOICE_MODE_SINGLE) | |
} | |
// Drawer tweaks | |
val closeDrawers = Tweak[DrawerLayout](_.closeDrawers()) | |
val drawerShadow = Tweak[DrawerLayout](_.setDrawerShadow(R.drawable.drawer_shadow, Gravity.START)) | |
// navigation | |
val nav = w[ListView] <~ | |
layoutParams[DrawerLayout](240 dp, MATCH_PARENT, Gravity.START) <~ | |
Bg.color(Color.parseColor("#FF363636")) <~ | |
singleNoDivider <~ | |
adapter.tweak <~ | |
FuncOn.itemClick[ListView] { (parent: AdapterView[_], view: View, pos: Int, id: Long) ⇒ | |
Ui(Log.i("Uf", adapter.getItem(pos).text)) ~ | |
(navSlot <~ checkItem(pos)) ~ | |
(drawerSlot <~ closeDrawers) | |
} <~ | |
wire(navSlot) | |
// f[...].framed returns a FrameLayout | |
// there is probably no point in wrapping | |
// it into an additional LinearLayout | |
val view = f[PrefsFragment].framed(Id.provinceOverview, Tag.provinceOverview) <~ | |
layoutParams[DrawerLayout](MATCH_PARENT, WRAP_CONTENT) | |
// the drawer | |
val drawer = l[DrawerLayout](view, nav) <~ | |
drawerShadow <~ | |
wire(drawerSlot) | |
setContentView(getUi(drawer)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment