diff --git a/.gitignore b/.gitignore new file mode 100755 index 0000000..77fd544 --- /dev/null +++ b/.gitignore @@ -0,0 +1,12 @@ +.gradle +.settings +.project +.classpath +.vscode +.idea +build +*.iml +Pods +xcuserdata +local.properties +local.gradle \ No newline at end of file diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..85d4135 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,38 @@ +# Do’s and Don’ts + +* **Search tickets before you file a new one.** Add to tickets if you have new information about the issue. +* **Keep tickets short but sweet.** Make sure you include all the context needed to solve the issue. Don't overdo it. Great tickets allow us to focus on solving problems instead of discussing them. +* **Take care of your ticket.** When you spend time to report a ticket with care we'll enjoy fixing it for you. +* **Use [GitHub-flavored Markdown](https://help.github.com/articles/markdown-basics/).** Especially put code blocks and console outputs in backticks (```` ``` ````). That increases the readability. Bonus points for applying the appropriate syntax highlighting. + +## Bug Reports + +In short, since you are most likely a developer, provide a ticket that you _yourself_ would _like_ to receive. + +First check if you are using the latest library version and Kotlin version before filing a ticket. + +Please include steps to reproduce and _all_ other relevant information, including any other relevant dependency and version information. + +## Feature Requests + +Please try to be precise about the proposed outcome of the feature and how it +would related to existing features. + + +## Pull Requests + +We **love** pull requests! + +All contributions _will_ be licensed under the Apache 2 license. + +Code/comments should adhere to the following rules: + +* Names should be descriptive and concise. +* Use four spaces and no tabs. +* Remember that source code usually gets written once and read often: ensure + the reader doesn't have to make guesses. Make sure that the purpose and inner + logic are either obvious to a reasonably skilled professional, or add a + comment that explains it. +* Please add a detailed description. + +If you consistently contribute improvements and/or bug fixes, we're happy to make you a maintainer. \ No newline at end of file diff --git a/LICENSE.md b/LICENSE.md new file mode 100644 index 0000000..9c8f3ea --- /dev/null +++ b/LICENSE.md @@ -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 {yyyy} {name of copyright owner} + + 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. \ No newline at end of file diff --git a/README.md b/README.md new file mode 100755 index 0000000..c1402d7 --- /dev/null +++ b/README.md @@ -0,0 +1,95 @@ +![moko-graphics](img/logo.png) +[![GitHub license](https://img.shields.io/badge/license-Apache%20License%202.0-blue.svg?style=flat)](http://www.apache.org/licenses/LICENSE-2.0) [![Download](https://api.bintray.com/packages/icerockdev/moko/moko-core/images/download.svg) ](https://bintray.com/icerockdev/moko/moko-core/_latestVersion) ![kotlin-version](https://img.shields.io/badge/kotlin-1.3.50-orange) + +# Mobile Kotlin graphics +This is a Kotlin Multiplatform library that provides graphics primitives to common code. + +## Table of Contents +- [Features](#features) +- [Requirements](#requirements) +- [Versions](#versions) +- [Installation](#installation) +- [Usage](#usage) +- [Samples](#samples) +- [Set Up Locally](#setup-locally) +- [Contributing](#contributing) +- [License](#license) + +## Features +- **Color** converting according to the platform-side requirements (argb/rgba). + +## Requirements +- Gradle version 5.4.1+ +- Android API 16+ +- iOS version 9.0+ + +## Versions +- kotlin 1.3.50 + - 0.1.0 + +## Installation +root build.gradle +```groovy +allprojects { + repositories { + maven { url = "https://dl.bintray.com/icerockdev/moko" } + } +} +``` + +project build.gradle +```groovy +dependencies { + commonMainApi("dev.icerock.moko:graphics:0.1.0") +} +``` + +settings.gradle +```groovy +enableFeaturePreview("GRADLE_METADATA") +``` + +## Usage +### Color +```kotlin +val red = Color( + red = 0xFF, + green = 0x00, + blue = 0x00, + alpha = 0xFF +) + +val rgba: Long = red.rgba +val argb: Long = red.argb // android compatible +``` + +## Samples +Please see more examples in the [sample directory](sample). + +## Set Up Locally +- The [graphics directory](graphics) contains the `graphics` library; +- The [sample directory](sample) contains sample apps for Android and iOS; plus the mpp-library connected to the apps; +- For local testing use the `:graphics:publishToMavenLocal` gradle task - so that sample apps use the locally published version. + +## Contributing +All development (both new features and bug fixes) is performed in the `develop` branch. This way `master` always contains the sources of the most recently released version. Please send PRs with bug fixes to the `develop` branch. Documentation fixes in the markdown files are an exception to this rule. They are updated directly in `master`. + +The `develop` branch is pushed to `master` on release. + +For more details on contributing please see the [contributing guide](CONTRIBUTING.md). + +## License + + Copyright 2019 IceRock MAG Inc. + + 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. \ No newline at end of file diff --git a/build.gradle.kts b/build.gradle.kts new file mode 100644 index 0000000..8b21163 --- /dev/null +++ b/build.gradle.kts @@ -0,0 +1,23 @@ +/* + * Copyright 2019 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license. + */ + +allprojects { + repositories { + mavenLocal() + + google() + jcenter() + + maven { url = uri("https://kotlin.bintray.com/kotlin") } + maven { url = uri("https://kotlin.bintray.com/kotlinx") } + maven { url = uri("https://dl.bintray.com/icerockdev/moko") } + } + + // workaround for https://youtrack.jetbrains.com/issue/KT-27170 + configurations.create("compileClasspath") +} + +tasks.register("clean", Delete::class).configure { + delete(rootProject.buildDir) +} diff --git a/buildSrc/build.gradle.kts b/buildSrc/build.gradle.kts new file mode 100644 index 0000000..396e934 --- /dev/null +++ b/buildSrc/build.gradle.kts @@ -0,0 +1,26 @@ +/* + * Copyright 2019 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license. + */ + +plugins { + `kotlin-dsl` +} + +repositories { + mavenLocal() + + jcenter() + google() + + maven { url = uri("https://dl.bintray.com/icerockdev/plugins") } +} + +dependencies { + implementation("dev.icerock:mobile-multiplatform:0.3.0") + implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.50") + implementation("com.android.tools.build:gradle:3.5.0") +} + +kotlinDslPluginOptions { + experimentalWarning.set(false) +} diff --git a/buildSrc/src/main/kotlin/Deps.kt b/buildSrc/src/main/kotlin/Deps.kt new file mode 100755 index 0000000..7c20516 --- /dev/null +++ b/buildSrc/src/main/kotlin/Deps.kt @@ -0,0 +1,40 @@ +/* + * Copyright 2019 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license. + */ + +object Deps { + object Plugins { + const val androidExtensions = + "org.jetbrains.kotlin:kotlin-android-extensions:${Versions.Plugins.androidExtensions}" + } + + object Libs { + object Android { + val kotlinStdLib = AndroidLibrary( + name = "org.jetbrains.kotlin:kotlin-stdlib:${Versions.kotlin}" + ) + val appCompat = AndroidLibrary( + name = "androidx.appcompat:appcompat:${Versions.Libs.Android.appCompat}" + ) + val annotation = AndroidLibrary( + name = "androidx.annotation:annotation:${Versions.Libs.Android.annotation}" + ) + } + + object MultiPlatform { + val kotlinStdLib = MultiPlatformLibrary( + android = Android.kotlinStdLib.name, + common = "org.jetbrains.kotlin:kotlin-stdlib-common:${Versions.kotlin}" + ) + val mokoGraphics = MultiPlatformLibrary( + common = "dev.icerock.moko:graphics:${Versions.Libs.MultiPlatform.mokoGraphics}", + iosX64 = "dev.icerock.moko:graphics-iosx64:${Versions.Libs.MultiPlatform.mokoGraphics}", + iosArm64 = "dev.icerock.moko:graphics-iosarm64:${Versions.Libs.MultiPlatform.mokoGraphics}" + ) + } + } + + val plugins: Map = mapOf( + "kotlin-android-extensions" to Plugins.androidExtensions + ) +} \ No newline at end of file diff --git a/buildSrc/src/main/kotlin/Versions.kt b/buildSrc/src/main/kotlin/Versions.kt new file mode 100755 index 0000000..dc9441b --- /dev/null +++ b/buildSrc/src/main/kotlin/Versions.kt @@ -0,0 +1,29 @@ +/* + * Copyright 2019 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license. + */ + +object Versions { + object Android { + const val compileSdk = 28 + const val targetSdk = 28 + const val minSdk = 16 + } + + const val kotlin = "1.3.50" + + object Plugins { + const val kotlin = Versions.kotlin + const val androidExtensions = Versions.kotlin + } + + object Libs { + object Android { + const val appCompat = "1.0.2" + const val annotation = "1.1.0" + } + + object MultiPlatform { + const val mokoGraphics: String = "0.1.0" + } + } +} \ No newline at end of file diff --git a/gradle.properties b/gradle.properties new file mode 100755 index 0000000..bcbe8df --- /dev/null +++ b/gradle.properties @@ -0,0 +1,9 @@ +org.gradle.jvmargs=-Xmx4096m +org.gradle.configureondemand=false +org.gradle.parallel=true + +kotlin.code.style=official + +android.useAndroidX=true +android.enableJetifier=true +android.databinding.enableV2=true \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar new file mode 100755 index 0000000..5c2d1cf Binary files /dev/null and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties new file mode 100755 index 0000000..4b7e1f3 --- /dev/null +++ b/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,5 @@ +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-5.5.1-bin.zip +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists diff --git a/gradlew b/gradlew new file mode 100755 index 0000000..8e25e6c --- /dev/null +++ b/gradlew @@ -0,0 +1,188 @@ +#!/usr/bin/env sh + +# +# Copyright 2015 the original author or 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. +# + +############################################################################## +## +## Gradle start up script for UN*X +## +############################################################################## + +# Attempt to set APP_HOME +# Resolve links: $0 may be a link +PRG="$0" +# Need this for relative symlinks. +while [ -h "$PRG" ] ; do + ls=`ls -ld "$PRG"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG=`dirname "$PRG"`"/$link" + fi +done +SAVED="`pwd`" +cd "`dirname \"$PRG\"`/" >/dev/null +APP_HOME="`pwd -P`" +cd "$SAVED" >/dev/null + +APP_NAME="Gradle" +APP_BASE_NAME=`basename "$0"` + +# 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"' + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD="maximum" + +warn () { + echo "$*" +} + +die () { + echo + echo "$*" + echo + exit 1 +} + +# 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 + ;; + 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" + which java >/dev/null 2>&1 || 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 + +# Increase the maximum file descriptors if we can. +if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then + MAX_FD_LIMIT=`ulimit -H -n` + if [ $? -eq 0 ] ; then + if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then + MAX_FD="$MAX_FD_LIMIT" + fi + ulimit -n $MAX_FD + if [ $? -ne 0 ] ; then + warn "Could not set maximum file descriptor limit: $MAX_FD" + fi + else + warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" + fi +fi + +# For Darwin, add options to specify how the application appears in the dock +if $darwin; then + GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" +fi + +# For Cygwin, switch paths to Windows format before running java +if $cygwin ; then + APP_HOME=`cygpath --path --mixed "$APP_HOME"` + CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` + JAVACMD=`cygpath --unix "$JAVACMD"` + + # We build the pattern for arguments to be converted via cygpath + ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` + SEP="" + for dir in $ROOTDIRSRAW ; do + ROOTDIRS="$ROOTDIRS$SEP$dir" + SEP="|" + done + OURCYGPATTERN="(^($ROOTDIRS))" + # Add a user-defined pattern to the cygpath arguments + if [ "$GRADLE_CYGPATTERN" != "" ] ; then + OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" + fi + # Now convert the arguments - kludge to limit ourselves to /bin/sh + i=0 + for arg in "$@" ; do + CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` + CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option + + if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition + eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` + else + eval `echo args$i`="\"$arg\"" + fi + i=$((i+1)) + done + case $i in + (0) set -- ;; + (1) set -- "$args0" ;; + (2) set -- "$args0" "$args1" ;; + (3) set -- "$args0" "$args1" "$args2" ;; + (4) set -- "$args0" "$args1" "$args2" "$args3" ;; + (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; + (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; + (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; + (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; + (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; + esac +fi + +# Escape application args +save () { + for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done + echo " " +} +APP_ARGS=$(save "$@") + +# Collect all arguments for the java command, following the shell quoting and substitution rules +eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" + +# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong +if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then + cd "$(dirname "$0")" +fi + +exec "$JAVACMD" "$@" diff --git a/gradlew.bat b/gradlew.bat new file mode 100755 index 0000000..9618d8d --- /dev/null +++ b/gradlew.bat @@ -0,0 +1,100 @@ +@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 + +@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=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@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%" == "0" goto init + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto init + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:init +@rem Get command-line arguments, handling Windows variants + +if not "%OS%" == "Windows_NT" goto win9xME_args + +:win9xME_args +@rem Slurp the command line arguments. +set CMD_LINE_ARGS= +set _SKIP=2 + +:win9xME_args_slurp +if "x%~1" == "x" goto execute + +set CMD_LINE_ARGS=%* + +: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 %CMD_LINE_ARGS% + +:end +@rem End local scope for the variables with windows NT shell +if "%ERRORLEVEL%"=="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! +if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 +exit /b 1 + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/graphics/build.gradle.kts b/graphics/build.gradle.kts new file mode 100644 index 0000000..287eced --- /dev/null +++ b/graphics/build.gradle.kts @@ -0,0 +1,39 @@ +/* + * Copyright 2019 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license. + */ + +plugins { + id("com.android.library") + id("org.jetbrains.kotlin.multiplatform") + id("dev.icerock.mobile.multiplatform") + id("maven-publish") +} + +group = "dev.icerock.moko" +version = Versions.Libs.MultiPlatform.mokoGraphics + +android { + compileSdkVersion(Versions.Android.compileSdk) + + defaultConfig { + minSdkVersion(Versions.Android.minSdk) + targetSdkVersion(Versions.Android.targetSdk) + } +} + +dependencies { + mppLibrary(Deps.Libs.MultiPlatform.kotlinStdLib) + + androidLibrary(Deps.Libs.Android.annotation) +} + +publishing { + repositories.maven("https://api.bintray.com/maven/icerockdev/moko/moko-graphics/;publish=1") { + name = "bintray" + + credentials { + username = System.getProperty("BINTRAY_USER") + password = System.getProperty("BINTRAY_KEY") + } + } +} diff --git a/graphics/src/androidMain/AndroidManifest.xml b/graphics/src/androidMain/AndroidManifest.xml new file mode 100755 index 0000000..90ce925 --- /dev/null +++ b/graphics/src/androidMain/AndroidManifest.xml @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/graphics/src/androidMain/kotlin/dev/icerock/moko/graphics/ColorExt.kt b/graphics/src/androidMain/kotlin/dev/icerock/moko/graphics/ColorExt.kt new file mode 100644 index 0000000..23bc1a2 --- /dev/null +++ b/graphics/src/androidMain/kotlin/dev/icerock/moko/graphics/ColorExt.kt @@ -0,0 +1,13 @@ +/* + * Copyright 2019 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license. + */ + +package dev.icerock.moko.graphics + +import androidx.annotation.ColorInt + +@ColorInt +fun Color.colorInt(): Int { + val maxColorValue: Int = 0xFF + return argb.toInt() +} diff --git a/graphics/src/commonMain/kotlin/dev/icerock/moko/graphics/Color.kt b/graphics/src/commonMain/kotlin/dev/icerock/moko/graphics/Color.kt new file mode 100755 index 0000000..0792b3c --- /dev/null +++ b/graphics/src/commonMain/kotlin/dev/icerock/moko/graphics/Color.kt @@ -0,0 +1,22 @@ +/* + * Copyright 2019 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license. + */ + +package dev.icerock.moko.graphics + +data class Color( + val red: Int, + val green: Int, + val blue: Int, + val alpha: Int +) { + val rgba: Long = alpha.toLong() or + blue.toLong().shl(8) or + green.toLong().shl(16) or + red.toLong().shl(24) + + val argb: Long = blue.toLong() or + green.toLong().shl(8) or + red.toLong().shl(16) or + alpha.toLong().shl(24) +} diff --git a/graphics/src/iosArm64Main b/graphics/src/iosArm64Main new file mode 120000 index 0000000..93d7d74 --- /dev/null +++ b/graphics/src/iosArm64Main @@ -0,0 +1 @@ +iosMain \ No newline at end of file diff --git a/graphics/src/iosMain/kotlin/dev/icerock/moko/graphics/ColorExt.kt b/graphics/src/iosMain/kotlin/dev/icerock/moko/graphics/ColorExt.kt new file mode 100644 index 0000000..61e5158 --- /dev/null +++ b/graphics/src/iosMain/kotlin/dev/icerock/moko/graphics/ColorExt.kt @@ -0,0 +1,17 @@ +/* + * Copyright 2019 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license. + */ + +package dev.icerock.moko.graphics + +import platform.UIKit.UIColor + +fun Color.toUIColor(): UIColor { + val maxColorValue: Int = 0xFF + return UIColor( + red = red.toDouble() / maxColorValue, + green = green.toDouble() / maxColorValue, + blue = blue.toDouble() / maxColorValue, + alpha = alpha.toDouble() / maxColorValue + ) +} diff --git a/graphics/src/iosX64Main b/graphics/src/iosX64Main new file mode 120000 index 0000000..93d7d74 --- /dev/null +++ b/graphics/src/iosX64Main @@ -0,0 +1 @@ +iosMain \ No newline at end of file diff --git a/img/logo.png b/img/logo.png new file mode 100644 index 0000000..f231c61 Binary files /dev/null and b/img/logo.png differ diff --git a/sample/android-app/build.gradle.kts b/sample/android-app/build.gradle.kts new file mode 100644 index 0000000..75c4798 --- /dev/null +++ b/sample/android-app/build.gradle.kts @@ -0,0 +1,51 @@ +/* + * Copyright 2019 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license. + */ + +plugins { + id("com.android.application") + id("kotlin-android") +} + +android { + compileSdkVersion(Versions.Android.compileSdk) + + dexOptions { + javaMaxHeapSize = "2g" + } + + defaultConfig { + minSdkVersion(Versions.Android.minSdk) + targetSdkVersion(Versions.Android.targetSdk) + + applicationId = "dev.icerock.moko.samples.graphics" + + versionCode = 1 + versionName = "0.1.0" + + vectorDrawables.useSupportLibrary = true + } + + buildTypes { + getByName("release") { + isMinifyEnabled = false + proguardFiles(getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro") + } + getByName("debug") { + isDebuggable = true + applicationIdSuffix = ".debug" + } + } + + packagingOptions { + exclude("META-INF/*.kotlin_module") + } +} + +dependencies { + implementation(Deps.Libs.Android.kotlinStdLib.name) + + implementation(Deps.Libs.Android.appCompat.name) + + implementation(project(":sample:mpp-library")) +} diff --git a/sample/android-app/proguard-rules.pro b/sample/android-app/proguard-rules.pro new file mode 100755 index 0000000..1ecf581 --- /dev/null +++ b/sample/android-app/proguard-rules.pro @@ -0,0 +1,17 @@ +# Add project specific ProGuard rules here. +# By default, the flags in this file are appended to flags specified +# in /opt/android/sdk/tools/proguard/proguard-android.txt +# You can edit the include path and order by changing the proguardFiles +# directive in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# Add any project specific keep options here: + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} diff --git a/sample/android-app/src/main/AndroidManifest.xml b/sample/android-app/src/main/AndroidManifest.xml new file mode 100755 index 0000000..1523029 --- /dev/null +++ b/sample/android-app/src/main/AndroidManifest.xml @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + diff --git a/sample/android-app/src/main/java/com/icerockdev/MainActivity.kt b/sample/android-app/src/main/java/com/icerockdev/MainActivity.kt new file mode 100755 index 0000000..8215b9e --- /dev/null +++ b/sample/android-app/src/main/java/com/icerockdev/MainActivity.kt @@ -0,0 +1,26 @@ +/* + * Copyright 2019 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license. + */ + +package com.icerockdev + +import android.os.Bundle +import android.view.View +import androidx.appcompat.app.AppCompatActivity +import com.icerockdev.library.GraphicsTest +import dev.icerock.moko.graphics.colorInt + +class MainActivity : AppCompatActivity() { + + private val graphicsTest = GraphicsTest() + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + + setContentView(R.layout.activity_main) + + val background: View = findViewById(R.id.background) + + background.setBackgroundColor(graphicsTest.backgroundColor.colorInt()) + } +} diff --git a/sample/android-app/src/main/res/layout/activity_main.xml b/sample/android-app/src/main/res/layout/activity_main.xml new file mode 100755 index 0000000..3bfe461 --- /dev/null +++ b/sample/android-app/src/main/res/layout/activity_main.xml @@ -0,0 +1,8 @@ + + \ No newline at end of file diff --git a/sample/android-app/src/main/res/values/strings.xml b/sample/android-app/src/main/res/values/strings.xml new file mode 100644 index 0000000..8dbdd2a --- /dev/null +++ b/sample/android-app/src/main/res/values/strings.xml @@ -0,0 +1,5 @@ + + + Start + Stop + \ No newline at end of file diff --git a/sample/gradlew b/sample/gradlew new file mode 120000 index 0000000..502f5a2 --- /dev/null +++ b/sample/gradlew @@ -0,0 +1 @@ +../gradlew \ No newline at end of file diff --git a/sample/ios-app/Podfile b/sample/ios-app/Podfile new file mode 100644 index 0000000..a57cc39 --- /dev/null +++ b/sample/ios-app/Podfile @@ -0,0 +1,22 @@ +source 'https://github.com/CocoaPods/Specs.git' + +# ignore all warnings from all pods +inhibit_all_warnings! + +use_frameworks! +platform :ios, '11.0' + +pre_install do |installer| + # We represent a Kotlin/Native module to CocoaPods as a vendored framework. + # CocoaPods needs access to such frameworks during installation process to obtain + # their type (static or dynamic) and configure the Xcode project accordingly. + # Build MultiPlatformLibrary framework to correct install Pod + puts "prepare MultiPlatformLibrary.framework (require some time...)" + `cd .. && ./gradlew :sample:mpp-library:syncMultiPlatformLibraryDebugFrameworkIosX64` + puts "preparing MultiPlatformLibrary.framework complete" +end + +target 'TestProj' do + # MultiPlatformLibrary + pod 'MultiPlatformLibrary', :path => '../mpp-library' +end diff --git a/sample/ios-app/Podfile.lock b/sample/ios-app/Podfile.lock new file mode 100644 index 0000000..847f78a --- /dev/null +++ b/sample/ios-app/Podfile.lock @@ -0,0 +1,16 @@ +PODS: + - MultiPlatformLibrary (0.1.0) + +DEPENDENCIES: + - MultiPlatformLibrary (from `../mpp-library`) + +EXTERNAL SOURCES: + MultiPlatformLibrary: + :path: "../mpp-library" + +SPEC CHECKSUMS: + MultiPlatformLibrary: cd722dcacda18e0f3b888e477d2bf1743af85ee1 + +PODFILE CHECKSUM: 4fe4be1b815729054ce80d124b3c324811469f77 + +COCOAPODS: 1.8.3 diff --git a/sample/ios-app/TestProj.xcodeproj/project.pbxproj b/sample/ios-app/TestProj.xcodeproj/project.pbxproj new file mode 100644 index 0000000..f5ef956 --- /dev/null +++ b/sample/ios-app/TestProj.xcodeproj/project.pbxproj @@ -0,0 +1,325 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 51; + objects = { + +/* Begin PBXBuildFile section */ + 2B70A10DE02726CA8E6981EB /* Pods_TestProj.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E8D683A7C91DCD56058C7435 /* Pods_TestProj.framework */; }; + 45D74FCC22BFDDFD00CAB0C8 /* TestViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 45D74FCB22BFDDFD00CAB0C8 /* TestViewController.swift */; }; + 45F4791D219463C7003D25FA /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 45F47912219463C7003D25FA /* LaunchScreen.storyboard */; }; + 45F4791E219463C7003D25FA /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 45F47914219463C7003D25FA /* Main.storyboard */; }; + 45F47921219463C7003D25FA /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 45F4791A219463C7003D25FA /* Assets.xcassets */; }; + 45F47922219463C7003D25FA /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 45F4791B219463C7003D25FA /* AppDelegate.swift */; }; +/* End PBXBuildFile section */ + +/* Begin PBXFileReference section */ + 287627FF1F319065007FA12B /* mokoSampleGraphics.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = mokoSampleGraphics.app; sourceTree = BUILT_PRODUCTS_DIR; }; + 45964D362282A1FD00C16658 /* mpp-library */ = {isa = PBXFileReference; lastKnownFileType = folder; name = "mpp-library"; path = "../mpp-library"; sourceTree = ""; }; + 45D74FCB22BFDDFD00CAB0C8 /* TestViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TestViewController.swift; sourceTree = ""; }; + 45F47913219463C7003D25FA /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; + 45F47915219463C7003D25FA /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; + 45F4791A219463C7003D25FA /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; + 45F4791B219463C7003D25FA /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; + 45F4791C219463C7003D25FA /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + A644D2F1C5377C40A53FCD6A /* Pods-TestProj.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-TestProj.release.xcconfig"; path = "Pods/Target Support Files/Pods-TestProj/Pods-TestProj.release.xcconfig"; sourceTree = ""; }; + DFBDF7D3559D080FDCA444A6 /* Pods-TestProj.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-TestProj.debug.xcconfig"; path = "Pods/Target Support Files/Pods-TestProj/Pods-TestProj.debug.xcconfig"; sourceTree = ""; }; + E8D683A7C91DCD56058C7435 /* Pods_TestProj.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_TestProj.framework; sourceTree = BUILT_PRODUCTS_DIR; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 287627FC1F319065007FA12B /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 2B70A10DE02726CA8E6981EB /* Pods_TestProj.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 0C46713DE6750675C174D0A7 /* Pods */ = { + isa = PBXGroup; + children = ( + DFBDF7D3559D080FDCA444A6 /* Pods-TestProj.debug.xcconfig */, + A644D2F1C5377C40A53FCD6A /* Pods-TestProj.release.xcconfig */, + ); + name = Pods; + sourceTree = ""; + }; + 287627F61F319065007FA12B = { + isa = PBXGroup; + children = ( + 45964D362282A1FD00C16658 /* mpp-library */, + 45F47910219463C7003D25FA /* src */, + 287628001F319065007FA12B /* Products */, + EE1ABB3E79CE541540D3155F /* Frameworks */, + 0C46713DE6750675C174D0A7 /* Pods */, + ); + indentWidth = 4; + sourceTree = ""; + tabWidth = 4; + usesTabs = 0; + }; + 287628001F319065007FA12B /* Products */ = { + isa = PBXGroup; + children = ( + 287627FF1F319065007FA12B /* mokoSampleGraphics.app */, + ); + name = Products; + sourceTree = ""; + }; + 45F47910219463C7003D25FA /* src */ = { + isa = PBXGroup; + children = ( + 45F47911219463C7003D25FA /* Resources */, + 45F4791A219463C7003D25FA /* Assets.xcassets */, + 45F4791B219463C7003D25FA /* AppDelegate.swift */, + 45F4791C219463C7003D25FA /* Info.plist */, + 45D74FCB22BFDDFD00CAB0C8 /* TestViewController.swift */, + ); + path = src; + sourceTree = ""; + }; + 45F47911219463C7003D25FA /* Resources */ = { + isa = PBXGroup; + children = ( + 45F47912219463C7003D25FA /* LaunchScreen.storyboard */, + 45F47914219463C7003D25FA /* Main.storyboard */, + ); + path = Resources; + sourceTree = ""; + }; + EE1ABB3E79CE541540D3155F /* Frameworks */ = { + isa = PBXGroup; + children = ( + E8D683A7C91DCD56058C7435 /* Pods_TestProj.framework */, + ); + name = Frameworks; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 287627FE1F319065007FA12B /* TestProj */ = { + isa = PBXNativeTarget; + buildConfigurationList = 287628111F319065007FA12B /* Build configuration list for PBXNativeTarget "TestProj" */; + buildPhases = ( + DDE4C06D580BF457BEDF8D0A /* [CP] Check Pods Manifest.lock */, + 287627FB1F319065007FA12B /* Sources */, + 287627FC1F319065007FA12B /* Frameworks */, + 287627FD1F319065007FA12B /* Resources */, + 02B727FAA6B9D00725C179CA /* [CP] Embed Pods Frameworks */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = TestProj; + productName = TestProj; + productReference = 287627FF1F319065007FA12B /* mokoSampleGraphics.app */; + productType = "com.apple.product-type.application"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 287627F71F319065007FA12B /* Project object */ = { + isa = PBXProject; + attributes = { + LastSwiftUpdateCheck = 0830; + LastUpgradeCheck = 0830; + ORGANIZATIONNAME = "IceRock Development"; + TargetAttributes = { + 287627FE1F319065007FA12B = { + CreatedOnToolsVersion = 8.3.3; + LastSwiftMigration = 0940; + }; + }; + }; + buildConfigurationList = 287627FA1F319065007FA12B /* Build configuration list for PBXProject "TestProj" */; + compatibilityVersion = "Xcode 9.3"; + developmentRegion = English; + hasScannedForEncodings = 0; + knownRegions = ( + English, + Base, + ); + mainGroup = 287627F61F319065007FA12B; + productRefGroup = 287628001F319065007FA12B /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 287627FE1F319065007FA12B /* TestProj */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + 287627FD1F319065007FA12B /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 45F4791E219463C7003D25FA /* Main.storyboard in Resources */, + 45F4791D219463C7003D25FA /* LaunchScreen.storyboard in Resources */, + 45F47921219463C7003D25FA /* Assets.xcassets in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXShellScriptBuildPhase section */ + 02B727FAA6B9D00725C179CA /* [CP] Embed Pods Frameworks */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + "${PODS_ROOT}/Target Support Files/Pods-TestProj/Pods-TestProj-frameworks-${CONFIGURATION}-input-files.xcfilelist", + ); + name = "[CP] Embed Pods Frameworks"; + outputFileListPaths = ( + "${PODS_ROOT}/Target Support Files/Pods-TestProj/Pods-TestProj-frameworks-${CONFIGURATION}-output-files.xcfilelist", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-TestProj/Pods-TestProj-frameworks.sh\"\n"; + showEnvVarsInLog = 0; + }; + DDE4C06D580BF457BEDF8D0A /* [CP] Check Pods Manifest.lock */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + ); + inputPaths = ( + "${PODS_PODFILE_DIR_PATH}/Podfile.lock", + "${PODS_ROOT}/Manifest.lock", + ); + name = "[CP] Check Pods Manifest.lock"; + outputFileListPaths = ( + ); + outputPaths = ( + "$(DERIVED_FILE_DIR)/Pods-TestProj-checkManifestLockResult.txt", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; + showEnvVarsInLog = 0; + }; +/* End PBXShellScriptBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + 287627FB1F319065007FA12B /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 45D74FCC22BFDDFD00CAB0C8 /* TestViewController.swift in Sources */, + 45F47922219463C7003D25FA /* AppDelegate.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXVariantGroup section */ + 45F47912219463C7003D25FA /* LaunchScreen.storyboard */ = { + isa = PBXVariantGroup; + children = ( + 45F47913219463C7003D25FA /* Base */, + ); + name = LaunchScreen.storyboard; + sourceTree = ""; + }; + 45F47914219463C7003D25FA /* Main.storyboard */ = { + isa = PBXVariantGroup; + children = ( + 45F47915219463C7003D25FA /* Base */, + ); + name = Main.storyboard; + sourceTree = ""; + }; +/* End PBXVariantGroup section */ + +/* Begin XCBuildConfiguration section */ + 2876280F1F319065007FA12B /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + CURRENT_PROJECT_VERSION = 0; + DEFINES_MODULE = YES; + SWIFT_VERSION = 4.0; + }; + name = Debug; + }; + 287628101F319065007FA12B /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + CURRENT_PROJECT_VERSION = 0; + DEFINES_MODULE = YES; + SWIFT_VERSION = 4.0; + }; + name = Release; + }; + 287628121F319065007FA12B /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = DFBDF7D3559D080FDCA444A6 /* Pods-TestProj.debug.xcconfig */; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CODE_SIGN_IDENTITY = "iPhone Developer"; + CODE_SIGN_STYLE = Manual; + DEVELOPMENT_TEAM = ""; + INFOPLIST_FILE = src/Info.plist; + PRODUCT_BUNDLE_IDENTIFIER = dev.icerock.moko.sample.graphics; + PRODUCT_NAME = mokoSampleGraphics; + PROVISIONING_PROFILE_SPECIFIER = ""; + SDKROOT = iphoneos; + SUPPORTED_PLATFORMS = "iphonesimulator iphoneos"; + SWIFT_SWIFT3_OBJC_INFERENCE = On; + }; + name = Debug; + }; + 287628131F319065007FA12B /* Release */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = A644D2F1C5377C40A53FCD6A /* Pods-TestProj.release.xcconfig */; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CODE_SIGN_IDENTITY = "iPhone Developer"; + CODE_SIGN_STYLE = Manual; + DEVELOPMENT_TEAM = ""; + INFOPLIST_FILE = src/Info.plist; + PRODUCT_BUNDLE_IDENTIFIER = dev.icerock.moko.sample.graphics; + PRODUCT_NAME = mokoSampleGraphics; + PROVISIONING_PROFILE_SPECIFIER = ""; + SDKROOT = iphoneos; + SUPPORTED_PLATFORMS = "iphonesimulator iphoneos"; + SWIFT_SWIFT3_OBJC_INFERENCE = On; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 287627FA1F319065007FA12B /* Build configuration list for PBXProject "TestProj" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 2876280F1F319065007FA12B /* Debug */, + 287628101F319065007FA12B /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 287628111F319065007FA12B /* Build configuration list for PBXNativeTarget "TestProj" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 287628121F319065007FA12B /* Debug */, + 287628131F319065007FA12B /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = 287627F71F319065007FA12B /* Project object */; +} diff --git a/sample/ios-app/TestProj.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/sample/ios-app/TestProj.xcodeproj/project.xcworkspace/contents.xcworkspacedata new file mode 100755 index 0000000..8294ef0 --- /dev/null +++ b/sample/ios-app/TestProj.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/sample/ios-app/TestProj.xcworkspace/contents.xcworkspacedata b/sample/ios-app/TestProj.xcworkspace/contents.xcworkspacedata new file mode 100755 index 0000000..f706927 --- /dev/null +++ b/sample/ios-app/TestProj.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,10 @@ + + + + + + + diff --git a/sample/ios-app/src/AppDelegate.swift b/sample/ios-app/src/AppDelegate.swift new file mode 100755 index 0000000..f2dd3fd --- /dev/null +++ b/sample/ios-app/src/AppDelegate.swift @@ -0,0 +1,16 @@ +/* + * Copyright 2019 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license. + */ + +import UIKit + +@UIApplicationMain +class AppDelegate: NSObject, UIApplicationDelegate { + + var window: UIWindow? + + func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? = nil) -> Bool { + + return true + } +} diff --git a/sample/ios-app/src/Assets.xcassets/AppIcon.appiconset/Contents.json b/sample/ios-app/src/Assets.xcassets/AppIcon.appiconset/Contents.json new file mode 100755 index 0000000..1040d84 --- /dev/null +++ b/sample/ios-app/src/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -0,0 +1,58 @@ +{ + "images" : [ + { + "idiom" : "mac", + "scale" : "1x", + "size" : "16x16" + }, + { + "idiom" : "mac", + "scale" : "2x", + "size" : "16x16" + }, + { + "idiom" : "mac", + "scale" : "1x", + "size" : "32x32" + }, + { + "idiom" : "mac", + "scale" : "2x", + "size" : "32x32" + }, + { + "idiom" : "mac", + "scale" : "1x", + "size" : "128x128" + }, + { + "idiom" : "mac", + "scale" : "2x", + "size" : "128x128" + }, + { + "idiom" : "mac", + "scale" : "1x", + "size" : "256x256" + }, + { + "idiom" : "mac", + "scale" : "2x", + "size" : "256x256" + }, + { + "idiom" : "mac", + "scale" : "1x", + "size" : "512x512" + }, + { + "idiom" : "mac", + "scale" : "2x", + "size" : "512x512" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} diff --git a/sample/ios-app/src/Assets.xcassets/Contents.json b/sample/ios-app/src/Assets.xcassets/Contents.json new file mode 100755 index 0000000..2d92bd5 --- /dev/null +++ b/sample/ios-app/src/Assets.xcassets/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "version" : 1, + "author" : "xcode" + } +} diff --git a/sample/ios-app/src/Info.plist b/sample/ios-app/src/Info.plist new file mode 100755 index 0000000..2da6f47 --- /dev/null +++ b/sample/ios-app/src/Info.plist @@ -0,0 +1,62 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleDisplayName + moko-graphics + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(BUNDLE_NAME) + CFBundlePackageType + APPL + CFBundleShortVersionString + 0.1.0 + CFBundleVersion + 1 + LSApplicationCategoryType + public.app-category.developer-tools + LSRequiresIPhoneOS + + NSAppTransportSecurity + + NSAllowsArbitraryLoads + + + NSMainStoryboardFile + Main + UILaunchStoryboardName + LaunchScreen + UIMainStoryboardFile + Main + UIRequiredDeviceCapabilities + + armv7 + + UIRequiresFullScreen + + UIStatusBarHidden + + UIStatusBarHidden~ipad + + UIStatusBarStyle + UIStatusBarStyleLightContent + UISupportedInterfaceOrientations + + UIInterfaceOrientationPortrait + + UISupportedInterfaceOrientations~ipad + + UIInterfaceOrientationPortrait + UIInterfaceOrientationLandscapeRight + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationPortraitUpsideDown + + + diff --git a/sample/ios-app/src/Resources/Base.lproj/LaunchScreen.storyboard b/sample/ios-app/src/Resources/Base.lproj/LaunchScreen.storyboard new file mode 100755 index 0000000..5a559db --- /dev/null +++ b/sample/ios-app/src/Resources/Base.lproj/LaunchScreen.storyboard @@ -0,0 +1,43 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sample/ios-app/src/Resources/Base.lproj/Main.storyboard b/sample/ios-app/src/Resources/Base.lproj/Main.storyboard new file mode 100755 index 0000000..2f181cd --- /dev/null +++ b/sample/ios-app/src/Resources/Base.lproj/Main.storyboard @@ -0,0 +1,48 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sample/ios-app/src/TestViewController.swift b/sample/ios-app/src/TestViewController.swift new file mode 100755 index 0000000..8f849d0 --- /dev/null +++ b/sample/ios-app/src/TestViewController.swift @@ -0,0 +1,17 @@ +/* + * Copyright 2019 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license. + */ + +import UIKit +import MultiPlatformLibrary + +class TestViewController: UIViewController { + + private let graphicsTest = GraphicsTest() + + override func viewDidLoad() { + super.viewDidLoad() + + view.backgroundColor = graphicsTest.backgroundColor.toUIColor() + } +} diff --git a/sample/mpp-library/MultiPlatformLibrary.podspec b/sample/mpp-library/MultiPlatformLibrary.podspec new file mode 100644 index 0000000..15ea36c --- /dev/null +++ b/sample/mpp-library/MultiPlatformLibrary.podspec @@ -0,0 +1,38 @@ +Pod::Spec.new do |spec| + spec.name = 'MultiPlatformLibrary' + spec.version = '0.1.0' + spec.homepage = 'Link to a Kotlin/Native module homepage' + spec.source = { :git => "Not Published", :tag => "Cocoapods/#{spec.name}/#{spec.version}" } + spec.authors = 'IceRock Development' + spec.license = '' + spec.summary = 'Shared code between iOS and Android' + + spec.vendored_frameworks = "build/cocoapods/framework/#{spec.name}.framework" + spec.libraries = "c++" + spec.module_name = "#{spec.name}_umbrella" + + spec.pod_target_xcconfig = { + 'MPP_LIBRARY_NAME' => 'MultiPlatformLibrary', + 'GRADLE_TASK[sdk=iphonesimulator*][config=*ebug]' => 'syncMultiPlatformLibraryDebugFrameworkIosX64', + 'GRADLE_TASK[sdk=iphonesimulator*][config=*elease]' => 'syncMultiPlatformLibraryReleaseFrameworkIosX64', + 'GRADLE_TASK[sdk=iphoneos*][config=*ebug]' => 'syncMultiPlatformLibraryDebugFrameworkIosArm64', + 'GRADLE_TASK[sdk=iphoneos*][config=*elease]' => 'syncMultiPlatformLibraryReleaseFrameworkIosArm64' + } + + spec.script_phases = [ + { + :name => 'Compile Kotlin/Native', + :execution_position => :before_compile, + :shell_path => '/bin/sh', + #:output_files => ['$TARGET_BUILD_DIR/$PRODUCT_NAME.framework/$PRODUCT_NAME'], + :script => <<-SCRIPT +MPP_PROJECT_ROOT="$SRCROOT/../../mpp-library" + +MPP_OUTPUT_DIR="$MPP_PROJECT_ROOT/build/cocoapods/framework" +MPP_OUTPUT_NAME="$MPP_OUTPUT_DIR/#{spec.name}.framework" + +"$MPP_PROJECT_ROOT/../gradlew" --configure-on-demand -p "$MPP_PROJECT_ROOT" "$GRADLE_TASK" + SCRIPT + } + ] +end diff --git a/sample/mpp-library/build.gradle.kts b/sample/mpp-library/build.gradle.kts new file mode 100644 index 0000000..94bdf92 --- /dev/null +++ b/sample/mpp-library/build.gradle.kts @@ -0,0 +1,27 @@ +/* + * Copyright 2019 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license. + */ + +plugins { + id("com.android.library") + id("org.jetbrains.kotlin.multiplatform") + id("dev.icerock.mobile.multiplatform") +} + +android { + compileSdkVersion(Versions.Android.compileSdk) + + defaultConfig { + minSdkVersion(Versions.Android.minSdk) + targetSdkVersion(Versions.Android.targetSdk) + } +} + +setupFramework( + exports = listOf(Deps.Libs.MultiPlatform.mokoGraphics) +) + +dependencies { + mppLibrary(Deps.Libs.MultiPlatform.kotlinStdLib) + mppLibrary(Deps.Libs.MultiPlatform.mokoGraphics) +} diff --git a/sample/mpp-library/src/androidMain/AndroidManifest.xml b/sample/mpp-library/src/androidMain/AndroidManifest.xml new file mode 100755 index 0000000..8f69414 --- /dev/null +++ b/sample/mpp-library/src/androidMain/AndroidManifest.xml @@ -0,0 +1,2 @@ + + diff --git a/sample/mpp-library/src/commonMain/kotlin/com/icerockdev/library/GraphicsTest.kt b/sample/mpp-library/src/commonMain/kotlin/com/icerockdev/library/GraphicsTest.kt new file mode 100755 index 0000000..f847ff1 --- /dev/null +++ b/sample/mpp-library/src/commonMain/kotlin/com/icerockdev/library/GraphicsTest.kt @@ -0,0 +1,11 @@ +/* + * Copyright 2019 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license. + */ + +package com.icerockdev.library + +import dev.icerock.moko.graphics.Color + +class GraphicsTest { + val backgroundColor = Color(red = 0xFF, green = 0xAA, blue = 0xAA, alpha = 0xFF) +} diff --git a/settings.gradle.kts b/settings.gradle.kts new file mode 100644 index 0000000..bdcf747 --- /dev/null +++ b/settings.gradle.kts @@ -0,0 +1,24 @@ +/* + * Copyright 2019 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license. + */ + +pluginManagement { + repositories { + jcenter() + google() + + maven { url = uri("https://dl.bintray.com/kotlin/kotlin") } + maven { url = uri("https://kotlin.bintray.com/kotlinx") } + } + resolutionStrategy.eachPlugin { + val module = Deps.plugins[requested.id.id] ?: return@eachPlugin + + useModule(module) + } +} + +enableFeaturePreview("GRADLE_METADATA") + +include(":graphics") +include(":sample:android-app") +include(":sample:mpp-library")