@lightningkite/android-xml-runtime
v1.0.2
Published
The runtime for Lightning Kite's Android Layout XML to HTML translator
Downloads
36
Keywords
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:
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.
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:
import com.lightningkite.safeinsets.SafeInsetsInterceptor
// somewhere before startup
ViewPump.init(SafeInsetsInterceptor)
Then use the interceptor in your activity:
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:
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 toUIControl
states as they need.CALayer
is used as the equivalent of aDrawable
.- A
compoundDrawable
extension, allowing you to reach a compound drawable. - A set of labeled toggles, used to emulate Android's
ChecKBox
andRadioButton
, based onM13Checkbox
, 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 createBinding
classes in iOS.