Skip to content

Commit

Permalink
feat:Reorganize the project structure
Browse files Browse the repository at this point in the history
  • Loading branch information
KevinnZou committed Oct 9, 2023
1 parent be114d8 commit ece9466
Show file tree
Hide file tree
Showing 43 changed files with 141 additions and 35 deletions.
10 changes: 5 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ build/
/captures
.externalNativeBuild
.cxx
iosApp/Podfile.lock
iosApp/Pods/*
iosApp/iosApp.xcworkspace/*
iosApp/iosApp.xcodeproj/*
!iosApp/iosApp.xcodeproj/project.pbxproj
sample/iosApp/Podfile.lock
sample/iosApp/Pods/*
sample/iosApp/iosApp.xcworkspace/*
sample/iosApp/iosApp.xcodeproj/*
!sample/iosApp/iosApp.xcodeproj/project.pbxproj
progressIndicator/progressIndicator.podspec
/convention-plugins/
keySec.gpg
2 changes: 1 addition & 1 deletion .run/desktopApp.run.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<configuration default="false" name="desktopApp" type="GradleRunConfiguration" factoryName="Gradle">
<ExternalSystemSettings>
<option name="executionName" />
<option name="externalProjectPath" value="$PROJECT_DIR$/desktopApp" />
<option name="externalProjectPath" value="$PROJECT_DIR$/sample/desktopApp" />
<option name="externalSystemIdString" value="GRADLE" />
<option name="scriptParameters" value="" />
<option name="taskDescriptions">
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ kotlin {
sourceSets {
val androidMain by getting {
dependencies {
implementation(project(":progressIndicator"))
implementation(project(":sample:shared"))
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package com.myapplication

import com.multiplatform.progressindicator.MainView
import android.os.Bundle
import androidx.activity.compose.setContent
import androidx.appcompat.app.AppCompatActivity
import com.kevinnzou.sample.shared.MainView

class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ kotlin {
val jvmMain by getting {
dependencies {
implementation(compose.desktop.currentOs)
implementation(project(":progressIndicator"))
implementation(project(":sample:shared"))
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import androidx.compose.ui.window.Window
import androidx.compose.ui.window.application
import com.multiplatform.progressindicator.MainView
import com.kevinnzou.sample.shared.MainView

fun main() = application {
Window(onCloseRequest = ::exitApplication) {
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "cd \"$SRCROOT/..\"\n./gradlew :progressIndicator:embedAndSignAppleFrameworkForXcode";
shellScript = "cd \"$SRCROOT/../..\"\n./gradlew :sample:shared:embedAndSignAppleFrameworkForXcode";
};
/* End PBXShellScriptBuildPhase section */

Expand Down Expand Up @@ -316,7 +316,7 @@
ENABLE_PREVIEWS = YES;
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
"$(SRCROOT)/../progressIndicator/build/xcode-frameworks/$(CONFIGURATION)/$(SDK_NAME)",
"$(SRCROOT)/../shared/build/xcode-frameworks/$(CONFIGURATION)/$(SDK_NAME)",
);
INFOPLIST_FILE = iosApp/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 14.1;
Expand All @@ -327,7 +327,7 @@
OTHER_LDFLAGS = (
"$(inherited)",
"-framework",
progressIndicator,
shared,
);
PRODUCT_BUNDLE_IDENTIFIER = "${BUNDLE_ID}${TEAM_ID}";
PRODUCT_NAME = "${APP_NAME}";
Expand All @@ -348,7 +348,7 @@
ENABLE_PREVIEWS = YES;
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
"$(SRCROOT)/../progressIndicator/build/xcode-frameworks/$(CONFIGURATION)/$(SDK_NAME)",
"$(SRCROOT)/../shared/build/xcode-frameworks/$(CONFIGURATION)/$(SDK_NAME)",
);
INFOPLIST_FILE = iosApp/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 14.1;
Expand All @@ -359,7 +359,7 @@
OTHER_LDFLAGS = (
"$(inherited)",
"-framework",
progressIndicator,
shared,
);
PRODUCT_BUNDLE_IDENTIFIER = "${BUNDLE_ID}${TEAM_ID}";
PRODUCT_NAME = "${APP_NAME}";
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import UIKit
import SwiftUI
import progressIndicator
import shared

