Tag: Aug

Unleashing Creativity with Custom Modifiers in Android Jetpack Compose | by Nirbhay Pherwani | Aug, 2023

Example 1 — Gradient Background Modifier Create a custom modifier that applies a gradient background to a composable. This can be used to provide a consistent visual theme across your app’s components. Gradient Background Custom Modifier fun Modifier.gradientBackground(colors: List<Color>): Modifier = composed {drawWithContent {drawRect(brush =…

Recreating UseCase: Embracing a Fluent and Fun Approach (2023) | by Stephen Siapno | Aug, 2023

After delving into functional programming, I began to investigate ways to enhance my use case. I initiated the code below, which shares similarities with my second article on Fluent and Fun Clean Architecture. fun placeOrderUseCase(orderRepository: OrderRepository) {if (orderRepository.isLoggedIn()) {val cart = orderRepository.getCart()if (cart.isNotEmpty()) {if (orderRepository.hasEnoughFunds(getTotalPrice()))…

MenuProvider API— Android. In this article, we will learn how to… | by Nav Singh | Aug, 2023

override fun onViewCreated(view: View, savedInstanceState: Bundle?) {super.onViewCreated(view, savedInstanceState)// Add options menu to the toolbarrequireActivity().addMenuProvider(object : MenuProvider {override fun onCreateMenu(menu: Menu, menuInflater: MenuInflater) {menuInflater.inflate(R.menu.main_menu, menu)}override fun onMenuItemSelected(menuItem: MenuItem): Boolean {return when (menuItem.itemId) {R.id.settings -> {true}else -> false}}}, viewLifecycleOwner)} Source link

Seamless Play of D&D — Implementing Drag and Drop Across Multiple Screens in Your Android App with Jetpack Compose | by Nirbhay Pherwani | Aug, 2023

The LongPressDraggable composable function is the foundation of our seamless D&D experience. It allows us to wrap any content (ex. horizontal pager) with dragging behavior, making it draggable upon a long-press gesture. Code @Composablefun LongPressDraggable(modifier: Modifier = Modifier,content: @Composable BoxScope.() -> Unit) {val state =…