video03 - KoreaSenchaUserGroup/Lab1 GitHub Wiki

VIDEO 03. [Concepts] Intro to Layouts (๊ต์ •์™„๋ฃŒ)

์›๋ฌธ : http://docs.sencha.com/touch/1-1/#!/video/15888504

๋ฒˆ์—ญ : https://github.com/KoreaSenchaUserGroup/Lab1/wiki/VIDEO-02.%5BConcepts%5D-Intro-to-List-Component

๊ธ€์“ด์ด : ์ด๋ฏผํ˜ธ (Github:tisohjung), ํ•œ๊ตญ์„ผ์ฐจ์œ ์ €๊ทธ๋ฃน SenchaCon ๋ฒˆ์—ญํŒ€

์œ„์—๋Š” ๋ฐ”๋กœ (๋‹ค๋“ฌ์–ด์ง„)๋ฒˆ์—ญ, ์•„๋ž˜๋Š” ๋“œ๋ž˜ํ”„ํŠธ ์˜/ํ•œ ๋ฒˆ์—ญ์ž…๋‹ˆ๋‹ค.

Sencha Touch - Intro to Layouts

์„ผ์ฐจ ํ„ฐ์น˜์—์„œ ์ธํ„ฐํŽ˜์ด์Šค๋ฅผ ๊ตฌ์„ฑํ•˜๋Š” ๊ธฐ๋ณธ์ ์ธ ๊ตฌ์กฐ๋Š” panel(ํŒ๋„ฌ)์ด๋‹ค. ๊ฐ panel์€ html ๋ฌธ์„œ๋ฅผ ์ถœ๋ ฅํ•  ์ˆ˜ ์žˆ์œผ๋ฉฐ ๋‹ค๋ฅธ panel์„ ํฌํ•จํ•˜๋Š” ์ปจํ…Œ์ด๋„ˆ๊ฐ€ ๋  ์ˆ˜๋„ ์žˆ๋‹ค. ์„ผ์ฐจ ํ„ฐ์น˜๋Š” panel๊ณผ ์ปจํ…Œ์ด๋„ˆ์˜ ๊ด€๊ณ„์—์„œ ์„œ๋กœ ๋‹ค๋ฅธ ๋‘ ๊ฐ€์ง€ ๋ฉ”์ปค๋‹ˆ์ฆ˜์„ ์ œ๊ณตํ•œ๋‹ค. ํ•˜๋‚˜๋Š” panel์„ ์ปจํ…Œ์ด๋„ˆ์˜ ๊ฐ€์žฅ ์œ„ ๋˜๋Š” ๊ฐ€์žฅ ์•„๋ž˜์— ๋ฐฐ์น˜ํ•˜์—ฌ ์ด์ƒ์ ์ธ ํˆด๋ฐ”๋ฅผ ๋งŒ๋“œ๋Š” ๊ฒƒ์ด๊ณ  ๋˜ ๋‹ค๋ฅธ ํ•˜๋‚˜๋Š” ํ•˜๋‚˜ ์ด์ƒ์˜ panel ์˜ ์œ„์น˜๋ฅผ ์กฐ์ ˆํ•˜๋Š” ๋ ˆ์ด์•„์›ƒ์œผ๋กœ ์“ฐ๋Š” ๊ฒƒ์ด๋‹ค.

๋ ˆ์ด์•„์›ƒ์€ ๋‚ด๋ถ€ panel๋“ค์ด ๊ณต๊ฐ„์„ ๋‚˜๋ˆ  ๊ฐ€์งˆ ์ˆ˜ ์žˆ๊ฒŒ ๊น”๋”ํžˆ ๋ฐฐ์—ดํ•˜๊ฑฐ๋‚˜ panel์„ ํ•œ ๋ฒˆ์— ํ•˜๋‚˜์”ฉ ๋ณด์—ฌ์ฃผ๋ฉด์„œ ํ™”๋ฉด์ „ํ™˜์„ ํ•œ๋‹ค. ์ด๋ฒˆ ์„น์…˜์—์„œ๋Š” ์„œ๋กœ ๋‹ค๋ฅธ layout์˜ ์ข…๋ฅ˜๋ฅผ ์‚ดํŽด๋ณด๊ณ  ๋” ๋‚˜์•„๊ฐ€ ์—ฌ๋Ÿฌ ๊ฐ€์ง€ layout์„ ํ˜ผํ•ฉํ•ด์„œ ์‚ฌ์šฉํ•˜๋Š” ๋ฐฉ๋ฒ•์„ ์‚ดํŽด๋ณด๊ฒ ๋‹ค.

layout์˜ ๊ธฐ๋ณธ๊ฐ’์€ โ€˜autoโ€™์ด๋‹ค. โ€˜autoโ€™๋Š” panel์„ html์˜ ๋ธ”๋ก์š”์†Œ์ฒ˜๋Ÿผ ๋™์ž‘ํ•˜๊ฒŒ ํ•œ๋‹ค. panel์€ ๊ฐ€๋กœ ์˜์—ญ์€ ๋ชจ๋‘ ์ฐจ์ง€ํ•˜์ง€๋งŒ ์„ธ๋กœ์˜์—ญ์€ ํ•„์š”ํ•œ ๋งŒํผ ์ฆ‰, ์ฝ˜ํ…์ธ ์˜ ๋†’์ด๋งŒํผ๋งŒ ์ฐจ์ง€ํ•œ๋‹ค. ๋งŒ์•ฝ panel์ด ์„ธ๋กœ์˜์—ญ์„ ๋ชจ๋‘ ์ฐจ์ง€ํ•˜๊ฒŒ ํ•˜๊ณ  ์‹ถ๋‹ค๋ฉด layout์„ โ€˜fitโ€™์œผ๋กœ ์ง€์ •ํ•œ๋‹ค. layout์„ โ€˜fitโ€™์œผ๋กœ ์ง€์ •ํ•˜๋ฉด panel์ด ๊ฐ€๋กœ์™€ ์„ธ๋กœ ๋ชจ๋“  ์˜์—ญ์„ ์ฐจ์ง€ํ•˜๊ฒŒ ๋œ๋‹ค. ๋”ฐ๋ผ์„œ โ€˜fitโ€™์€ panel์— ํ•˜๋‚˜์˜ ์š”์†Œ๋งŒ ๋„ฃ๊ณ  ์‹ถ์„ ๋•Œ ์ ํ•ฉํ•˜๋‹ค. layout์„ โ€˜fitโ€™์œผ๋กœ ์„ค์ •ํ•˜๊ณ  ํ•˜๋‚˜ ์ด์ƒ์˜ ๊ตฌ์„ฑ์š”์†Œ๋ฅผ ๋„ฃ์œผ๋ฉด ์ž‘๋™์‹œํ‚ฌ ๋•Œ ๋ฌธ์ œ๊ฐ€ ๋ฐœ์ƒํ•œ๋‹ค.

โ€˜cardโ€™ layout์€ โ€˜fitโ€™๊ณผ ๊ฐ™์ด ํ•˜๋‚˜์˜ panel๋งŒ ๋ณด์—ฌ์ค€๋‹ค. ํ•˜์ง€๋งŒ โ€˜fitโ€™ layout์€ ํ•œ ๊ฐ€์ง€ ์š”์†Œ๋งŒ ๋„ฃ์„ ์ˆ˜ ์žˆ๊ณ  โ€˜cardโ€™ layout์€ ํ•˜๋‚˜ ์ด์ƒ์˜ ์š”์†Œ๋ฅผ ๋„ฃ์„ ์ˆ˜ ์žˆ๋‹ค. ์ด ์˜ˆ์ œ์—์„œ๋Š” rootPanel์„ ์ž๋ฐ”์Šคํฌ๋ฆฝํŠธ ์ฝ˜์†”์—์„œ ์ ‘๊ทผํ•˜๊ธฐ ์œ„ํ•ด ์ „์—ญ๋ณ€์ˆ˜๋กœ ํ• ๋‹นํ–ˆ๋‹ค. rootPanel์˜ layout์€ โ€˜cardโ€™์ด๋ฉฐ โ€œred, amber, greenโ€ 3๊ฐœ์˜ ํŒจ๋„๋กœ ๊ตฌ์„ฑ๋ผ์žˆ๋‹ค. ์•„๋ž˜ ์˜ˆ์ œ๋ฅผ ์‹คํ–‰ํ•ด ๋ณด๋ฉด ์ฒซ ๋ฒˆ์งธ ์š”์†Œ์ธ โ€œredโ€๊ฐ€ ๋ณด์ธ๋‹ค.

