Skip to content

Instantly share code, notes, and snippets.

Avatar
🇧🇷

Alexandre H.T.R. Bonfitto alexandrehtrb

🇧🇷
View GitHub Profile
@alexandrehtrb
alexandrehtrb / createKotlinSharedModule.bat
Created Jan 28, 2019
Script Batch para criar módulo Kotlin Multiplatform
View createKotlinSharedModule.bat
@echo OFF
echo Criando o modulo Kotlin Multiplatform...
mkdir SharedModule\src\commonMain\kotlin
mkdir SharedModule\src\commonTest\kotlin
mkdir SharedModule\src\androidMain\kotlin
mkdir SharedModule\src\androidTest\kotlin
mkdir SharedModule\src\iOSMain\kotlin
mkdir SharedModule\src\iOSTest\kotlin
type NUL > SharedModule\build.gradle
@alexandrehtrb
alexandrehtrb / createKotlinSharedModule.sh
Created Jan 28, 2019
Script Shell para criar módulo Kotlin Multiplatform
View createKotlinSharedModule.sh
echo Criando o modulo Kotlin Multiplatform...
mkdir SharedModule
cd SharedModule
echo "" > build.gradle
mkdir src
cd src
mkdir commonMain
cd commonMain
@alexandrehtrb
alexandrehtrb / ViewController.swift
Created Jan 28, 2019
ViewController do KotlinSharedIOS
View ViewController.swift
import UIKit
import KotlinSharedLibrary
class ViewController: UIViewController {
@IBOutlet weak var labelDemo: UILabel!
override func viewDidLoad() {
super.viewDidLoad()
let person = IosPerson.init(name: "Alex", age: 25)
@alexandrehtrb
alexandrehtrb / MainActivity.java
Created Jan 28, 2019
MainActivity da KotlinSharedLibrary
View MainActivity.java
package br.com.dextra.kotlinsharedandroid.app;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.widget.TextView;
import br.com.dextra.kotlinsharedandroid.R;
import br.com.dextra.kotlinsharedlibrary.AndroidPerson;
public class MainActivity extends AppCompatActivity {
@alexandrehtrb
alexandrehtrb / activity_main.xml
Created Jan 28, 2019
Layout XML do MainActivity do KotlinSharedAndroid
View activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="@+id/activity_main_center_text"
android:layout_width="wrap_content"
@alexandrehtrb
alexandrehtrb / IosPerson.kt
Last active Jan 28, 2019
IosPerson.kt do KotlinSharedLibrary
View IosPerson.kt
package br.com.dextra.kotlinsharedlibrary
import platform.UIKit.UIDevice
import platform.UIKit.UILabel
import platform.UIKit.UIView
import platform.UIKit.UIViewController
data class IosPerson(override val name: String,
override val age: Int): Person() {
@alexandrehtrb
alexandrehtrb / AndroidPerson.kt
Created Jan 28, 2019
AndroidPerson.kt do KotlinSharedLibrary
View AndroidPerson.kt
package br.com.dextra.kotlinsharedlibrary
import java.io.Serializable
data class AndroidPerson(
override val name: String,
override val age: Int): Person(), Serializable {
override fun platformName(): String {
return "Android"
@alexandrehtrb
alexandrehtrb / Person.kt
Created Jan 28, 2019
Person.kt do KotlinSharedLibrary
View Person.kt
package br.com.dextra.kotlinsharedlibrary
abstract class Person {
abstract val name: String
abstract val age: Int
abstract fun platformName(): String
fun createApplicationScreenMessage() : String {
@alexandrehtrb
alexandrehtrb / settings.gradle
Created Jan 28, 2019
settings.gradle do projeto raíz Android
View settings.gradle
include ':app'
include ':KotlinSharedLibrary'
project(':KotlinSharedLibrary').projectDir = file('../KotlinSharedLibrary') // Caminho da pasta do módulo KotlinSharedLibrary
@alexandrehtrb
alexandrehtrb / build.gradle
Created Jan 28, 2019
Mavens do Kotlin e Android Studio Gradle Plugin no build.gradle do projeto raíz Android
View build.gradle
buildscript {
ext.kotlin_version = '1.3.10'
ext.gradle_plugin_version = '3.4.0-alpha10'
repositories {
google()
jcenter()
maven { url "https://dl.bintray.com/jetbrains/kotlin-native-dependencies" }
}
dependencies {
classpath "com.android.tools.build:gradle:$gradle_plugin_version"