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
| if (cardUuid != null && cardUuid.isNotEmpty()) { | |
| observe({ repository.getCard(cardUuid) }) { | |
| state.card = it | |
| state.loadingState = LoadingState.Loaded | |
| } | |
| } |
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
| when (val element = state.selectedElement) { | |
| null -> { | |
| SurfacePropertyControls(state.card.upSide) | |
| } | |
| else -> { | |
| ElementControls(element) | |
| } | |
| } |
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
| @Model | |
| data class CardDesignerState( | |
| var loadingState: LoadingState = LoadingState.Loaded, | |
| var card: MemoryCard = MemoryCard(), | |
| var selectedElement: MemoryCardElement? = null, | |
| var editElement: MemoryCardElement? = null, | |
| var layersDropDownOpen: Boolean = false | |
| ) |
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
| @Composable | |
| fun CardDesignerScreen(repository: MemoryCardRepository = get(), cardUuid: String? = null) { | |
| val state = remember { CardDesignerState() } | |
| if (cardUuid != null && cardUuid.isNotEmpty()) { | |
| observe({ repository.getCard(cardUuid) }) { | |
| state.card = it | |
| state.loadingState = LoadingState.Loaded | |
| } | |
| } |
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
| addRecyclerView( | |
| view = { inflater, parent -> | |
| inflater.inflate(R.layout.simple_carousel, parent, false) | |
| }, | |
| data = PaginatedLiveData<String> { | |
| hasMore = { loaded.size < 100 } | |
| nextPage = { | |
| delay(2000) | |
| listOf("Hello") | |
| } |
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
| val data = PaginatedLiveData<String> { | |
| hasMore = { loaded.size < 100 } | |
| nextPage = { | |
| listOf("Hello") | |
| } | |
| } |
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
| class InfiniteHelloJubakoActivity : AppCompatActivity() { | |
| override fun onCreate(savedInstanceState: Bundle?) { | |
| super.onCreate(savedInstanceState) | |
| setContentView(R.layout.activity_jubako_recycler) | |
| recyclerView.withJubako(this).load(HelloAssembler()) | |
| } | |
| class HelloAssembler : SimpleJubakoAssembler() { | |
| var counter = 0 |
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
| // Set page size to 1 so we can see it loading (descriptions are delayed by 500ms) | |
| recyclerView.withJubako(this, pageSize(1)).load { | |
| (0 until 100).forEach { i -> | |
| addRecyclerView( | |
| // | |
| // Inflate a view for our carousel | |
| // | |
| view = { inflater, parent -> | |
| inflater.inflate(R.layout.simple_carousel, parent, false) | |
| }, |
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
| companion object { | |
| fun getNumbersEnglish(): LiveData<List<String>> { | |
| return object : LiveData<List<String>>() { | |
| override fun onActive() { | |
| GlobalScope.launch(Dispatchers.IO) { | |
| delay(500) | |
| postValue(listOf("One", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight")) | |
| } | |
| } | |
| } |
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
| class SimpleCarouselsActivity : AppCompatActivity() { | |
| override fun onCreate(savedInstanceState: Bundle?) { | |
| super.onCreate(savedInstanceState) | |
| setContentView(R.layout.activity_jubako_recycler) | |
| // Set page size to 1 so we can see it loading (descriptions are delayed by 500ms) | |
| recyclerView.withJubako(this, pageSize(1)).load { | |
| (0 until 100).forEach { i -> | |
| addRecyclerView( |