์ฝ˜์†”์—์„œ rootPanel์˜ ActiveItem์„ ๋‹ค์Œ๊ณผ ๊ฐ™์ด 1๋กœ ์ง€์ •ํ•˜๋ฉด red panel์ด amber panel๋กœ ๋ฐ”๋€Œ๊ณ , rootPanel์˜ ActiveItem์„ ๋‹ค์Œ๊ณผ ๊ฐ™์ด 2๋กœ ์ง€์ •ํ•˜๋ฉด panel์ด green panel๋กœ ๋ฐ”๋€Œ๋Š” ๊ฒƒ์„ ํ™•์ธํ•  ์ˆ˜ ์žˆ๋‹ค.

rootPanel.ActiveItem(1)
rootPanel.ActiveItem(2)
rootPanel.ActiveItem(0)

โ€˜cardโ€™ layout์€ ์ฝ”๋“œ๋กœ panel์„ ์ „ํ™˜ํ•  ์ˆ˜ ์žˆ์ง€๋งŒ, UI(์‚ฌ์šฉ์ž์ธํ„ฐํŽ˜์ด์Šค)๋Š” ์ง€์›ํ•˜์ง€ ์•Š๋Š”๋‹ค.

์„ผ์ฐจ ํ„ฐ์น˜์—๋Š” UI๋ฅผ ์ง€์›ํ•˜๋Š” ๋‘ ๊ฐ€์ง€ panel์ด ์žˆ๋‹ค. ํ•˜๋‚˜๋Š” Carousel์ด๊ณ  ๋‹ค๋ฅธ ํ•˜๋‚˜๋Š” TabPanel์ด๋‹ค. ์ง€๊ธˆ๋ถ€ํ„ฐ UI๋ฅผ ์ง€์›ํ•˜๋Š” ๋‘ ๊ฐ€์ง€ panel์„ ์‚ดํŽด๋ณด๊ฒ ๋‹ค.

panel์„ TabPanel๋กœ ๋ฐ”๊พธ๊ณ  ์‹คํ–‰ํ•ด๋ณด๋ฉด ํƒญ ํ˜•์‹์˜ UI๊ฐ€ ์ƒ๊ธฐ๋ฉฐ ๊ฐ ์ด๋ฆ„์„ ํด๋ฆญํ•ด์„œ panel์„ ์ „ํ™˜ํ•  ์ˆ˜ ์žˆ๋‹ค. TabPanel ํ™”๋ฉด ์ „ํ™˜์˜ ๊ธฐ๋ณธ๊ฐ’์€ โ€˜slideโ€™ ํ˜•์‹์ด์ง€๋งŒ โ€˜fadeโ€™, โ€˜slideโ€™, โ€˜flipโ€™, โ€˜cubeโ€™, โ€˜wipeโ€™ ๋“ฑ์œผ๋กœ ์„ค์ •ํ•  ์ˆ˜ ์žˆ๋‹ค.

์ผ๋ฐ˜ panel์—์„œ๋Š” ์—ฌ๋Ÿฌ ๊ฐ€์ง€ layout์„ ์„ค์ •ํ•  ์ˆ˜ ์žˆ์ง€๋งŒ TabPanel์€ โ€˜cardโ€™ ํ˜•์‹์˜ layout๋งŒ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๋‹ค. ๋”ฐ๋ผ์„œ TabPanel์—์„œ ๋‹ค๋ฅธ ํ˜•์‹์˜ layout์œผ๋กœ ๋ณ€๊ฒฝํ•˜์—ฌ๋„ ๊ฐ’์ด ๋ฌด์‹œ๋˜๋ฉฐ โ€˜cardโ€™ ํ˜•์‹์œผ๋กœ๋งŒ ๋ณด์ธ๋‹ค. ํƒญ ํ˜•์‹์˜ UI๋ฟ๋งŒ ์•„๋‹ˆ๋ผ setActiveItem() ํ•จ์ˆ˜๋กœ panel ๊ฐ„์˜ ์ „ํ™˜์„ ์ฝ˜์†”์„ ํ†ตํ•ด์„œ๋„ ํ•  ์ˆ˜ ์žˆ๋‹ค.

์ด๋ฒˆ์—๋Š” Carousel์„ ์‹ค์Šตํ•ด ๋ณด๊ธฐ ์œ„ํ•ด TabPanel์„ Carousel๋กœ ๋ณ€๊ฒฝํ•˜๊ณ  ๋ธŒ๋ผ์šฐ์ €์—์„œ ์ƒˆ๋กœ ๊ณ ์นจ์„ ํ•œ๋‹ค. TabPanel์—์„œ์™€ ๊ฐ™์ด layout์„ card๋กœ ์„ค์ •ํ•˜์˜€๊ธฐ ๋•Œ๋ฌธ์— ํ•˜๋‚˜์˜ ํŒจ๋„๋งŒ ๋ณด์ธ๋‹ค. Carousel์—์„œ๋Š” ํƒญ์ด ์•„๋‹Œ ์Šค์™€์ดํ”„๋กœ ํ™”๋ฉด์„ ์ „ํ™˜ํ•  ์ˆ˜ ์žˆ๋‹ค. ๋˜ํ•œ ์•„๋žซ๋ถ€๋ถ„์— ์žˆ๋Š” ์ธ๋””์ผ€์ดํ„ฐ๋ฅผ ํ†ตํ•ด ๋ช‡ ๊ฐœ์˜ panel์ด ์žˆ์œผ๋ฉฐ ํ˜„์žฌ ๋ช‡ ๋ฒˆ์งธ ํŽ˜์ด์ง€์— ์žˆ๋Š”์ง€ ์•Œ ์ˆ˜ ์žˆ๋‹ค. Carousel์€ ๊ธฐ๋ณธ์œผ๋กœ ์ˆ˜ํ‰์œผ๋กœ ์Šค์™€์ดํ”„ํ•˜์ง€๋งŒ direction์„ โ€˜verticalโ€™๋กœ ๋ณ€๊ฒฝํ•˜๋ฉด ์ˆ˜์ง์œผ๋กœ ์Šค์™€์ดํ”„ํ•  ์ˆ˜ ์žˆ๋‹ค.

์ง€๊ธˆ๊นŒ์ง€ ํ•œ ๊ฐœ์˜ panel์„ ๋ณด์—ฌ์ฃผ๊ธฐ์— ์ ํ•ฉํ•œ โ€˜fitโ€™ layout๊ณผ ํ•œ ๋ฒˆ์— ํ•˜๋‚˜์˜ panel๋งŒ ๋ณด์—ฌ์ค„ ์ˆ˜ ์žˆ์ง€๋งŒ ์—ฌ๋Ÿฌ ๊ฐœ์˜ panle์„ ๊ฐ€์งˆ ์ˆ˜ ์žˆ๋Š” โ€˜cardโ€™ layout์„ ์‚ดํŽด๋ณด์•˜๋‹ค. ๊ทธ๋ ‡๋‹ค๋ฉด ์—ฌ๋Ÿฌ ๊ฐœ์˜ panel์„ ๋™์‹œ์— ๋ณด์—ฌ์ฃผ๋ ค๋ฉด ์–ด๋–ป๊ฒŒ ํ•ด์•ผ ํ• ๊นŒ? ๋ฐ”๋กœ hbox์™€ vbox ๋ ˆ์ด์•„์›ƒ์„ ์‚ฌ์šฉํ•˜๋ฉด ๋œ๋‹ค.

