Xamarin.Forms 使いこなし術

Xamarin.Forms 使いこなし術

JXUG#18で発表した内容

Abf04d3b669c9b2d7a8d94df64f774e7?s=128

yo ohtagawa

October 28, 2016
Tweet

Transcript

  1. Xamarin.Forms ࢖͍͜ͳ͠ज़ 2016/10/28 JXUG #18 @AyaseSHʢଠా઒ ༸ʣ

  2. ͜ͷൃݴ͸ݸਓͷݟղ͕
 ଟ෼ʹؚ·Ε͓ͯΓɺ
 ॴଐ͢Δ૊৫ͷެࣜݟղͰ͸͋Γ·ͤΜ

  3. ࢓ࣄͰ
 ʮ܅ɺ͜Ε͔ΒXamarinͶʯ ͱݴΘΕͨਓ΁

  4. ʮ͡Ό͋͜Μͳײ͡ͷ
 ɹΞϓϦΛ࡞ͬͯΑʯ ͱݴΘΕͨਓ΁

  5. ࣗݾ঺հ • ΞΧ΢ϯτID:ɹAyaseSH • ΞΧ΢ϯτ໊:ɹΦʔλΨʔʢଠా઒༸ʣ • ΍ͬͨ͜ͱ:ɹ೔ຊञΞϓϦ”Sakenomy”Λ୲౰ • Sakenomyͱ͸:ɹ Wܥྻ

    J04 NPOPUPVDI9BNBSJOJ04 WҎ߱ J04 "OESPJE 9BNBSJO'PSNTJ04"OESPJE
  6. ͔͍͘͏ࢲ΋ ʮ܅ɺXamarin.FormsͶʯ ͱݴΘΕͨਓͰ͢ɻ^^;

  7. ը૾΍จࣈϦιʔεͷ؅ཧ FormsͷػೳΛ࢖͍෼͚ Embedded Native Controls

  8. ը૾΍จࣈϦιʔεͷ؅ཧ

  9. ը૾΍จࣈϦιʔεͷ؅ཧ • XamarinͰ͸ϦιʔεΛPCL؅ཧ͢ΔͨΊʹ RESX(Resource File)͕࢖༻Մೳ • VSͰςΩετͷϦιʔε؅ཧͱͯ͠࢖͏΋ͷͱಉ͡ • આ໌ͱͯ͠͸XamarinͷެࣜυΩϡϝϯτಡΊ͹े෼ •

    ը૾͸αϙʔτ͞Εͯ·ͤΜ͕ɺؤுΕ͹ग़དྷ·͢ɻ
 ৄ͘͠͸ moonmile͞ΜͷϒϩάهࣄΛʂ
  10. ϩʔΧϥΠζ΍Δͱ͖ͷ஫ҙ఺ • PCL΍iOSͰ͸ ‘zh-Hans’, ’zh-Hant’͕࢖͑·͕͢ɺ Xamarin.AndroidͰ͸ ‘zh-CN’, ‘zh-TW’͔͠࢖͑ͳ͍ • iOSͰ͸ResxΛ࢖༻͢Δ৔߹͸ඞཁͳ͍Ͱ͕͢ɺ

    info.plistͰCFBundleLocalizationsʹݴޠίʔυΛઃఆ ͠ͳ͍ͱίϯτϩʔϧͷσϑΥϧτςΩετ͕มΘΒͳ ͍
 ex: Picker΍KeyboardͷDone ΍ NavigationͷBack
  11. Xamarin Studio͋Δ͋Δ • XSͰ͸σϑΥϧτ໊ͷ ”Resources” ͸มߋਪ঑
 Xamarin.Forms.Resources Ϋϥε͕ଘࡏ͢ΔͷͰඃΓ ·͢ •

    VS͸σβΠφʔͰ௥ՃͰ͖Δ͕
 XS͸XmlͰ΍Δ͔͠ͳ͍…ͭΒ͍… <data name=“Hoge_Text" xml:space="preserve"> <value>Hoge</value> <comment>͜Ε͸΄͛Λදࣔ͢ΔςΩετͰ͢</comment> </data>
  12. ࢲతݟղ ͦͷ̍ • Ͳ͜·Ͱڞ༗͢Δʁ • Xamarin.FormsʢPCLʣͰݺͼग़͢ςΩετ͸Ϛετ • ઃఆͰݺͼग़͢ςΩετ͸ωΠςΟϒ • ios:

    ΞϓϦ໊
 ϓϥΠόγʔΞΫηεͷUsageDescription ← new! • android: ΞϓϦ໊ • ը૾͸ωΠςΟϒͷํ๏ • ݴޠͱαΠζͷؔ܎͕ີ • ೉͍͜͠ͱߟ͑ΔΑΓ΋ී௨ͷํ๏Ͱ
 σόΠεʹ༏͍͠ΞϓϦ͕͓͢͢Ί
  13. ࢲతݟղ ͦͷ2 • ϩʔΧϥΠζͱ͍͏ࢹ఺Ͱߟ͑Δ • ݴޠ΍ը૾Λม͑Δ΋ͷ͸αϙʔ τ͞Ε͍ͯΔ • ͕ʂਂ͘ϩʔΧϥΠζͱߟ͑Δͱ ͦ΋ͦ΋FormsΛ࢖͏͜ͱΛߟ͑

    ௚͠·͠ΐ͏ • ΞϥϏΞޠͳͲͷςΩετ͕ӈ͔Βࠨ ΁ͷݴޠͷ৔߹͸Layout Λࠨӈٯʹ ͢Δඞཁ͕͋Γ·͢ • αϙʔτΛߟ͑ΔͳΒ͹ΦϨΦϨ࣮૷ ͢ΔΑΓ΋ωΠςΟϒ͔Βαϙʔτ͞ Ε͍ͯΔػೳΛ࢖͍·͠ΐ͏(^^)
  14. FormsͷػೳΛ࢖͍෼͚

  15. FormsͷػೳΛ࢖͍෼͚ • Triggers • Behaviors • Effects • Custom Renderers

    • Dependency Service • Messaging Center • Properties Dictionary
  16. FormsͷػೳΛ࢖͍෼͚ • Triggers PCLͷΈͰগ͠Πϕϯτ͔ΒViewΛม͍͑ͨɻ΋͔ͯ͠͠ ValueConverter? • Behaviors PCLͷΈͰ৽͍͠৚݅Λ૿΍͢ɻ˓˓ͯ͠Έͨɻ • Effects

    Platformຖ࣮૷Ͱ͖Δɻ࠶ར༻ੑ͕ߴ͍ ← ͕͜͜ॏཁ • Custom Renderers ͳΜͰ΋ग़དྷΔ༏౳ੜɻListViewͰ͸ Custom RendererҎ֎͋Γ͑ͳ͍www • Dependency Service FormsͷఱఢɻϋʔυͷAPIΛݺΜͩΓɺPlatformͷҧ͍ΛΫογϣϯͯ͘͠ΕΔ • Messaging Center ϫʔΫΞϥ΢ϯυɻͲ͔͜ΒͰ΋ϝοηʔδΛૹΓɺड৴ଆʹॲཧͤ͞Δ͜ͱ͕ग़དྷΔ • Properties Dictionary ϫʔΫΞϥ΢ϯυɻͲ͔͜ΒͰ΋Forms͕ఏڙͯ͘͠ΕΔσΟΫγϣφϦʔʹอଘग़དྷΔ
  17. ࢲతݟղ νʔτ ਖ਼͍͠ ָ 5SJHHFST #FIBWJPST ۤ 1SPQFSUJFT %JDUJPOBSZ .FTTBHJOH

    $FOUFS &⒎FDUT $VTUPN 3FOEFSFST
  18. ࢲతݟղ νʔτ ਖ਼͍͠ ָ 5SJHHFST #FIBWJPST ۤ 1SPQFSUJFT %JDUJPOBSZ .FTTBHJOH

    $FOUFS &⒎FDUT $VTUPN 3FOEFSFST %FQFOEFODZ4FSWJDF
  19. Native Embedding

  20. Embedded Native Controls • PlatformಠࣗͷίϯτϩʔϧΛFormsͰݺͼग़ͤΔ • v2.3.0 ʹshared projectͷΈՄೳ •

    v2.3.3 ͔Β͸ɺxamlͷΈPCLͰ΋Մೳ • ౰ͨΓલͰ͕͢…
 ݱࡏ͸ɺ x:Name ࢖༻ෆՄ
 ίʔυϏϋΠϯυ͕ग़དྷͳ͍ͷͰBindingʹͯߦ͍· ͠ΐ͏ɻ
  21. • ωΠςΟϒ஌Βͳ͍ͱίʔσΟϯά͕େม… • ࢥͬͨ͜ͱ • ίʔυϏϋΠϯυ͍ͨ͠ • Ͱ͖ͳͯ͘΋ωΠςΟϒͰRendererͰ͖Ε͹… • ΋͏ͪΐͬͱௐ΂·͢ʂ

  22. ੿͍ൃදͰ͕ͨ͠ ͝੩ௌ͋Γ͕ͱ͏͍͟͝·ͨ͠ɻ
 
 ͦͯ͜͠Ε͔Β͕
 ຊ൪Ͱ͢ʂʂ(๑•̀ŷ•́)و✧