initial import from openclaw workspace
Build Android app / Build (push) Has been cancelled
Build iOS app / Build (push) Has been cancelled
Template Cleanup / Template Cleanup (push) Has been cancelled

This commit is contained in:
xiaobai committed 2026-03-04 13:45:32 +08:00
commit 27d0d57b56
59 files changed
+2666

No files matched your search

+4
View File
@@ -0,0 +1,4 @@
root = true
[*]
ij_kotlin_name_count_to_use_star_import = 2147483647
+3
View File
@@ -0,0 +1,3 @@
# Kotlin Multiplatform app template
This is a basic Kotlin Multiplatform app template for Android and iOS. It includes shared business logic and data handling, and native UI implementations using Jetpack Compose and SwiftUI.
+24
View File
@@ -0,0 +1,24 @@
name: Build Android app
on:
push:
branches:
- main
pull_request:
jobs:
test:
name: Build
runs-on: macOS-latest
# Only run build in template repo
if: github.event.repository.name == 'KMP-App-Template-Native' && github.repository_owner == 'Kotlin'
steps:
- name: Check out code
uses: actions/checkout@v4
- name: Set up JDK 21
uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: 21
- name: Android debug build
run: ./gradlew assembleDebug --stacktrace
+26
View File
@@ -0,0 +1,26 @@
name: Build iOS app
on:
push:
branches:
- main
pull_request:
jobs:
test:
name: Build
runs-on: macOS-latest
# Only run build in template repo
if: github.event.repository.name == 'KMP-App-Template-Native' && github.repository_owner == 'Kotlin'
steps:
- name: Check out code
uses: actions/checkout@v4
- name: Set up JDK 21
uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: 21
- name: Set Xcode version
run: sudo xcode-select -s /Applications/Xcode_16.2.app/Contents/Developer
- name: iOS debug build
run: cd iosApp && xcodebuild -scheme iosApp -configuration Debug -destination 'platform=iOS Simulator,OS=latest,name=iPhone 16' CODE_SIGNING_ALLOWED='NO'
+40
View File
@@ -0,0 +1,40 @@
# GitHub Actions Workflow responsible for cleaning up the template repository from
# template-specific files. This workflow is supposed to be triggered automatically
# when a new template-based repository has been created.
name: Template Cleanup
on:
push:
branches:
- main
jobs:
# Run cleaning process only if workflow is triggered by the non-Kotlin/KMP-App-Template-Native repository.
template-cleanup:
name: Template Cleanup
runs-on: ubuntu-latest
if: github.event.repository.name != 'KMP-App-Template-Native' || github.repository_owner != 'Kotlin'
permissions:
contents: write
steps:
- name: Fetch Sources
uses: actions/checkout@v2
- name: Cleanup
run: |
mv .github/CLEAN_README.md README.md
rm LICENSE
rm -rf .github
- name: Commit files
run: |
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
git add .
git commit -m "Clean up template"
- name: Push changes
uses: ad-m/github-push-action@master
with:
branch: main
github_token: ${{ secrets.GITHUB_TOKEN }}
+18
View File
@@ -0,0 +1,18 @@
*.iml
.kotlin
.gradle
**/build/
xcuserdata
!src/**/build/
local.properties
.idea
.DS_Store
captures
.externalNativeBuild
.cxx
*.xcodeproj/*
!*.xcodeproj/project.pbxproj
!*.xcodeproj/xcshareddata/
!*.xcodeproj/project.xcworkspace/
!*.xcworkspace/contents.xcworkspacedata
**/xcshareddata/WorkspaceSettings.xcsettings
+201
View File
@@ -0,0 +1,201 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright 2023 JetBrains s.r.o. and respective authors and developers.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
+32
View File
@@ -0,0 +1,32 @@
# Kotlin Multiplatform app template
[![official project](http://jb.gg/badges/official.svg)](https://confluence.jetbrains.com/display/ALL/JetBrains+on+GitHub)
[![License](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
This is a basic Kotlin Multiplatform app template for Android and iOS. It includes shared business logic and data handling, and native UI implementations using Jetpack Compose and SwiftUI.
> The template is also available [with shared UI written in Compose Multiplatform](https://github.com/kotlin/KMP-App-Template).
>
> The [`amper` branch](https://github.com/Kotlin/kmp-mini-shopping/tree/amper) showcases the same project configured with [Amper](https://github.com/JetBrains/amper).
![Screenshots of the app](images/screenshots.png)
### Technologies
The data displayed by the app is from [The Metropolitan Museum of Art Collection API](https://metmuseum.github.io/).
The app uses the following multiplatform dependencies in its implementation:
- [Ktor](https://ktor.io/) for networking
- [kotlinx.serialization](https://github.com/Kotlin/kotlinx.serialization) for JSON handling
- [Koin](https://github.com/InsertKoinIO/koin) for dependency injection
- [KMP-ObservableViewModel](https://github.com/rickclephas/KMP-ObservableViewModel) for shared ViewModel implementations in common code
- [KMP-NativeCoroutines](https://github.com/rickclephas/KMP-NativeCoroutines)
> These are just some of the possible libraries to use for these tasks with Kotlin Multiplatform, and their usage here isn't a strong recommendation for these specific libraries over the available alternatives. You can find a wide variety of curated multiplatform libraries in the [kmp-awesome](https://github.com/terrakok/kmp-awesome) repository.
And the following Android-specific dependencies:
- [Jetpack Compose](https://developer.android.com/jetpack/compose)
- [Navigation component](https://developer.android.com/jetpack/compose/navigation)
- [Coil](https://github.com/coil-kt/coil) for image loading
+10
View File
@@ -0,0 +1,10 @@
plugins {
alias(libs.plugins.androidApplication) apply false
alias(libs.plugins.androidLibrary) apply false
alias(libs.plugins.composeCompiler) apply false
alias(libs.plugins.composeMultiplatform) apply false
alias(libs.plugins.kotlinMultiplatform) apply false
alias(libs.plugins.kotlinxSerialization) apply false
alias(libs.plugins.kmpNativeCoroutines) apply false
alias(libs.plugins.ksp) apply false
}
+72
View File
@@ -0,0 +1,72 @@
import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
plugins {
alias(libs.plugins.kotlinMultiplatform)
alias(libs.plugins.androidApplication)
alias(libs.plugins.composeCompiler)
alias(libs.plugins.composeMultiplatform)
alias(libs.plugins.kotlinxSerialization)
}
kotlin {
androidTarget {
@OptIn(ExperimentalKotlinGradlePluginApi::class)
compilerOptions {
jvmTarget.set(JvmTarget.JVM_11)
}
}
sourceSets {
androidMain.dependencies {
implementation(libs.androidx.compose.ui.tooling.preview)
implementation(libs.androidx.activity.compose)
implementation(libs.androidx.viewmodel.compose)
implementation(libs.androidx.navigation.compose)
implementation(libs.koin.androidx.compose)
implementation(libs.coil.compose)
implementation(libs.coil.network.ktor)
}
commonMain.dependencies {
implementation(compose.runtime)
implementation(compose.foundation)
implementation(compose.material3)
implementation(compose.ui)
implementation(compose.components.resources)
implementation(compose.components.uiToolingPreview)
implementation(projects.shared)
implementation(libs.kotlinx.serialization.core)
}
}
}
android {
namespace = "com.example.minishop"
compileSdk = 35
defaultConfig {
applicationId = "com.example.minishop"
minSdk = 24
targetSdk = 35
versionCode = 1
versionName = "1.0"
}
packaging {
resources {
excludes += "/META-INF/{AL2.0,LGPL2.1}"
}
}
buildTypes {
getByName("release") {
isMinifyEnabled = false
}
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
}
}
dependencies {
debugImplementation(libs.androidx.compose.ui.tooling)
}
@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<uses-permission android:name="android.permission.INTERNET" />
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@android:style/Theme.Material.Light.NoActionBar">
<activity
android:exported="true"
android:windowSoftInputMode="adjustResize"
android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
@@ -0,0 +1,320 @@
package com.example.minishop
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.items
import androidx.compose.material3.Button
import androidx.compose.material3.Card
import androidx.compose.material3.ElevatedCard
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.NavigationBar
import androidx.compose.material3.NavigationBarItem
import androidx.compose.material3.OutlinedButton
import androidx.compose.material3.OutlinedTextField
import androidx.compose.material3.Scaffold
import androidx.compose.material3.Text
import androidx.compose.material3.TextButton
import androidx.compose.material3.TopAppBar
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import com.example.minishop.cart.CartState
import com.example.minishop.cart.CartStore
import com.example.minishop.data.FakeProductRepository
import com.example.minishop.data.FavoriteStore
import com.example.minishop.model.Product
private enum class Tab { Home, Favorites, Cart }
@Composable
fun App() {
MaterialTheme {
val repo = remember { FakeProductRepository() }
val cartStore = remember { CartStore() }
val favoriteStore = remember { FavoriteStore() }
var currentTab by remember { mutableStateOf(Tab.Home) }
var selected by remember { mutableStateOf<Product?>(null) }
var inDetail by remember { mutableStateOf(false) }
var tick by remember { mutableStateOf(0) }
var query by remember { mutableStateOf("") }
val allProducts = remember { repo.getProducts() }
val products = remember(query, tick) {
allProducts.filter {
it.title.contains(query, ignoreCase = true) ||
it.description.contains(query, ignoreCase = true)
}
}
val favorites = remember(tick) { favoriteStore.all() }
val cartState = remember(tick) { cartStore.state() }
Scaffold(
topBar = {
TopAppBar(
title = {
Text(
when {
inDetail -> "商品详情"
currentTab == Tab.Home -> "Mini Shopping"
currentTab == Tab.Favorites -> "收藏夹"
else -> "购物车"
}
)
},
actions = {
if (inDetail) {
TextButton(onClick = { inDetail = false }) { Text("返回") }
}
}
)
},
bottomBar = {
if (!inDetail) {
NavigationBar {
NavigationBarItem(
selected = currentTab == Tab.Home,
onClick = { currentTab = Tab.Home },
icon = { Text("🏠") },
label = { Text("首页") }
)
NavigationBarItem(
selected = currentTab == Tab.Favorites,
onClick = { currentTab = Tab.Favorites },
icon = { Text("❤️") },
label = { Text("收藏(${favorites.size})") }
)
NavigationBarItem(
selected = currentTab == Tab.Cart,
onClick = { currentTab = Tab.Cart },
icon = { Text("🛒") },
label = { Text("购物车(${cartState.totalCount})") }
)
}
}
}
) { padding ->
Box(Modifier.padding(padding).fillMaxSize()) {
when {
inDetail -> ProductDetailScreen(
product = selected,
isFavorite = selected?.let { favoriteStore.isFavorite(it.id) } == true,
onBack = { inDetail = false },
onToggleFavorite = {
selected?.let {
favoriteStore.toggle(it.id)
tick++
}
},
onAdd = {
cartStore.add(it)
tick++
}
)
currentTab == Tab.Home -> ProductListScreen(
products = products,
query = query,
onQueryChange = { query = it },
isFavorite = { favoriteStore.isFavorite(it) },
quantityOf = { cartState.quantityOf(it) },
onToggleFavorite = { id ->
favoriteStore.toggle(id)
tick++
},
onClick = {
selected = it
inDetail = true
}
)
currentTab == Tab.Favorites -> FavoriteScreen(
products = allProducts.filter { favoriteStore.isFavorite(it.id) },
quantityOf = { cartState.quantityOf(it) },
onOpen = {
selected = it
inDetail = true
},
onAdd = {
cartStore.add(it)
tick++
}
)
else -> CartScreen(
cartState = cartState,
onInc = { id -> cartStore.increase(id); tick++ },
onDec = { id -> cartStore.decrease(id); tick++ },
onRemove = { id -> cartStore.remove(id); tick++ },
onClear = { cartStore.clear(); tick++ }
)
}
}
}
}
}
@Composable
private fun ProductListScreen(
products: List<Product>,
query: String,
onQueryChange: (String) -> Unit,
isFavorite: (String) -> Boolean,
quantityOf: (String) -> Int,
onToggleFavorite: (String) -> Unit,
onClick: (Product) -> Unit
) {
Column(Modifier.fillMaxSize().padding(12.dp), verticalArrangement = Arrangement.spacedBy(10.dp)) {
OutlinedTextField(
modifier = Modifier.fillMaxWidth(),
value = query,
onValueChange = onQueryChange,
singleLine = true,
label = { Text("搜索课程") },
placeholder = { Text("输入标题或描述") }
)
if (products.isEmpty()) {
EmptyState("没有匹配的商品")
} else {
LazyColumn(verticalArrangement = Arrangement.spacedBy(8.dp)) {
items(products) { p ->
ElevatedCard(onClick = { onClick(p) }, modifier = Modifier.fillMaxWidth()) {
Column(Modifier.padding(12.dp), verticalArrangement = Arrangement.spacedBy(6.dp)) {
Row(Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.SpaceBetween) {
Text(p.title, style = MaterialTheme.typography.titleMedium)
Text("¥${formatPrice(p.price)}")
}
Text(p.description, style = MaterialTheme.typography.bodySmall)
Row(horizontalArrangement = Arrangement.spacedBy(8.dp)) {
OutlinedButton(onClick = { onToggleFavorite(p.id) }) {
Text(if (isFavorite(p.id)) "已收藏" else "收藏")
}
val q = quantityOf(p.id)
if (q > 0) Text("已加购 x$q", style = MaterialTheme.typography.bodySmall)
}
}
}
}
}
}
}
}
@Composable
private fun ProductDetailScreen(
product: Product?,
isFavorite: Boolean,
onBack: () -> Unit,
onToggleFavorite: () -> Unit,
onAdd: (Product) -> Unit
) {
if (product == null) {
EmptyState("商品不存在")
return
}
Column(Modifier.fillMaxSize().padding(16.dp), verticalArrangement = Arrangement.spacedBy(12.dp)) {
Text(product.title, style = MaterialTheme.typography.headlineSmall)
Text("价格:¥${formatPrice(product.price)}")
Text(product.description)
Row(horizontalArrangement = Arrangement.spacedBy(8.dp)) {
Button(onClick = onBack) { Text("返回") }
Button(onClick = { onAdd(product) }) { Text("加入购物车") }
OutlinedButton(onClick = onToggleFavorite) {
Text(if (isFavorite) "取消收藏" else "收藏")
}
}
}
}
@Composable
private fun CartScreen(
cartState: CartState,
onInc: (String) -> Unit,
onDec: (String) -> Unit,
onRemove: (String) -> Unit,
onClear: () -> Unit
) {
Column(Modifier.fillMaxSize().padding(16.dp), verticalArrangement = Arrangement.spacedBy(12.dp)) {
if (cartState.items.isNotEmpty()) {
OutlinedButton(onClick = onClear) { Text("清空购物车") }
}
if (cartState.items.isEmpty()) {
EmptyState("购物车为空")
} else {
LazyColumn(Modifier.weight(1f), verticalArrangement = Arrangement.spacedBy(8.dp)) {
items(cartState.items) { item ->
Card(Modifier.fillMaxWidth()) {
Column(Modifier.padding(12.dp), verticalArrangement = Arrangement.spacedBy(8.dp)) {
Row(Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.SpaceBetween) {
Text(item.product.title)
Text("¥${formatPrice(item.product.price * item.quantity)}")
}
Row(horizontalArrangement = Arrangement.spacedBy(6.dp)) {
OutlinedButton(onClick = { onDec(item.product.id) }) { Text("-") }
Text("数量 ${item.quantity}")
OutlinedButton(onClick = { onInc(item.product.id) }) { Text("+") }
OutlinedButton(onClick = { onRemove(item.product.id) }) { Text("移除") }
}
}
}
}
}
Text("总件数:${cartState.totalCount}")
Text("合计:¥${formatPrice(cartState.totalPrice)}", style = MaterialTheme.typography.titleMedium)
}
}
}
@Composable
private fun FavoriteScreen(
products: List<Product>,
quantityOf: (String) -> Int,
onOpen: (Product) -> Unit,
onAdd: (Product) -> Unit
) {
if (products.isEmpty()) {
EmptyState("你还没有收藏课程")
} else {
LazyColumn(Modifier.fillMaxSize().padding(16.dp), verticalArrangement = Arrangement.spacedBy(8.dp)) {
items(products) { p ->
ElevatedCard(onClick = { onOpen(p) }, modifier = Modifier.fillMaxWidth()) {
Column(Modifier.padding(12.dp), verticalArrangement = Arrangement.spacedBy(6.dp)) {
Text(p.title, style = MaterialTheme.typography.titleMedium)
Text("¥${formatPrice(p.price)}")
Row(horizontalArrangement = Arrangement.spacedBy(8.dp)) {
Button(onClick = { onAdd(p) }) { Text("加入购物车") }
val q = quantityOf(p.id)
if (q > 0) Text("已加购 x$q")
}
}
}
}
}
}
}
@Composable
private fun EmptyState(text: String) {
Box(Modifier.fillMaxSize().padding(24.dp)) {
Text(text, style = MaterialTheme.typography.bodyLarge)
}
}
private fun formatPrice(price: Double): String = "%.2f".format(price)
@@ -0,0 +1,14 @@
package com.example.minishop
import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
class MainActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContent {
App()
}
}
}
@@ -0,0 +1,30 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:aapt="http://schemas.android.com/aapt"
android:width="108dp"
android:height="108dp"
android:viewportWidth="108"
android:viewportHeight="108">
<path android:pathData="M31,63.928c0,0 6.4,-11 12.1,-13.1c7.2,-2.6 26,-1.4 26,-1.4l38.1,38.1L107,108.928l-32,-1L31,63.928z">
<aapt:attr name="android:fillColor">
<gradient
android:endX="85.84757"
android:endY="92.4963"
android:startX="42.9492"
android:startY="49.59793"
android:type="linear">
<item
android:color="#44000000"
android:offset="0.0" />
<item
android:color="#00000000"
android:offset="1.0" />
</gradient>
</aapt:attr>
</path>
<path
android:fillColor="#FFFFFF"
android:fillType="nonZero"
android:pathData="M65.3,45.828l3.8,-6.6c0.2,-0.4 0.1,-0.9 -0.3,-1.1c-0.4,-0.2 -0.9,-0.1 -1.1,0.3l-3.9,6.7c-6.3,-2.8 -13.4,-2.8 -19.7,0l-3.9,-6.7c-0.2,-0.4 -0.7,-0.5 -1.1,-0.3C38.8,38.328 38.7,38.828 38.9,39.228l3.8,6.6C36.2,49.428 31.7,56.028 31,63.928h46C76.3,56.028 71.8,49.428 65.3,45.828zM43.4,57.328c-0.8,0 -1.5,-0.5 -1.8,-1.2c-0.3,-0.7 -0.1,-1.5 0.4,-2.1c0.5,-0.5 1.4,-0.7 2.1,-0.4c0.7,0.3 1.2,1 1.2,1.8C45.3,56.528 44.5,57.328 43.4,57.328L43.4,57.328zM64.6,57.328c-0.8,0 -1.5,-0.5 -1.8,-1.2s-0.1,-1.5 0.4,-2.1c0.5,-0.5 1.4,-0.7 2.1,-0.4c0.7,0.3 1.2,1 1.2,1.8C66.5,56.528 65.6,57.328 64.6,57.328L64.6,57.328z"
android:strokeWidth="1"
android:strokeColor="#00000000" />
</vector>
@@ -0,0 +1,170 @@
<?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="108dp"
android:height="108dp"
android:viewportWidth="108"
android:viewportHeight="108">
<path
android:fillColor="#3DDC84"
android:pathData="M0,0h108v108h-108z" />
<path
android:fillColor="#00000000"
android:pathData="M9,0L9,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,0L19,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M29,0L29,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M39,0L39,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M49,0L49,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M59,0L59,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M69,0L69,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M79,0L79,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M89,0L89,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M99,0L99,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,9L108,9"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,19L108,19"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,29L108,29"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,39L108,39"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,49L108,49"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,59L108,59"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,69L108,69"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,79L108,79"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,89L108,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,99L108,99"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,29L89,29"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,39L89,39"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,49L89,49"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,59L89,59"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,69L89,69"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,79L89,79"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M29,19L29,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M39,19L39,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M49,19L49,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M59,19L59,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M69,19L69,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M79,19L79,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
</vector>
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@drawable/ic_launcher_background" />
<foreground android:drawable="@drawable/ic_launcher_foreground" />
</adaptive-icon>
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@drawable/ic_launcher_background" />
<foreground android:drawable="@drawable/ic_launcher_foreground" />
</adaptive-icon>
Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

@@ -0,0 +1,16 @@
<resources>
<string name="app_name">Mini Shopping</string>
<string name="label_title">Title</string>
<string name="label_artist">Artist</string>
<string name="label_date">Date</string>
<string name="label_dimensions">Dimensions</string>
<string name="label_medium">Medium</string>
<string name="label_department">Department</string>
<string name="label_repository">Repository</string>
<string name="label_credits">Credits</string>
<string name="back">Back</string>
<string name="no_data_available">No data available</string>
</resources>
+12
View File
@@ -0,0 +1,12 @@
kotlin.code.style=official
kotlin.daemon.jvmargs=-Xmx2048M
#Gradle
org.gradle.jvmargs=-Xmx2048M -Dfile.encoding=UTF-8
#Android
android.nonTransitiveRClass=true
android.useAndroidX=true
# Workaround for https://youtrack.jetbrains.com/issue/KT-74278/, should be fixed in Kotlin 2.2.0
kotlin.native.toolchain.enabled=false
+43
View File
@@ -0,0 +1,43 @@
[versions]
agp = "8.9.3"
androidx-activityCompose = "1.10.1"
androidx-navigationCompose = "2.9.0"
androidx-ui-tooling = "1.8.3"
androidx-viewmodelCompose = "2.9.1"
coil = "3.2.0"
compose-multiplatform = "1.8.2"
kmpObservableViewmodel = "1.0.0-BETA-12"
kmpNativeCoroutines = "1.0.0-ALPHA-45"
koin = "4.1.0"
kotlin = "2.2.0"
kotlinx-serialization = "1.8.1"
ksp = "2.2.0-2.0.2"
ktor = "3.1.3"
[libraries]
androidx-activity-compose = { module = "androidx.activity:activity-compose", version.ref = "androidx-activityCompose" }
androidx-compose-ui-tooling = { module = "androidx.compose.ui:ui-tooling", version.ref = "androidx-ui-tooling" }
androidx-compose-ui-tooling-preview = { module = "androidx.compose.ui:ui-tooling-preview", version.ref = "androidx-ui-tooling" }
androidx-navigation-compose = { module = "androidx.navigation:navigation-compose", version.ref = "androidx-navigationCompose" }
androidx-viewmodel-compose = { module = "androidx.lifecycle:lifecycle-viewmodel-compose", version.ref = "androidx-viewmodelCompose" }
coil-compose = { group = "io.coil-kt.coil3", name = "coil-compose", version.ref = "coil" }
coil-network-ktor = { group = "io.coil-kt.coil3", name = "coil-network-ktor3", version.ref = "coil" }
kmp-observable-viewmodel = { module = "com.rickclephas.kmp:kmp-observableviewmodel-core", version.ref = "kmpObservableViewmodel" }
koin-androidx-compose = { module = "io.insert-koin:koin-androidx-compose", version.ref = "koin" }
koin-core = { module = "io.insert-koin:koin-core", version.ref = "koin" }
kotlinx-serialization-core = { module = "org.jetbrains.kotlinx:kotlinx-serialization-core", version.ref = "kotlinx-serialization" }
ktor-client-content-negotiation = { module = "io.ktor:ktor-client-content-negotiation", version.ref = "ktor" }
ktor-client-core = { module = "io.ktor:ktor-client-core", version.ref = "ktor" }
ktor-client-darwin = { module = "io.ktor:ktor-client-darwin", version.ref = "ktor" }
ktor-client-okhttp = { module = "io.ktor:ktor-client-okhttp", version.ref = "ktor" }
ktor-serialization-kotlinx-json = { module = "io.ktor:ktor-serialization-kotlinx-json", version.ref = "ktor" }
[plugins]
androidApplication = { id = "com.android.application", version.ref = "agp" }
androidLibrary = { id = "com.android.library", version.ref = "agp" }
composeCompiler = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "kotlin" }
composeMultiplatform = { id = "org.jetbrains.compose", version.ref = "compose-multiplatform" }
kmpNativeCoroutines = { id = "com.rickclephas.kmp.nativecoroutines", version.ref = "kmpNativeCoroutines" }
kotlinMultiplatform = { id = "org.jetbrains.kotlin.multiplatform", version.ref = "kotlin" }
kotlinxSerialization = { id = "org.jetbrains.kotlin.plugin.serialization", version.ref = "kotlin" }
ksp = { id = "com.google.devtools.ksp", version.ref = "ksp" }
Binary file not shown.
+7
View File
@@ -0,0 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.13-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Vendored Executable
+251
View File
@@ -0,0 +1,251 @@
#!/bin/sh
#
# Copyright © 2015-2021 the original authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# SPDX-License-Identifier: Apache-2.0
#
##############################################################################
#
# Gradle start up script for POSIX generated by Gradle.
#
# Important for running:
#
# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
# noncompliant, but you have some other compliant shell such as ksh or
# bash, then to run this script, type that shell name before the whole
# command line, like:
#
# ksh Gradle
#
# Busybox and similar reduced shells will NOT work, because this script
# requires all of these POSIX shell features:
# * functions;
# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
# * compound commands having a testable exit status, especially «case»;
# * various built-in commands including «command», «set», and «ulimit».
#
# Important for patching:
#
# (2) This script targets any POSIX shell, so it avoids extensions provided
# by Bash, Ksh, etc; in particular arrays are avoided.
#
# The "traditional" practice of packing multiple parameters into a
# space-separated string is a well documented source of bugs and security
# problems, so this is (mostly) avoided, by progressively accumulating
# options in "$@", and eventually passing that to Java.
#
# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
# see the in-line comments for details.
#
# There are tweaks for specific operating systems such as AIX, CygWin,
# Darwin, MinGW, and NonStop.
#
# (3) This script is generated from the Groovy template
# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# within the Gradle project.
#
# You can find Gradle at https://github.com/gradle/gradle/.
#
##############################################################################
# Attempt to set APP_HOME
# Resolve links: $0 may be a link
app_path=$0
# Need this for daisy-chained symlinks.
while
APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
[ -h "$app_path" ]
do
ls=$( ls -ld "$app_path" )
link=${ls#*' -> '}
case $link in #(
/*) app_path=$link ;; #(
*) app_path=$APP_HOME$link ;;
esac
done
# This is normally unused
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
warn () {
echo "$*"
} >&2
die () {
echo
echo "$*"
echo
exit 1
} >&2
# OS specific support (must be 'true' or 'false').
cygwin=false
msys=false
darwin=false
nonstop=false
case "$( uname )" in #(
CYGWIN* ) cygwin=true ;; #(
Darwin* ) darwin=true ;; #(
MSYS* | MINGW* ) msys=true ;; #(
NONSTOP* ) nonstop=true ;;
esac
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD=$JAVA_HOME/jre/sh/java
else
JAVACMD=$JAVA_HOME/bin/java
fi
if [ ! -x "$JAVACMD" ] ; then
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
else
JAVACMD=java
if ! command -v java >/dev/null 2>&1
then
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
fi
# Increase the maximum file descriptors if we can.
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
case $MAX_FD in #(
max*)
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC2039,SC3045
MAX_FD=$( ulimit -H -n ) ||
warn "Could not query maximum file descriptor limit"
esac
case $MAX_FD in #(
'' | soft) :;; #(
*)
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC2039,SC3045
ulimit -n "$MAX_FD" ||
warn "Could not set maximum file descriptor limit to $MAX_FD"
esac
fi
# Collect all arguments for the java command, stacking in reverse order:
# * args from the command line
# * the main class name
# * -classpath
# * -D...appname settings
# * --module-path (only if needed)
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
# For Cygwin or MSYS, switch paths to Windows format before running java
if "$cygwin" || "$msys" ; then
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
JAVACMD=$( cygpath --unix "$JAVACMD" )
# Now convert the arguments - kludge to limit ourselves to /bin/sh
for arg do
if
case $arg in #(
-*) false ;; # don't mess with options #(
/?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
[ -e "$t" ] ;; #(
*) false ;;
esac
then
arg=$( cygpath --path --ignore --mixed "$arg" )
fi
# Roll the args list around exactly as many times as the number of
# args, so each arg winds up back in the position where it started, but
# possibly modified.
#
# NB: a `for` loop captures its iteration list before it begins, so
# changing the positional parameters here affects neither the number of
# iterations, nor the values presented in `arg`.
shift # remove old arg
set -- "$@" "$arg" # push replacement arg
done
fi
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Collect all arguments for the java command:
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
# and any embedded shellness will be escaped.
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
# treated as '${Hostname}' itself on the command line.
set -- \
"-Dorg.gradle.appname=$APP_BASE_NAME" \
-classpath "$CLASSPATH" \
org.gradle.wrapper.GradleWrapperMain \
"$@"
# Stop when "xargs" is not available.
if ! command -v xargs >/dev/null 2>&1
then
die "xargs is not available"
fi
# Use "xargs" to parse quoted args.
#
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
#
# In Bash we could simply go:
#
# readarray ARGS < <( xargs -n1 <<<"$var" ) &&
# set -- "${ARGS[@]}" "$@"
#
# but POSIX shell has neither arrays nor command substitution, so instead we
# post-process each arg (as a line of input to sed) to backslash-escape any
# character that might be a shell metacharacter, then use eval to reverse
# that process (while maintaining the separation between arguments), and wrap
# the whole thing up as a single "set" statement.
#
# This will of course break if any of these variables contains a newline or
# an unmatched quote.
#
eval "set -- $(
printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
xargs -n1 |
sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
tr '\n' ' '
)" '"$@"'
exec "$JAVACMD" "$@"
Vendored
+94
View File
@@ -0,0 +1,94 @@
@rem
@rem Copyright 2015 the original author or authors.
@rem
@rem Licensed under the Apache License, Version 2.0 (the "License");
@rem you may not use this file except in compliance with the License.
@rem You may obtain a copy of the License at
@rem
@rem https://www.apache.org/licenses/LICENSE-2.0
@rem
@rem Unless required by applicable law or agreed to in writing, software
@rem distributed under the License is distributed on an "AS IS" BASIS,
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@rem See the License for the specific language governing permissions and
@rem limitations under the License.
@rem
@rem SPDX-License-Identifier: Apache-2.0
@rem
@if "%DEBUG%"=="" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@rem
@rem ##########################################################################
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
set DIRNAME=%~dp0
if "%DIRNAME%"=="" set DIRNAME=.
@rem This is normally unused
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if %ERRORLEVEL% equ 0 goto execute
echo. 1>&2
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. 1>&2
goto fail
:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto execute
echo. 1>&2
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. 1>&2
goto fail
:execute
@rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
:end
@rem End local scope for the variables with windows NT shell
if %ERRORLEVEL% equ 0 goto mainEnd
:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
set EXIT_CODE=%ERRORLEVEL%
if %EXIT_CODE% equ 0 set EXIT_CODE=1
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
exit /b %EXIT_CODE%
:mainEnd
if "%OS%"=="Windows_NT" endlocal
:omega
Binary file not shown.

After

Width:  |  Height:  |  Size: 859 KiB

+3
View File
@@ -0,0 +1,3 @@
TEAM_ID=
BUNDLE_ID=com.example.minishop.kmp-mini-shopping
APP_NAME=KMP App
+457
View File
@@ -0,0 +1,457 @@
// !$*UTF8*$!
{
archiveVersion = 1;
classes = {
};
objectVersion = 56;
objects = {
/* Begin PBXBuildFile section */
058557BB273AAA24004C7B11 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 058557BA273AAA24004C7B11 /* Assets.xcassets */; };
058557D9273AAEEB004C7B11 /* Preview Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 058557D8273AAEEB004C7B11 /* Preview Assets.xcassets */; };
2152FB042600AC8F00CF470E /* iOSApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2152FB032600AC8F00CF470E /* iOSApp.swift */; };
7555FF83242A565900829871 /* ListView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7555FF82242A565900829871 /* ListView.swift */; };
EB049AFF2C1AEB680032A688 /* KMPObservableViewModelCore in Frameworks */ = {isa = PBXBuildFile; productRef = EB049AFE2C1AEB680032A688 /* KMPObservableViewModelCore */; };
EB049B012C1AEB680032A688 /* KMPObservableViewModelSwiftUI in Frameworks */ = {isa = PBXBuildFile; productRef = EB049B002C1AEB680032A688 /* KMPObservableViewModelSwiftUI */; };
EB1C5CC72AE06906002852BE /* DetailView.swift in Sources */ = {isa = PBXBuildFile; fileRef = EB1C5CC62AE06906002852BE /* DetailView.swift */; };
EB50C4902BE0EB69005DE781 /* KMPNativeCoroutinesAsync in Frameworks */ = {isa = PBXBuildFile; productRef = EB50C48F2BE0EB69005DE781 /* KMPNativeCoroutinesAsync */; };
EB50C4922BE0EB69005DE781 /* KMPNativeCoroutinesCore in Frameworks */ = {isa = PBXBuildFile; productRef = EB50C4912BE0EB69005DE781 /* KMPNativeCoroutinesCore */; };
EB50C4942BE0F0D8005DE781 /* KMPObservableViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = EB50C4932BE0F0D8005DE781 /* KMPObservableViewModel.swift */; };
/* End PBXBuildFile section */
/* Begin PBXFileReference section */
058557BA273AAA24004C7B11 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
058557D8273AAEEB004C7B11 /* Preview Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = "Preview Assets.xcassets"; sourceTree = "<group>"; };
2152FB032600AC8F00CF470E /* iOSApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = iOSApp.swift; sourceTree = "<group>"; };
7555FF7B242A565900829871 /* KMP App.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "KMP App.app"; sourceTree = BUILT_PRODUCTS_DIR; };
7555FF82242A565900829871 /* ListView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListView.swift; sourceTree = "<group>"; };
7555FF8C242A565B00829871 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
AB3632DC29227652001CCB65 /* Config.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = Config.xcconfig; sourceTree = "<group>"; };
EB1C5CC62AE06906002852BE /* DetailView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DetailView.swift; sourceTree = "<group>"; };
EB50C4932BE0F0D8005DE781 /* KMPObservableViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KMPObservableViewModel.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
B92378962B6B1156000C7307 /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
EB049AFF2C1AEB680032A688 /* KMPObservableViewModelCore in Frameworks */,
EB049B012C1AEB680032A688 /* KMPObservableViewModelSwiftUI in Frameworks */,
EB50C4922BE0EB69005DE781 /* KMPNativeCoroutinesCore in Frameworks */,
EB50C4902BE0EB69005DE781 /* KMPNativeCoroutinesAsync in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXFrameworksBuildPhase section */
/* Begin PBXGroup section */
058557D7273AAEEB004C7B11 /* Preview Content */ = {
isa = PBXGroup;
children = (
058557D8273AAEEB004C7B11 /* Preview Assets.xcassets */,
);
path = "Preview Content";
sourceTree = "<group>";
};
42799AB246E5F90AF97AA0EF /* Frameworks */ = {
isa = PBXGroup;
children = (
);
name = Frameworks;
sourceTree = "<group>";
};
7555FF72242A565900829871 = {
isa = PBXGroup;
children = (
AB1DB47929225F7C00F7AF9C /* Configuration */,
7555FF7D242A565900829871 /* iosApp */,
7555FF7C242A565900829871 /* Products */,
42799AB246E5F90AF97AA0EF /* Frameworks */,
);
sourceTree = "<group>";
};
7555FF7C242A565900829871 /* Products */ = {
isa = PBXGroup;
children = (
7555FF7B242A565900829871 /* KMP App.app */,
);
name = Products;
sourceTree = "<group>";
};
7555FF7D242A565900829871 /* iosApp */ = {
isa = PBXGroup;
children = (
058557BA273AAA24004C7B11 /* Assets.xcassets */,
7555FF82242A565900829871 /* ListView.swift */,
7555FF8C242A565B00829871 /* Info.plist */,
2152FB032600AC8F00CF470E /* iOSApp.swift */,
058557D7273AAEEB004C7B11 /* Preview Content */,
EB1C5CC62AE06906002852BE /* DetailView.swift */,
EB50C4932BE0F0D8005DE781 /* KMPObservableViewModel.swift */,
);
path = iosApp;
sourceTree = "<group>";
};
AB1DB47929225F7C00F7AF9C /* Configuration */ = {
isa = PBXGroup;
children = (
AB3632DC29227652001CCB65 /* Config.xcconfig */,
);
path = Configuration;
sourceTree = "<group>";
};
/* End PBXGroup section */
/* Begin PBXNativeTarget section */
7555FF7A242A565900829871 /* iosApp */ = {
isa = PBXNativeTarget;
buildConfigurationList = 7555FFA5242A565B00829871 /* Build configuration list for PBXNativeTarget "iosApp" */;
buildPhases = (
F36B1CEA2AD836FC00CB74D5 /* Compile Kotlin Framework */,
7555FF77242A565900829871 /* Sources */,
B92378962B6B1156000C7307 /* Frameworks */,
7555FF79242A565900829871 /* Resources */,
);
buildRules = (
);
dependencies = (
);
name = iosApp;
packageProductDependencies = (
EB50C48F2BE0EB69005DE781 /* KMPNativeCoroutinesAsync */,
EB50C4912BE0EB69005DE781 /* KMPNativeCoroutinesCore */,
EB049AFE2C1AEB680032A688 /* KMPObservableViewModelCore */,
EB049B002C1AEB680032A688 /* KMPObservableViewModelSwiftUI */,
);
productName = iosApp;
productReference = 7555FF7B242A565900829871 /* KMP App.app */;
productType = "com.apple.product-type.application";
};
/* End PBXNativeTarget section */
/* Begin PBXProject section */
7555FF73242A565900829871 /* Project object */ = {
isa = PBXProject;
attributes = {
BuildIndependentTargetsInParallel = YES;
LastSwiftUpdateCheck = 1130;
LastUpgradeCheck = 1540;
ORGANIZATIONNAME = orgName;
TargetAttributes = {
7555FF7A242A565900829871 = {
CreatedOnToolsVersion = 11.3.1;
};
};
};
buildConfigurationList = 7555FF76242A565900829871 /* Build configuration list for PBXProject "iosApp" */;
compatibilityVersion = "Xcode 14.0";
developmentRegion = en;
hasScannedForEncodings = 0;
knownRegions = (
en,
Base,
);
mainGroup = 7555FF72242A565900829871;
packageReferences = (
EB50C48E2BE0EB69005DE781 /* XCRemoteSwiftPackageReference "KMP-NativeCoroutines" */,
EB049AFD2C1AEB680032A688 /* XCRemoteSwiftPackageReference "KMP-ObservableViewModel" */,
);
productRefGroup = 7555FF7C242A565900829871 /* Products */;
projectDirPath = "";
projectRoot = "";
targets = (
7555FF7A242A565900829871 /* iosApp */,
);
};
/* End PBXProject section */
/* Begin PBXResourcesBuildPhase section */
7555FF79242A565900829871 /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
058557D9273AAEEB004C7B11 /* Preview Assets.xcassets in Resources */,
058557BB273AAA24004C7B11 /* Assets.xcassets in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXResourcesBuildPhase section */
/* Begin PBXShellScriptBuildPhase section */
F36B1CEA2AD836FC00CB74D5 /* Compile Kotlin Framework */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputFileListPaths = (
);
inputPaths = (
);
name = "Compile Kotlin Framework";
outputFileListPaths = (
);
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "if [ \"YES\" = \"$OVERRIDE_KOTLIN_BUILD_IDE_SUPPORTED\" ]; then\n echo \"Skipping Gradle build task invocation due to OVERRIDE_KOTLIN_BUILD_IDE_SUPPORTED environment variable set to \\\"YES\\\"\"\n exit 0\nfi\ncd \"$SRCROOT/..\"\n./gradlew :shared:embedAndSignAppleFrameworkForXcode\n";
};
/* End PBXShellScriptBuildPhase section */
/* Begin PBXSourcesBuildPhase section */
7555FF77242A565900829871 /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
EB1C5CC72AE06906002852BE /* DetailView.swift in Sources */,
2152FB042600AC8F00CF470E /* iOSApp.swift in Sources */,
EB50C4942BE0F0D8005DE781 /* KMPObservableViewModel.swift in Sources */,
7555FF83242A565900829871 /* ListView.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXSourcesBuildPhase section */
/* Begin XCBuildConfiguration section */
7555FFA3242A565B00829871 /* Debug */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = AB3632DC29227652001CCB65 /* Config.xcconfig */;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_NONNULL = YES;
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_ENABLE_OBJC_WEAK = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
COPY_PHASE_STRIP = NO;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
ENABLE_USER_SCRIPT_SANDBOXING = NO;
GCC_C_LANGUAGE_STANDARD = gnu11;
GCC_DYNAMIC_NO_PIC = NO;
GCC_NO_COMMON_BLOCKS = YES;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_PREPROCESSOR_DEFINITIONS = (
"DEBUG=1",
"$(inherited)",
);
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 15.3;
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
MTL_FAST_MATH = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
};
name = Debug;
};
7555FFA4242A565B00829871 /* Release */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = AB3632DC29227652001CCB65 /* Config.xcconfig */;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_NONNULL = YES;
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_ENABLE_OBJC_WEAK = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
COPY_PHASE_STRIP = NO;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
ENABLE_NS_ASSERTIONS = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_USER_SCRIPT_SANDBOXING = NO;
GCC_C_LANGUAGE_STANDARD = gnu11;
GCC_NO_COMMON_BLOCKS = YES;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 15.3;
MTL_ENABLE_DEBUG_INFO = NO;
MTL_FAST_MATH = YES;
SDKROOT = iphoneos;
SWIFT_COMPILATION_MODE = wholemodule;
SWIFT_OPTIMIZATION_LEVEL = "-O";
VALIDATE_PRODUCT = YES;
};
name = Release;
};
7555FFA6242A565B00829871 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
DEVELOPMENT_ASSET_PATHS = "\"iosApp/Preview Content\"";
DEVELOPMENT_TEAM = "${TEAM_ID}";
ENABLE_PREVIEWS = YES;
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
"$(SRCROOT)/../shared/build/xcode-frameworks/$(CONFIGURATION)/$(SDK_NAME)",
);
INFOPLIST_FILE = iosApp/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 16.0;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
);
PRODUCT_BUNDLE_IDENTIFIER = "${BUNDLE_ID}${TEAM_ID}";
PRODUCT_NAME = "${APP_NAME}";
PROVISIONING_PROFILE_SPECIFIER = "";
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Debug;
};
7555FFA7242A565B00829871 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
DEVELOPMENT_ASSET_PATHS = "\"iosApp/Preview Content\"";
DEVELOPMENT_TEAM = "${TEAM_ID}";
ENABLE_PREVIEWS = YES;
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
"$(SRCROOT)/../shared/build/xcode-frameworks/$(CONFIGURATION)/$(SDK_NAME)",
);
INFOPLIST_FILE = iosApp/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 16.0;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
);
PRODUCT_BUNDLE_IDENTIFIER = "${BUNDLE_ID}${TEAM_ID}";
PRODUCT_NAME = "${APP_NAME}";
PROVISIONING_PROFILE_SPECIFIER = "";
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Release;
};
/* End XCBuildConfiguration section */
/* Begin XCConfigurationList section */
7555FF76242A565900829871 /* Build configuration list for PBXProject "iosApp" */ = {
isa = XCConfigurationList;
buildConfigurations = (
7555FFA3242A565B00829871 /* Debug */,
7555FFA4242A565B00829871 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
7555FFA5242A565B00829871 /* Build configuration list for PBXNativeTarget "iosApp" */ = {
isa = XCConfigurationList;
buildConfigurations = (
7555FFA6242A565B00829871 /* Debug */,
7555FFA7242A565B00829871 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */
/* Begin XCRemoteSwiftPackageReference section */
EB049AFD2C1AEB680032A688 /* XCRemoteSwiftPackageReference "KMP-ObservableViewModel" */ = {
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/rickclephas/KMP-ObservableViewModel";
requirement = {
kind = exactVersion;
version = "1.0.0-BETA-12";
};
};
EB50C48E2BE0EB69005DE781 /* XCRemoteSwiftPackageReference "KMP-NativeCoroutines" */ = {
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/rickclephas/KMP-NativeCoroutines.git";
requirement = {
kind = exactVersion;
version = "1.0.0-ALPHA-45-spm-async";
};
};
/* End XCRemoteSwiftPackageReference section */
/* Begin XCSwiftPackageProductDependency section */
EB049AFE2C1AEB680032A688 /* KMPObservableViewModelCore */ = {
isa = XCSwiftPackageProductDependency;
package = EB049AFD2C1AEB680032A688 /* XCRemoteSwiftPackageReference "KMP-ObservableViewModel" */;
productName = KMPObservableViewModelCore;
};
EB049B002C1AEB680032A688 /* KMPObservableViewModelSwiftUI */ = {
isa = XCSwiftPackageProductDependency;
package = EB049AFD2C1AEB680032A688 /* XCRemoteSwiftPackageReference "KMP-ObservableViewModel" */;
productName = KMPObservableViewModelSwiftUI;
};
EB50C48F2BE0EB69005DE781 /* KMPNativeCoroutinesAsync */ = {
isa = XCSwiftPackageProductDependency;
package = EB50C48E2BE0EB69005DE781 /* XCRemoteSwiftPackageReference "KMP-NativeCoroutines" */;
productName = KMPNativeCoroutinesAsync;
};
EB50C4912BE0EB69005DE781 /* KMPNativeCoroutinesCore */ = {
isa = XCSwiftPackageProductDependency;
package = EB50C48E2BE0EB69005DE781 /* XCRemoteSwiftPackageReference "KMP-NativeCoroutines" */;
productName = KMPNativeCoroutinesCore;
};
/* End XCSwiftPackageProductDependency section */
};
rootObject = 7555FF73242A565900829871 /* Project object */;
}
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<Workspace
version = "1.0">
<FileRef
location = "self:">
</FileRef>
</Workspace>
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>
@@ -0,0 +1,24 @@
{
"originHash" : "db79fcc1e89ddda40b63c6b4784113d9a3818a7e51c1cbcb2a074b98d190aa0f",
"pins" : [
{
"identity" : "kmp-nativecoroutines",
"kind" : "remoteSourceControl",
"location" : "https://github.com/rickclephas/KMP-NativeCoroutines.git",
"state" : {
"revision" : "85c30240bf393bc50c1f10256300afbfe230ba22",
"version" : "1.0.0-ALPHA-45-spm-async"
}
},
{
"identity" : "kmp-observableviewmodel",
"kind" : "remoteSourceControl",
"location" : "https://github.com/rickclephas/KMP-ObservableViewModel",
"state" : {
"revision" : "7f94fb6a63c25ee77f464c6eb7aeb38d9ed587d5",
"version" : "1.0.0-BETA-12"
}
}
],
"version" : 3
}
@@ -0,0 +1,11 @@
{
"colors" : [
{
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
@@ -0,0 +1,13 @@
{
"images" : [
{
"idiom" : "universal",
"platform" : "ios",
"size" : "1024x1024"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
@@ -0,0 +1,6 @@
{
"info" : {
"author" : "xcode",
"version" : 1
}
}
+40
View File
@@ -0,0 +1,40 @@
import SwiftUI
import Shared
struct DetailView: View {
let product: Product
let favoriteStore: FavoriteStore
let cartStore: CartStore
let onChanged: () -> Void
var body: some View {
VStack(alignment: .leading, spacing: 12) {
Text(product.title)
.font(.title2)
Text("价格:¥\(String(format: "%.2f", product.price))")
.font(.headline)
Text(product.description_)
.foregroundStyle(.secondary)
HStack(spacing: 10) {
Button("加入购物车") {
cartStore.add(product: product)
onChanged()
}
.buttonStyle(.borderedProminent)
Button(favoriteStore.isFavorite(productId: product.id) ? "取消收藏" : "收藏") {
favoriteStore.toggle(productId: product.id)
onChanged()
}
.buttonStyle(.bordered)
}
Spacer()
}
.padding()
.navigationTitle("商品详情")
}
}
+50
View File
@@ -0,0 +1,50 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>$(DEVELOPMENT_LANGUAGE)</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>$(PRODUCT_BUNDLE_PACKAGE_TYPE)</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleVersion</key>
<string>1</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>CADisableMinimumFrameDurationOnPhone</key>
<true/>
<key>UIApplicationSceneManifest</key>
<dict>
<key>UIApplicationSupportsMultipleScenes</key>
<false/>
</dict>
<key>UILaunchScreen</key>
<dict/>
<key>UIRequiredDeviceCapabilities</key>
<array>
<string>armv7</string>
</array>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>UISupportedInterfaceOrientations~ipad</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationPortraitUpsideDown</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
</dict>
</plist>
@@ -0,0 +1,2 @@
// Kept for Xcode project file compatibility after removing template view-model bindings.
// Mini Shopping iOS UI currently uses direct Shared business classes.
+71
View File
@@ -0,0 +1,71 @@
import SwiftUI
import Shared
struct ListView: View {
@State private var query: String = ""
@State private var tick: Int = 0
private let repository = FakeProductRepository()
private let favoriteStore = FavoriteStore()
private let cartStore = CartStore()
private var products: [Product] {
let all = repository.getProducts()
guard !query.isEmpty else { return all }
return all.filter {
$0.title.localizedCaseInsensitiveContains(query) ||
$0.description_.localizedCaseInsensitiveContains(query)
}
}
var body: some View {
NavigationStack {
VStack(spacing: 12) {
TextField("搜索课程", text: $query)
.textFieldStyle(.roundedBorder)
.padding(.horizontal)
List(products, id: \.id) { product in
NavigationLink {
DetailView(
product: product,
favoriteStore: favoriteStore,
cartStore: cartStore,
onChanged: { tick += 1 }
)
} label: {
VStack(alignment: .leading, spacing: 6) {
HStack {
Text(product.title)
.font(.headline)
Spacer()
Text("¥\(String(format: "%.2f", product.price))")
.font(.subheadline)
}
Text(product.description_)
.font(.caption)
.foregroundStyle(.secondary)
HStack(spacing: 8) {
Button(favoriteStore.isFavorite(productId: product.id) ? "已收藏" : "收藏") {
favoriteStore.toggle(productId: product.id)
tick += 1
}
.buttonStyle(.bordered)
let q = cartStore.state().quantityOf(productId: product.id)
if q > 0 {
Text("已加购 x\(q)")
.font(.caption)
}
}
}
.padding(.vertical, 4)
}
}
}
.navigationTitle("Mini Shopping")
}
}
}
+17
View File
@@ -0,0 +1,17 @@
{
"sourceLanguage" : "en",
"strings" : {
"NoDataAvailable" : {
"extractionState" : "manual",
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "No data available"
}
}
}
}
},
"version" : "1.0"
}
@@ -0,0 +1,6 @@
{
"info" : {
"author" : "xcode",
"version" : 1
}
}
+10
View File
@@ -0,0 +1,10 @@
import SwiftUI
@main
struct iOSApp: App {
var body: some Scene {
WindowGroup {
ListView()
}
}
}
+338
View File
@@ -0,0 +1,338 @@
[
{
"objectID": 436535,
"title": "Wheat Field with Cypresses",
"artistDisplayName": "Vincent van Gogh",
"medium": "Oil on canvas",
"dimensions": "28 7/8 × 36 3/4 in. (73.2 × 93.4 cm)",
"objectURL": "https://www.metmuseum.org/art/collection/search/436535",
"objectDate": "1889",
"primaryImage": "https://images.metmuseum.org/CRDImages/ep/original/DT1567.jpg",
"primaryImageSmall": "https://images.metmuseum.org/CRDImages/ep/web-large/DT1567.jpg",
"repository": "Metropolitan Museum of Art, New York, NY",
"department": "European Paintings",
"creditLine": "Purchase, The Annenberg Foundation Gift, 1993"
},
{
"objectID": 11207,
"title": "The Flower Girl",
"artistDisplayName": "Charles Cromwell Ingham",
"medium": "Oil on canvas",
"dimensions": "36 x 28 3/8 in. (91.4 x 72.1 cm)",
"objectURL": "https://www.metmuseum.org/art/collection/search/11207",
"objectDate": "1846",
"primaryImage": "https://images.metmuseum.org/CRDImages/ad/original/DT2784.jpg",
"primaryImageSmall": "https://images.metmuseum.org/CRDImages/ad/web-large/DT2784.jpg",
"repository": "Metropolitan Museum of Art, New York, NY",
"department": "The American Wing",
"creditLine": "Gift of William Church Osborn, 1902"
},
{
"objectID": 202192,
"title": "Potpourri vase (pot-pourri gondole)",
"artistDisplayName": "Sèvres Manufactory",
"medium": "Soft-paste porcelain decorated in polychrome enamels, gold",
"dimensions": "Overall, body with lid (confirmed): 12 3/16 x 14 1/4 x 7 3/4 in. (31 x 36.2 x 19.7 cm); Overall, base (confirmed): 2 5/16 x 9 x 5 1/4 in. (5.9 x 22.9 x 13.3 cm); Height assembled (confirmed): 14 1/8 in. (35.9 cm)",
"objectURL": "https://www.metmuseum.org/art/collection/search/202192",
"objectDate": "1757",
"primaryImage": "https://images.metmuseum.org/CRDImages/es/original/DP149951.jpg",
"primaryImageSmall": "https://images.metmuseum.org/CRDImages/es/web-large/DP149951.jpg",
"repository": "Metropolitan Museum of Art, New York, NY",
"department": "European Sculpture and Decorative Arts",
"creditLine": "Gift of Samuel H. Kress Foundation, 1958"
},
{
"objectID": 11227,
"title": "Autumn Oaks",
"artistDisplayName": "George Inness",
"medium": "Oil on canvas",
"dimensions": "20 3/8 x 30 1/8 in. (54.3 x 76.5 cm)",
"objectURL": "https://www.metmuseum.org/art/collection/search/11227",
"objectDate": "ca. 1878",
"primaryImage": "https://images.metmuseum.org/CRDImages/ad/original/DT264804.jpg",
"primaryImageSmall": "https://images.metmuseum.org/CRDImages/ad/web-large/DT264804.jpg",
"repository": "Metropolitan Museum of Art, New York, NY",
"department": "The American Wing",
"creditLine": "Gift of George I. Seney, 1887"
},
{
"objectID": 11120,
"title": "Fishing Boats, Key West",
"artistDisplayName": "Winslow Homer",
"medium": "Watercolor and graphite on off-white wove paper",
"dimensions": "13 15/16 x 21 3/4 in. (35.4 x 55.2 cm)\r\nFramed: 24 1/2 x 30 1/2 in. (62.2 x 77.5 cm)",
"objectURL": "https://www.metmuseum.org/art/collection/search/11120",
"objectDate": "1903",
"primaryImage": "https://images.metmuseum.org/CRDImages/ad/original/DP119111.jpg",
"primaryImageSmall": "https://images.metmuseum.org/CRDImages/ad/web-large/DP119111.jpg",
"repository": "Metropolitan Museum of Art, New York, NY",
"department": "The American Wing",
"creditLine": "Amelia B. Lazarus Fund, 1910"
},
{
"objectID": 436532,
"title": "Self-Portrait with a Straw Hat (obverse: The Potato Peeler)",
"artistDisplayName": "Vincent van Gogh",
"medium": "Oil on canvas",
"dimensions": "16 x 12 1/2 in. (40.6 x 31.8 cm)",
"objectURL": "https://www.metmuseum.org/art/collection/search/436532",
"objectDate": "1887",
"primaryImage": "https://images.metmuseum.org/CRDImages/ep/original/DT1502_cropped2.jpg",
"primaryImageSmall": "https://images.metmuseum.org/CRDImages/ep/web-large/DT1502_cropped2.jpg",
"repository": "Metropolitan Museum of Art, New York, NY",
"department": "European Paintings",
"creditLine": "Bequest of Miss Adelaide Milton de Groot (1876-1967), 1967"
},
{
"objectID": 438817,
"title": "The Dance Class",
"artistDisplayName": "Edgar Degas",
"medium": "Oil on canvas",
"dimensions": "32 7/8 x 30 3/8 in. (83.5 x 77.2 cm)",
"objectURL": "https://www.metmuseum.org/art/collection/search/438817",
"objectDate": "1874",
"primaryImage": "https://images.metmuseum.org/CRDImages/ep/original/DP-20101-001.jpg",
"primaryImageSmall": "https://images.metmuseum.org/CRDImages/ep/web-large/DP-20101-001.jpg",
"repository": "Metropolitan Museum of Art, New York, NY",
"department": "European Paintings",
"creditLine": "Bequest of Mrs. Harry Payne Bingham, 1986"
},
{
"objectID": 10997,
"title": "Still Life—Violin and Music",
"artistDisplayName": "William Michael Harnett",
"medium": "Oil on canvas",
"dimensions": "40 x 30 in. (101.6 x 76.2 cm)",
"objectURL": "https://www.metmuseum.org/art/collection/search/10997",
"objectDate": "1888",
"primaryImage": "https://images.metmuseum.org/CRDImages/ad/original/DT2046.jpg",
"primaryImageSmall": "https://images.metmuseum.org/CRDImages/ad/web-large/DT2046.jpg",
"repository": "Metropolitan Museum of Art, New York, NY",
"department": "The American Wing",
"creditLine": "Catharine Lorillard Wolfe Collection, Wolfe Fund, 1963"
},
{
"objectID": 436528,
"title": "Irises",
"artistDisplayName": "Vincent van Gogh",
"medium": "Oil on canvas",
"dimensions": "29 x 36 1/4 in. (73.7 x 92.1 cm)",
"objectURL": "https://www.metmuseum.org/art/collection/search/436528",
"objectDate": "1890",
"primaryImage": "https://images.metmuseum.org/CRDImages/ep/original/DP346474.jpg",
"primaryImageSmall": "https://images.metmuseum.org/CRDImages/ep/web-large/DP346474.jpg",
"repository": "Metropolitan Museum of Art, New York, NY",
"department": "European Paintings",
"creditLine": "Gift of Adele R. Levy, 1958"
},
{
"objectID": 13137,
"title": "The Indian Hunter",
"artistDisplayName": "John Quincy Adams Ward",
"medium": "Bronze",
"dimensions": "16 1/8 x 10 1/2 x 15 1/4 in. (41 x 26.7 x 38.7 cm)",
"objectURL": "https://www.metmuseum.org/art/collection/search/13137",
"objectDate": "1860, cast by 1883",
"primaryImage": "https://images.metmuseum.org/CRDImages/ad/original/DP259785.jpg",
"primaryImageSmall": "https://images.metmuseum.org/CRDImages/ad/web-large/DP259785.jpg",
"repository": "Metropolitan Museum of Art, New York, NY",
"department": "The American Wing",
"creditLine": "Morris K. Jesup Fund, 1973"
},
{
"objectID": 11619,
"title": "Cider Making",
"artistDisplayName": "William Sidney Mount",
"medium": "Oil on canvas",
"dimensions": "27 x 34 1/8 in. (68.6 x 86.7 cm)",
"objectURL": "https://www.metmuseum.org/art/collection/search/11619",
"objectDate": "1840–41",
"primaryImage": "https://images.metmuseum.org/CRDImages/ad/original/DT72.jpg",
"primaryImageSmall": "https://images.metmuseum.org/CRDImages/ad/web-large/DT72.jpg",
"repository": "Metropolitan Museum of Art, New York, NY",
"department": "The American Wing",
"creditLine": "Purchase, Bequest of Charles Allen Munn, by exchange, 1966"
},
{
"objectID": 11737,
"title": "Still Life with Cake",
"artistDisplayName": "Raphaelle Peale",
"medium": "Oil on wood",
"dimensions": "10 3/4 x 15 1/4 in. (27.3 x 38.7 cm)",
"objectURL": "https://www.metmuseum.org/art/collection/search/11737",
"objectDate": "1818",
"primaryImage": "https://images.metmuseum.org/CRDImages/ad/original/DT64.jpg",
"primaryImageSmall": "https://images.metmuseum.org/CRDImages/ad/web-large/DT64.jpg",
"repository": "Metropolitan Museum of Art, New York, NY",
"department": "The American Wing",
"creditLine": "Maria DeWitt Jesup Fund, 1959"
},
{
"objectID": 503046,
"title": "Grand Pianoforte",
"artistDisplayName": "Érard",
"medium": "Satinwood veneer, oak, spruce, iron, steel, ebony, ivory, gilding, mother-of-pearl, holly, mahogany, burl walnut, tulipwood, silver wire",
"dimensions": "Height (Total): 37 1/2 in. (95.3 cm)\r\nWidth (Of case, perpendicular to keyboard): 97 1/4 in. (247 cm)\r\nDepth (Of case, parallel to keyboard): 58 7/8 in. (149.5 cm)",
"objectURL": "https://www.metmuseum.org/art/collection/search/503046",
"objectDate": "ca. 1840",
"primaryImage": "https://images.metmuseum.org/CRDImages/mi/original/DP225545.jpg",
"primaryImageSmall": "https://images.metmuseum.org/CRDImages/mi/web-large/DP225545.jpg",
"repository": "Metropolitan Museum of Art, New York, NY",
"department": "Musical Instruments",
"creditLine": "Gift of Mrs. Henry McSweeney, 1959"
},
{
"objectID": 503219,
"title": "Division Viol",
"artistDisplayName": "Richard Meares",
"medium": "Spruce, ebony, maple",
"dimensions": "Height: 46 1/16 in. (117 cm)\r\nWidth (At lower bout): 14 3/4 in. (37.4 cm)\r\nDepth (At bottom block): 5 in. (12.7 cm)",
"objectURL": "https://www.metmuseum.org/art/collection/search/503219",
"objectDate": "ca. 1680",
"primaryImage": "https://images.metmuseum.org/CRDImages/mi/original/DP331229.jpg",
"primaryImageSmall": "https://images.metmuseum.org/CRDImages/mi/web-large/DP331229.jpg",
"repository": "Metropolitan Museum of Art, New York, NY",
"department": "Musical Instruments",
"creditLine": "Purchase, Louis V. Bell Fund, Mrs. Vincent Astor Gift, and funds from various donors, 1982"
},
{
"objectID": 11396,
"title": "Stage Fort across Gloucester Harbor",
"artistDisplayName": "Fitz Henry Lane (formerly Fitz Hugh Lane)",
"medium": "Oil on canvas",
"dimensions": "38 x 60 in. (96.5 x 152.4 cm)",
"objectURL": "https://www.metmuseum.org/art/collection/search/11396",
"objectDate": "1862",
"primaryImage": "https://images.metmuseum.org/CRDImages/ad/original/DT5586.jpg",
"primaryImageSmall": "https://images.metmuseum.org/CRDImages/ad/web-large/DT5586.jpg",
"repository": "Metropolitan Museum of Art, New York, NY",
"department": "The American Wing",
"creditLine": "Purchase, Rogers and Fletcher Funds, Erving and Joyce Wolf Fund, Raymond J. Horowitz Gift, Bequest of Richard De Wolfe Brixey, by exchange, and John Osgood and Elizabeth Amis Cameron Blanchard Memorial Fund, 1978"
},
{
"objectID": 738466,
"title": "Modern chromatics : with applications to art and industry",
"artistDisplayName": "Ogden Nicholas Rood",
"medium": "",
"dimensions": "3 pages, 1 leaf, [v]-viii, [9]-329 pages : color frontispiece, illustrations, diagrams ; Height: 7 7/8 in. (20 cm)",
"objectURL": "https://www.metmuseum.org/art/collection/search/738466",
"objectDate": "1879",
"primaryImage": "https://images.metmuseum.org/CRDImages/li/original/b1100612_001.jpg",
"primaryImageSmall": "https://images.metmuseum.org/CRDImages/li/web-large/b1100612_001.jpg",
"repository": "Metropolitan Museum of Art, New York, NY",
"department": "The Libraries",
"creditLine": ""
},
{
"objectID": 437299,
"title": "Jalais Hill, Pontoise",
"artistDisplayName": "Camille Pissarro",
"medium": "Oil on canvas",
"dimensions": "34 1/4 x 45 1/4 in. (87 x 114.9 cm)",
"objectURL": "https://www.metmuseum.org/art/collection/search/437299",
"objectDate": "1867",
"primaryImage": "https://images.metmuseum.org/CRDImages/ep/original/DT1859.jpg",
"primaryImageSmall": "https://images.metmuseum.org/CRDImages/ep/web-large/DT1859.jpg",
"repository": "Metropolitan Museum of Art, New York, NY",
"department": "European Paintings",
"creditLine": "Bequest of William Church Osborn, 1951"
},
{
"objectID": 506174,
"title": "Kettle Drums",
"artistDisplayName": "Franz Peter Bundsen",
"medium": "Silver, iron, calfskin, textiles, gilding,",
"dimensions": "2010.138.1: 16 1/2 × 23 × 23 in., 52.9 lb. (41.9 × 58.4 × 58.4 cm, 24 kg)\r\n2010.138.2: 16 3/4 × 24 1/2 × 24 1/2 in. (42.5 × 62.2 × 62.2 cm)",
"objectURL": "https://www.metmuseum.org/art/collection/search/506174",
"objectDate": "1780",
"primaryImage": "https://images.metmuseum.org/CRDImages/mi/original/DP229625.jpg",
"primaryImageSmall": "https://images.metmuseum.org/CRDImages/mi/web-large/DP229625.jpg",
"repository": "Metropolitan Museum of Art, New York, NY",
"department": "Musical Instruments",
"creditLine": "Purchase, Robert Alonzo Lehman Bequest, Acquisitions Fund, and Frederick M. Lehman Bequest, 2010"
},
{
"objectID": 11311,
"title": "Lake George",
"artistDisplayName": "John Frederick Kensett",
"medium": "Oil on canvas",
"dimensions": "44 1/8 x 66 3/8 in. (112.1 x 168.6 cm)",
"objectURL": "https://www.metmuseum.org/art/collection/search/11311",
"objectDate": "1869",
"primaryImage": "https://images.metmuseum.org/CRDImages/ad/original/DT84.jpg",
"primaryImageSmall": "https://images.metmuseum.org/CRDImages/ad/web-large/DT84.jpg",
"repository": "Metropolitan Museum of Art, New York, NY",
"department": "The American Wing",
"creditLine": "Bequest of Maria DeWitt Jesup, from the collection of her husband, Morris K. Jesup, 1914"
},
{
"objectID": 250551,
"title": "Terracotta neck-amphora (jar) with lid and knob (27.16)",
"artistDisplayName": "Exekias",
"medium": "Terracotta",
"dimensions": "H. 18 1/2 in. (47 cm)\r\ndiameter 9 3/4 in. (24.8 cm)",
"objectURL": "https://www.metmuseum.org/art/collection/search/250551",
"objectDate": "ca. 540 BCE",
"primaryImage": "https://images.metmuseum.org/CRDImages/gr/original/DP218568.jpg",
"primaryImageSmall": "https://images.metmuseum.org/CRDImages/gr/web-large/DP218568.jpg",
"repository": "Metropolitan Museum of Art, New York, NY",
"department": "Greek and Roman Art",
"creditLine": "Rogers Fund, 1917"
},
{
"objectID": 14931,
"title": "A Rose",
"artistDisplayName": "Thomas Anshutz",
"medium": "Oil on canvas",
"dimensions": "58 x 43 7/8 in. (147.3 x 111.4 cm)",
"objectURL": "https://www.metmuseum.org/art/collection/search/14931",
"objectDate": "1907",
"primaryImage": "https://images.metmuseum.org/CRDImages/ad/original/DT104.jpg",
"primaryImageSmall": "https://images.metmuseum.org/CRDImages/ad/web-large/DT104.jpg",
"repository": "Metropolitan Museum of Art, New York, NY",
"department": "The American Wing",
"creditLine": "Marguerite and Frank A. Cosgrove Jr. Fund, 1993"
},
{
"objectID": 436323,
"title": "Marie Emilie Coignet de Courson (1716–1806) with a Dog",
"artistDisplayName": "Jean Honoré Fragonard",
"medium": "Oil on canvas",
"dimensions": "32 x 25 3/4 in. (81.3 x 65.4 cm)",
"objectURL": "https://www.metmuseum.org/art/collection/search/436323",
"objectDate": "ca. 1769",
"primaryImage": "https://images.metmuseum.org/CRDImages/ep/original/DP-1019-01.jpg",
"primaryImageSmall": "https://images.metmuseum.org/CRDImages/ep/web-large/DP-1019-01.jpg",
"repository": "Metropolitan Museum of Art, New York, NY",
"department": "European Paintings",
"creditLine": "Fletcher Fund, 1937"
},
{
"objectID": 459028,
"title": "Portrait of Alvise Contarini(?); (verso) A Tethered Roebuck",
"artistDisplayName": "Jacometto (Jacometto Veneziano)",
"medium": "Oil on wood; verso: oil and gold on wood",
"dimensions": "Overall 4 5/8 x 3 3/8 in. ; recto, painted surface 4 1/8 x 3 1/8 in.; verso, painted surface 4 3/8 x 3 1/8 in.",
"objectURL": "https://www.metmuseum.org/art/collection/search/459028",
"objectDate": "ca. 1485–95",
"primaryImage": "https://images.metmuseum.org/CRDImages/rl/original/DP221485.jpg",
"primaryImageSmall": "https://images.metmuseum.org/CRDImages/rl/web-large/DP221485.jpg",
"repository": "Metropolitan Museum of Art, New York, NY",
"department": "Robert Lehman Collection",
"creditLine": "Robert Lehman Collection, 1975"
},
{
"objectID": 10481,
"title": "Heart of the Andes",
"artistDisplayName": "Frederic Edwin Church",
"medium": "Oil on canvas",
"dimensions": "66 1/8 x 120 3/16 in. (168 x 302.9cm)",
"objectURL": "https://www.metmuseum.org/art/collection/search/10481",
"objectDate": "1859",
"primaryImage": "https://images.metmuseum.org/CRDImages/ad/original/DT78.jpg",
"primaryImageSmall": "https://images.metmuseum.org/CRDImages/ad/web-large/DT78.jpg",
"repository": "Metropolitan Museum of Art, New York, NY",
"department": "The American Wing",
"creditLine": "Bequest of Margaret E. Dows, 1909"
}
]
+20
View File
@@ -0,0 +1,20 @@
rootProject.name = "kmp-mini-shopping"
enableFeaturePreview("TYPESAFE_PROJECT_ACCESSORS")
pluginManagement {
repositories {
google()
mavenCentral()
gradlePluginPortal()
}
}
dependencyResolutionManagement {
repositories {
google()
mavenCentral()
}
}
include(":shared")
include(":composeApp")
+64
View File
@@ -0,0 +1,64 @@
import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
plugins {
alias(libs.plugins.kotlinMultiplatform)
alias(libs.plugins.androidLibrary)
alias(libs.plugins.kotlinxSerialization)
alias(libs.plugins.ksp)
alias(libs.plugins.kmpNativeCoroutines)
}
kotlin {
androidTarget {
@OptIn(ExperimentalKotlinGradlePluginApi::class)
compilerOptions {
jvmTarget.set(JvmTarget.JVM_11)
}
}
listOf(
iosX64(),
iosArm64(),
iosSimulatorArm64()
).forEach { iosTarget ->
iosTarget.binaries.framework {
baseName = "Shared"
isStatic = true
}
}
sourceSets {
androidMain.dependencies {
implementation(libs.ktor.client.okhttp)
}
iosMain.dependencies {
implementation(libs.ktor.client.darwin)
}
commonMain.dependencies {
implementation(libs.ktor.client.core)
implementation(libs.ktor.client.content.negotiation)
implementation(libs.ktor.serialization.kotlinx.json)
implementation(libs.koin.core)
api(libs.kmp.observable.viewmodel)
}
// Required by KMM-ViewModel
all {
languageSettings.optIn("kotlinx.cinterop.ExperimentalForeignApi")
languageSettings.optIn("kotlin.experimental.ExperimentalObjCName")
}
}
}
android {
namespace = "com.example.minishop.shared"
compileSdk = 35
compileOptions {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
}
defaultConfig {
minSdk = 24
}
}
@@ -0,0 +1,17 @@
package com.example.minishop.cart
import com.example.minishop.model.Product
data class CartItem(
val product: Product,
val quantity: Int
)
data class CartState(
val items: List<CartItem> = emptyList()
) {
val totalCount: Int get() = items.sumOf { it.quantity }
val totalPrice: Double get() = items.sumOf { it.product.price * it.quantity }
fun quantityOf(productId: String): Int = items.firstOrNull { it.product.id == productId }?.quantity ?: 0
}
@@ -0,0 +1,32 @@
package com.example.minishop.cart
import com.example.minishop.model.Product
class CartStore {
private val mutable = mutableMapOf<String, CartItem>()
fun state(): CartState = CartState(mutable.values.sortedBy { it.product.id })
fun add(product: Product) {
val exist = mutable[product.id]
mutable[product.id] = if (exist == null) CartItem(product, 1) else exist.copy(quantity = exist.quantity + 1)
}
fun increase(productId: String) {
val item = mutable[productId] ?: return
mutable[productId] = item.copy(quantity = item.quantity + 1)
}
fun decrease(productId: String) {
val item = mutable[productId] ?: return
if (item.quantity <= 1) mutable.remove(productId) else mutable[productId] = item.copy(quantity = item.quantity - 1)
}
fun remove(productId: String) {
mutable.remove(productId)
}
fun clear() {
mutable.clear()
}
}
@@ -0,0 +1,18 @@
package com.example.minishop.data
import com.example.minishop.model.Product
class FakeProductRepository : ProductRepository {
private val products = listOf(
Product("1", "KMP 入门课", 99.0, "跨平台开发基础课程"),
Product("2", "Compose 实战课", 149.0, "Compose 多端 UI 实战"),
Product("3", "Kotlin 协程训练营", 129.0, "协程与 Flow 进阶"),
Product("4", "Clean 架构速成", 199.0, "从0构建可维护架构"),
Product("5", "SQLDelight 实战", 119.0, "KMP 本地数据库方案"),
Product("6", "Ktor API 实战", 159.0, "跨平台网络层搭建"),
)
override fun getProducts(): List<Product> = products
override fun getProductById(id: String): Product? = products.find { it.id == id }
}
@@ -0,0 +1,13 @@
package com.example.minishop.data
class FavoriteStore {
private val ids = linkedSetOf<String>()
fun isFavorite(productId: String): Boolean = ids.contains(productId)
fun all(): Set<String> = ids.toSet()
fun toggle(productId: String) {
if (!ids.add(productId)) ids.remove(productId)
}
}
@@ -0,0 +1,8 @@
package com.example.minishop.data
import com.example.minishop.model.Product
interface ProductRepository {
fun getProducts(): List<Product>
fun getProductById(id: String): Product?
}
@@ -0,0 +1,8 @@
package com.example.minishop.model
data class Product(
val id: String,
val title: String,
val price: Double,
val description: String
)