โ€˜cardโ€™ layout์„ vbox๋กœ ๋ณ€๊ฒฝํ•œ ๋’ค ๋ธŒ๋ผ์šฐ์ €์—์„œ ์ƒˆ๋กœ ๊ณ ์นจ์„ ํ•ด ๋ณด๋ฉด 3๊ฐœ์˜ panel์ด ๋™์‹œ์— ๋ณด์ด๋Š” ๊ฒƒ์„ ํ™•์ธํ•  ์ˆ˜ ์žˆ๋‹ค. ํ•˜์ง€๋งŒ ๊ฐ panel์˜ ์ฝ˜ํ…์ธ ์˜ ๋„ˆ๋น„์™€ ๋†’์ด๋งŒํผ๋งŒ ์ฐจ์ง€ํ•˜๊ฒŒ ๋œ๋‹ค. panel์˜ ๋„ˆ๋น„๋ฅผ ๊ฝ‰ ์ฑ„์šฐ๋ ค๋ฉด align ๋ณ€์ˆ˜๋ฅผ stretch๋กœ ์„ค์ •ํ•ด ์ค€๋‹ค. align์„ โ€˜stretchโ€™๋กœ ์„ค์ •ํ•œ ๊ฒฐ๊ณผ๋Š” layout์ด โ€˜autoโ€™์ผ ๋•Œ์™€ ๊ฐ™๋‹ค. ํ•˜์ง€๋งŒ โ€˜vboxโ€™ layout์€ โ€˜autoโ€™ layout๋ณด๋‹ค ๋” ๋งŽ์€ ์ œ์–ด๋ฅผ ์ œ๊ณตํ•œ๋‹ค.

pack ์†์„ฑ์˜ ๊ธฐ๋ณธ๊ฐ’์€ โ€˜startโ€™์ด๋ฉฐ โ€˜centerโ€™์™€ โ€˜endโ€™๋กœ ๋ณ€๊ฒฝํ•  ์ˆ˜ ์žˆ๋‹ค. pack ์†์„ฑ์œผ๋กœ panel์˜ ์„ธ๋กœ ์œ„์น˜๋ฅผ ๋ณ€๊ฒฝํ•  ์ˆ˜ ์žˆ๋‹ค. ์„ธ๋กœ ๋†’์ด๋Š” flex ์†์„ฑ์„ ์ด์šฉํ•ด ์กฐ์ ˆํ•  ์ˆ˜ ์žˆ์œผ๋ฉฐ panel์ด ์ฐจ์ง€ํ•  ์„ธ๋กœ ๊ณต๊ฐ„์˜ ๋น„์œจ์„ ์กฐ์ ˆํ•œ๋‹ค. ์˜ˆ๋ฅผ ๋“ค์–ด ๊ฐ panel์˜ flex ๊ฐ’์„ ๋ชจ๋‘ 1๋กœ ์„ค์ •ํ•˜๋ฉด ๋ชจ๋‘ ๊ฐ™์€ ๋น„์œจ์˜ ๋†’์ด๋ฅผ ์ฐจ์ง€ํ•˜๊ฒŒ ๋œ๋‹ค.

์˜ˆ์ œ์—์„œ๋Š” ๋ชจ๋“  panel์˜ ์†์„ฑ์œผ๋กœ flex ๊ฐ’์„ ์„ค์ •ํ–ˆ์ง€๋งŒ ๋” ๋น ๋ฅด๊ณ  ์‰ฌ์šด ๋ฐฉ๋ฒ•๋„ ์žˆ๋‹ค. ๋ฐ”๋กœ ๋””ํดํŠธ ๋ณ€์ˆ˜์— ํ•ด์‹œ ๊ฐ’์œผ๋กœ flex ์†์„ฑ์„ ๋„ฃ๋Š” ๋ฐฉ๋ฒ•์ด๋‹ค. ๋‹ค์Œ๊ณผ ๊ฐ™์ด ๋””ํดํŠธ ๋ณ€์ˆ˜์— ํ•ด์‹œ ๊ฐ’์œผ๋กœ flex ๊ฐ’์„ ์„ค์ •ํ•˜๋ฉด ๊ฐ panel์—์„œ ์„ค์ •ํ•œ flex ๊ฐ’์„ ์ง€์›Œ๋„ ๊ฐ™์€ ๊ฒฐ๊ณผ๊ฐ€ ์ถœ๋ ฅ๋œ๋‹ค.

vbox layout์€ ์„ธ๋กœ๋กœ panel์„ ๋‚˜๋ˆ ์„œ ๋ฐฐ์น˜ํ•˜๊ณ  hbox layout์€ ๊ฐ€๋กœ๋กœ panel์„ ๋‚˜๋ˆ ์„œ ๋ฐฐ์น˜ํ•œ๋‹ค. hbox layout ์—ญ์‹œ vbox layout๊ณผ ๊ฐ™์ด align, pack, flex ์†์„ฑ์„ ์ด์šฉํ•  ์ˆ˜ ์žˆ๋‹ค. ํ•˜์ง€๋งŒ ๊ฐ ํŒจ๋„์„ ์œ„์—์„œ ์•„๋ž˜๋กœ๊ฐ€ ์•„๋‹Œ ์™ผ์ชฝ์—์„œ ์˜ค๋ฅธ์ชฝ์œผ๋กœ ๋ฐฐ์น˜ํ•œ๋‹ค.

๋ชจ๋“  panel์€ ์ž๊ธฐ ์ž์‹ ์— ํฌํ•จ๋œ ์š”์†Œ๋กœ ๋ณผ ์ˆ˜ ์žˆ์œผ๋ฉฐ ๋‹ค๋ฅธ panel์„ ํฌํ•จํ•  ์ˆ˜ ์žˆ๋Š” ์ปจํ…Œ์ด๋„ˆ๋กœ๋„ ๋ณผ ์ˆ˜ ์žˆ๋‹ค. ๋”ฐ๋ผ์„œ panel์€ ์„œ๋กœ ๋‹ค๋ฅธ layout์„ ์ด์šฉํ•ด์„œ ์„œ๋กœ ํฌํ•จํ•  ์ˆ˜ ์žˆ๋‹ค.

์˜ˆ์ œ์—์„œ๋Š” ์Šคํฌ๋ฆฐ์„ ๊ฝ‰ ์ฑ„์šฐ๋Š” ๋ฃจํŠธ ๋ ˆ๋ฒจ์˜ panel์„ ์ƒ์„ฑํ–ˆ์œผ๋ฉฐ ์ด ๋ฃจํŠธ ๋ ˆ๋ฒจ์˜ panel์€ align๊ณผ flex๊ฐ€ ์„ค์ •๋œ โ€˜vboxโ€™ layout์œผ๋กœ ์ •๋ ฌ๋œ 3๊ฐœ์˜ panel์„ ํฌํ•จํ•œ๋‹ค. ๋˜ํ•œ vbox layout์œผ๋กœ ์ •๋ ฌ๋œ panel์ธ topChanger, centerChanger, bottomChanger panel์€ ์„œ๋กœ ๋‹ค๋ฅธ 3๊ฐ€์ง€ ์ƒ‰์˜ panel์„ ํฌํ•จํ•˜๋Š” carousel์ด๋‹ค.

