Skip to content
Meta abstraction of visual components for Kotlin Multiplatform
Kotlin Swift Groovy Ruby
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.github
android-ktx
documentation Improve metaviews documentation (#24) Nov 21, 2019
gradle/wrapper
jenkins-jobs
metaviews mirego.release commit next working version Jan 20, 2020
sample
swift-extensions
.gitignore
.travis.yml Add pull request template (#25) Nov 25, 2019
CODE_OF_CONDUCT.md Fix typo in code of conduct Nov 26, 2019
LICENSE.md
README.md
Trikot.metaviews.podspec
build.gradle Update to Kotlin 1.3.50 Aug 23, 2019
gradle.properties Upgrade to kotlin 1.3.61 (#29) Dec 4, 2019
gradlew Initial commit May 30, 2019
gradlew.bat
settings.gradle

README.md

Trikot.metaviews

Metaviews expose properties that can be binded to Android or iOS UI components. It allows 2 way interactions between Kotlin Multiplatform Common Code and platform UI.

Its a functionnal Meta abstraction of visual components.

The basics

Both iOS and Android comes with a binding library that supports basics UI components (View, Label, Button, Input, Image) designed to be bound to their meta equivalent (MetaView, MetaLabel, MetaButton, MetaImage, ect...). Since MetaViews are interfaces that are not meant to be modified, Mutable implementations are included to create each type of MetaView (MutableMetaView, MutableMetaLabel, MutableMetaButton, MutableMetaImage, ect...). We suggest that custom MetaView definition and implementation follow the same pattern.

All properties are reactive and observed by the platforms. They are ReactiveStreams Publisher<T>. See Trikot.streams for more inforamtion about Publishers.

Additionally, you can easily replace a property with another org.reactivestreams.Publisher<T> (Like a Flow Coroutine per example).

See (Sample application)[https://github.com/mirego/trikot.metaviews/tree/master/sample] for all possibilities.

iOS UILabel Android TextView

Interfaces provides documentation

Multiplatform Sample

Common code

class SearchViewModel() {
    private val numberOfClickPublisher = Publishers.behaviorSubject(0)
    private val labelTextPublisher = numberOfClickPublisher.map { "Clicked $it times" }
    private val metaLabel = MutableMetaLabel().also {
        it.text = labelTextPublisher
    }
    private val metaButton = MutableMetaButton().also {
        it.text = "Click Me".just() // .just() Transform any value into Single Publisher of this value
        it.onTap.value = MetaAction { numberOfClickPublisher.value += 1 }.just()
    }
}

iOS

See swift extensions for more information.

Helps connect a publisher to a variable in a reactive environment.

let label = UILabel()
let button = UIButton()
label.metaLabel = searchViewModel.metaLabel
button.metaButton = searchViewModel.metaButton

Android

See android extensions for more information.

 <TextView
            ...
            core:meta_view="@{searchViewModel.metaLabel}"
            app:lifecycleOwnerWrapper="@{lifecycleOwnerWrapper}"
            />
 <Button
            ...
            core:meta_view="@{searchViewModel.metaButton}"
            app:lifecycleOwnerWrapper="@{lifecycleOwnerWrapper}"
            />

Installation

Import dependencies
    api "com.mirego.trikot:metaviews:$trikot_metaviews_version"
    jvm "com.mirego.trikot:metaviews-jvm:$trikot_metaviews_version"
    js "com.mirego.trikot:metaviews-js:$trikot_metaviews_version"
    iosx64 "com.mirego.trikot:metaviews-iosx64:$trikot_metaviews_version"
    iosarm64 "com.mirego.trikot:metaviews-iosarm64:$trikot_metaviews_version"

License

Trikot.metaviews is © 2018-2019 Mirego and may be freely distributed under the New BSD license. See the LICENSE.md file.

About Mirego

Mirego is a team of passionate people who believe that work is a place where you can innovate and have fun. We’re a team of talented people who imagine and build beautiful Web and mobile applications. We come together to share ideas and change the world.

We also love open-source software and we try to give back to the community as much as we can.

You can’t perform that action at this time.