hansemannn / titanium-material

Use the native Material UI/UX framework (https://github.com/CosmicMind/Material) in Titanium!

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

iOS Material Library in Titanium

Use the native Material UI/UX framework in Titanium!

This module project contains pure Swift libraries. A proof of concept includes an example of using the RaisedButton API. For more API's, submit a pull request to expose components like BottomNavigationView, Snackbar or MotionAnimation.

Requirements

  • Swift 4.1+ (embedded into the hook in hooks/), iOS 8+
  • Titanium SDK 6.3.0+ (7.1.0+ recommended)

API'S

Root-Module

Methods

createRaisedButton(args)

Creates a new raised button.

createTextField(args)

Creates a new text field.

createCardView(args)

Creates a new card view.


RaisedButton (extends Ti.UI.View)

Additional Properties

  • title (String)
  • color (String)
  • selectedColor (String)
  • pulseColor (String)
  • image (String)

CardView (extends Ti.UI.View)

Additional Properties

  • contentView (Ti.UI.View)
  • contentViewInsets (Dictionary)
  • backgroundColor (String)
  • cornerRadius (Number)

TextField (extends Ti.UI.View)

Additional Properties

  • value (String)
  • hintText (String)
  • hintTextColor (String)
  • font (Dictionary)

Events

  • change
  • focus
  • blur

Compile native libraries

iOS

This project uses the following two Swift dependencies:

  • Material
  • Motion

This projects resolves all dependencies already for you, including setting the Swift version using the hook placed in hooks/.

Right now, Titanium only supports CocoaPods for Hyperloop, so in order to use it for classic modules, you need to create universal "fat" frameworks and strip the unused architectures again (this is taken care of by the SDK already). A universal library can be created by grabbing the frameworks from Debug-iphonesimulator (Simulator architectures) and Debug-iphoneos (Device architectures) and combine them using the following commands:

  1. Install CocoaPods (sudo gem install cocoapods) and run pod install in the native/ directory of this repository
  2. Create the following folder structures: sim/, device/ & universal/
  3. Copy the .framework files from Debug-iphonesimulator to sim/
  4. Copy the .framework files from Debug-iphoneos to device/
  5. Copy the .framework files from device to universal/ (they are the base for universal frameworks)
  6. Copy the Modules/*.swiftmodule to the universal directory of the framework
  7. Use the following command to merge the sim- and device-frameworks together:
lipo -create -output universal/<name>.framework/<name> sim/<name>.framework/<name> device/<name>.framework/<name>
  1. Replace the final frameworks in <module-project>/platform
  2. Make a pull request to this repo, so others can benefit from it as well

These steps are based on a Shell Script used natively.

Note: In the future, this will all be done by CocoaPods. Make sure to follow TIMOB-25927 regarding Swift support in the SDK.

Example

var Material = require('ti.material');

var win = Ti.UI.createWindow({
  backgroundColor: '#fff'
});

var btn = Material.createRaisedButton({
  width: 300,
  height: 40,
  title: 'Titanium rocks!'
});

btn.addEventListener('click', function() {
  alert('YEY!');
});

win.add(btn);
win.open();

Author

Hans Knöchel (@hansemannnn / Web)

License

MIT

Contributing

Code contributions are greatly appreciated, please submit a new Pull-Request!

About

Use the native Material UI/UX framework (https://github.com/CosmicMind/Material) in Titanium!

License:MIT License


Languages

Language:Objective-C 98.1%Language:JavaScript 1.7%Language:Ruby 0.1%