์˜ˆ์ œ์ฝ”๋“œ๋ฅผ ๋ธŒ๋ผ์šฐ์ €์—์„œ ์‹คํ–‰ํ•ด ๋ณด๋ฉด 3๊ฐ€์ง€ ์ƒ‰์˜ panel์ด ๊ฐ€๋กœ๋กœ ๋Š˜๋ ค์ ธ ํ™”๋ฉด์„ ๊ฝ‰ ์ฑ„์šฐ๋Š” ๊ฒƒ์„ ๋ณผ ์ˆ˜ ์žˆ๋‹ค. ์ด๊ฒƒ์ด vbox์˜ ์„ฑ๊ฒฉ์ด๋‹ค. ํ•˜์ง€๋งŒ ๊ฐ ์„ธ ๊ฐ€์ง€ ์ƒ‰์€ layout์ด card์ธ ํŒจ๋„ ๊ทธ ์ž์ฒด์ด๋‹ค. ๋”ฐ๋ผ์„œ ๊ฐ panel์„ ์ขŒ์šฐ๋กœ ์Šค์™€์ดํ•‘ํ•ด์„œ ์ƒ‰์„ ์„ž๊ณ  ์งœ ๋งž์ถœ ์ˆ˜ ์žˆ๋‹ค. ์ด์ œ ๋‹ค์Œ ๋‹จ๊ณ„๋กœ ๋„˜์–ด๊ฐ€์„œ style์„ cls ํด๋ž˜์Šค๋กœ ๋ณ€๊ฒฝํ•ด๋ณด์ž.

css์— ๊ฐ panel์— ๋“ค์–ด๊ฐ€๋Š” carousel์˜ ๋ฐฐ๊ฒฝ ์ด๋ฏธ์ง€์— ์ ์šฉ๋  ํ•จ์ˆ˜๋ฅผ ์ง€์ •ํ–ˆ๋‹ค. ๋˜ํ•œ background-size๋ฅผ contain์œผ๋กœ ์„ค์ •ํ•ด ํŒจ๋„ ํฌ๊ธฐ์— ๋”ฐ๋ผ ํฌ๊ธฐ๊ฐ€ ๋ณ€ํ•˜๊ฒŒ ํ•˜์˜€๋‹ค. ์ด ์˜ˆ์ œ์ฝ”๋“œ๋ฅผ ๋ธŒ๋ผ์šฐ์ €์—์„œ ์‹คํ–‰ํ•ด๋ณด๋ฉด ๋ชฌ์Šคํ„ฐ์˜ ๋จธ๋ฆฌ, ๋ชธ, ๋‹ค๋ฆฌ๋ฅผ ๋ฐ”๊ฟ€ ์ˆ˜ ์žˆ๋Š” ํ™”๋ฉด์ด ๋‚˜์˜จ๋‹ค. ์ด ๋ชฌ์Šคํ„ฐ๋ฅผ ๊ตฌ์„ฑํ•˜๋Š” ์ด๋ฏธ์ง€๋Š” flickr์—์„œ ์ฐพ์•˜์œผ๋ฉฐ creative commons์— ์ €์ž‘๊ถŒ์ด ๋“ฑ๋ก๋˜์–ด์žˆ์œผ๋ฉฐ ๋ฐ˜๋“œ์‹œ ์ €์ž‘์ž์™€ ์ถœ์ฒ˜๋ฅผ ํ•„์ˆ˜๋กœ ํ‘œ์‹œํ•ด์•ผ ํ•œ๋‹ค. ๋”ฐ๋ผ์„œ ์ œ์ž‘์ž์˜ ์›น์‚ฌ์ดํŠธ๋กœ ๊ฐˆ ์ˆ˜ ์žˆ๋Š” ๋งํฌ๋ฅผ ๋‹ด์„ panel์„ ํ•˜๋‚˜ ๋” ๋งŒ๋“ค์—ˆ๋‹ค. ๋งํฌ๋ฅผ ๋‹ด์€ credits panel์„ items ๋ฐฐ์—ด์— ๋ฐ”๋กœ ๋„ฃ์œผ๋ฉด ๋‹ค์Œ๊ณผ ๊ฐ™์ด 4๊ฐœ์˜ panel์ด ํ™”๋ฉด์„ ๊ท ๋“ฑํ•˜๊ฒŒ ๋‚˜๋ˆ ๊ฐ–๋Š”๋‹ค. ์˜ˆ์ œ์—์„œ๋Š” credits panel์— ํ•„์š”ํ•œ ๋งŒํผ์˜ ๋†’์ด๋งŒ ์ฃผ๊ณ  panel์˜ ๊ฐ€์žฅ ์•„๋ž˜์— ๋ถ™์ด๊ธฐ ์œ„ํ•ด credits panel์„ items ๋ฐฐ์—ด์—์„œ ๋นผ์„œ dockedItems์— ๋„ฃ์—ˆ๋‹ค. dock ๋ณ€์ˆ˜๋ฅผ โ€œbuttomโ€์œผ๋กœ ์„ค์ •ํ•ด ์ปจํ…Œ์ด๋„ˆ์˜ ํ•˜๋‹จ์— ๋ถ™์—ฌ์ฃผ๋ฉด ์›ํ•˜๋Š” ๊ฒฐ๊ณผ๋ฅผ ์–ป์„ ์ˆ˜ ์žˆ๋‹ค.

์˜ˆ์ œ์—์„œ ์„ผ์ฐจํ„ฐ์น˜๊ฐ€ ์ œ๊ณตํ•˜๋Š” ๋ชจ๋ฐ”์ผ ์•ฑ์„ ๋งŒ๋“ค๊ธฐ ์œ„ํ•ด ํ”ํžˆ ์‚ฌ์šฉํ•˜๋Š” ์—ฌ๋Ÿฌ ์ธํ„ฐํŽ˜์ด์Šค ํŒจํ„ด์„ ๋ณผ ์ˆ˜ ์žˆ๋‹ค. ํ•˜์ง€๋งŒ ์œ„์—์„œ ๋‹ค๋ฃฌ panel๋“ค์€ ์ž์ฃผ ๊ฑฐ๋ก ๋˜๋Š” ๊ฒƒ์„ ๋งŒ๋“ค ๋•Œ ๋งŽ์€ ๋„์›€์ด ๋  ๊ฒƒ์ด๋‹ค.

Sencha Touch - Intro to Layouts

In Sencha Touch the basic building block for creating an interface is the panel. Each panel can display html content or it can be treated as a container to hold other panels. Sencha Touch provides two distinct mechanisms for positioning panels with respect to their containers. You can either dock a panel, so that it sticks to one of the edges of its container, which is ideal for creating toolbars, or you can use a layout that will handle the positioning of one or more panels.

์„ผ์ฐจ ํ„ฐ์น˜์—์„œ ์ธํ„ฐํŽ˜์ด์Šค๋ฅผ ๋งŒ๋“œ๋Š” ๊ธฐ๋ณธ์ ์ธ ๊ตฌ์กฐ๋Š” 'panel' ์ž…๋‹ˆ๋‹ค. ๊ฐ panel์€ html ๋ฌธ์„œ๋ฅผ ํ‘œ์‹œ ํ•  ์ˆ˜ ์žˆ์œผ๋ฉฐ ๋‹ค๋ฅธ panel์„ ํฌํ•จํ•˜๋Š” ์ปจํ…Œ์ด๋„ˆ๊ฐ€ ๋  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ์„ผ์ฐจ ํ„ฐ์น˜๋Š” panel๊ณผ ์ปจํ…Œ์ด๋„ˆ์˜ ๊ด€๊ณ„์— ์žˆ์–ด์„œ ๋‘๊ฐ€์ง€์˜ ์„œ๋กœ ๋‹ค๋ฅธ ๋ฉ”์ปค๋‹ˆ์ฆ˜์„ ์ œ๊ณตํ•ฉ๋‹ˆ๋‹ค. panel ์„ ์ปจํ…Œ์ด๋„ˆ์— ์ฒ˜์Œ์ด๋‚˜ ๋์— ๋„ฃ์–ด์„œ ์ด์ƒ์ ์ธ ํˆด๋ฐ”๋ฅผ ๋งŒ๋“ค๊ฑฐ๋‚˜, ํ•˜๋‚˜ ์ด์ƒ์˜ panel ์œ„์น˜๋ฅผ ์กฐ์ ˆํ•˜๋Š” ๋ ˆ์ด์•„์›ƒ์— ์“ธ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

