doc01 - KoreaSenchaUserGroup/Lab1 GitHub Wiki
์๋ฌธ : http://docs.sencha.com/touch/2-0/#!/guide/getting_started
๋ฒ์ญ : ์ ๊ฑด์ฐ [Github:NangChun]
ํธ์ง : ์ค๊ฐํฌ [Github:5312559]
(์ต์ข ํธ์ง์ผ : 2012.03.24)
Note: This guide will be updated to reflect the content of the video shortly.
์ฐธ๊ณ : ๋ณธ ๊ฐ์ด๋๋ ๋น๋์ค์ ๋ด์ฉ์ ๋ฐ์ํด ๊ณง ์ ๋ฐ์ดํธํ ์์ ์ ๋๋ค.
Sencha Touch enables you to quickly and easily create HTML5 based mobile apps that work on Android, iOS and Blackberry devices and produce a native-app-like experience inside a browser.
์ผ์ฐจํฐ์น๋ฅผ ์ด์ฉํ๋ฉด ๋น ๋ฅด๊ณ ์ฝ๊ฒ html ๊ธฐ๋ฐ์ ๋ชจ๋ฐ์ผ ์ฑ์ ๋ง๋ค ์ ์๋ค. ์ผ์ฐจํฐ์น๋ก ๋ง๋ ๋ชจ๋ฐ์ผ ์ฑ์ Android, iOS ๊ทธ๋ฆฌ๊ณ ๋ธ๋๋ฒ ๋ฆฌ์์ ์๋๋๋ฉฐ ๋ธ๋ผ์ฐ์ ์์ ๋ค์ดํฐ๋ธ ์ฑ๊ณผ ๊ฐ์ ๊ฒฝํ์ ์ ๊ณตํ๋ค.
Here's what you need to get started:
- The free Sencha Touch 2.0 SDK
- A web server running locally on your computer
- A modern web browser; Chrome and Safari are recommended
Download and unzip the latest version of the SDK. Place the unzipped folder into your web server's document root. If you don't have a web server or aren't sure, we recommend using a simple one-click installer like WAMP or MAMP.
Once you have the folder in the right place, open your web browser and point it to http://localhost/sencha-touch-folder (or wherever your web server is configured to serve from) and you should see the Sencha Touch Welcome page. If that's all working you're ready to start your first app.
์์์ ์ํ ์ค๋น์ฌํญ์ ๋ค์๊ณผ ๊ฐ๋ค.
- ๋ฌด๋ฃ๋ฒ์ ์ ์ผ์ฐจํฐ์น 2.0 SDK
- ๋ก์ปฌ์์ ์คํ๋๋ ์น ์๋ฒ ์ปดํจํฐ
- ์ต์ ์น ๋ธ๋ผ์ฐ์ ; ํฌ๋กฌ๊ณผ ์ฌํ๋ฆฌ๋ฅผ ์ถ์ฒํ๋ค.
์ต์ ๋ฒ์ ์ SDK๋ฅผ ๋ด๋ ค๋ฐ์ ์์ถ์ ํ๊ณ , ์น ์๋ฒ์ document ๋ฃจํธ์ ์์ถ์ ํผ ํด๋๋ฅผ ๋ฃ๋๋ค. (์ญ์์ฃผ: MAMP๋ผ๋ฉด, ์์ฉํ๋ก๊ทธ๋จ -> MAMP -> htdocs๊ฐ ๋ฃจํธ ํด๋) ์น ์๋ฒ๊ฐ ์ค๋น๋ผ ์์ง ์๋ค๋ฉด, WAMP ๋๋ MAMP๋ฅผ ์ฌ์ฉํ๊ธธ ์ถ์ฒํ๋ฉฐ, ๋ค์๊ณผ ๊ฐ์ด ๊ฐ๋จํ๊ฒ ํ ๋ฒ์ ํด๋ฆญ์ผ๋ก ์ค์นํ ์ ์๋ค.
์น ์๋ฒ์ ๋ฃจํธ์ SDK ํด๋๋ฅผ ๋ฃ์ ํ, ์น ๋ธ๋ผ์ฐ์ ๋ฅผ ์ด๊ณ ์ฃผ์์ฐฝ์ http://localhost/sencha-touch-folder(์น ์๋ฒ๋ง๋ค ๊ตฌ์ฑํ ์ ์๊ฒ ์ ๊ณต๋จ)๋ผ๊ณ ์ ๋ ฅํ๋ฉด ์ผ์ฐจํฐ์น ํ์ํ์ด์ง๊ฐ ๋ํ๋๋ค. ์ด์ ์ฒซ ๋ฒ์งธ ์์ฉํ๋ก๊ทธ๋จ์ ๋ง๋ค ์ค๋น๊ฐ ๋๊ฒ์ด๋ค.
Sencha Touch apps work best when they follow the simple application structure guidelines we provide. This is a small set of conventions and classes that make writing maintainable apps simpler, especially when you work as part of a team.
The first step is to set up the simple folder structure that will house the app. Initially all you need is two files and a copy of Sencha Touch. By convention, these are:
- index.html - a simple HTML file that includes Sencha Touch and your application file
- app.js - a file where you define the app name, home screen icon, and what it's supposed to do on launch
- touch - a copy of the downloaded Sencha Touch folder
Let's start with the index.html file. Here's what it looks like:
<!DOCTYPE html>
<html>
<head>
<title>Getting Started</title>
<link rel="stylesheet" href="touch/resources/css/sencha-touch.css" type="text/css">
<script type="text/javascript" src="touch/builds/sencha-touch-all-debug.js"></script>
<script type="text/javascript" src="app.js"></script>
</head>
<body></body>
</html>
This is probably one of the simplest HTML pages you'll ever write. All it does is include Sencha Touch (the JavaScript file and its stylesheet), and your app.js. Note that the body is empty - we'll let Sencha Touch fill that up.
Next, let's look at the contents of our app.js file. We'll keep things simple to start and just call alert
to make sure everything's working:
@example raw miniphone
Ext.application({
name: 'Sencha',
launch: function() {
alert('launched');
}
});
That's all you need to get started. Now, launch Safari or Chrome and make sure it works as expected. You can also click the small Preview icon next to the example above to run it. So far it doesn't do very much, but the fact that the alert message pops up means Sencha Touch is on the page and the app launched.
The last thing we're going to do is create a Panel with the time-honored Hello World. This is really simple, all we need to do is update our launch function to use Ext.create, like this:
@example raw miniphone
Ext.application({
name: 'Sencha',
launch: function() {
Ext.create('Ext.Panel', {
fullscreen: true,
html: 'Hello World'
});
}
});
์ผ์ฐจํฐ์น๋ ์ผ์ฐจํฐ์น์์ ์ ๊ณตํ๋ ๊ฐ๋จํ ์ ํ๋ฆฌ์ผ์ด์ ๊ตฌ์กฐ ์ง์นจ์ ๋ฐ๋ฅผ ๋ ๊ฐ์ฅ ์ ์๋ํ๋ค. ์ด ๊ตฌ์กฐ ์ง์นจ์ ๊ท์ฝ๊ณผ ํด๋์ค์ ์งํฉ์ผ๋ก ํนํ ํ์ ์ผ์์ผ๋ก ์ผํ ๋, ์ฑ์ ๋จ์ํ๊ฒ ์ ์งํ๋ฉด์ ์์ฑํ ์ ์๊ฒ ๋๋๋ค.
๋จผ์ ์ฑ์ ์คํํ๊ธฐ ์ํ ํด๋ ๊ตฌ์กฐ๋ฅผ ์ค์ ํ๋ค. ์ด๊ธฐ ์ค์ ์๋ ๋ ๊ฐ์ ํ์ผ๊ณผ ์ผ์ฐจํฐ์น ๋ณต์ฌ๋ณธ์ด ํ์ํ๋ค. ๋ณดํต ์ด ์ธ ํ์ผ์ ๋ค์๊ณผ ๊ฐ๋ค:
- index.html - ์ผ์ฐจํฐ์น ์์ฉ ํ๋ก๊ทธ๋จ ํ์ผ์ ํฌํจํ ๊ฐ๋จํ HTML ํ์ผ
- app.js - ์ฑ์ ์ด๋ฆ, ํ ํ๋ฉด ์์ด์ฝ, ์คํ ๋ฐฉ๋ฒ์ ์ ์ํ ํ์ผ
- touch - ๋ด๋ ค๋ฐ์ Sencha Touch ํด๋์ ์ฌ๋ณธ
index.html ํ์ผ์์ ์์ ํ๋ฉฐ, ๋ด์ฉ์ ๋ค์๊ณผ ๊ฐ๋ค.
<!DOCTYPE html>
<html>
<head>
<title>Getting Started</title>
<link rel="stylesheet" href="touch/resources/css/sencha-touch.css" type="text/css">
<script type="text/javascript" src="touch/builds/sencha-touch-all-debug.js"></script>
<script type="text/javascript" src="app.js"></script>
</head>
<body></body>
</html>
์ ์ฝ๋๋ ์์ฃผ ์ฌ์ฉํ ์๋ง๋ ๊ฐ์ฅ ๊ฐ๋จํ HTML ๊ฐ์ด๋ฐ ํ๋์ผ ๊ฒ์ด๋ค. Sencha Touch (์๋ฐ ์คํฌ๋ฆฝํธ ํ์ผ๊ณผ ์คํ์ผ ์ํธ)์ app.js๋ฅผ ํฌํจํ๋ค. ์ฐธ๊ณ ๋ก ๋ณธ๋ฌธ์ ๋น์ด ์๋ค โ ์ฌ๋ฌ๋ถ๊ณผ ํจ๊ป Sencha Touch๋ฅผ ์ฑ์๋๊ฐ ๊ฒ์ด๋ค.
๋ค์์ผ๋ก, app.js ํ์ผ์ ๋ด์ฉ์ ๋ณด์. ํญ์ alert
๋ฅผ ํธ์ถํ๋ ๊ฐ๋จํ ์ฑ์ ๋ง๋ค๊ฒ ๋ค.
@example raw miniphone
Ext.application({
name: 'Sencha',
launch: function() {
alert('launched');
}
});
์ ์ฝ๋๊ฐ ์์ํ๋ ๋ฐ ํ์ํ ์ ๋ถ๋ค. ์ด์ ์ฌํ๋ฆฌ๋ ํฌ๋กฌ์ ์คํํ๊ณ ์์๋๋ก ์๋ํ๋์ง ํ์ธํ๋ผ. ๋๋ ์์ ์์ ์๋ ์์ ๋ฏธ๋ฆฌ๋ณด๊ธฐ ์์ด์ฝ์ ํด๋ฆญํด ์คํํด ๋ณผ ์๋ ์๋ค. ์ง๊ธ๊น์ง ๋ง์ด ํ์ง๋ ์์์ง๋ง โalertโ ์ฐฝ์ ํ์ ์ ์ผ์ฐจํฐ์น๊ฐ ํ์ด์ง์ ์๊ณ ์ฑ์ด ์คํ๋์์ ์๋ฏธํ๋ค.
๋ง์ง๋ง์ผ๋ก Panel์ ๋ง๋ค๊ณ ์ ํต์ ์ธ Hello World๋ฅผ ๋์๋ณด์. Hello World๋ฅผ ๋์ฐ๋ ์ผ์ ๋งค์ฐ ๊ฐ๋จํ๋ค. launch ํจ์๋ฅผ ๊ฐฑ์ ํ๊ธฐ์ํด Ext.create๋ฅผ ์ฌ์ฉํ์ผ๋ฉฐ ์ฝ๋๋ ๋ค์๊ณผ ๊ฐ๋ค.
@example raw miniphone
Ext.application({
name: 'Sencha',
launch: function() {
Ext.create('Ext.Panel', {
fullscreen: true,
html: 'Hello World'
});
}
});
Now that we've put together the simplest of pages and achieved Hello World, it's time to create our first simple app. The next step is to go through the First Application guide, which builds on what you've just done and builds a simple but powerful app in around 15 minutes.
If you'd like to skip ahead or find out more detailed information about other aspects of the framework we recommend checking out the following guides and resources:
์ง๊ธ๊น์ง ๊ฐ์ฅ ๊ฐ๋จํ ํ์ด์ง๋ฅผ ๋ง๋ค๊ณ Hello World๋ฅผ ์ถ๋ ฅํ๋ค. ์ด์ ๊ฐ๋จํ ์ฒซ ๋ฒ์งธ ์ฑ์ ๋ง๋ค ์ฐจ๋ก์ด๋ค. ๋ค์ ๋จ๊ณ๋ ์ฒซ๋ฒ์งธ ์์ฉํ๋ก๊ทธ๋จ ๊ฐ์ด๋๋ฅผ ์ตํ๊ณ , ๋ฐฉ๊ธ ํ๋ ๊ฒ๊ณผ ๊ฐ์ด 15๋ถ ์์ ๊ฐ๋จํ์ง๋ง ๊ฐ๋ ฅํ ์ฑ์ ๋น๋ ํ ๊ฒ์ด๋ค.
์์ผ๋ก ๋์ด๊ฐ๊ฑฐ๋ ํ๋ ์์ํฌ์ ๋ํ ์์ธํ ์ ๋ณด๋ฅผ ์๊ณ ์ถ๋ค๋ฉด ๋ค์ ๊ฐ์ด๋๋ ์์ ๋ฅผ ์ฐธ๊ณ ํ๋ค:
- Components and Containers
- Intro to Applications
- The Layout System
- The Data Package
- What's New in Sencha Touch 2