《【范圣佑】以 Kotlin Multiplatform 打造多平台应用.pdf》由会员分享,可在线阅读,更多相关《【范圣佑】以 Kotlin Multiplatform 打造多平台应用.pdf(50页珍藏版)》请在三个皮匠报告上搜索。
1、以 otlin Multiplatform范圣佑JetBrains 技术布道师打造多平台应用JetBrains 技术布道师 负责 IDE 产品及 Kotlin 语言推广 协助 Kotlin 社区生态范圣佑多平台开发痛点 各种型式的前端多平台开发痛点 各种型式的前端 需要适应多种开发語多平台开发痛点 各种型式的前端 需要适应多种开发語 重复的实现DTOValidationServiceHTTP01Kotlin 多平台Kotlin 发展史2016Kotlin 1.0 正式发布2019Google I/O 宣布 Android 开发 优先支持 Kotlin2022发布 Kotlin 1.72023发
2、布 Kotlin 1.8一眼看透 10 年历程General-purpose Static typing OOP+FP Open Source(Apache 2.0)2011JetBrains 正式公布 Kotlin 编程语言2017Google I/O 宣布 支持以 Kotlin 开发 Android AKotlin 编译器Kotlin 多平台ServerKotlin/JVMWebKotlin/JSDesktopKotlin/JVMAndroidKotlin/JVMiOSKotlin/N共享业务代码Compose 发展史2020JetBrains 开始将 Compose 转成 Multipl
3、atform从 Android 到 多平台2017Google I/O 宣布 支持以 Kotlin 开发 Android App2017Google 开始研发 Jetpack Compose 2019Google I/O 宣布 Android 开发 优先支持 Kotlin2021发布 Jetpack Compose 1.0 版2021发布 Compose Multiplatform 1.0 版多平台共享02以 实现多平台开发环境kdoctor可通过 Homebrew 安装的命令行,用于检查开发环境是否符合 Kotlin Multiplatform Mobile 的要求。Compose Mult
4、iplatform 项目模板项目结构 androidApp iosApp desktopApp shared-commonMain-androidMain-iosMain-desktopMain 先从 Mobile UI 开始Shared UI共用 UI 代码Composablefun App()PreviewComposablefun PrevewApp()App()图片Compose 组件Composable fun App()Image(painterResource(.),.)文本框Compose 组件Composable fun App()val username=remember
5、mutableStateOf(.)val password=remember mutableStateOf(.)TextField(label=Text(text=Username),value=username.value,onValueChange=username.value=it)TextField(label=Text(text=Password),value=password.value,visualTransformation=PasswordVisualTransformation(),keyboardOptions=KeyboardOptions(keyboardType=K
6、eyboardType.Password ),onValueChange=password.value=it)按钮Compose 组件Composable fun App()Button(onClick=/.,shape=RoundedCornerShape(50.dp),modifier=Modifier.fillMaxWidth().height(50.dp)Text(text=Login)布局Compose 组件Composable fun App()Column(modifier=Modifier.padding(20.dp),verticalArrangement=Arrangeme