The layouts work either by neatly arranging inner panels to use the available space or by just showing one panel at a time and providing someway of changing the focus between panels. in this screen cast i will demonstrate each of the different layout types than go on to show how they can be combined in anyway you can think of.

๋ ˆ์ด์•„์›ƒ์€ ๋‚ด๋ถ€ panel๋“ค์ด ๊ณต๊ฐ„์„ ์ž˜ ์ฐจ์ง€ํ•˜๊ฒŒ ๊น”๋”ํžˆ ๋ฐฐ์—ดํ•˜๊ฑฐ๋‚˜, panel์„ ํ•œ๋ฒˆ์— ํ•˜๋‚˜์”ฉ ๋ณด์—ฌ์ฃผ๋ฉฐ ์‹œ์ ๋ณ€ํ™”๋ฅผ ์กฐ์ ˆ ํ•ฉ๋‹ˆ๋‹ค. ์ด ํ™”๋ฉด์—์„œ๋Š” ๊ฐ๊ฐ์˜ ๋‹ค๋ฅธ layout ์ข…๋ฅ˜๋ฅผ ์‹œ์—ฐํ•˜๊ณ  ๋” ๋‚˜์•„๊ฐ€ ํ˜ผํ•ฉํ•ด์„œ ์“ฐ๋Š”๊ฒƒ์„ ๋ณด์—ฌ๋“œ๋ฆฌ๊ฒ ์Šต๋‹ˆ๋‹ค.

0:54 layout:auto

The default layout type is auto. This causes a panel to behave much like a regular block level element in a html document. The panel will fill the entire available width, but it will only occupy as much height as is required to accommodate the content.

๋ ˆ์ด์•„์›ƒ์˜ ๋””ํดํŠธ๊ฐ’์€ 'auto' ์ž…๋‹ˆ๋‹ค. ์ด๊ฒƒ์€ panel์„ ํ•˜์—ฌ๊ธˆ ๋ธ”๋ก๋‹จ์œ„์˜ html ์š”์†Œ ์ฒ˜๋Ÿผ ๋™์ž‘ํ•˜๊ฒŒ ํ•ฉ๋‹ˆ๋‹ค. panel์€ ๊ฐ€๋กœ๋กœ ๊ฐ€๋Šฅํ•œ ํฌ๊ธฐ๋ฅผ ๋ชจ๋‘ ์ฐจ์ง€ ํ•˜์ง€๋งŒ, ์„ธ๋กœ๋กœ๋Š” ํ•„์š”ํ•œ ๋งŒํผ๋งŒ ์ฐจ์ง€ํ•ฉ๋‹ˆ๋‹ค.

1:11 Layout:fit

if you want to make a panel fill the entire available space, you can use the fit layout type. As u can c, this causes the panel to stretch vertically as well as horizontally. The fit layout is perfect, if u only want to add a single component to a panel. But it won't work if u add any additional component after that.

๋งŒ์ผ panel์ด ๋ชจ๋“  ๊ณต๊ฐ„์„ ์ฐจ์ง€ํ•˜๊ฒŒ ํ•˜๊ธฐ ์›ํ•˜๋ฉด, fit layout์„ ์‚ฌ์šฉํ•˜์‹œ๋ฉด ๋ฉ๋‹ˆ๋‹ค. ์—ฌ๊ธฐ์—์„œ ๋ณผ ์ˆ˜ ์žˆ๋“ฏ์ด, panel์ด ์„ธ๋กœ ๊ฐ€๋กœ ๋ชจ๋“  ์˜์—ญ์„ ์ฐจ์ง€ํ•˜๋Š”๊ฒƒ์„ ๋ณผ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. fit layout์€ panel์— ํ•˜๋‚˜์˜ ์š”์†Œ๋งŒ์„ ๋„ฃ๊ธฐ ์›ํ• ๋•Œ ์ ํ•ฉํ•ฉ๋‹ˆ๋‹ค. ์ถ”๊ฐ€์ ์ธ ๊ตฌ์„ฑ ์š”์†Œ๋ฅผ ๋„ฃ๊ฒŒ๋˜๋ฉด์€ ์ž‘๋™์‹œ ๋ฌธ์ œ๊ฐ€ ์ƒ๊น๋‹ˆ๋‹ค.

01:32 Layout:card

The card layout is similar to fit in that it only displays a single panel at a time. Where as the fit layout can only accept a single item, the card layout will accommodate multiple components. In this example i have deliberately assigned the "rootPanel" to a global variable, so that i can access it in the javascript console. The root panel uses a card layout and contains 3 items "red, amber, green" panels. If we look at it in the browser, u'll c that only the first component is visible.

card layout์€ ํ•˜๋‚˜์˜ panel๋งŒ ๋ณด์—ฌ์ฃผ๋Š” ์ ์—์žˆ์–ด์„œ fit ์™€ ๋น„์Šทํ•ฉ๋‹ˆ๋‹ค. fit layout์€ ํ•œ๊ฐ€์ง€ ์•„์ดํ…œ์„ ์ˆ˜์šฉ ํ•  ์ˆ˜ ์žˆ๋Š” ๋ฐ˜๋ฉด, card layout์€ ์—ฌ๋Ÿฌ๊ฐœ์˜ ์š”์†Œ๋ฅผ ์ˆ˜์šฉ ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ์ด ์˜ˆ์ œ์—์„œ๋Š” rootPanel์„ ์ž๋ฐ”์Šคํฌ๋ฆฝํŠธ์ฝ˜์†”์—์„œ ์ ‘๊ทผํ•˜๊ธฐ ์œ„ํ•ด ์˜๋„์ ์œผ๋กœ ์ „์—ญ๋ณ€์ˆ˜๋กœ ํ• ๋‹นํ–ˆ์Šต๋‹ˆ๋‹ค. rootPanel์€ card layout์„ ์“ฐ๋ฉฐ, 3๊ฐœ์˜ ์•„์ดํ…œ์ธ "red, amber, green"ํŒจ๋„๋กœ ๊ตฌ์„ฑ๋˜์žˆ์Šต๋‹ˆ๋‹ค. ๋ธŒ๋ผ์šฐ์ €๋ฅผ ๋ณด๋ฉด์€, ์ฒซ๋ฒˆ์งธ ์š”์†Œ๊ฐ€ ๋ณด์ด๋Š”๊ฒƒ์„ ์•Œ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

But if i open the console i can manipulate the rootPanel programmatically calling rootPanel.setActiveItem(1) will reveal the amber panel, and calling rootPanel.setActiveItem(2) will reveal the green panel. The card layout provides a programmatic interface for switching focus between panels. But it doesn't provide a user interface. In sencha touch there are two specialized kinds of panel that do provide a user interface to the card layout, the Carousel, and the TabPanel. So lets have a look at these.

์ฝ˜์†”์„ ์—ด๋ฉด rootPanel์„ ์กฐ์ž‘ํ•ด์„œ rootPanel.setActiveItem(1)์„ ํ•˜๋ฉด amber ํŒจ๋„์„, rootPanel.setActiveitem(2)๋ฅผ ํ•˜๋ฉด greenํŒจ๋„์ด ๋ณด์ด๋Š”๊ฒƒ์„ ๋ณผ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. card layout์€ ํŒจ๋„๊ฐ„์— ์ดˆ์ ์„ ์ „ํ™˜ํ•˜๊ธฐ ์œ„ํ•œ ํ”„๋กœ๊ทธ๋ž˜๋ฐ ์ธํ„ฐํŽ˜์ด์Šค๋ฅผ ์ง€์›ํ•ฉ๋‹ˆ๋‹ค. ํ•˜์ง€๋งŒ UI(์œ ์ €์ธํ„ฐํŽ˜์ด์Šค)๋Š” ์ง€์›ํ•˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค. ์„ผ์ฐจ ํ„ฐ์น˜์—๋Š” ๋‘๊ฐ€์ง€ UI๋ฅผ ์ง€์›ํ•˜๋Š” panel ์ด ์žˆ์Šต๋‹ˆ๋‹ค. Carousel๊ณผ TabPanel์ž…๋‹ˆ๋‹ค. ํ•œ๋ฒˆ ์‚ดํŽด๋ณผ๊นŒ์š”