struct ComposeView: UIViewControllerRepresentable {
func makeUIViewController(context: Context) -> UIViewController {
Expand Down
File renamed without changes.
File renamed without changes.
67 changes: 67 additions & 0 deletions sample/shared/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
plugins {
kotlin("multiplatform")
id("org.jetbrains.compose")
id("com.android.library")
}

@OptIn(org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi::class)
kotlin {
targetHierarchy.default()

android {
compilations.all {
kotlinOptions {
jvmTarget = "1.8"
}
}
}

jvm("desktop")

listOf(
iosX64(),
iosArm64(),
iosSimulatorArm64()
).forEach {
it.binaries.framework {
baseName = "shared"
isStatic = true
}
}

sourceSets {
val commonMain by getting {
dependencies {
implementation(compose.runtime)
implementation(compose.foundation)
implementation(compose.material)
implementation(project(":progressIndicator"))
}
}
val androidMain by getting {
dependencies {
api("androidx.activity:activity-compose:1.7.2")
api("androidx.appcompat:appcompat:1.6.1")
api("androidx.core:core-ktx:1.10.1")
}
}
val commonTest by getting {
dependencies {
implementation(kotlin("test"))
}
}
val desktopMain by getting {
dependencies {
implementation(compose.desktop.common)
}
}
}
}

android {
namespace = "com.kevinnzou.sample.shared"
compileSdk = 33
defaultConfig {
minSdk = 24
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.kevinnzou.sample.shared

import androidx.compose.runtime.Composable

class AndroidPlatform : Platform {
override val name: String = "Android ${android.os.Build.VERSION.SDK_INT}"
}

actual fun getPlatform(): Platform = AndroidPlatform()

@Composable
fun MainView() = App()
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
package com.multiplatform.progressindicator
package com.kevinnzou.sample.shared

import androidx.compose.material.MaterialTheme
import androidx.compose.runtime.Composable
import sample.BasicProgressIndicatorSample

/**
* Created By Kevin Zou On 2023/10/9
*/
@Composable
fun App() {
MaterialTheme {
BasicProgressIndicatorSample()
}
}

expect fun getPlatformName(): String
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.kevinnzou.sample.shared

class Greeting {
private val platform: Platform = getPlatform()

fun greet(): String {
return "Hello, ${platform.name}!"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.kevinnzou.sample.shared

interface Platform {
val name: String
}

expect fun getPlatform(): Platform
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
package com.multiplatform.progressindicator
package com.kevinnzou.sample.shared

import androidx.compose.desktop.ui.tooling.preview.Preview
import androidx.compose.runtime.Composable

actual fun getPlatformName(): String = "Desktop"
class DesktopPlatform: Platform {
override val name: String = "Desktop"
}
actual fun getPlatform(): Platform {
return DesktopPlatform()
}

@Composable
fun MainView() = App()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.kevinnzou.sample.shared

import androidx.compose.ui.window.ComposeUIViewController
import platform.UIKit.UIDevice

class IOSPlatform: Platform {
override val name: String = UIDevice.currentDevice.systemName() + " " + UIDevice.currentDevice.systemVersion
}

actual fun getPlatform(): Platform = IOSPlatform()

Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
package com.multiplatform.progressindicator
package com.kevinnzou.sample.shared

import androidx.compose.ui.window.ComposeUIViewController

actual fun getPlatformName(): String = "iOS"

/**
* Created By Kevin Zou On 2023/10/9
*/
fun MainViewController() = ComposeUIViewController { App() }
5 changes: 3 additions & 2 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
rootProject.name = "compose-progressIndicator-multiplatform"

include(":androidApp")
include(":sample:androidApp")
include(":progressIndicator")
include(":desktopApp")
include(":sample:desktopApp")
includeBuild("convention-plugins")

pluginManagement {
Expand Down Expand Up @@ -40,3 +40,4 @@ dependencyResolutionManagement {
maven("https://maven.pkg.jetbrains.space/public/p/compose/dev")
}
}
include(":sample:shared")

0 comments on commit ece9466

Please sign in to comment.