{"id":393458,"date":"2024-06-29T11:01:26","date_gmt":"2024-06-29T11:01:26","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=393458"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=393458","title":{"rendered":"<span>SDK \u0447\u0430\u0442\u0430 \u0438 Kotlin Multiplatform<\/span>"},"content":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/a12\/c01\/479\/a12c014798849ebc1bbdd4a266b48672.png\" width=\"888\" height=\"399\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/a12\/c01\/479\/a12c014798849ebc1bbdd4a266b48672.png\"\/><figcaption><\/figcaption><\/figure>\n<p>\u041f\u0440\u0438\u0432\u0435\u0442, \u043c\u0435\u043d\u044f \u0437\u043e\u0432\u0443\u0442 \u0421\u0435\u0440\u0433\u0435\u0439, \u044f Android Lead \u0432 \u043a\u043e\u043c\u043f\u0430\u043d\u0438\u0438 Broniboy \u2014\u00a0 \u0441\u0435\u0440\u0432\u0438\u0441\u0435 \u043c\u0443\u043b\u044c\u0442\u0438\u0434\u043e\u0441\u0442\u0430\u0432\u043a\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u0441 \u0440\u0435\u0441\u0442\u043e\u0440\u0430\u043d\u0430\u043c\u0438, \u043d\u043e \u0438 \u0441 \u043c\u0430\u0433\u0430\u0437\u0438\u043d\u0430\u043c\u0438, \u0430\u043f\u0442\u0435\u043a\u0430\u043c\u0438 \u0438 \u043e\u0431\u044b\u0447\u043d\u044b\u043c\u0438 \u043b\u044e\u0434\u044c\u043c\u0438. \u0423\u0447\u0438\u0442\u044b\u0432\u0430\u044f \u0443\u0440\u043e\u0432\u0435\u043d\u044c \u043a\u043e\u043d\u043a\u0443\u0440\u0435\u043d\u0446\u0438\u0438 \u043d\u0430 \u044d\u0442\u043e\u043c \u0440\u044b\u043d\u043a\u0435, \u043a\u0430\u0436\u0434\u044b\u0439 \u043a\u043b\u0438\u0435\u043d\u0442 \u043d\u0430 \u0441\u0447\u0435\u0442\u0443. \u0414\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043e\u0434\u043d\u043e\u0439 \u043e\u0448\u0438\u0431\u043a\u0438, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u0442\u0435\u0440\u044f\u0442\u044c \u0435\u0433\u043e, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043d\u0430\u043c \u043d\u0443\u0436\u0435\u043d \u043d\u0430\u0434\u0451\u0436\u043d\u044b\u0439 \u043a\u0430\u043d\u0430\u043b \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439. \u041d\u0430\u0448 \u0432\u044b\u0431\u043e\u0440 \u043f\u0430\u043b \u043d\u0430 \u0447\u0430\u0442, \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u0438 \u043f\u043e\u043d\u044f\u0442\u043d\u044b\u0439 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044e \u043a\u0430\u043d\u0430\u043b \u0441\u0432\u044f\u0437\u0438. \u041e\u043d \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u043f\u0435\u0440\u0430\u0442\u0438\u0432\u043d\u043e \u0440\u0435\u0430\u0433\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043d\u0430 \u0436\u0430\u043b\u043e\u0431\u044b, \u043d\u043e \u0438 \u043f\u0440\u0438\u0432\u043d\u043e\u0441\u0442\u0438 \u0447\u0430\u0441\u0442\u0438\u0447\u043a\u0443 \u00ab\u0447\u0435\u043b\u043e\u0432\u0435\u0447\u043d\u043e\u0441\u0442\u0438\u00bb \u0432 \u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u0441 \u0442\u0435\u0445\u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u043e\u0439.<\/p>\n<p>\u0418\u0437\u0443\u0447\u0438\u0432 \u0433\u043e\u0442\u043e\u0432\u044b\u0435 SDK \u0438 \u0432\u0437\u0432\u0435\u0441\u0438\u0432 \u0432\u0441\u0435 \u00ab\u0437\u0430\u00bb \u0438 \u00ab\u043f\u0440\u043e\u0442\u0438\u0432\u00bb, \u043c\u044b \u0440\u0435\u0448\u0438\u043b\u0438 \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439 SDK \u0447\u0430\u0442\u0430. \u041e\u0434\u043d\u0430 \u0438\u0437 \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0445 \u0438\u0434\u0435\u0439 \u2014 \u043f\u0435\u0440\u0435\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u043a\u043e\u0434\u0430 \u043c\u0435\u0436\u0434\u0443 \u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u0430\u043c\u0438, \u0430 \u0441\u0435\u0433\u043e\u0434\u043d\u044f \u044d\u0442\u043e Android, iOS \u0438 Web. \u041f\u043e\u044d\u0442\u043e\u043c\u0443, \u0434\u043b\u044f MVP \u043c\u044b \u0440\u0435\u0448\u0438\u043b\u0438 \u043f\u043e\u043f\u0440\u043e\u0431\u043e\u0432\u0430\u0442\u044c Kotlin Multiplatform.<\/p>\n<p>\u0418\u0437\u0443\u0447\u0438\u0432 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u0438\u043c\u0435\u0440\u043e\u0432 \u0438 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a \u043d\u0430 \u043f\u0440\u043e\u0441\u0442\u043e\u0440\u0430\u0445 \u0418\u043d\u0442\u0435\u0440\u043d\u0435\u0442\u0430, \u0432\u044b\u0431\u0440\u0430\u043b\u0438 \u0442\u0430\u043a\u043e\u0439 \u0441\u0442\u0435\u043a \u0442\u0435\u0445\u043d\u043e\u043b\u043e\u0433\u0438\u0439:<\/p>\n<ul>\n<li>\n<p>Ktor \u0438 Kotlin Serialization \u0434\u043b\u044f \u0441\u0435\u0442\u0438;<\/p>\n<\/li>\n<li>\n<p>SQDelight \u0434\u043b\u044f \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f;<\/p>\n<\/li>\n<li>\n<p>Koin \u0434\u043b\u044f DI;<\/p>\n<\/li>\n<li>\n<p>JetBrain Compose, MVIKotlin \u0438 Decompose \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043a\u0430\u0440\u043a\u0430\u0441\u0430 \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u044b \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f;<\/p>\n<\/li>\n<li>\n<p>\u0438 Coroutines \u0434\u043b\u044f \u0441\u0432\u044f\u0437\u0438 \u0432\u0441\u0435\u0433\u043e \u044d\u0442\u043e\u0433\u043e \u0432\u043e\u0435\u0434\u0438\u043d\u043e.<\/p>\n<\/li>\n<\/ul>\n<p>\u041d\u043e \u0432\u0441\u0451 \u0436\u0435 \u0441\u043e\u0431\u0440\u0430\u0442\u044c \u044d\u0442\u043e \u0432 \u0435\u0434\u0438\u043d\u0443\u044e \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443, \u043d\u0435\u0441\u043c\u043e\u0442\u0440\u044f \u043d\u0430 \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u0432\u044b\u0431\u043e\u0440 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a, \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u044e\u0449\u0438\u0445 \u043c\u0443\u043b\u044c\u0442\u0438\u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u0435\u043d\u043d\u043e\u0441\u0442\u044c, \u043e\u043a\u0430\u0437\u0430\u043b\u043e\u0441\u044c \u043d\u0435\u0442\u0440\u0438\u0432\u0438\u0430\u043b\u044c\u043d\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0435\u0439. \u0418\u0437-\u0437\u0430 \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0438\u044f \u043e\u043f\u044b\u0442\u0430 \u0438 \u043c\u0430\u043b\u043e\u0433\u043e \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u0430\u043a\u0442\u0443\u0430\u043b\u044c\u043d\u043e\u0439 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u043f\u0440\u0438\u0448\u043b\u043e\u0441\u044c \u0431\u044b \u043f\u043e\u0442\u0440\u0430\u0442\u0438\u0442\u044c \u043c\u043d\u043e\u0433\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043c\u044b \u0440\u0435\u0448\u0438\u043b\u0438 \u043d\u0430\u0447\u0430\u0442\u044c \u0441 \u043f\u0440\u043e\u0441\u0442\u044b\u0445 \u0438 \u043f\u043e\u043d\u044f\u0442\u043d\u044b\u0445 \u043a\u0440\u0430\u0439\u043d\u0438\u0445 \u0441\u043b\u043e\u0451\u0432, \u0438 \u0443\u0436\u0435 \u043f\u043e\u0442\u043e\u043c, \u0438\u043c\u0435\u044f \u0433\u043e\u0442\u043e\u0432\u044b\u0435 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u044b, \u0441\u0432\u044f\u0437\u0430\u0442\u044c \u0438\u0445 \u0432\u043e\u0435\u0434\u0438\u043d\u043e.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/781\/c2e\/153\/781c2e153b986a6e5e03107ca2186cd9.png\" width=\"1600\" height=\"1066\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/781\/c2e\/153\/781c2e153b986a6e5e03107ca2186cd9.png\"\/><figcaption><\/figcaption><\/figure>\n<h3>Data<\/h3>\n<p>Data-\u0441\u043b\u043e\u0439 \u043e\u043a\u0430\u0437\u0430\u043b\u0441\u044f \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u044b\u043c: Ktor \u0438 Coroutines \u0438\u043c\u0435\u044e\u0442 \u0438\u0441\u0447\u0435\u0440\u043f\u044b\u0432\u0430\u044e\u0449\u0443\u044e \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044e, SQDelight \u043d\u0430\u043f\u043e\u043c\u0438\u043d\u0430\u0435\u0442 Room, \u0430 Koin \u043d\u0438\u0447\u0435\u043c \u043d\u0435 \u043e\u0442\u043b\u0438\u0447\u0430\u0435\u0442\u0441\u044f \u043e\u0442 Android-\u0432\u0430\u0440\u0438\u0430\u043d\u0442\u0430. \u041a\u043e\u043d\u0435\u0447\u043d\u043e, \u043f\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 Ktor \u043e\u0449\u0443\u0449\u0430\u0435\u0442\u0441\u044f \u043d\u0435\u0445\u0432\u0430\u0442\u043a\u0430 Retrofit\u2019\u0430 \u0441 \u0435\u0433\u043e \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u044f\u043c\u0438, \u043d\u043e \u0438\u0445 \u0443\u0441\u043f\u0435\u0448\u043d\u043e \u0437\u0430\u043c\u0435\u043d\u044f\u044e\u0442 DSL-\u0441\u0431\u043e\u0440\u0449\u0438\u043a\u0438. \u0410 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0430 OkHttpClient \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043f\u0435\u0440\u0435\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043a\u043b\u0438\u0435\u043d\u0442 \u0438\u0437 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0433\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f.<\/p>\n<pre><code class=\"kotlin\">private val client = HttpClient(OkHttp) {     engine { preconfigured = OkHttpClient() }     install(JsonFeature) }  suspend fun test(): String {     return client.get { url(\"https:\/\/google.com\") } }<\/code><\/pre>\n<p>\u0421 SQDelight \u0432\u0441\u0451 \u0435\u0449\u0451 \u043f\u0440\u043e\u0449\u0435: \u044d\u0442\u043e Room, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u0442 \u0432\u0441\u0435 \u043a\u043b\u0430\u0441\u0441\u044b \u0437\u0430 \u043d\u0430\u0441, \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043b\u0438\u0448\u044c \u0443\u043a\u0430\u0437\u0430\u0442\u044c \u0441\u0445\u0435\u043c\u0443.<\/p>\n<pre><code class=\"kotlin\">CREATE TABLE message (   id INTEGER PRIMARY KEY,   text TEXT NOT NULL );  messages: SELECT * FROM message;  insert: INSERT INTO message VALUES ?;<\/code><\/pre>\n<p>\u0421 Koin \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u044f \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043e\u0442\u043b\u0438\u0447\u0430\u0435\u0442\u0441\u044f, \u0442\u0430\u043a \u043a\u0430\u043a \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0435\u0433\u043e \u043d\u0435 \u0433\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u043e, \u0430 \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0430 \u0432\u0440\u0435\u043c\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0447\u0430\u0442\u043e\u043c. \u041a \u0441\u0447\u0430\u0441\u0442\u044c\u044e, \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0432 Koin \u0435\u0441\u0442\u044c \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c Context Isolation, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0438\u0437\u043e\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 SDK, \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u044f \u0438 \u0443\u0434\u0430\u043b\u044f\u044f \u0438\u0445 \u043f\u0440\u0438 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438.<\/p>\n<pre><code class=\"kotlin\">interface ChatKoinComponent : KoinComponent {      override fun getKoin() = koinApp.koin      companion object {         private var koinApp: KoinApplication = koinApplication {...}     } }<\/code><\/pre>\n<h3>UI<\/h3>\n<p>\u041f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u043c \u043a \u0434\u0440\u0443\u0433\u043e\u043c\u0443 \u043a\u043e\u043d\u0446\u0443 \u043d\u0430\u0448\u0435\u0439 \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u044b \u2014 UI. \u0425\u043e\u0442\u044f \u043c\u044b \u0441\u043c\u043e\u0433\u043b\u0438 \u043b\u0435\u0433\u043a\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 , \u0434\u043e\u0431\u0438\u0442\u044c\u0441\u044f \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430 \u00ab\u043a\u0430\u043a \u0432 \u043c\u0430\u043a\u0435\u0442\u0435\u00bb \u043e\u043a\u0430\u0437\u0430\u043b\u043e\u0441\u044c \u043d\u0435 \u0442\u0430\u043a \u043f\u0440\u043e\u0441\u0442\u043e.<\/p>\n<p><strong>\u041f\u043e\u043b\u0435 \u0432\u0432\u043e\u0434\u0430 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f<\/strong>. \u0423\u0448\u043b\u043e \u043c\u043d\u043e\u0433\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u043d\u0430 \u0442\u043e, \u0447\u0442\u043e\u0431\u044b \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0435\u0433\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u043e\u0439 \u0432\u044b\u0441\u043e\u0442\u044b \u0438 \u0432\u044b\u0440\u043e\u0432\u043d\u044f\u0442\u044c \u043f\u043e \u0446\u0435\u043d\u0442\u0440\u0443, \u043d\u0435 \u0443\u043c\u0435\u043d\u044c\u0448\u0430\u044f \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u043a\u043b\u0438\u043a\u0430\u0431\u0435\u043b\u044c\u043d\u0443\u044e\u0439 \u0437\u043e\u043d\u0443.<\/p>\n<pre><code class=\"kotlin\">@Composable internal fun InputField(inputTextState: String) {     Row(             modifier = Modifier                 .fillMaxWidth()                 .height(IntrinsicSize.Min), \/\/ \u0432\u044b\u0440\u043e\u0432\u043d\u044f\u0442\u044c \u0432\u044b\u0441\u043e\u0442\u0443 \u0438\u043a\u043e\u043d\u043a\u0438 \u0438 \u043f\u043e\u043b\u044f \u0432\u0432\u043e\u0434\u0430             verticalAlignment = Alignment.CenterVertically,     ) {         Icon(modifier = Modifier.fillMaxHeight())         BasicTextField(                 value = inputTextState,                 onValueChange = {...},                 modifier = Modifier                     .weight(1f)                     .fillMaxHeight(),                 maxLines = 3,                 decorationBox = { innerTextField ->                     Box(contentAlignment = Alignment.CenterStart) { \/\/ \u0432\u044b\u0440\u043e\u0432\u043d\u044f\u0442\u044c \u0442\u0435\u043a\u0441\u0442 \u043f\u043e \u0441\u0435\u0440\u0435\u0434\u0438\u043d\u0435 \u043f\u043e\u043b\u0435 \u0432\u0432\u043e\u0434\u0430                         if (inputTextState.isEmpty()) {                             Text(                                     text = \"Hint...\",                             )                         }                         innerTextField()                     }                 }         )     } }<\/code><\/pre>\n<p><strong>\u0421\u0441\u044b\u043b\u043a\u0438 \u0432 \u0442\u0435\u043a\u0441\u0442\u0435<\/strong>. \u0412 Compose \u043d\u0435\u0442 autolink\u2019\u0430, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u0440\u0438\u0448\u043b\u043e\u0441\u044c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043e\u0431\u044b\u0447\u043d\u044b\u0439 TextView.<\/p>\n<pre><code class=\"kotlin\">AndroidView(         factory = {             TextView(it).apply {                 movementMethod = BetterLinkMovementMethod.newInstance().apply {                     setOnLinkClickListener { _, url ->                         onLinkClick(url)                         true                     }                 }             }         },         modifier = Modifier.weight(weight = 1f, fill = false),         {             it.text = message.text             LinkifyCompat.addLinks(it, Linkify.WEB_URLS)         } )<\/code><\/pre>\n<p><strong>BottomSheet<\/strong>. \u0418\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f <code>BottomSheet<\/code> \u0447\u0435\u0440\u0435\u0437 \u043c\u0435\u0442\u043e\u0434\u044b:<\/p>\n<pre><code class=\"kotlin\">val bottomSheetState = rememberBottomSheetState(BottomSheetValue.Collapsed) if (bottomSheetState.currentValue != BottomSheetValue.Collapsed) {     DisposableEffect(bottomSheetState) {         onDispose { component.onDismiss() } \/\/ \u0441\u043b\u0443\u0448\u0430\u0435\u043c \u0437\u0430\u043a\u0440\u044b\u0442\u0438\u0435 BottomSheet     } } val bottomSheetStateUpdate by component.bottomSheetStateUpdate.collectAsState() LaunchedEffect(bottomSheetStateUpdate) { \/\/ \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 BottomSheet \u043c\u043e\u0436\u043d\u043e \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u043c\u0435\u0442\u043e\u0434\u0430\u043c\u0438, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c LaunchedEffect     when (bottomSheetStateUpdate) {         BottomSheetState.Expanded -> bottomSheetState.expand()         BottomSheetState.Collapsed -> bottomSheetState.collapse()     } }<\/code><\/pre>\n<p>\u041e\u0431\u044a\u0435\u0434\u0438\u043d\u0438\u0432 \u043f\u043e\u043b\u0443\u0447\u0438\u0432\u0448\u0438\u0435\u0441\u044f \u0441\u043b\u043e\u0438, \u043c\u044b \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u043b\u0438, \u0447\u0442\u043e \u0432\u0441\u0451 \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442. \u041f\u043e\u0441\u043b\u0435 \u044d\u0442\u043e\u0433\u043e \u043e\u0441\u0442\u0430\u043b\u043e\u0441\u044c \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u043b\u043e\u0439 \u0431\u0438\u0437\u043d\u0435\u0441-\u043b\u043e\u0433\u0438\u043a\u0438, \u0441\u0432\u044f\u0437\u0430\u0432 \u0432\u0441\u0451 \u0432\u043e\u0435\u0434\u0438\u043d\u043e.<\/p>\n<h3>Domain<\/h3>\n<p>\u0418\u043c\u0435\u044f \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u044b \u0441 \u043e\u0431\u0435\u0438\u0445 \u0441\u0442\u043e\u0440\u043e\u043d \u0438 \u043e\u043f\u0440\u043e\u0431\u043e\u0432\u0430\u0432 \u0440\u0430\u0437\u043d\u044b\u0435 \u043f\u043e\u0434\u0445\u043e\u0434\u044b, \u043c\u044b \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043b\u0438 \u043b\u043e\u0433\u0438\u0447\u043d\u0443\u044e \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0443, \u043f\u043e\u0434\u0445\u043e\u0434\u044f\u0449\u0443\u044e \u0434\u043b\u044f \u043d\u0430\u0448\u0438\u0445 \u044d\u043a\u0440\u0430\u043d\u043e\u0432:<\/p>\n<p>Composable, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0435\u0442 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u044d\u043a\u0440\u0430\u043d\u0430 \u0438 \u043e\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043b\u044f\u0435\u0442 \u043d\u0430\u0432\u0438\u0433\u0430\u0446\u0438\u044e:<\/p>\n<pre><code class=\"kotlin\">Children(routerState = component.routerState) {     when (val child = it.instance) {         is ChatRoot.Child.Main -> ChatMainContent(child.component)     } }<\/code><\/pre>\n<p>Component, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0440\u0435\u0430\u0433\u0438\u0440\u0443\u0435\u0442 \u043d\u0430 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f \u044d\u043a\u0440\u0430\u043d\u0430:<\/p>\n<pre><code class=\"kotlin\">internal class ChatRootComponent(componentContext: ComponentContext) : ChatRoot, ComponentContext by componentContext {      private val router = router&lt;Configuration, ChatRoot.Child>(::createChild)     private val store = instanceKeeper.getStore { ChatRootStore(storeFactory) }     override val routerState = router.state     override val state = store.states      private fun createChild(configuration: Configuration, componentContext: ComponentContext): ChatRoot.Child {...} }<\/code><\/pre>\n<p>Store, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0435\u0442 \u0438 \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u0442 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e:<\/p>\n<pre><code class=\"kotlin\">internal class ChatRootStore(storeFactory: StoreFactory) : ChatRootStore, Store&lt;Intent, State, Label> by storeFactory.createStore() {      private class ExecutorImpl : CoroutineExecutor&lt;Intent, Unit, State, Result, Label>() {         override fun executeAction(action: Unit, getState: () -> State) {...}         override fun executeIntent(intent: Intent, getState: () -> State) {...}     }      private object ReducerImpl : Reducer&lt;State, Result> {         override fun State.reduce(result: Result): State {...}     } }<\/code><\/pre>\n<p>\u0418 \u043d\u0430 \u044d\u0442\u043e\u043c \u0432\u0441\u0451, \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0433\u043e\u0442\u043e\u0432\u0430!<\/p>\n<h3>\u0417\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435<\/h3>\n<p>\u041c\u044b \u0441\u0447\u0438\u0442\u0430\u0435\u043c \u044d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442 \u0443\u0441\u043f\u0435\u0448\u043d\u044b\u043c. Kotlin Multiplatform \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043f\u0435\u0440\u0435\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0437\u043d\u0430\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u0443\u044e \u0447\u0430\u0441\u0442\u044c \u043b\u043e\u0433\u0438\u043a\u0438. \u041f\u0440\u0438 \u044d\u0442\u043e\u043c \u0432\u0441\u0435\u0433\u0434\u0430 \u043c\u043e\u0436\u043d\u043e \u043e\u0431\u043e\u0439\u0442\u0438 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u043d\u044b\u0435 \u043c\u0435\u0441\u0442\u0430 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e expect\/actual. \u042d\u0442\u043e \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442 \u0433\u0438\u0431\u043a\u043e\u0441\u0442\u0438 \u0432 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 \u043e\u0431\u0449\u0435\u0433\u043e \u043c\u043e\u0434\u0443\u043b\u044f \u0441\u0440\u0435\u0434\u0438 \u0440\u0430\u0437\u043d\u044b\u0445 \u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c.<\/p>\n<p>\u0411\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f \u043c\u0443\u043b\u044c\u0442\u0438\u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u0435\u043d\u043d\u043e\u0441\u0442\u0438, \u043d\u0430\u043c \u0443\u0434\u0430\u043b\u043e\u0441\u044c \u043e\u0449\u0443\u0442\u0438\u043c\u043e \u0441\u043e\u043a\u0440\u0430\u0442\u0438\u0442\u044c \u0437\u0430\u0442\u0440\u0430\u0442\u044b \u043d\u0430 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0443 SDK. \u0414\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0439 \u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u044b \u043d\u0430\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e UI-\u0441\u043b\u043e\u0439, \u0430 \u0431\u0438\u0437\u043d\u0435\u0441-\u043b\u043e\u0433\u0438\u043a\u0430 \u0431\u0443\u0434\u0435\u0442 \u043f\u0435\u0440\u0435\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0430 \u0438\u0437 \u043e\u0431\u0449\u0435\u0433\u043e \u043c\u043e\u0434\u0443\u043b\u044f. \u0411\u043e\u043b\u0435\u0435 \u0442\u043e\u0433\u043e, \u0431\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f \u044d\u0442\u043e\u043c\u0443 \u0447\u0430\u0442 \u043d\u0430 \u0432\u0441\u0435\u0445 \u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u0430\u0445 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0435\u0434\u0438\u043d\u043e\u043e\u0431\u0440\u0430\u0437\u043d\u043e.<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/589875\/\"> https:\/\/habr.com\/ru\/articles\/589875\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>\u041f\u0440\u0438\u0432\u0435\u0442, \u043c\u0435\u043d\u044f \u0437\u043e\u0432\u0443\u0442 \u0421\u0435\u0440\u0433\u0435\u0439, \u044f Android Lead \u0432 \u043a\u043e\u043c\u043f\u0430\u043d\u0438\u0438 Broniboy \u2014\u00a0 \u0441\u0435\u0440\u0432\u0438\u0441\u0435 \u043c\u0443\u043b\u044c\u0442\u0438\u0434\u043e\u0441\u0442\u0430\u0432\u043a\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u0441 \u0440\u0435\u0441\u0442\u043e\u0440\u0430\u043d\u0430\u043c\u0438, \u043d\u043e \u0438 \u0441 \u043c\u0430\u0433\u0430\u0437\u0438\u043d\u0430\u043c\u0438, \u0430\u043f\u0442\u0435\u043a\u0430\u043c\u0438 \u0438 \u043e\u0431\u044b\u0447\u043d\u044b\u043c\u0438 \u043b\u044e\u0434\u044c\u043c\u0438. \u0423\u0447\u0438\u0442\u044b\u0432\u0430\u044f \u0443\u0440\u043e\u0432\u0435\u043d\u044c \u043a\u043e\u043d\u043a\u0443\u0440\u0435\u043d\u0446\u0438\u0438 \u043d\u0430 \u044d\u0442\u043e\u043c \u0440\u044b\u043d\u043a\u0435, \u043a\u0430\u0436\u0434\u044b\u0439 \u043a\u043b\u0438\u0435\u043d\u0442 \u043d\u0430 \u0441\u0447\u0435\u0442\u0443. \u0414\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043e\u0434\u043d\u043e\u0439 \u043e\u0448\u0438\u0431\u043a\u0438, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u0442\u0435\u0440\u044f\u0442\u044c \u0435\u0433\u043e, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043d\u0430\u043c \u043d\u0443\u0436\u0435\u043d \u043d\u0430\u0434\u0451\u0436\u043d\u044b\u0439 \u043a\u0430\u043d\u0430\u043b \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439. \u041d\u0430\u0448 \u0432\u044b\u0431\u043e\u0440 \u043f\u0430\u043b \u043d\u0430 \u0447\u0430\u0442, \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u0438 \u043f\u043e\u043d\u044f\u0442\u043d\u044b\u0439 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044e \u043a\u0430\u043d\u0430\u043b \u0441\u0432\u044f\u0437\u0438. \u041e\u043d \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u043f\u0435\u0440\u0430\u0442\u0438\u0432\u043d\u043e \u0440\u0435\u0430\u0433\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043d\u0430 \u0436\u0430\u043b\u043e\u0431\u044b, \u043d\u043e \u0438 \u043f\u0440\u0438\u0432\u043d\u043e\u0441\u0442\u0438 \u0447\u0430\u0441\u0442\u0438\u0447\u043a\u0443 \u00ab\u0447\u0435\u043b\u043e\u0432\u0435\u0447\u043d\u043e\u0441\u0442\u0438\u00bb \u0432 \u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u0441 \u0442\u0435\u0445\u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u043e\u0439.<\/p>\n<p>\u0418\u0437\u0443\u0447\u0438\u0432 \u0433\u043e\u0442\u043e\u0432\u044b\u0435 SDK \u0438 \u0432\u0437\u0432\u0435\u0441\u0438\u0432 \u0432\u0441\u0435 \u00ab\u0437\u0430\u00bb \u0438 \u00ab\u043f\u0440\u043e\u0442\u0438\u0432\u00bb, \u043c\u044b \u0440\u0435\u0448\u0438\u043b\u0438 \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439 SDK \u0447\u0430\u0442\u0430. \u041e\u0434\u043d\u0430 \u0438\u0437 \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0445 \u0438\u0434\u0435\u0439 \u2014 \u043f\u0435\u0440\u0435\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u043a\u043e\u0434\u0430 \u043c\u0435\u0436\u0434\u0443 \u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u0430\u043c\u0438, \u0430 \u0441\u0435\u0433\u043e\u0434\u043d\u044f \u044d\u0442\u043e Android, iOS \u0438 Web. \u041f\u043e\u044d\u0442\u043e\u043c\u0443, \u0434\u043b\u044f MVP \u043c\u044b \u0440\u0435\u0448\u0438\u043b\u0438 \u043f\u043e\u043f\u0440\u043e\u0431\u043e\u0432\u0430\u0442\u044c Kotlin Multiplatform.<\/p>\n<p>\u0418\u0437\u0443\u0447\u0438\u0432 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u0438\u043c\u0435\u0440\u043e\u0432 \u0438 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a \u043d\u0430 \u043f\u0440\u043e\u0441\u0442\u043e\u0440\u0430\u0445 \u0418\u043d\u0442\u0435\u0440\u043d\u0435\u0442\u0430, \u0432\u044b\u0431\u0440\u0430\u043b\u0438 \u0442\u0430\u043a\u043e\u0439 \u0441\u0442\u0435\u043a \u0442\u0435\u0445\u043d\u043e\u043b\u043e\u0433\u0438\u0439:<\/p>\n<ul>\n<li>\n<p>Ktor \u0438 Kotlin Serialization \u0434\u043b\u044f \u0441\u0435\u0442\u0438;<\/p>\n<\/li>\n<li>\n<p>SQDelight \u0434\u043b\u044f \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f;<\/p>\n<\/li>\n<li>\n<p>Koin \u0434\u043b\u044f DI;<\/p>\n<\/li>\n<li>\n<p>JetBrain Compose, MVIKotlin \u0438 Decompose \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043a\u0430\u0440\u043a\u0430\u0441\u0430 \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u044b \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f;<\/p>\n<\/li>\n<li>\n<p>\u0438 Coroutines \u0434\u043b\u044f \u0441\u0432\u044f\u0437\u0438 \u0432\u0441\u0435\u0433\u043e \u044d\u0442\u043e\u0433\u043e \u0432\u043e\u0435\u0434\u0438\u043d\u043e.<\/p>\n<\/li>\n<\/ul>\n<p>\u041d\u043e \u0432\u0441\u0451 \u0436\u0435 \u0441\u043e\u0431\u0440\u0430\u0442\u044c \u044d\u0442\u043e \u0432 \u0435\u0434\u0438\u043d\u0443\u044e \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443, \u043d\u0435\u0441\u043c\u043e\u0442\u0440\u044f \u043d\u0430 \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u0432\u044b\u0431\u043e\u0440 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a, \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u044e\u0449\u0438\u0445 \u043c\u0443\u043b\u044c\u0442\u0438\u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u0435\u043d\u043d\u043e\u0441\u0442\u044c, \u043e\u043a\u0430\u0437\u0430\u043b\u043e\u0441\u044c \u043d\u0435\u0442\u0440\u0438\u0432\u0438\u0430\u043b\u044c\u043d\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0435\u0439. \u0418\u0437-\u0437\u0430 \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0438\u044f \u043e\u043f\u044b\u0442\u0430 \u0438 \u043c\u0430\u043b\u043e\u0433\u043e \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u0430\u043a\u0442\u0443\u0430\u043b\u044c\u043d\u043e\u0439 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u043f\u0440\u0438\u0448\u043b\u043e\u0441\u044c \u0431\u044b \u043f\u043e\u0442\u0440\u0430\u0442\u0438\u0442\u044c \u043c\u043d\u043e\u0433\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043c\u044b \u0440\u0435\u0448\u0438\u043b\u0438 \u043d\u0430\u0447\u0430\u0442\u044c \u0441 \u043f\u0440\u043e\u0441\u0442\u044b\u0445 \u0438 \u043f\u043e\u043d\u044f\u0442\u043d\u044b\u0445 \u043a\u0440\u0430\u0439\u043d\u0438\u0445 \u0441\u043b\u043e\u0451\u0432, \u0438 \u0443\u0436\u0435 \u043f\u043e\u0442\u043e\u043c, \u0438\u043c\u0435\u044f \u0433\u043e\u0442\u043e\u0432\u044b\u0435 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u044b, \u0441\u0432\u044f\u0437\u0430\u0442\u044c \u0438\u0445 \u0432\u043e\u0435\u0434\u0438\u043d\u043e.<\/p>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<h3>Data<\/h3>\n<p>Data-\u0441\u043b\u043e\u0439 \u043e\u043a\u0430\u0437\u0430\u043b\u0441\u044f \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u044b\u043c: Ktor \u0438 Coroutines \u0438\u043c\u0435\u044e\u0442 \u0438\u0441\u0447\u0435\u0440\u043f\u044b\u0432\u0430\u044e\u0449\u0443\u044e \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044e, SQDelight \u043d\u0430\u043f\u043e\u043c\u0438\u043d\u0430\u0435\u0442 Room, \u0430 Koin \u043d\u0438\u0447\u0435\u043c \u043d\u0435 \u043e\u0442\u043b\u0438\u0447\u0430\u0435\u0442\u0441\u044f \u043e\u0442 Android-\u0432\u0430\u0440\u0438\u0430\u043d\u0442\u0430. \u041a\u043e\u043d\u0435\u0447\u043d\u043e, \u043f\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 Ktor \u043e\u0449\u0443\u0449\u0430\u0435\u0442\u0441\u044f \u043d\u0435\u0445\u0432\u0430\u0442\u043a\u0430 Retrofit\u2019\u0430 \u0441 \u0435\u0433\u043e \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u044f\u043c\u0438, \u043d\u043e \u0438\u0445 \u0443\u0441\u043f\u0435\u0448\u043d\u043e \u0437\u0430\u043c\u0435\u043d\u044f\u044e\u0442 DSL-\u0441\u0431\u043e\u0440\u0449\u0438\u043a\u0438. \u0410 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0430 OkHttpClient \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043f\u0435\u0440\u0435\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043a\u043b\u0438\u0435\u043d\u0442 \u0438\u0437 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0433\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f.<\/p>\n<pre><code class=\"kotlin\">private val client = HttpClient(OkHttp) {     engine { preconfigured = OkHttpClient() }     install(JsonFeature) }  suspend fun test(): String {     return client.get { url(\"https:\/\/google.com\") } }<\/code><\/pre>\n<p>\u0421 SQDelight \u0432\u0441\u0451 \u0435\u0449\u0451 \u043f\u0440\u043e\u0449\u0435: \u044d\u0442\u043e Room, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u0442 \u0432\u0441\u0435 \u043a\u043b\u0430\u0441\u0441\u044b \u0437\u0430 \u043d\u0430\u0441, \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043b\u0438\u0448\u044c \u0443\u043a\u0430\u0437\u0430\u0442\u044c \u0441\u0445\u0435\u043c\u0443.<\/p>\n<pre><code class=\"kotlin\">CREATE TABLE message (   id INTEGER PRIMARY KEY,   text TEXT NOT NULL );  messages: SELECT * FROM message;  insert: INSERT INTO message VALUES ?;<\/code><\/pre>\n<p>\u0421 Koin \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u044f \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043e\u0442\u043b\u0438\u0447\u0430\u0435\u0442\u0441\u044f, \u0442\u0430\u043a \u043a\u0430\u043a \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0435\u0433\u043e \u043d\u0435 \u0433\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u043e, \u0430 \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0430 \u0432\u0440\u0435\u043c\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0447\u0430\u0442\u043e\u043c. \u041a \u0441\u0447\u0430\u0441\u0442\u044c\u044e, \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0432 Koin \u0435\u0441\u0442\u044c \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c Context Isolation, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0438\u0437\u043e\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 SDK, \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u044f \u0438 \u0443\u0434\u0430\u043b\u044f\u044f \u0438\u0445 \u043f\u0440\u0438 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438.<\/p>\n<pre><code class=\"kotlin\">interface ChatKoinComponent : KoinComponent {      override fun getKoin() = koinApp.koin      companion object {         private var koinApp: KoinApplication = koinApplication {...}     } }<\/code><\/pre>\n<h3>UI<\/h3>\n<p>\u041f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u043c \u043a \u0434\u0440\u0443\u0433\u043e\u043c\u0443 \u043a\u043e\u043d\u0446\u0443 \u043d\u0430\u0448\u0435\u0439 \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u044b \u2014 UI. \u0425\u043e\u0442\u044f \u043c\u044b \u0441\u043c\u043e\u0433\u043b\u0438 \u043b\u0435\u0433\u043a\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 , \u0434\u043e\u0431\u0438\u0442\u044c\u0441\u044f \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430 \u00ab\u043a\u0430\u043a \u0432 \u043c\u0430\u043a\u0435\u0442\u0435\u00bb \u043e\u043a\u0430\u0437\u0430\u043b\u043e\u0441\u044c \u043d\u0435 \u0442\u0430\u043a \u043f\u0440\u043e\u0441\u0442\u043e.<\/p>\n<p><strong>\u041f\u043e\u043b\u0435 \u0432\u0432\u043e\u0434\u0430 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f<\/strong>. \u0423\u0448\u043b\u043e \u043c\u043d\u043e\u0433\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u043d\u0430 \u0442\u043e, \u0447\u0442\u043e\u0431\u044b \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0435\u0433\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u043e\u0439 \u0432\u044b\u0441\u043e\u0442\u044b \u0438 \u0432\u044b\u0440\u043e\u0432\u043d\u044f\u0442\u044c \u043f\u043e \u0446\u0435\u043d\u0442\u0440\u0443, \u043d\u0435 \u0443\u043c\u0435\u043d\u044c\u0448\u0430\u044f \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u043a\u043b\u0438\u043a\u0430\u0431\u0435\u043b\u044c\u043d\u0443\u044e\u0439 \u0437\u043e\u043d\u0443.<\/p>\n<pre><code class=\"kotlin\">@Composable internal fun InputField(inputTextState: String) {     Row(             modifier = Modifier                 .fillMaxWidth()                 .height(IntrinsicSize.Min), \/\/ \u0432\u044b\u0440\u043e\u0432\u043d\u044f\u0442\u044c \u0432\u044b\u0441\u043e\u0442\u0443 \u0438\u043a\u043e\u043d\u043a\u0438 \u0438 \u043f\u043e\u043b\u044f \u0432\u0432\u043e\u0434\u0430             verticalAlignment = Alignment.CenterVertically,     ) {         Icon(modifier = Modifier.fillMaxHeight())         BasicTextField(                 value = inputTextState,                 onValueChange = {...},                 modifier = Modifier                     .weight(1f)                     .fillMaxHeight(),                 maxLines = 3,                 decorationBox = { innerTextField ->                     Box(contentAlignment = Alignment.CenterStart) { \/\/ \u0432\u044b\u0440\u043e\u0432\u043d\u044f\u0442\u044c \u0442\u0435\u043a\u0441\u0442 \u043f\u043e \u0441\u0435\u0440\u0435\u0434\u0438\u043d\u0435 \u043f\u043e\u043b\u0435 \u0432\u0432\u043e\u0434\u0430                         if (inputTextState.isEmpty()) {                             Text(                                     text = \"Hint...\",                             )                         }                         innerTextField()                     }                 }         )     } }<\/code><\/pre>\n<p><strong>\u0421\u0441\u044b\u043b\u043a\u0438 \u0432 \u0442\u0435\u043a\u0441\u0442\u0435<\/strong>. \u0412 Compose \u043d\u0435\u0442 autolink\u2019\u0430, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u0440\u0438\u0448\u043b\u043e\u0441\u044c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043e\u0431\u044b\u0447\u043d\u044b\u0439 TextView.<\/p>\n<pre><code class=\"kotlin\">AndroidView(         factory = {             TextView(it).apply {                 movementMethod = BetterLinkMovementMethod.newInstance().apply {                     setOnLinkClickListener { _, url ->                         onLinkClick(url)                         true                     }                 }             }         },         modifier = Modifier.weight(weight = 1f, fill = false),         {             it.text = message.text             LinkifyCompat.addLinks(it, Linkify.WEB_URLS)         } )<\/code><\/pre>\n<p><strong>BottomSheet<\/strong>. \u0418\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f <code>BottomSheet<\/code> \u0447\u0435\u0440\u0435\u0437 \u043c\u0435\u0442\u043e\u0434\u044b:<\/p>\n<pre><code class=\"kotlin\">val bottomSheetState = rememberBottomSheetState(BottomSheetValue.Collapsed) if (bottomSheetState.currentValue != BottomSheetValue.Collapsed) {     DisposableEffect(bottomSheetState) {         onDispose { component.onDismiss() } \/\/ \u0441\u043b\u0443\u0448\u0430\u0435\u043c \u0437\u0430\u043a\u0440\u044b\u0442\u0438\u0435 BottomSheet     } } val bottomSheetStateUpdate by component.bottomSheetStateUpdate.collectAsState() LaunchedEffect(bottomSheetStateUpdate) { \/\/ \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 BottomSheet \u043c\u043e\u0436\u043d\u043e \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u043c\u0435\u0442\u043e\u0434\u0430\u043c\u0438, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c LaunchedEffect     when (bottomSheetStateUpdate) {         BottomSheetState.Expanded -> bottomSheetState.expand()         BottomSheetState.Collapsed -> bottomSheetState.collapse()     } }<\/code><\/pre>\n<p>\u041e\u0431\u044a\u0435\u0434\u0438\u043d\u0438\u0432 \u043f\u043e\u043b\u0443\u0447\u0438\u0432\u0448\u0438\u0435\u0441\u044f \u0441\u043b\u043e\u0438, \u043c\u044b \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u043b\u0438, \u0447\u0442\u043e \u0432\u0441\u0451 \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442. \u041f\u043e\u0441\u043b\u0435 \u044d\u0442\u043e\u0433\u043e \u043e\u0441\u0442\u0430\u043b\u043e\u0441\u044c \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u043b\u043e\u0439 \u0431\u0438\u0437\u043d\u0435\u0441-\u043b\u043e\u0433\u0438\u043a\u0438, \u0441\u0432\u044f\u0437\u0430\u0432 \u0432\u0441\u0451 \u0432\u043e\u0435\u0434\u0438\u043d\u043e.<\/p>\n<h3>Domain<\/h3>\n<p>\u0418\u043c\u0435\u044f \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u044b \u0441 \u043e\u0431\u0435\u0438\u0445 \u0441\u0442\u043e\u0440\u043e\u043d \u0438 \u043e\u043f\u0440\u043e\u0431\u043e\u0432\u0430\u0432 \u0440\u0430\u0437\u043d\u044b\u0435 \u043f\u043e\u0434\u0445\u043e\u0434\u044b, \u043c\u044b \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043b\u0438 \u043b\u043e\u0433\u0438\u0447\u043d\u0443\u044e \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0443, \u043f\u043e\u0434\u0445\u043e\u0434\u044f\u0449\u0443\u044e \u0434\u043b\u044f \u043d\u0430\u0448\u0438\u0445 \u044d\u043a\u0440\u0430\u043d\u043e\u0432:<\/p>\n<p>Composable, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0435\u0442 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u044d\u043a\u0440\u0430\u043d\u0430 \u0438 \u043e\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043b\u044f\u0435\u0442 \u043d\u0430\u0432\u0438\u0433\u0430\u0446\u0438\u044e:<\/p>\n<pre><code class=\"kotlin\">Children(routerState = component.routerState) {     when (val child = it.instance) {         is ChatRoot.Child.Main -> ChatMainContent(child.component)     } }<\/code><\/pre>\n<p>Component, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0440\u0435\u0430\u0433\u0438\u0440\u0443\u0435\u0442 \u043d\u0430 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f \u044d\u043a\u0440\u0430\u043d\u0430:<\/p>\n<pre><code class=\"kotlin\">internal class ChatRootComponent(componentContext: ComponentContext) : ChatRoot, ComponentContext by componentContext {      private val router = router&lt;Configuration, ChatRoot.Child>(::createChild)     private val store = instanceKeeper.getStore { ChatRootStore(storeFactory) }     override val routerState = router.state     override val state = store.states      private fun createChild(configuration: Configuration, componentContext: ComponentContext): ChatRoot.Child {...} }<\/code><\/pre>\n<p>Store, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0435\u0442 \u0438 \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u0442 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e:<\/p>\n<pre><code class=\"kotlin\">internal class ChatRootStore(storeFactory: StoreFactory) : ChatRootStore, Store&lt;Intent, State, Label> by storeFactory.createStore() {      private class ExecutorImpl : CoroutineExecutor&lt;Intent, Unit, State, Result, Label>() {         override fun executeAction(action: Unit, getState: () -> State) {...}         override fun executeIntent(intent: Intent, getState: () -> State) {...}     }      private object ReducerImpl : Reducer&lt;State, Result> {         override fun State.reduce(result: Result): State {...}     } }<\/code><\/pre>\n<p>\u0418 \u043d\u0430 \u044d\u0442\u043e\u043c \u0432\u0441\u0451, \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0433\u043e\u0442\u043e\u0432\u0430!<\/p>\n<h3>\u0417\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435<\/h3>\n<p>\u041c\u044b \u0441\u0447\u0438\u0442\u0430\u0435\u043c \u044d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442 \u0443\u0441\u043f\u0435\u0448\u043d\u044b\u043c. Kotlin Multiplatform \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043f\u0435\u0440\u0435\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0437\u043d\u0430\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u0443\u044e \u0447\u0430\u0441\u0442\u044c \u043b\u043e\u0433\u0438\u043a\u0438. \u041f\u0440\u0438 \u044d\u0442\u043e\u043c \u0432\u0441\u0435\u0433\u0434\u0430 \u043c\u043e\u0436\u043d\u043e \u043e\u0431\u043e\u0439\u0442\u0438 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u043d\u044b\u0435 \u043c\u0435\u0441\u0442\u0430 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e expect\/actual. \u042d\u0442\u043e \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442 \u0433\u0438\u0431\u043a\u043e\u0441\u0442\u0438 \u0432 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 \u043e\u0431\u0449\u0435\u0433\u043e \u043c\u043e\u0434\u0443\u043b\u044f \u0441\u0440\u0435\u0434\u0438 \u0440\u0430\u0437\u043d\u044b\u0445 \u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c.<\/p>\n<p>\u0411\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f \u043c\u0443\u043b\u044c\u0442\u0438\u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u0435\u043d\u043d\u043e\u0441\u0442\u0438, \u043d\u0430\u043c \u0443\u0434\u0430\u043b\u043e\u0441\u044c \u043e\u0449\u0443\u0442\u0438\u043c\u043e \u0441\u043e\u043a\u0440\u0430\u0442\u0438\u0442\u044c \u0437\u0430\u0442\u0440\u0430\u0442\u044b \u043d\u0430 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0443 SDK. \u0414\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0439 \u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u044b \u043d\u0430\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e UI-\u0441\u043b\u043e\u0439, \u0430 \u0431\u0438\u0437\u043d\u0435\u0441-\u043b\u043e\u0433\u0438\u043a\u0430 \u0431\u0443\u0434\u0435\u0442 \u043f\u0435\u0440\u0435\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0430 \u0438\u0437 \u043e\u0431\u0449\u0435\u0433\u043e \u043c\u043e\u0434\u0443\u043b\u044f. \u0411\u043e\u043b\u0435\u0435 \u0442\u043e\u0433\u043e, \u0431\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f \u044d\u0442\u043e\u043c\u0443 \u0447\u0430\u0442 \u043d\u0430 \u0432\u0441\u0435\u0445 \u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u0430\u0445 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0435\u0434\u0438\u043d\u043e\u043e\u0431\u0440\u0430\u0437\u043d\u043e.<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/589875\/\"> https:\/\/habr.com\/ru\/articles\/589875\/<\/a><br \/><\/br><\/br><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-393458","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/393458","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=393458"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/393458\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=393458"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=393458"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=393458"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}