02:45 TabPanel

If i change this panel into a TabPanel, then refresh the page in the browser, u'll c that it has created a tabbed user interface. I can click on each title to activate its corresponding penal. By default the tabPanel will use a slide transition when switching focus. But u can override this values with 'fade', 'slide', 'flip', 'cube', or 'wipe'. Where as a regular panel allows u to specify the layout, the tabPanel requires a layout of 'card'. So if you try to set it to anything else, the value will just be ignored. I still have access to the setActiveItem function. And i can use this to change the inner panels programmatically.

์ œ๊ฐ€ ์ด panel์„ TabPanel๋กœ ๋ฐ”๊พธ๊ณ , ๋ธŒ๋ผ์šฐ์ €๋ฅผ ์ƒˆ๋กœ๊ณ ์น˜๋ฉด, ํƒญํ˜•์‹์˜ ์œ ์ €์ธํ„ฐํŽ˜์ด์Šค๊ฐ€ ์ƒ๊ธด๊ฒƒ์„ ๋ณผ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ๊ฐ๊ฐ์˜ ์ด๋ฆ„์„ ํด๋ฆญํ•ด์„œ ๊ฐ ํŒจ๋„์„ ํ™œ์„ฑํ™” ์‹œํ‚ฌ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ๋””ํดํŠธ๊ฐ’์œผ๋กœ tabPanel์€ ์Šฌ๋ผ์ด๋“œ ํ˜•์‹์˜ ํ™”๋ฉด์ „ํ™˜์„ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค, ํ•˜์ง€๋งŒ 'fade', 'slide', 'flip', 'cube', or 'wipe' ๋“ฑ์œผ๋กœ ์žฌ์ •์˜ ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ์ผ๋ฐ˜ panel์—์„œ๋Š” layout์„ ์„ค์ • ํ•  ์ˆ˜ ์žˆ๋Š” ๋ฐ˜๋ฉด, tabPanel์€ 'card'ํ˜•์‹์˜ layout๋งŒ์„ ์‚ฌ์šฉ ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ๋•Œ๋ฌธ์— ๋‹ค๋ฅธ๊ฒƒ์œผ๋กœ ์žฌ์ •์˜ํ•ด๋„ ๊ฐ’์ด ๋ฌด์‹œ๋  ๊ฒƒ์ž…๋‹ˆ๋‹ค. ์—ฌ์ „ํžˆ setActiveItem ํ•จ์ˆ˜๋Š” ์‚ฌ์šฉ ํ•  ์ˆ˜ ์žˆ์œผ๋ฉฐ, ๋‚ด๋ถ€ ํŒจ๋„๊ฐ„์˜ ์ „ํ™˜์„ ์ฝ˜์†”์„ ํ†ตํ•ด ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

03:33 Carousel

Now i'm going to switch the tabPanel for a Carousel, and refresh the page in the browser. Again this uses a card layout, so only one panel is visible at a time. But instead of using tab to switch, I can just swipe from side to side. Notice too have the indicator at the bottom gives a sense of how many panels there are, and which page u r on. By default the carousel works horizontally. But the direction parameter can be set to either horizontal or vertical.

์ด๋ฒˆ์—๋Š” tabPanel์—์„œ Carousel๋กœ ๋ฐ”๊ฟ”๋ณด๊ณ  ๋ธŒ๋ผ์šฐ์ €์—์„œ ์ƒˆ๋กœ๊ณ ์นจํ•ด๋ณด๊ฒ ์Šต๋‹ˆ๋‹ค. ์ „๊ณผ๊ฐ™์ด card layout์„ ์‚ฌ์šฉํ–ˆ๊ธฐ์— ํ•˜๋‚˜์˜ ํŒจ๋„๋งŒ์ด ๋ณด์ด๋Š”๊ฒƒ์„ ์•Œ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ํ•˜์ง€๋งŒ ํƒญ์„ ์ด์šฉํ•ด ํ™”๋ฉด์„ ์ „ํ™˜ ํ•˜์ง€ ์•Š๊ณ  ์Šค์™€์ดํ”„๋ฅผ ํ†ตํ•ด ์ „ํ™˜ ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ์•„๋ž˜ ๋ถ€๋ถ„์—๋Š” ๋ช‡๊ฐœ์˜ ํŽ˜์ด์ง€๊ฐ€ ์žˆ๊ณ  ํ˜„์žฌ ๋ช‡๋ฒˆ์งธ ํŽ˜์ด์ง€์— ์žˆ๋Š”์ง€ ํ‘œ์‹œ๊ฐ€ ๋˜์žˆ๋Š”๊ฑธ ๋ณผ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ๋””ํดํŠธ๊ฐ’์œผ๋กœ carousel์€ ์ˆ˜ํ‰ ์ด๋™ํ•ฉ๋‹ˆ๋‹ค. ํ•˜์ง€๋งŒ direction ๋ณ€์ˆ˜๋ฅผ ์ด์šฉํ•ด ๋ฐ”๊ฟ€ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

04:10 Boxlayout

So far i've shown that the fit layout is suitable for a single panel, and that the card layout can hold multiple panels, but it will only display one at a time. So what if you want to display more than one panel simultaneously? Thats when the HBox and the VBoxLayouts come in.

์—ฌ๊ธฐ๊นŒ์ง€ ํ•˜๋‚˜์˜ ํŒจ๋„์—๋Š” fit layout์ด ์ ํ•ฉํ•˜๋‹ค๊ณ , card layout์€ ํ•œ๋ฒˆ์— ํ•˜๋‚˜์”ฉ๋ฐ–์— ๋ณด์—ฌ์ฃผ์ง„ ์•Š์ง€๋งŒ ์—ฌ๋Ÿฌ๊ฐœ์˜ ํŒจ๋„์„ ๊ฐ€์งˆ ์ˆ˜ ์žˆ๋‹ค๋Š” ๊ฒƒ์„ ๋ณด์—ฌ๋“œ๋ ธ์Šต๋‹ˆ๋‹ค. ๊ทธ๋ ‡๋‹ค๋ฉด ์—ฌ๋Ÿฌ๊ฐœ์˜ ํŒจ๋„์„ ๋™์‹œ์— ๋ณด์—ฌ์ฃผ๋ ค๋ฉด ์–ด๋–ป๊ฒŒ ํ• ๊นŒ์š”? ๋ฐ”๋กœ hbox์™€ vbox ๋ ˆ์ด์•„์›ƒ์„ ์‚ฌ์šฉํ•˜๋ฉด๋ฉ๋‹ˆ๋‹ค.

Here i'm going to switch the card layout for "vbox". When i refresh the browser, u'll c that all three panels r visible. But they only occupy as much height and width as their contents requires. To make the panels use all available horizontal space, i can set the align parameter to "stretch". This makes it look just the same as if layout was set to auto. But the vbox layout offers much more control over where components occupy vertical space. The pack perimeter is set to the "start" by default.

