Created
February 24, 2019 08:23
-
-
Save ShoMasegi/d9476a169368f4778835c92ba8665aba to your computer and use it in GitHub Desktop.
Epoxy_Layout
This file contains 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
class MainController internal constructor(): TypedEpoxyController<City>() { | |
interface Delegate { | |
fun onLinkClick(view: View) {} | |
fun onHeaderViewVisibilityChanged(percentVisibleHeight: Float) {} | |
} | |
var delegate: Delegate? = null | |
override fun buildModels(data: City?) { | |
data ?: return | |
headerView { | |
id("header view") | |
cityName(data.name) | |
description(data.description) | |
onVisibilityChanged { _, _, percentVisibleHeight, _, _, _ -> | |
delegate?.onHeaderViewVisibilityChanged(percentVisibleHeight) | |
} | |
} | |
linkView { | |
id("link view") | |
onLinkClick { view -> delegate?.onLinkClick(view) } | |
} | |
homeHeaderView { | |
id("home header view") | |
headerTitle("Popular Homes") | |
} | |
horizontalCarousel { | |
id("carousel") | |
numViewsToShowOnScreen(1.05f) | |
padding(Carousel.Padding.dp(12, 0)) | |
withModelsFrom(data.popularHomes) { | |
HomeItemBindingModel_() | |
.id(it.name) | |
.title(it.name) | |
.username(it.owner) | |
} | |
} | |
homeHeaderView { | |
id("home header view") | |
headerTitle("North End") | |
} | |
carousel { | |
id("carousel") | |
numViewsToShowOnScreen(1.05f) | |
padding(Carousel.Padding.dp(12, 0)) | |
withModelsFrom(data.popularHomes) { | |
HomeItemBindingModel_() | |
.id(it.name) | |
.title(it.name) | |
.username(it.owner) | |
} | |
} | |
footerView { | |
id("footer view") | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment