# xorum.io - Medium

Mobile iOS - Medium

This is one page of public article previews, not the complete archive. Follow Next page to continue. Summaries are not the original full articles.

## Customizing Material Theme with Jetpack Compose

DevFeed: [Customizing Material Theme with Jetpack Compose](<https://devfeed.tech/articles/customizing-material-theme-with-jetpack-compose-24732.md>)

Original publisher: [Read original article](<https://medium.com/xorum-io/customizing-material-theme-with-jetpack-compose-fd07e386c71?source=rss----92bb7980cc9f---4>)

Author: Yev Kanivets

Published: 2022-02-06T19:19:30Z

Content type: tutorial

Language: en

Sources: [xorum.io - Medium](<https://devfeed.tech/sources/xorum-io-medium.md>)

Topics: [Jetpack Compose](<https://devfeed.tech/topics/jetpack-compose.md>), [Compose](<https://devfeed.tech/topics/compose.md>), [Android](<https://devfeed.tech/topics/android.md>), [Mobile](<https://devfeed.tech/topics/mobile.md>), [ui](<https://devfeed.tech/topics/ui.md>), [XML](<https://devfeed.tech/topics/xml.md>), [Library](<https://devfeed.tech/topics/library.md>), [Dark Mode](<https://devfeed.tech/topics/dark-mode.md>)

Tags: [android](<https://devfeed.tech/tags/android.md>), [android-development](<https://devfeed.tech/tags/android-development.md>), [compose](<https://devfeed.tech/tags/compose.md>), [dark-mode](<https://devfeed.tech/tags/dark-mode.md>), [jetpack-compose](<https://devfeed.tech/tags/jetpack-compose.md>), [library](<https://devfeed.tech/tags/library.md>), [mobile](<https://devfeed.tech/tags/mobile.md>), [mobile-app-development](<https://devfeed.tech/tags/mobile-app-development.md>), [mobile-development](<https://devfeed.tech/tags/mobile-development.md>), [ui](<https://devfeed.tech/tags/ui.md>), [xml](<https://devfeed.tech/tags/xml.md>)

### AI overview

This tutorial explains how to define and customize themes in Jetpack Compose for an Android application. It covers composable themes, color and typography systems, light and dark mode changes, XML theme compatibility, and the AppCompat Compose Theme Adapter during a transition from XML.

### Source excerpt

When Jetpack Compose went stable in July 2021, many Android developers started experimenting with it to see if it's mature enough to be used in production. Spoiler alert: it's more than ready and more delightful than XML! At the same time, we decided to redesign our mobile app called Codeforces WatchR, which is available on both iOS and Android. So it was a no-brainer to execute this redesign for the Android app using Jetpack Compose. Redesigned Codeforces WatchR app in the dark mode This article will describe the first step in our Jetpack Compose journey -- defining and using the Theme. Jetpack Compose theme, to be exact, since, as it's turned out, XML themes aren't fully compatible with Jetpack Compose. @Composable Theme As you already know, Jetpack Compose is built on the concept of Composable functions. It means that our whole UI is declared as a hierarchy of functions capable of rendering all possible views for all possible states. The theme doesn't make an exception to this rule. If we think about it, colors and fonts can easily change while the application is on the screen. Hence we need to recompose our UI to reflect the change (light/dark mode change, for example). So it makes total sense to have a theme as a Composable function. Even though there is a library that provides partial compatibility between XML and Jetpack Compose themes, the conversion is far from perfect. So we decided to support two sets of themes for the transition period. The AppCompat Compose Theme Adapter library allows you to easily re-use AppCompat XML themes for theming in Jetpack Compose. It creates a MaterialTheme with the color and typography values from the context's theme.Theme Structure As discussed above, the theme is a Composable function. It takes the content to be themed and returns ... nothing. But it provides an adequately configured theme object to the content by using CompositionLocalProvider. In the Theme object, we get a number of systems. There are color, typography, and

## Saving Christmas with Kotlin

DevFeed: [Saving Christmas with Kotlin](<https://devfeed.tech/articles/saving-christmas-with-kotlin-24739.md>)

Original publisher: [Read original article](<https://medium.com/xorum-io/saving-christmas-with-kotlin-e3e239b6fe3d?source=rss----92bb7980cc9f---4>)

Author: Yev Kanivets

Published: 2022-01-29T12:24:13Z

Content type: tutorial

Language: en

Sources: [xorum.io - Medium](<https://devfeed.tech/sources/xorum-io-medium.md>)

Topics: [Kotlin](<https://devfeed.tech/topics/kotlin.md>), [Advent of Code](<https://devfeed.tech/topics/advent-of-code.md>), [competitive-programming](<https://devfeed.tech/topics/competitive-programming.md>), [Programming](<https://devfeed.tech/topics/programming.md>)

Tags: [advent-of-code](<https://devfeed.tech/tags/advent-of-code.md>), [algorithms](<https://devfeed.tech/tags/algorithms.md>), [competitive-programming](<https://devfeed.tech/tags/competitive-programming.md>), [data-structures](<https://devfeed.tech/tags/data-structures.md>), [kotlin](<https://devfeed.tech/tags/kotlin.md>), [programming](<https://devfeed.tech/tags/programming.md>)

### AI overview

A developer describes using Kotlin to complete all 50 challenges of Advent of Code 2021 over 25 days and shares links to a four-part series of Kotlin ideas and solutions. The article also discusses Kotlin's suitability for competitive programming.

### Source excerpt

It's been a month since I've saved a Christmas. Now, I feel it's time to tell you exactly how I did it. I wasn't alone, though. My faithful companion was crucial to the success of my mission. Yes, Kotlin, I'm talking about you. But let's return to the day when it all started: I was minding my own business on a ship at sea when the overboard alarm goes off! I rushed to see if I could help. Apparently, one of the Elves tripped and accidentally sent the sleigh keys flying into the ocean!Before I knew it, I was inside a submarine the Elves kept ready for situations like this. It was covered in Christmas lights (because of course it is), and it even had an experimental antenna that should be able to track the keys if I could boost its signal strength high enough; there was a little meter that indicated the antenna's signal strength by displaying 0-50 stars.My instincts told me that in order to save Christmas, I needed to get all fifty stars by December 25th. It turns out that 200K+ other people happened to get into a similar situation. You can still see the complete log of our adventures on this site. Some people call it the "Advent of Code" and say it happens yearly. My way down It took me 25 days and 50 challenges (yeah, two challenges per day) to get those sleigh keys and save the Christmas. Every day at 7 a.m. (UTC+2), we reached a new milestone that unlocked two more challenges to solve. Most of them took from one to two hours to get done. Thank God there was a pretty good Internet connection in my submarine (I could even work remotely and didn't need to take a vacation for such a noble task), so I still had plenty of time to share my ideas and solutions: Ideas and Solutions for Advent of Code 2021 in Kotlin -- Part 1/4 Ideas and Solutions for Advent of Code 2021 in Kotlin -- Part 2/4 Ideas and Solutions for Advent of Code 2021 in Kotlin -- Part 3/4 Ideas and Solutions for Advent of Code 2021 in Kotlin -- Part 4/4 Spending 25 days locked in a submarine and solving chall

## Ideas and Solutions for Advent of Code 2021 in Kotlin -- Part 4/4

DevFeed: [Ideas and Solutions for Advent of Code 2021 in Kotlin -- Part 4/4](<https://devfeed.tech/articles/ideas-and-solutions-for-advent-of-code-2021-in-kotlin-part-4-4-24736.md>)

Original publisher: [Read original article](<https://medium.com/xorum-io/ideas-and-solutions-for-advent-of-code-2021-in-kotlin-part-4-4-75c207692bdb?source=rss----92bb7980cc9f---4>)

Author: Yev Kanivets

Published: 2021-12-26T14:39:41Z

Content type: tutorial

Language: en

Sources: [xorum.io - Medium](<https://devfeed.tech/sources/xorum-io-medium.md>)

Topics: [Advent of Code](<https://devfeed.tech/topics/advent-of-code.md>), [Kotlin](<https://devfeed.tech/topics/kotlin.md>), [3D](<https://devfeed.tech/topics/3d.md>), [pixel](<https://devfeed.tech/topics/pixel.md>)

Tags: [3d](<https://devfeed.tech/tags/3d.md>), [advent-of-code](<https://devfeed.tech/tags/advent-of-code.md>), [algorithms](<https://devfeed.tech/tags/algorithms.md>), [array](<https://devfeed.tech/tags/array.md>), [beacon](<https://devfeed.tech/tags/beacon.md>), [competitive-programming](<https://devfeed.tech/tags/competitive-programming.md>), [data-structures](<https://devfeed.tech/tags/data-structures.md>), [kotlin](<https://devfeed.tech/tags/kotlin.md>), [pixel](<https://devfeed.tech/tags/pixel.md>), [points](<https://devfeed.tech/tags/points.md>), [scanner](<https://devfeed.tech/tags/scanner.md>), [solutions](<https://devfeed.tech/tags/solutions.md>)

### AI overview

A Kotlin walkthrough of Advent of Code 2021 tasks 19 and 20. It explains matching rotated point sets in 3D space using beacon intersections, then enhancing an image represented as a 2D pixel array while accounting for infinite padding and changing background values.

### Source excerpt

Ideas and Solutions for Advent of Code 2021 in Kotlin -- Part 4/4 The final week of Advent of Code was, obviously, the most challenging one. To be honest I was close to being happy with just a silver star multiple times. But at the end, tenacity made the difference. 50 stars are mine this year 🌟 Ideas and Solutions for tasks 1 to 6 can be found here, for tasks 7 to 12 -- here, for tasks 13 to 18 -- here. Day 19: Beacon Scanner We are provided with several sets of points in 3D space. Those points are rotated differently in each set, so we don't know how X, Y, and Z coordinates are aligned between sets. Our goal is to merge all those sets into a single group by matching points (sub-task one) and find the most significant distance between coordinate origins after they are matched. Here is the complete task. This is an exciting task! I've initially learned about this idea from The Three-Body Problem book, which introduced the concept of locating any star in the Universe by the distances from a few nearest stars -- in our case, "a few" means 12. Think about it as a star fingerprint ;) So to match the sets of points in 3D space, we need: check all combinations of rotations in three dimensions (in our task, the step is 90 degrees, so there are 48 combinations) for the whole set assume that each pair of points from the first set and the second set is an intersection by adjusting all points to that pair check how many adjusted points intersect between the two sets if there are more than 12 intersections, voilá -- the sets are matched The embedded Kotlin's functions like intersect, map, and mapNotNull make the solution, even for such a complex task, elegant. Day 20: Trench Map This image-enhancing task provides us with the initial photo (2D array of black and white pixels), and enhancing guidance (1D array). Enhancing happens in steps, where for each pixel, we found its enhanced value as a result of a combination of itself + all eight adjacent pixels. Here is the complete task. We

## Ideas and Solutions for Advent of Code 2021 in Kotlin -- Part 3/4

DevFeed: [Ideas and Solutions for Advent of Code 2021 in Kotlin -- Part 3/4](<https://devfeed.tech/articles/ideas-and-solutions-for-advent-of-code-2021-in-kotlin-part-3-4-24735.md>)

Original publisher: [Read original article](<https://medium.com/xorum-io/ideas-and-solutions-for-advent-of-code-2021-in-kotlin-part-3-4-dbfd577703cc?source=rss----92bb7980cc9f---4>)

Author: Yev Kanivets

Published: 2021-12-26T14:22:49Z

Content type: tutorial

Language: en

Sources: [xorum.io - Medium](<https://devfeed.tech/sources/xorum-io-medium.md>)

Topics: [Advent of Code](<https://devfeed.tech/topics/advent-of-code.md>), [Kotlin](<https://devfeed.tech/topics/kotlin.md>), [Programming](<https://devfeed.tech/topics/programming.md>), [competitive-programming](<https://devfeed.tech/topics/competitive-programming.md>), [Graphs](<https://devfeed.tech/topics/graphs.md>), [math](<https://devfeed.tech/topics/math.md>)

Tags: [advent-of-code](<https://devfeed.tech/tags/advent-of-code.md>), [algorithms](<https://devfeed.tech/tags/algorithms.md>), [array](<https://devfeed.tech/tags/array.md>), [code](<https://devfeed.tech/tags/code.md>), [competitive-programming](<https://devfeed.tech/tags/competitive-programming.md>), [data-structures](<https://devfeed.tech/tags/data-structures.md>), [graph-theory](<https://devfeed.tech/tags/graph-theory.md>), [kotlin](<https://devfeed.tech/tags/kotlin.md>), [memory](<https://devfeed.tech/tags/memory.md>), [pairs](<https://devfeed.tech/tags/pairs.md>), [programming](<https://devfeed.tech/tags/programming.md>), [solutions](<https://devfeed.tech/tags/solutions.md>), [time](<https://devfeed.tech/tags/time.md>)

### AI overview

This article presents high-level ideas and Kotlin solutions for Advent of Code 2021 tasks from days 13 to 15. It discusses folding a 2D array, modeling polymer growth with dynamic programming, and finding a shortest path in a 2D array.

### Source excerpt

Ideas and Solutions for Advent of Code 2021 in Kotlin -- Part 3/4 The third week of Advent of Code requires more time and even some competitive programming knowledge like dynamic programming and graph theory. In this article, I share some high-level ideas and my solutions if you need a hint or a few to get that gold star. Ideas and Solutions for tasks 1 to 6 can be found here, for tasks 7 to 12 -- here. Day 13: Transparent Origami The 2D array contains two types of symbols -- . and #. This array can be folded horizontally and vertically multiple times. When folding # symbols replace . symbols, but not vice versa. Here is the complete task. This is a modeling task, which you can do on the 2D array itself, but the possible range is quite large, so you can hit a memory limit. The smarter solution would be to fold the # symbols (the initial input, actually). Such folding can be done with Kotlin's fold function using the initial value of # symbol positions and mapNotNull, which mirrors X or Y coordinates depending on the fold direction. Here is my solution. Day 14: Extended Polymerization We get the initial string (template) consisting of uppercase letters, which describe the initial state of the polymer. The list of pair insertion rules allows growing the initial polymer step by step exponentially. We need to model this growth during 10 (first sub-task) and 40 (second sub-task) steps. Here is the complete task. The first sub-task can be solved just by modeling, but even 20 steps are too long and require too much memory and time. The (much) better solution is based on dynamic programming. You can easily see that every pair grows independently of others (new elements are always added inside the pair). It means that the solution can be found for each pair separately and then combined. It doesn't speed up things sufficiently though. But makes the solution easier? Yes. Now, let's grow each pair step by step. So at each step, every pair (usually) produces two more pairs, which h

## Ideas and Solutions for Advent of Code 2021 in Kotlin -- Part 2/4

DevFeed: [Ideas and Solutions for Advent of Code 2021 in Kotlin -- Part 2/4](<https://devfeed.tech/articles/ideas-and-solutions-for-advent-of-code-2021-in-kotlin-part-2-4-24734.md>)

Original publisher: [Read original article](<https://medium.com/xorum-io/ideas-and-solutions-for-advent-of-code-2021-in-kotlin-part-2-4-5079d5066653?source=rss----92bb7980cc9f---4>)

Author: Yev Kanivets

Published: 2021-12-18T19:56:15Z

Content type: tutorial

Language: en

Sources: [xorum.io - Medium](<https://devfeed.tech/sources/xorum-io-medium.md>)

Topics: [Advent of Code](<https://devfeed.tech/topics/advent-of-code.md>), [Kotlin](<https://devfeed.tech/topics/kotlin.md>), [Algorithms, Complexity](<https://devfeed.tech/topics/algorithms-complexity.md>), [Data structures](<https://devfeed.tech/topics/data-structures.md>), [Graphs](<https://devfeed.tech/topics/graphs.md>)

Tags: [advent-of-code](<https://devfeed.tech/tags/advent-of-code.md>), [algorithms](<https://devfeed.tech/tags/algorithms.md>), [algorithms-and-data-structures](<https://devfeed.tech/tags/algorithms-and-data-structures.md>), [competetive-programming](<https://devfeed.tech/tags/competetive-programming.md>), [data-structures](<https://devfeed.tech/tags/data-structures.md>), [graph](<https://devfeed.tech/tags/graph.md>), [kotlin](<https://devfeed.tech/tags/kotlin.md>)

### AI overview

This article presents ideas and partial solutions for Advent of Code 2021 tasks 7 through 9 in Kotlin. It discusses minimizing alignment cost for an array, decoding malfunctioning seven-segment displays, and locating low points and basins in a two-dimensional digit map using breadth-first or depth-first search.

### Source excerpt

Ideas and Solutions for Advent of Code 2021 in Kotlin -- Part 2/4 The second week of Advent of Code introduces us to more difficult tasks, some of which require fundamental knowledge in algorithms and data structures. Do you need an idea or a tiny hint to get that gold star? Here we are, the second six tasks. What's special about this article? I won't be sharing the complete editorial, but the key idea only, so you can still solve the task by yourself. And if you need more guidance, there is a source code linked. Ideas and Solutions for tasks 1 to 6 can be found here. Day 7: The Treachery of Whales We are provided with an array of different values, which we need to align to a single value with the lowest possible cost. The cost function is different for the two sub-tasks. Here is the complete task. The solution is as simple as checking all possible values to align from min value to max value in the original array and choosing one with the lowest cost. The cost function (array of cost of moving value by 0, 1, 2 ... N) can be passed as an argument to your solution. Here is my solution. Day 8: Seven Segment Search Malfunctioning seven-segment digital display sends us some signals, which we need to decode knowing the representation of the full set of digits and which segments are used for each entry. Here is the complete task. The first sub-task requires you to parse only four digits -- 1, 4, 7, 8. All of them are unique in terms of segments used, so guessing them is relatively simple. The second sub-task asks you to guess the other 6 digits. I'm sure there are many different sequences in which you can guess them, but in my case, I've done the following: segments b and d are present in digit 4, but not in digit 1 segment bd is present only in digit 5 between all digits that use 5 segments then we can decode segments c and f by looking on the intersection of digits 1 and 5 using newly discovered segments, we find digits 3, 2, and 6 segment d can be found as an intersection o

## Ideas and Solutions for Advent of Code 2021 in Kotlin -- Part 1/4

DevFeed: [Ideas and Solutions for Advent of Code 2021 in Kotlin -- Part 1/4](<https://devfeed.tech/articles/ideas-and-solutions-for-advent-of-code-2021-in-kotlin-part-1-4-24733.md>)

Original publisher: [Read original article](<https://medium.com/xorum-io/ideas-and-solutions-for-advent-of-code-2021-in-kotlin-part-1-4-9a16d9e3bd57?source=rss----92bb7980cc9f---4>)

Author: Yev Kanivets

Published: 2021-12-13T15:31:55Z

Content type: tutorial

Language: en

Sources: [xorum.io - Medium](<https://devfeed.tech/sources/xorum-io-medium.md>)

Topics: [Advent of Code](<https://devfeed.tech/topics/advent-of-code.md>), [Kotlin](<https://devfeed.tech/topics/kotlin.md>), [Programming](<https://devfeed.tech/topics/programming.md>), [Code](<https://devfeed.tech/topics/code.md>)

Tags: [advent-of-code](<https://devfeed.tech/tags/advent-of-code.md>), [algorithms](<https://devfeed.tech/tags/algorithms.md>), [array](<https://devfeed.tech/tags/array.md>), [commands](<https://devfeed.tech/tags/commands.md>), [competitive-programming](<https://devfeed.tech/tags/competitive-programming.md>), [data-structures](<https://devfeed.tech/tags/data-structures.md>), [kotlin](<https://devfeed.tech/tags/kotlin.md>), [map](<https://devfeed.tech/tags/map.md>), [programming](<https://devfeed.tech/tags/programming.md>), [solutions](<https://devfeed.tech/tags/solutions.md>)

### AI overview

A Kotlin-focused walkthrough of the first six Advent of Code 2021 puzzles. It explains the key solution ideas for the early tasks, including array comparisons, submarine movement modeling, and binary-number calculations, while linking to source code for further guidance.

### Source excerpt

Ideas and Solutions for Advent of Code 2021 in Kotlin -- Part 1/4 There are so many things to do before Christmas, so I was always wondering how people find extra time to solve a daily programming puzzle of Advent of Code. Well, this year I'm one of those lucky folks with a bunch of spare time. Advent of Code is an annual event of Christmas-oriented programming challenges started December 2015. Every year since then, on the first day of December, a programming puzzle is published every day for twenty-four days. You can solve the puzzle and provide an answer using the language of your choice. Extra reason by JetBrains in the form of the giveaway of some Kotlin care packages has certainly contributed to my motivation. But what's the point of solving tasks without sharing your ideas and solutions with the community ;) So here we are, the first six tasks. What's special about this article? I won't be sharing the complete editorial, but the key idea only, so you can still solve the task by yourself. And if you need more guidance, there is a source code linked. Day 1: Sonar Sweep We are given an array of heights of a seafloor. We need to calculate the number of times heights (sub-task one) and sliding triples of heights (sub-task two) are increasing. Complete task is here. To solve both tasks we need to go from left to right and compare the previous element (or sliding triple) to the current one. That's pretty simple, but challenge yourself to craft the beautiful code. In Kotlin we may consider using drop and foldIndexed functions for this. Here is my solution. Day 2: Dive! The submarine can move in 2D space (horizontal position and depth) controlled by the set of commands. Moves mechanics are slightly different between subtasks, but the overall approach and goal are the same -- model moves and find the resulting position. Complete task is here. The first sub-task can be solved by folding horizontal position and depth changes, but the second sub-task should be modeled exact

## KMM Oddity #2: Initialization order of top-level properties

DevFeed: [KMM Oddity #2: Initialization order of top-level properties](<https://devfeed.tech/articles/kmm-oddity-2-initialization-order-of-top-level-properties-24738.md>)

Original publisher: [Read original article](<https://medium.com/xorum-io/kmm-oddity-2-initialization-order-of-top-level-properties-edd11ec350a2?source=rss----92bb7980cc9f---4>)

Author: Yev Kanivets

Published: 2021-11-15T15:44:44Z

Content type: tutorial

Language: en

Sources: [xorum.io - Medium](<https://devfeed.tech/sources/xorum-io-medium.md>)

Topics: [Kotlin Multiplatform](<https://devfeed.tech/topics/kotlin-multiplatform.md>), [kotlin-native](<https://devfeed.tech/topics/kotlin-native.md>), [Android](<https://devfeed.tech/topics/android.md>), [iOS](<https://devfeed.tech/topics/ios.md>), [Redux](<https://devfeed.tech/topics/redux.md>)

Tags: [android](<https://devfeed.tech/tags/android.md>), [ios](<https://devfeed.tech/tags/ios.md>), [kmm](<https://devfeed.tech/tags/kmm.md>), [kmp](<https://devfeed.tech/tags/kmp.md>), [kotlin](<https://devfeed.tech/tags/kotlin.md>), [kotlin-multiplatform](<https://devfeed.tech/tags/kotlin-multiplatform.md>), [kotlin-native](<https://devfeed.tech/tags/kotlin-native.md>), [mobile](<https://devfeed.tech/tags/mobile.md>), [redux](<https://devfeed.tech/tags/redux.md>)

### AI overview

This article examines an initialization-order oddity involving Kotlin top-level properties in Kotlin Multiplatform Mobile. It compares behavior when dependent properties are declared in one file or separate files, including differing initialization sequences in Android and iOS applications.

### Source excerpt

Kotlin Multiplatform goes Beta this Spring (2022), so it removes all major hassles (Memory Model and Kotlin/Native concurrency, for example) which KMP developers face. But even with the Stable version (hopefully by the end of 2022), we are going to have a certain number of minor issues or simply oddities while using this relatively young technology (especially with Kotlin/Native). Most of them are already reported in Kotlin's YouTrack, so go check it before stressing out. I've encountered many such issues myself for the past two years with Kotlin Multiplatform Mobile. In this series of articles, I'll share my favorite oddities of KMM with explanations and workarounds (if possible). Top-level properties In Kotlin, we are able to declare top-level (or global) variables, which are accessible from anywhere in the given module or even the whole application. For example, let's say that we have a data class Order: https://medium.com/media/a25461d8a0d6b9b56cb9dd912331f029/href This class has a name and an optional dependency to another Order. The init block is here to help us understand when it's initialized. While it's generally a bad idea to declare instances of such class as a global variable, we are going to do it twice in the same file for now. As you can see, orderB depends on orderA, so it must be initialized first. https://medium.com/media/b290af047e51b599b293e0aca4e01fee/href It's done for demo purposes here, but a real application can require it as well (think about store, reducers, and middleware from Redux architectural pattern, which are all global variables by default). When run, we see the expected order of initialization in logs of both, Android and iOS applications: Init orderA / Init orderB. Single-file initialization order When we have all connected top-level variables in the same file, things are simple. To check it, swap the orderA with orderB. https://medium.com/media/25fc0522be792d1cfa0da6cbd4ec7f90/href Do you see? Android Studio will complain about

## KMM Oddity #1: Interface methods with underscores

DevFeed: [KMM Oddity #1: Interface methods with underscores](<https://devfeed.tech/articles/kmm-oddity-1-interface-methods-with-underscores-24737.md>)

Original publisher: [Read original article](<https://medium.com/xorum-io/kmm-oddity-1-interface-methods-with-underscores-21523b8ed797?source=rss----92bb7980cc9f---4>)

Author: Yev Kanivets

Published: 2021-09-20T04:23:21Z

Content type: tutorial

Language: en

Sources: [xorum.io - Medium](<https://devfeed.tech/sources/xorum-io-medium.md>)

Topics: [Kotlin Multiplatform](<https://devfeed.tech/topics/kotlin-multiplatform.md>), [Kotlin](<https://devfeed.tech/topics/kotlin.md>), [Objective-C](<https://devfeed.tech/topics/objective-c.md>), [interfaces](<https://devfeed.tech/topics/interfaces.md>), [Mobile](<https://devfeed.tech/topics/mobile.md>), [iOS](<https://devfeed.tech/topics/ios.md>), [kotlin-native](<https://devfeed.tech/topics/kotlin-native.md>)

Tags: [android](<https://devfeed.tech/tags/android.md>), [compiler](<https://devfeed.tech/tags/compiler.md>), [interfaces](<https://devfeed.tech/tags/interfaces.md>), [ios](<https://devfeed.tech/tags/ios.md>), [kmm](<https://devfeed.tech/tags/kmm.md>), [kotlin](<https://devfeed.tech/tags/kotlin.md>), [kotlin-multiplatform](<https://devfeed.tech/tags/kotlin-multiplatform.md>), [kotlin-native](<https://devfeed.tech/tags/kotlin-native.md>), [mobile](<https://devfeed.tech/tags/mobile.md>), [multiplatform](<https://devfeed.tech/tags/multiplatform.md>), [objective-c](<https://devfeed.tech/tags/objective-c.md>)

### AI overview

This article examines a Kotlin Multiplatform Mobile interoperability oddity in iOS. It explains how the Kotlin/Native compiler can expose an interface method with an underscore suffix, such as eat(food_:), when similarly named methods from different interfaces may clash in Objective-C.

### Source excerpt

Kotlin Multiplatform attracts more and more developers every day. Especially after the technology transitioned to the Alpha stage. On its way to Beta, KMP removes all major hassles (Memory Model, for example). Nonetheless, you can still find "a few" more minor bugs and oddities reported in Kotlin's YouTrack. They aren't blockers for using KMP in your production application but may cost you several hours of wondering what and why is happening in your mobile application (mainly on iOS). I faced many such issues myself since I've started using Kotlin Multiplatform Mobile two years ago. In this series of articles, I'll share my favorite oddities of KMM with explanations and workarounds (if possible). Kotlin/Native Obj-C interop Shared KMM modules are written in Kotlin, hence can be used in Android native applications as it is. On iOS, it's more complicated because of Objective-C and Swift, which can't directly use Kotlin code. Kotlin/Native plugin compiles shared KMM modules to iOS frameworks, which contain binary and Obj-C header. You can find them in the build folder of the shared module, under bin/iOS/. Many concepts of Kotlin don't exist in Obj-C, so specific shortcuts and workarounds need to be applied to make it work. It is where some oddities start appearing. Interface methods naming clash Let's say we have two types of pets -- Dog and Cat, which we need to feed with some specific Food. In Kotlin, we could represent that with two interfaces, each having an internal (embedded) Food class. https://medium.com/media/b868e0383cdc20566aef171daa863a87/href It works perfectly well in Android, but on iOS Dog will have eat(food_:) method instead of eat(food:). Where does that underscore suffix come from? And why do we need it? It looks like Kotlin/Native compiler thinks there will be a clash between eat(food:) methods of Dog and Cat interfaces, so it's safer to make them different by implicitly adding an underscore to the 2nd one. I'm not sure it will become a problem and i

## Simple string localization in Kotlin Multiplatform

DevFeed: [Simple string localization in Kotlin Multiplatform](<https://devfeed.tech/articles/simple-string-localization-in-kotlin-multiplatform-24740.md>)

Original publisher: [Read original article](<https://medium.com/xorum-io/simple-string-localization-in-kmm-beaffc5e7a17?source=rss----92bb7980cc9f---4>)

Author: Yev Kanivets

Published: 2021-08-14T16:30:03Z

Content type: tutorial

Language: en

Sources: [xorum.io - Medium](<https://devfeed.tech/sources/xorum-io-medium.md>)

Topics: [Kotlin Multiplatform](<https://devfeed.tech/topics/kotlin-multiplatform.md>), [Localization (l10n)](<https://devfeed.tech/topics/localization.md>), [Mobile](<https://devfeed.tech/topics/mobile.md>), [Android](<https://devfeed.tech/topics/android.md>), [iOS](<https://devfeed.tech/topics/ios.md>), [business logic](<https://devfeed.tech/topics/business-logic.md>)

Tags: [android](<https://devfeed.tech/tags/android.md>), [article](<https://devfeed.tech/tags/article.md>), [how-to](<https://devfeed.tech/tags/how-to.md>), [ios](<https://devfeed.tech/tags/ios.md>), [kotlin](<https://devfeed.tech/tags/kotlin.md>), [kotlin-multiplatform](<https://devfeed.tech/tags/kotlin-multiplatform.md>), [kotlin-multiplatform-mobile](<https://devfeed.tech/tags/kotlin-multiplatform-mobile.md>), [mobile](<https://devfeed.tech/tags/mobile.md>)

### AI overview

This tutorial explains how to access localized strings from Kotlin Multiplatform Mobile shared code while retaining native string localization on Android and iOS. It outlines the platforms' differing localization mechanisms and presents an approach for retrieving localized, formatted, and plural strings from shared code.

### Source excerpt

Kotlin Multiplatform Mobile gives us a lot of freedom on what to share and how to share between native mobile applications. Usually, it's just the shared business logic, and no user-facing things live in the common KMM module. But sometimes we need more ... This article will describe a simple (no 3rd party needed) way to access and use localized strings from the KMM module. This approach is based on the native string localization provided by Android and iOS applications, so no changes to strings management are needed from your side. Native localization iOS and Android have similar approaches to the localization of strings with some major differences in details. Let's do a quick recap to get context before diving into the KMM stuff. On both operating systems, we have all localizable strings extracted to files (one per language) in the form of key-value lists. Once the application is run on the user's device, the operating system detects the closest language file and uses it to render your app's UI. Rather straightforward. The main difference can be seen when it comes to using those strings in the code though. https://medium.com/media/cc9c336339f06c04a4b01f98ad707e2c/href On Android, you have a generated R class, which contains all string keys, accessible during the compilation, so you have an auto-completion and compile-time check for the existence of all strings you are trying to use. https://medium.com/media/fb7cfa6d362cd3fd353fa29bd35a64e1/href On iOS, you pass the string key to NSLocalizedString, which is resolved and localized during the runtime, so you don't have the auto-completion and compile-time check. String key is used as the default value. KMM localization To me, strings are one of the most user-facing parts of mobile applications, so I'm not sure that we should share it or have just one strings file in a KMM module. My take on it is that we should leave the power of strings to native platforms and developers. Even though, we still may need to access those

## Battle-tested template project for backend with Kotlin and Ktor

DevFeed: [Battle-tested template project for backend with Kotlin and Ktor](<https://devfeed.tech/articles/battle-tested-template-project-for-backend-with-kotlin-and-ktor-24731.md>)

Original publisher: [Read original article](<https://medium.com/xorum-io/battle-tested-template-project-for-backend-with-kotlin-and-ktor-c655a2e276c2?source=rss----92bb7980cc9f---4>)

Author: Yev Kanivets

Published: 2021-07-16T05:24:17Z

Content type: tutorial

Language: en

Sources: [xorum.io - Medium](<https://devfeed.tech/sources/xorum-io-medium.md>)

Topics: [Kotlin](<https://devfeed.tech/topics/kotlin.md>), [Ktor](<https://devfeed.tech/topics/ktor.md>), [Template](<https://devfeed.tech/topics/template.md>), [mvc](<https://devfeed.tech/topics/mvc.md>), [Authentication](<https://devfeed.tech/topics/authentication.md>), [Authorization](<https://devfeed.tech/topics/authorization.md>), [Framework](<https://devfeed.tech/topics/framework.md>), [API](<https://devfeed.tech/topics/api.md>), [Firebase](<https://devfeed.tech/topics/firebase.md>), [Gradle](<https://devfeed.tech/topics/gradle.md>), [Heroku](<https://devfeed.tech/topics/heroku.md>), [Postman](<https://devfeed.tech/topics/postman.md>)

Tags: [api](<https://devfeed.tech/tags/api.md>), [architecture](<https://devfeed.tech/tags/architecture.md>), [authentication](<https://devfeed.tech/tags/authentication.md>), [authorization](<https://devfeed.tech/tags/authorization.md>), [backend](<https://devfeed.tech/tags/backend.md>), [firebase](<https://devfeed.tech/tags/firebase.md>), [gradle](<https://devfeed.tech/tags/gradle.md>), [heroku](<https://devfeed.tech/tags/heroku.md>), [intellij](<https://devfeed.tech/tags/intellij.md>), [intellij-idea](<https://devfeed.tech/tags/intellij-idea.md>), [kotlin](<https://devfeed.tech/tags/kotlin.md>), [ktor](<https://devfeed.tech/tags/ktor.md>), [mvc](<https://devfeed.tech/tags/mvc.md>), [open-source](<https://devfeed.tech/tags/open-source.md>), [postgresql](<https://devfeed.tech/tags/postgresql.md>), [postman](<https://devfeed.tech/tags/postman.md>), [project](<https://devfeed.tech/tags/project.md>)

### AI overview

This article presents a personal Ktor template for Kotlin backend applications, describing its production use, project structure, tools, libraries, MVC-based architecture, API design, Heroku deployment files, and Firebase Auth integration.

### Source excerpt

With Kotlin and Ktor technologies gaining more popularity among the community of backend developers, dozens of different sample applications and templates are created and published as open-source projects. Ktor is an asynchronous framework for creating microservices, web applications, and more. It's fun, free, and open source. So it doesn't force any particular architecture, set of libraries, or framework to be used, which means that you are free to choose what's best for you and your project. Today, I'm finally ready to share my personal Ktor template, polished by almost a year of use in production applications. This article gives a short overview of the template, its architecture, chosen tools, and libraries. Tools Since we are using Kotlin to develop Ktor applications, pretty much any IDE compatible with Java/Kotlin should work. But the default choice is IntelliJ IDEA, of course. Community edition (free) will work just fine. Postman is a great choice for documenting, testing, and sharing your backend APIs. There are many similar tools. You can use cURL requests, for example. But always think about your API users first. What will be the most convenient for them, as they depend on you a lot. Structure Most of the Kotlin projects (including Ktor) are powered by Gradle, so they look quite similar. My template isn't different, with many Gradle-related files in the root and single src folder. Other files are related to Heroku deployment, but more on this later. Architecture Ktor isn't forcing you for any particular approach, so you are free to choose and implement the architecture that fits your needs best. In our case, we implemented classical MVC (Model -- View -- Controller) architecture with a public API instead of View and dedicated Interactors, which encapsulate all business logic related to each endpoint. Firebase Auth Most applications require some authentication and authorization business logic, so my template includes one of the possible implementations out of