์—ฌ๊ธฐ์— card layout์„ vbox๋กœ ๊ต์ฒดํ•ด๋ณด๊ฒ ์Šต๋‹ˆ๋‹ค. ๋ธŒ๋ผ์šฐ์ ธ๋ฅผ ์ƒˆ๋กœ๊ณ ์น˜๋ฉด, 3๊ฐœ ํŒจ๋„์ด ๋‹ค ๋ณด์ด๋Š”๊ฒƒ์„ ์•Œ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ํ•˜์ง€๋งŒ ๋‚ด์šฉ์ด ํ•„์š”ํ•œ ๋งŒํผ์˜ ๋„“์ด์™€ ๋†’์ด๋งŒ ๊ฐ€์ง€๊ฒŒ ๋ฉ๋‹ˆ๋‹ค. ํŒจ๋„์˜ ๋„“์ด๋ฅผ ๊ฝ‰ ์ฑ„์šฐ๊ธฐ ์œ„ํ•ด์„œ๋Š” align ๋ณ€์ˆ˜์— "stretch"๋ฅผ ์ง€์ •ํ•ด์ฃผ๋ฉด ๋ฉ๋‹ˆ๋‹ค. ์ด์ œ ๋ณด์‹œ๋ฉด์€ layout์ด auto ์˜€์„๋•Œ์™€ ๊ฐ™์•„์กŒ์„๊ฒ๋‹ˆ๋‹ค. ํ•˜์ง€๋งŒ vbox layout์€ ์„ธ๋กœ ์˜์—ญ์— ๋Œ€ํ•ด ๋” ๋งŽ์€ ์ œ์–ด๋ฅผ ์ œ๊ณตํ•ฉ๋‹ˆ๋‹ค. pack ๋ณ€์ˆ˜๋Š” ๋””ํดํŠธ๊ฐ’์œผ๋กœ start๋กœ ๋˜์–ด์žˆ์Šต๋‹ˆ๋‹ค.

But it can also take the values "center" and "end". This affects the vertical positioning of the panels. U can control the vertical height of each individual panel using the flex parameter. This specifies the proportion of the vertical space that the each panel will occupy. If i set flex to 1 for each panel, they will occupy the same amour of height.

ํ•˜์ง€๋งŒ "center"์™€ "end" ๊ฐ’์„ ์ค„ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ์ด๊ฒƒ์€ panel์˜ ์„ธ๋กœ ์œ„์น˜๋ฅผ ๋ณ€๊ฒฝํ•ฉ๋‹ˆ๋‹ค. ์„ธ๋กœ ๋†’์ด๋Š” flex๋ณ€์ˆ˜๋ฅผ ์ด์šฉํ•ด ์กฐ์ ˆ ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ์ด๊ฒƒ์€ ๊ฐ๊ฐ์˜ ํŒจ๋„์ด ์ฐจ์ง€ํ•  ์„ธ๋กœ ๊ณต๊ฐ„์˜ ๋น„์œจ์„ ์กฐ์ ˆํ•ฉ๋‹ˆ๋‹ค. ๊ฐ ํŒจ๋„์˜ flex๊ฐ’ ๋ชจ๋‘ 1๋กœ ์„ค์ •ํ•˜๋ฉด ๋ชจ๋‘ ๊ฐ™์€ ๋น„์œจ์˜ ๋†’์ด๋ฅผ ์ฐจ์ง€ํ•˜๊ฒŒ ๋ฉ๋‹ˆ๋‹ค.

What i've done here is to specify the value for flex on every panel within the box. But there is a quicker and a dryer way of doing this. which is to create a hash of default values, including the flex parameter. Now i can remove the setting for each individual panel. The vbox layout distributes panels vertically. There is also an hbox layout which arranges panels horizontally. This can also be tweaked using align, pack, and flex parameters. But each one works from left to right, rather than from top to bottom.

์—ฌ๊ธฐ์„œ๋Š” ๋ชจ๋“  ํŒจ๋„์˜ ๋ฐ•์Šค ์•ˆ์— flex๊ฐ’์„ ์„ค์ •ํ–ˆ์Šต๋‹ˆ๋‹ค. ํ•˜์ง€๋งŒ ๋” ๋น ๋ฅด๊ณ  ์‰ฌ์šด ๋ฐฉ๋ฒ•์œผ๋กœ ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ๋ฐ”๋กœ ๋””ํดํŠธ ๋ณ€์ˆ˜์— ํ•ด์‹œ๊ฐ’์œผ๋กœ flex๋ณ€์ˆ˜๋ฅผ ๋„ฃ๋Š”๊ฒƒ์ž…๋‹ˆ๋‹ค. ์ด์ œ ๊ฐ๊ฐ์˜ ํŒจ๋„์— ์žˆ๋Š” ๊ฐ’์„ ์ง€์›Œ๋„ ๋ฉ๋‹ˆ๋‹ค. vbox ๋ ˆ์ด์•„์›ƒ์€ ์„ธ๋กœ๋กœ ํŒจ๋„์„ ๋‚˜๋ˆ„๋Š”๋ฐ˜๋ฉด hbox ๋ ˆ์ด์•„์›ƒ์€ ๊ฐ€๋กœ๋กœ ํŽ˜๋„์„ ๋ฐฐ์น˜ํ•ฉ๋‹ˆ๋‹ค. ์ด๊ฒƒ ์—ญ์‹œ align, pack, flex ๋ณ€์ˆ˜ ๋“ฑ์„ ์ด์šฉํ•ด ์ˆ˜์ • ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ํ•˜์ง€๋งŒ ๊ฐ๊ฐ์„ ์œ„์—์„œ ์•„๋ž˜๋กœ ์ •์˜ํ•˜๋Š”๊ฒŒ ์•„๋‹Œ ์ขŒ์—์„œ ์šฐ๋กœ ์ •์˜ํ•ฉ๋‹ˆ๋‹ค.

06:07 Mix&Match

Every panel can be treated as a component in itself, or as a container for other panels. so it's possible to nest panels together using different layouts for each one. Here i've created a root level panel that fills the screen. It contains 3 panels arranged using a vbox layout with align and flex set setup, so as to use all of the available space. The topChanger, centerChanger, and the bottomChanger panels are all carousels, each containing three panels of different colors.

๋ชจ๋“  ํŒจ๋„์€ ์ž๊ธฐ์ž์‹ ์— ํฌํ•จ๋œ ์š”์†Œ๋กœ ๋ณผ ์ˆ˜ ์žˆ์œผ๋ฉฐ ๋‹ค๋ฅธ ํŒจ๋„์„ ํฌํ•จ ํ•  ์ˆ˜ ์žˆ๋Š” ์ปจํ…Œ์ด๋„ˆ๋กœ๋„ ์—ฌ๊ธธ ์ˆ˜ ์žˆ๋‹ค. ๊ทธ๋ž˜์„œ panel์€ ์„œ๋กœ ๋‹ค๋ฅธ ๋ ˆ์ด์•„์›ƒ์„ ์ด์šฉํ•ด์„œ ์„œ๋กœ๋ฅผ ํฌํ•จํ•  ์ˆ˜ ์žˆ๋‹ค. ์—ฌ๊ธฐ์„œ๋Š” ์Šคํฌ๋ฆฐ์„ ๊ฝ‰ ์ฑ„์šฐ๋Š” ๋ฃจํŠธ๋ ˆ๋ฒจ์˜ ํŒจ๋„์„ ์ƒ์„ฑํ–ˆ๋‹ค. ์ด๊ฒƒ์€ ๋ชจ๋“  ๊ณต๊ฐ„์„ ์‚ฌ์šฉํ•˜๊ธฐ์œ„ํ•œ ๋ฐฉ๋ฒ•์œผ๋กœ align๊ณผ flex๊ฐ€ ์„ค์ •๋œ vbox layout์œผ๋กœ ์ •๋ ฌ๋œ 3๊ฐœ์˜ ํŒจ๋„์„ ํฌํ•จํ•œ๋‹ค. topChanger, centerChanger, ๊ทธ๋ฆฌ๊ณ  bottomChanger panel๋“ค์ด ๊ฐ๊ฐ 3๊ฐœ์˜ ๋‹ค๋ฅธ ์ƒ‰์˜ ํŒจ๋„์„ ํฌํ•จํ•˜๋Š” carousels๋‹ค. If we take a look at this in the browser u'll c three strips of colors stretching to fill the available vertical space. That's the vbox behavior. But each colored panel is itself, just one of 3 cards arranged in a carousel. So i can swipe each of these to mix & match the colors. Let's take this to the next level, and switch out the inline styles(style:) for classes(cls:).

