Upgrade to Pro — share decks privately, control downloads, hide ads and more …

titanium mokumoku 20140319

Avatar for coe coe
March 21, 2014

titanium mokumoku 20140319

Titanium Cross Platform

Avatar for coe

coe

March 21, 2014
Tweet

More Decks by coe

Other Decks in Technology

Transcript

  1. Titaniumの悪循環 Titaniumで両⽅方作 れるらしいよ コストダウン できるのな ら・・・ iOSでは動かない Androidでもこの機能欲しい if(OS_IOS) If(OS_ANDROID)

    もっと もっと iOS、Androidの分岐がいたる ところに⼊入ったメンテしづら いスパゲッティの出来上がり 各所各所でOSごとの分 岐を設けます ⼀一時的に要件は満たさ れます
  2. *  画⾯面遷移の処理理⽅方法をiOS,Androidで統⼀一できるから (iOSのNavigationWindowとか意識識しなくていい) なんで? #グローバルに現在のタブを保持   $.index.addEventListener  "open",  (e)  -­‐>

         Alloy.Globals.currentTab  =  e.source.activeTab  if  e?.source?.activeTab?   $.index.addEventListener  "focus",  (e)  -­‐>      Alloy.Globals.currentTab  =  e.tab  if  e?.tab?     clickMe  =  (e)-­‐>      nextwindow  =  Ti.UI.createWindow()      Alloy.Globals.currentTab.open  nextwindow  #ここで画面遷移   $.index.open()   app/controller/index.coffee
  3. Controller編 #共通機能クラス部分 class  HogeWindowInplBase      constructor:-­‐>      hello:(e)-­‐>

             alert  "hello"      thankyou:-­‐>          alert  "Thank  you"   #OSによって使用する継承クラスを決定 IMPL  =  if  OS_IOS  then  class  HogeWindowInplIos  extends  HogeWindowInplBase      hello:(e)-­‐>          alert  "hello  iOS"   else  if  OS_ANDROID  then  class  HogeWindowInplAndroid  extends  HogeWindowInplBase      hello:(e)-­‐>          alert  "hello  Android"     #コントローラ実装部 impl  =  new  IMPL()   clickHello  =  (e)-­‐>      impl.hello()  #ここはOSによって異なる clickThankyou  =  (e)-­‐>      impl.thankyou()  #ここはOS共通 app/controllers/HogeWindow.coffee
  4. UI編 ファイル構成例   └──  views          ├──

     UIWindow.xml  ←OS独自のビューが設定されていない場合          ├──  index.xml          └──  ios                  └──  UIWindow.xml  ←iOS独自のビュー
  5. UI編 iOS/UIWindow.xml UIWindow.xml <Alloy>          <Window>  

                   <View  class="container">                          <Button  >hello</Button>                          <Button  >thankyou</Button>                  </View>          </Window>   </Alloy> <Alloy>          <Window>                  <Toolbar  class="container">                          <Items>                                  <Button  >hello</Button>                                  <Button  >thankyou</Button>                          </Items>                  </Toolbar>          </Window>   </Alloy>     ※iOSなので、せっかくだからToolbarを使いたい!