# @lightningkite/android-xml-runtime

> The runtime for Lightning Kite's Android Layout XML to HTML translator

Latest version **1.0.2** (published 2023-03-15) · MIT license · 0 weekly downloads

## Install

```sh
npm install @lightningkite/android-xml-runtime
pnpm add @lightningkite/android-xml-runtime
yarn add @lightningkite/android-xml-runtime
bun add @lightningkite/android-xml-runtime
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.2 |
| Published | 2023-03-15 |
| First published | 2022-01-19 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 23 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2 |
| Author | Lightning Kite |
| Maintainers | despaintroy, lightningkitejoseph, lksvedin |
| Keywords | khrysalis |

## Links

- npm: https://www.npmjs.com/package/@lightningkite/android-xml-runtime
- Repository: https://github.com/lightningkite/android-layout-translator
- Homepage: https://github.com/lightningkite/android-layout-translator#readme
- Issues: https://github.com/lightningkite/android-layout-translator/issues
- npm.io page: https://npm.io/package/@lightningkite/android-xml-runtime

## Recent versions

- 1.0.2 (latest) — 2023-03-15
- 0.9.3 — 2022-04-18
- 0.9.2 — 2022-03-10
- 0.9.1 — 2022-03-03
- 0.9.0 — 2022-03-03
- 0.8.0 — 2022-01-19
- 0.1.3 — 2022-01-19
- 0.1.1 — 2022-01-19
- 0.1.0 — 2022-01-19

## README

# Android XML to iOS Xib converter

This project converts Android layout files and resources into iOS layout files and resources.

It is composed of a few parts:

## Plugin

The Gradle plugin does the actual conversion work.  It adds a task in the `ios` group called `xmlToXib`.  Running this task will convert the resources of the Android project into iOS assets and move them into the given destination.  It is configured as follows:

```kotlin
plugins {
    id("com.lightningkite.androidlayouttranslator")
    //...
}
//...

val androidRuntimeVersion: String by extra
dependencies {
    //...
    implementation("com.lightningkite.androidlayouttranslator:android-runtime:${androidRuntimeVersion}")
    equivalents("com.lightningkite.androidlayouttranslator:android-runtime:$androidRuntimeVersion:equivalents")
}

androidLayoutConverter {
    iosProjectName = "My Project"
    iosModuleName = "MyProject"
    iosFolder = rootDir.resolve("ios")
    
    webProjectName = "MyProject"
    webFolder = rootDir.resolve("web")
}
```

You can read more about equivalents [here](equivalents.md).

This also generates [`Binding`]() files like Android does

## Android Safe Insets

A small project that makes a convenient way to handle safe insets in Android that translates effectively to iOS.

Setup:

Initialize `ViewPump` with our inflation interceptor as follows:

```kotlin
import com.lightningkite.safeinsets.SafeInsetsInterceptor

// somewhere before startup
ViewPump.init(SafeInsetsInterceptor)
```

Then use the interceptor in your activity:

```kotlin
class MainActivity : Activity {
    //...
    private var appCompatDelegate: AppCompatDelegate? = null
    override fun getDelegate(): AppCompatDelegate {
        if (appCompatDelegate == null) {
            appCompatDelegate = ViewPumpAppCompatDelegate(
                super.getDelegate(),
                this
            )
        }
        return appCompatDelegate!!
    }
}
```

On views that are supposed to have padding equal to the region taken by the status bar / button bar, add the following attribute:

```xml
app:safeInsets="top|horizontal"
```

And that's it!

## XmlToXibRuntime

The iOS runtime for the translator.  Fairly lightweight, it contains the following:

- `CALayer` tools, allowing layers to autosize and respond to `UIControl` states as they need.  `CALayer` is used as the equivalent of a `Drawable`.
- A `compoundDrawable` extension, allowing you to reach a compound drawable.
- A set of labeled toggles, used to emulate Android's `ChecKBox` and `RadioButton`, based on `M13Checkbox`, a Cocoapod
- A set of custom views extending the ability to customize font usage.
- A `XibView` class that inflates a `.xib` of the same name, used to create `Binding` classes in iOS.

---
_Source: https://npm.io/package/@lightningkite/android-xml-runtime · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