๋ธŒ๋ผ์šฐ์ €์—์„œ ๋ณด๋ฉด, 3๊ฐœ์˜ ์ƒ‰์ค„์ด ์ขŒ์šฐ๋กœ ๋Š˜๋ ค์ ธ ์œ„์•„๋ž˜ ํ™”๋ฉด์€ ๊ฝ‰ ์ฑ„์šฐ๋Š”๊ฒƒ์„ ๋ณผ ์ˆ˜ ์žˆ๋‹ค. ์ด๊ฒƒ์ด vbox์˜ ์„ฑ๊ฒฉ์ด๋‹ค. ํ•˜์ง€๋งŒ ๊ฐ๊ฐ์˜ ์ƒ‰์€ 3๊ฐœ์˜ card๋กœ๋œ ํŒจ๋„ ๊ทธ ์ž์ฒด์ด๋‹ค. ๊ทธ๋ž˜์„œ ๊ฐ๊ฐ์„ ์ขŒ์šฐ๋กœ ์Šฌ๋ผ์ด๋“œ ํ•ด์„œ ์ƒ‰์„ ์„ž๊ณ  ์งœ๋งž์ถœ ์ˆ˜ ์žˆ๋‹ค. ๊ทธ๋Ÿผ ๋‹ค์Œ ๋‹จ๊ณ„๋กœ ๋„˜์–ด๊ฐ€์„œ style๋ฅผ clsํด๋ž˜์Šค๋กœ ๋ฐ”๊ฟ”๋ณด์ž.

In my style-sheet i've created rules that apply a background image to each panel in the carousel. i'm also using the background-size contain rule which will scale the image to fit when the panels change size. Now when i refresh the browser, i get to switch the head, torso, and the legs of a little monster. i found these illustrations on flickr, and they are distributed under "creative commons" license. That means i can remix and redistribute them as long as i give credit to the original artist. So i want to add one more panel containing link to the illustrator's website. let's c what happens if i add this directly to the items array. the vbox layout causes this item to occupy the same amount of vertical space as the three carousels. I'd prefer to make the panel containing the credits, take up no more room than it needs to. ideally i just like to stick it to the bottom of the containing panel. This can be achieved by moving the credits panel from the items array to the dockedItems array. setting the dock property to "bottom" fixes it to the bottom of its' container. And that achieves the desired result.

๋‚ด ์Šคํƒ€์ผ-์‹œํŠธ์—์„œ๋Š” ๊ฐ๊ฐ์˜ ํŒจ๋„์— ๋“ค์–ด๊ฐ€๋Š” carousel์˜ ๋ฐฐ๊ฒฝ ์ด๋ฏธ์ง€์— ์ ์šฉ๋  ํ•จ์ˆ˜๋ฅผ ์ง€์ •ํ•ด์คฌ๋‹ค. ๋˜ํ•œ background-size์— contain์„ ์ ์šฉ์‹œ์ผœ ํŒจ๋„ ํฌ๊ธฐ์— ๋ณ€ํ™”์—๋”ฐ๋ผ ํฌ๊ธฐ๊ฐ€ ๋งž๊ฒŒ ํ–ˆ๋‹ค. ๋ธŒ๋ผ์šฐ์ €๋ฅผ ์ƒˆ๋กœ๊ณ ์น˜๋ฉด, ๋ชฌ์Šคํ„ฐ์˜ ๋จธ๋ฆฌ, ๋ชธ, ๋‹ค๋ฆฌ๋ฅผ ๋ฐ”๊ฟ€ ์ˆ˜ ์žˆ๋Š”ํ™”๋ฉด์ด ๋‚˜์˜จ๋‹ค. ์ด ์ด๋ฏธ์ง€๋“ค์€ flickr์—์„œ ์ฐพ์•˜์œผ๋ฉฐ creative commons ์— ์ €์ž‘๊ถŒ ๋“ฑ๋ก์ด๋˜์žˆ๋‹ค. ์ด๋œป์€ ์ด๋ฏธ์ง€์˜ ์ œ์ž‘์ž ํฌ๋ ˆ๋”ง์„ ์ฃผ๋Š” ๋Œ€์‹  ๊ฐ€์ ธ๋‹ค ์“ธ ์ˆ˜ ์žˆ๋‹ค. ๋•Œ๋ฌธ์— ์ œ์ž‘์ž์˜ ์›น์‚ฌ์ดํŠธ์— ๋งํฌ๋ฅผ ๊ฑฐ๋Š” panel์„ ํ•˜๋‚˜ ๋” ๋งŒ๋“ค์–ด์•ผํ•œ๋‹ค. items ๋ฐฐ์—ด์— ๋ฐ”๋กœ ์ง‘์–ด๋„ฃ์œผ๋ฉด ์–ด๋–ป๊ฒŒ ๋˜๋Š”์ง€ ๋ณด์ž. vbox ๋ ˆ์ด์•„์›ƒ์€ ์œ„์˜ 3๊ฐœ carousel๊ณผ ๊ฐ™์€ ๋†’์ด๋ฅผ ์ฐจ์ง€ํ•˜๋Š” ํŒจ๋„์„ ๋งŒ๋“ค์–ด์ค€๋‹ค. ๋‚˜๋Š” ํฌ๋ ˆ๋”ง ํŒจ๋„์— ํ•„์š”ํ•œ ๋งŒํผ์˜ ๋†’์ด๋งŒ์„ ์ฃผ๊ณ ์‹ถ๋‹ค. ์ด์ƒ์ ์œผ๋กœ ํŒจ๋„์˜ ์ œ์ผ ๋ฐ‘์— ๋ถ™์ด๊ณ ์‹ถ๋‹ค. ์ด๊ฒƒ์€ items๋ฐฐ์—ด์—์„œ creditํŒจ๋„์„ ๋นผ์„œ dockedItems์— ๋„ฃ๋Š”๊ฒƒ์œผ๋กœ ํ•ด๊ฒฐ๋œ๋‹ค. dock๋ณ€์ˆ˜๋ฅผ "bottom"์œผ๋กœ ์ •์ดํ•˜๋ฉด ์ปจํ…Œ์ด๋„ˆ์˜ ํ•˜๋‹จ์— ๋ถ™์—ฌ์ค€๋‹ค. ์งœ์ž”~์›ํ•˜๋Š” ๊ฒฐ๊ณผ๋‹ค.

08:17 Outro

In practice u'll find that many common interface patterns for building mobile applications r provided by one of sencha touch's more specialized panel types. But the layouts covered in this episode will be a great help on those occasions when u need to build something more of the spoke.

์—ฐ์Šต์—์„œ๋Š” ์„ผ์ฐจํ„ฐ์น˜์˜ ์„ธ๋ถ€ ํŒจ๋„ ํƒ€์ž…์ด ๋ชจ๋ฐ”์ผ ์•ฑ์„ ๋งŒ๋“ค๊ธฐ ์œ„ํ•œ ๋งŽ์€ ์ธํ„ฐํŽ˜์ด์Šค ํŒจํ„ด์„ ์ œ๊ณตํ•˜๋Š” ๊ฒƒ์„ ๋ณผ ์ˆ˜ ์žˆ๋‹ค. ํ•˜์ง€๋งŒ ์œ„์—์„œ ํ–ˆ๋˜ ๋‚ด์šฉ์€ ์ž์ฃผ ๊ฑฐ๋ก ๋˜๋Š” ๊ฒƒ์„ ๋งŒ๋“ค๋•Œ์— ๋งŽ์€ ๋„์›€์„ ์ค„ ๊ฒƒ์ด๋‹ค.