1. ํ์ ์ฌ์ ์๊ฑด & ์์คํ ์๊ตฌ์ฌ์ (Prerequisites & System Requirements)
๐ป ์์คํ ์ค์น ๋ฐ ์คํ ์๊ตฌ์ฌ์ (System Requirements)
| ํญ๋ชฉ | ์ต์ ์ฌ์ (Minimum) | ๊ถ์ฅ ์ฌ์ (Recommended) | ์ฐธ๊ณ ๋ฐ ๋น๊ณ |
|---|---|---|---|
| ์ด์์ฒด์ (OS) | Windows 10/11 (64-bit), macOS 13+ Ventura, Linux (Ubuntu 22.04+) | macOS 15+ Sequoia (Apple Silicon) / Windows 11 | iOS ๋ค์ดํฐ๋ธ ์ฑ ๋น๋ ๋ฐ ์๋ฎฌ๋ ์ดํฐ๋ macOS ํ์ |
| CPU | 4 ์ฝ์ด ์ด์ (Intel Core i5 / AMD Ryzen 5 / Apple M1) | 8 ์ฝ์ด ์ด์ (Apple M2/M3/M4 ๋๋ Core i7/Ryzen 7) | Vite ๋ฒ๋ค๋ง, Stencil ์น ์ปดํฌ๋ํธ ์ปดํ์ผ ๋ฐ ์๋ฎฌ๋ ์ดํฐ ๊ตฌ๋ |
| ๋ฉ๋ชจ๋ฆฌ (RAM) | 8 GB RAM ์ด์ | 16 GB ~ 32 GB RAM ์ด์ | ๋ธ๋ผ์ฐ์ DevTools + Android Studio / Xcode ๋์ ์คํ |
| ๋์คํฌ (Storage) | 15 GB ์ด์์ ์ฌ์ ๋์คํฌ ๊ณต๊ฐ | 50 GB ~ 100 GB ์ด์์ ๊ณ ์ NVMe SSD | node_modules, Android SDK, Xcode ๋ฐ ๋น๋ ์บ์ ๋ณด๊ด |
| ๋คํธ์ํฌ / ๋ฐํ์ | Node.js v20.0.0+ LTS, npm 10+ | Node.js v22.x LTS, pnpm 9/10+, @ionic/cli v7.2+ | React 18/19, Vue 3.5+, Angular 18/19+ ๋ฐ Capacitor 7 ํธํ |
Ionic Framework 8์ ์น ํ์ค Web Components(Stencil ๊ธฐ๋ฐ Shadow DOM) ์์ ๊ตฌ์ถ๋ ์คํ์์ค ๋ชจ๋ฐ์ผ UI ํดํท์ ๋๋ค. ๋จ์ผ HTML/CSS/TypeScript ์ฝ๋๋ฒ ์ด์ค๋ง์ผ๋ก ์คํ ์ค์ธ ๋๋ฐ์ด์ค ํ๋ซํผ์ ์๋ ๊ฐ์งํ์ฌ **iOS์์๋ Apple Cupertino ๋์์ธ(๋ค์ดํฐ๋ธ ์ค์์ดํ ๋ค๋ก๊ฐ๊ธฐ, ๋ฐํฌ๋ช ๋ธ๋ฌ ํค๋)**์ผ๋ก, **Android์์๋ Google Material Design 3(๋ฆฌํ ํจ๊ณผ, ๋จธํฐ๋ฆฌ์ผ ํ์ดํฌ๊ทธ๋ํผ)**๋ก 100% ๋ค์ดํฐ๋ธ์ ๋์ผํ UX์ 60~120fps ํ๋์จ์ด ๊ฐ์ ์ ๋๋ฉ์ด์ ์ ์ ๊ณตํฉ๋๋ค.
๐ ๏ธ 1. Node.js ๋ฒ์ ํ์ธ ๋ฐ Ionic CLI ๊ธ๋ก๋ฒ ์ค์น
Ionic ํ๋ก์ ํธ ์ค์บํด๋ฉ, ๋ก์ปฌ ๊ฐ๋ฐ ์๋ฒ(ionic serve), ๊ทธ๋ฆฌ๊ณ Capacitor ๋ค์ดํฐ๋ธ ๋๊ธฐํ๋ฅผ ์ด๊ดํ๋ ๊ณต์ CLI๋ฅผ ์ค์นํฉ๋๋ค.
# 1. Node.js ๋ฒ์ ํ์ธ (v20 LTS ๋๋ v22 LTS ๊ถ์ฅ)
node -v
# ์ถ๋ ฅ ์: v22.11.0
# 2. Ionic CLI ์ต์ ๋ฒ์ ๊ธ๋ก๋ฒ ์ค์น
npm install -g @ionic/cli
# 3. ์ค์น๋ Ionic CLI ๋ฒ์ ๋ฐ ํ๊ฒฝ ์ง๋จ
ionic --version
# ์ถ๋ ฅ ์: 7.2.0
๐ฆ 2. ํ๋ ์์ํฌ๋ณ Ionic 8 ์ ๊ท ํ๋ก์ ํธ ์์ฑ (ionic start)
Ionic์ ํน์ ํ๋ก ํธ์๋์ ์ข ์๋์ง ์์ผ๋ฉฐ React, Vue 3, Angular ์ค ํ์ ์ฃผ๋ ฅ ์คํ์ ์ ํํด ์์ํ ์ ์์ต๋๋ค.
# [๋ฐฉ๋ฒ A] ๋ํํ ๋ง๋ฒ์ฌ๋ก ํ๋ก์ ํธ ์์ฑ
ionic start
# [๋ฐฉ๋ฒ B] ๋ช
๋ น์ด ํ ์ค๋ก ์ฆ์ ์์ฑ (ํ
ํ๋ฆฟ: blank | tabs | sidemenu)
# 1) Ionic React (Vite + TypeScript ๊ธฐ๋ณธ ๋ด์ฅ)
ionic start my-ionic-app tabs --type=react --capacitor
# 2) Ionic Vue 3 (Vite + Vue Router + TypeScript)
ionic start my-ionic-vue tabs --type=vue --capacitor
# 3) Ionic Angular (Standalone Components ๊ธฐ๋ณธ ์ง์)
ionic start my-ionic-ng tabs --type=angular --capacitor
# ์์ฑ๋ ํ๋ก์ ํธ ํด๋ ์ด๋ ๋ฐ ๋ธ๋ผ์ฐ์ ๊ฐ๋ฐ ์๋ฒ ๊ธฐ๋
cd my-ionic-app
ionic serve
์ฝ์ ์ถ๋ ฅ ์์ (ionic serve):
> vite
VITE v6.0.1 ready in 340 ms
โ Local: http://localhost:8100/
โ Network: http://192.168.0.15:8100/
2. ์ง๊ด์ ์ธ ๋ฉํ ๋ชจ๋ธ & ํต์ฌ ์ํคํ ์ฒ (Mental Model & Architecture)
Ionic Framework 8์ด ์ด๋ป๊ฒ ๋จ์ผ ์ฝ๋๋ก iOS, Android, PWA ์น์ ๋์์ ๊ตฌํํ๋์ง ๋ณด์ฌ์ฃผ๋ ํต์ฌ ์ํคํ ์ฒ ํ์ดํ๋ผ์ธ์ ๋๋ค:
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Application Codebase (๋จ์ผ ํ๋ก ํธ์๋ ์ฝ๋) โ
โ @ionic/react (JSX) โ @ionic/vue (SFC) โ @ionic/angular โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Ionic Framework 8 Core (@ionic/core Web Components) โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ Adaptive Styling Engine (๋ชจ๋) โ โ Mobile Gesture & Animation Engine โ โ
โ โ - mode="ios" (Cupertino ์คํ์ผ) โ โ - 60/120fps ํ์ด์ง ์ ํ ์ ๋๋ฉ์ด์
โ โ
โ โ - mode="md" (Material Design 3) โ โ - ์ค์์ดํ ๋ค๋ก๊ฐ๊ธฐ (Swipe-to-Go) โ โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ Shadow DOM & CSS Custom Properties (--ion-color-primary, --background) โ โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Capacitor 7 Runtime & Native Bridge โ
โ iOS (WKWebView / Swift) โ Android (Chromium / Kotlin) โ PWA (Web) โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ๏ธ Ionic 8 + Capacitor vs React Native vs Flutter ์ํคํ ์ฒ ๋น๊ต
| ๋น๊ต ํญ๋ชฉ | Ionic 8 + Capacitor 7 | React Native (Expo) | Flutter |
|---|---|---|---|
| ๋ ๋๋ง ๋ฐฉ์ | ์์คํ WebView ๋ด์ฅ ํ์ค DOM / CSS (Shadow DOM ์บก์ํ) | JS ์ค๋ ๋ โ JSI โ OEM ๋ค์ดํฐ๋ธ ์์ ฏ ๋งคํ | Skia / Impeller ์์ฒด ๊ทธ๋ํฝ ์์ง ์บ๋ฒ์ค ์ง์ ๋ ๋๋ง |
| ์คํ์ผ๋ง ๋ฐ UI | 100% ํ์ค CSS3, Flexbox/Grid, Tailwind CSS ๊ทธ๋๋ก ์ฌ์ฉ | ์ ํ๋ StyleSheet ๋ถ๋ถ ์งํฉ (์น CSS ์ง์ ์ฌ์ฉ ๋ถ๊ฐ) | Dart ์์ ฏ ํธ๋ฆฌ ์ค์ฒฉ ์ ์ธ ๋ฐฉ์ |
| ์น(PWA) ์ฝ๋ ๊ณต์ ์จ | 100% ๋์ผ ์ฝ๋๋ก ์น(SPA/PWA)๊ณผ ์ฑ ๋์ ๋ฐฐํฌ | react-native-web ๋ณํ ๊ณ์ธต ํ์ (ํธํ์ฑ ์ ์ฝ ์กด์ฌ) | Wasm/Canvas ์น ์ถ๋ ฅ ์ง์ํ๋ SEO ๋ฐ ์ด๊ธฐ ๋ฒ๋ค ๋ฌด๊ฑฐ์ |
| ํ๋ซํผ ์ ์ํ ํ ๋ง | OS ๊ฐ์งํ์ฌ iOS ๋์์ธ / Android ๋์์ธ ์๋ ๋ถ๊ธฐ | ๊ฐ๋ฐ์๊ฐ ์ง์ ํ๋ซํผ๋ณ ๋ถ๊ธฐ ์คํ์ผ๋ง ์์ฑ ํ์ | Material ๋๋ Cupertino ์์ ฏ์ ๋ณ๋๋ก ๊ตฌ๋ถํด ์์ฑ |
3. [์ด๋ณด์ 1๋จ๊ณ] ํฌ๋ก์๋: ๋ชจ๋ฐ์ผ ํ๋ฉด ๊ณจ๊ฒฉ(IonPage)๊ณผ ์๋ช
์ฃผ๊ธฐ
์ผ๋ฐ ์น ํ์ด์ง์ ๋ฌ๋ฆฌ ๋ชจ๋ฐ์ผ ์ฑ์ ์๋จ ๊ณ ์ ์ํ๋ฐ/๋ค๋น๊ฒ์ด์
๋ฐ(IonHeader), ๋
๋ฆฝ์ ์ธ ๊ฐ์ ์คํฌ๋กค ์์ญ(IonContent), ํ๋จ ๊ณ ์ ํญ/ํด๋ฐ(IonFooter) ๊ตฌ์กฐ๋ฅผ ๋ฐ๋์ ์ง์ผ์ผ ํ๋ฉด ์ ํ ์ ๋๋ฉ์ด์
๊ณผ ๋
ธ์น ์์ญ(Safe Area)์ด ์ ์ ์๋ํฉ๋๋ค.
๐ฑ ์์ ํ ์ฒซ ๋ฒ์งธ ๋ชจ๋ฐ์ผ ํ๋ฉด ์์ (Home.tsx - Ionic React)
import React, { useState } from 'react';
import {
IonPage,
IonHeader,
IonToolbar,
IonTitle,
IonContent,
IonFooter,
IonButton,
IonIcon,
IonCard,
IonCardHeader,
IonCardSubtitle,
IonCardTitle,
IonCardContent,
IonBadge,
useIonViewDidEnter,
useIonViewWillLeave,
} from '@ionic/react';
import { rocketOutline, notificationsOutline, refreshOutline } from 'ionicons/icons';
const Home: React.FC = () => {
const [visitCount, setVisitCount] = useState<number>(1);
// ๐ก Ionic ํ์ด์ง ์ ์ฉ ์๋ช
์ฃผ๊ธฐ ํ
(ํ๋ฉด ์ ํ ์ ๋๋ฉ์ด์
์ด ์์ ํ ๋๋ ์งํ ํธ์ถ)
// ๋ชจ๋ฐ์ผ ๋ค๋น๊ฒ์ด์
์คํ์์๋ ์ปดํฌ๋ํธ๊ฐ ์ธ๋ง์ดํธ๋์ง ์๊ณ ์บ์ฑ๋๋ฏ๋ก useEffect ๋์ ํ์ ์ฌ์ฉ!
useIonViewDidEnter(() => {
console.log('โ
Home ํ๋ฉด ์ง์
์๋ฃ (API ๋ฐ์ดํฐ ๊ฐฑ์ ์์ )');
});
useIonViewWillLeave(() => {
console.log('๐ ๋ค๋ฅธ ํ๋ฉด์ผ๋ก ์ด๋ ์์ (ํ์ด๋จธ/๊ตฌ๋
์ ๋ฆฌ ์์ )');
});
return (
<IonPage>
{/* 1. ์๋จ ๊ณ ์ ํค๋ ์์ญ (iOS ์คํฌ๋กค ์ ๋ฐํฌ๋ช
๋ธ๋ฌ ํจ๊ณผ ์ง์) */}
<IonHeader translucent={true}>
<IonToolbar color="primary">
<IonTitle>LuckyTech ๋ชจ๋ฐ์ผ</IonTitle>
<IonButton slot="end" fill="clear" color="light">
<IonIcon slot="icon-only" icon={notificationsOutline} />
<IonBadge color="danger" style={{ position: 'absolute', top: 4, right: 2 }}>
3
</IonBadge>
</IonButton>
</IonToolbar>
</IonHeader>
{/* 2. ๋ณธ๋ฌธ ์คํฌ๋กค ์์ญ (fullscreen=true ์ค์ ์ iOS ๋ฐํฌ๋ช
ํค๋ ์๋๋ก ์์ฐ์ค๋ฝ๊ฒ ์คํฌ๋กค) */}
<IonContent fullscreen={true} className="ion-padding">
{/* iOS Large Title (์คํฌ๋กค์ ๋ด๋ฆฌ๋ฉด ์๋จ ๊ธฐ๋ณธ ํ์ดํ๋ก ๋ถ๋๋ฝ๊ฒ ์ถ์๋จ) */}
<IonHeader collapse="condense">
<IonToolbar>
<IonTitle size="large">LuckyTech ๋ชจ๋ฐ์ผ</IonTitle>
</IonToolbar>
</IonHeader>
<IonCard mode="ios">
<IonCardHeader>
<IonCardSubtitle>IONIC FRAMEWORK 8</IonCardSubtitle>
<IonCardTitle>๋ค์ดํฐ๋ธ ์ ์ํ UI ์นด๋</IonCardTitle>
</IonCardHeader>
<IonCardContent>
ํ์ฌ ์นด์ดํธ: <strong>{visitCount}ํ</strong> ํด๋ฆญ๋์์ต๋๋ค. iOS์์๋ ์ฟ ํผํฐ๋
ธ ์คํ์ผ๋ก,
Android์์๋ Material 3 ์คํ์ผ๋ก ์๋ ๋ ๋๋ง๋ฉ๋๋ค.
</IonCardContent>
</IonCard>
<IonButton
expand="block"
size="large"
onClick={() => setVisitCount((prev) => prev + 1)}
>
<IonIcon slot="start" icon={rocketOutline} />
์นด์ดํธ ์ฆ๊ฐ์ํค๊ธฐ
</IonButton>
<IonButton
expand="block"
fill="outline"
color="medium"
className="ion-margin-top"
onClick={() => setVisitCount(0)}
>
<IonIcon slot="start" icon={refreshOutline} />
์ด๊ธฐํ
</IonButton>
</IonContent>
{/* 3. ํ๋จ ๊ณ ์ ํธํฐ ์์ญ */}
<IonFooter>
<IonToolbar>
<IonTitle size="small" className="ion-text-center">
v8.4.0 โข Powered by Ionic & Capacitor 7
</IonTitle>
</IonToolbar>
</IonFooter>
</IonPage>
);
};
export default Home;
๐ Ionic ํ์ด์ง ์๋ช ์ฃผ๊ธฐ ํ / ๋ฉ์๋ ๋น๊ตํ (React vs Vue vs Angular)
๋ชจ๋ฐ์ผ ์ฑ์ ๋ค๋ก๊ฐ๊ธฐ๋ฅผ ์ํด ์ด์ ํ๋ฉด์ DOM์ ๊ทธ๋๋ก ์ ์ง(Keep-Alive)ํฉ๋๋ค. ๋ฐ๋ผ์ ํ์ค useEffect๋ onMounted๋ ์ต์ด 1ํ๋ง ์คํ๋ฉ๋๋ค. ํ๋ฉด์ ๋ค์ ๋์์ฌ ๋๋ง๋ค ์คํํด์ผ ํ๋ ๋ก์ง์ ๋ฐ๋์ Ionic ์๋ช
์ฃผ๊ธฐ๋ฅผ ์ฌ์ฉํ์ธ์.
| ์คํ ์์ | Ionic React (Hooks) | Ionic Vue 3 (Composition) | Ionic Angular (Lifecycle) | ์ฃผ์ ์ค๋ฌด ์ฉ๋ |
|---|---|---|---|---|
| ํ๋ฉด ์ง์ ์ง์ (์ ๋๋ฉ์ด์ ์์ ์ ) | useIonViewWillEnter | onIonViewWillEnter | ionViewWillEnter() | ์ํ ์ด๊ธฐํ, ์ค์ผ๋ ํค UI ์ค๋น |
| ํ๋ฉด ์ง์ ์๋ฃ (์ ๋๋ฉ์ด์ ์ข ๋ฃ ํ) | useIonViewDidEnter | onIonViewDidEnter | ionViewDidEnter() | ๋ฌด๊ฑฐ์ด API ํธ์ถ, ์นด๋ฉ๋ผ/์ฐจํธ ์ด๊ธฐํ, ํฌ์ปค์ค |
| ํ๋ฉด ์ดํ ์ง์ (์ ๋๋ฉ์ด์ ์์ ์ ) | useIonViewWillLeave | onIonViewWillLeave | ionViewWillLeave() | ์ ๋ ฅ ํผ ์์ ์ ์ฅ, ํค๋ณด๋ ์จ๊น |
| ํ๋ฉด ์ดํ ์๋ฃ (์ ๋๋ฉ์ด์ ์ข ๋ฃ ํ) | useIonViewDidLeave | onIonViewDidLeave | ionViewDidLeave() | ์ธํฐ๋ฒ ํ์ด๋จธ ํด์ , ์น์์ผ/์ผ์ ๊ตฌ๋ ์ค์ง |
4. [2๋จ๊ณ] ํต์ฌ ๋ชจ๋ฐ์ผ UI ์ปดํฌ๋ํธ & ์ธํฐ๋์ ํจํด
4.1 ๋ฆฌ์คํธ(IonList), ์ค์์ดํ ์ก์
(IonItemSliding), ๋น๊ฒจ์ ์๋ก๊ณ ์นจ(IonRefresher)
๋ชจ๋ฐ์ผ ์ฑ์์ ๊ฐ์ฅ ๋น๋ฒํ๊ฒ ์ฐ์ด๋ ๋น๊ฒจ์ ์๋ก๊ณ ์นจ(Pull-to-Refresh), ์ค์๊ฐ ๊ฒ์๋ฐ(IonSearchbar), ์ข์ฐ๋ก ๋ฐ์ด์ ์ญ์ /๊ณ ์ (IonItemSliding), **๋ฌดํ ์คํฌ๋กค(IonInfiniteScroll)**์ ๊ฒฐํฉํ ํตํฉ ์์ ์
๋๋ค.
import React, { useState } from 'react';
import {
IonPage,
IonHeader,
IonToolbar,
IonTitle,
IonContent,
IonSearchbar,
IonRefresher,
IonRefresherContent,
IonList,
IonItemSliding,
IonItem,
IonLabel,
IonAvatar,
IonNote,
IonItemOptions,
IonItemOption,
IonIcon,
IonInfiniteScroll,
IonInfiniteScrollContent,
RefresherEventDetail,
IonInfiniteScrollCustomEvent,
} from '@ionic/react';
import { trashOutline, starOutline } from 'ionicons/icons';
interface Message {
id: number;
sender: string;
title: string;
time: string;
}
const MessageListPage: React.FC = () => {
const [searchText, setSearchText] = useState('');
const [messages, setMessages] = useState<Message[]>([
{ id: 1, sender: '๊น๊ฐ๋ฐ', title: 'Ionic 8 ๋ฐฐํฌ ์ผ์ ๊ณต์ ๋๋ฆฝ๋๋ค.', time: '์ค์ 10:24' },
{ id: 2, sender: '๋ฐ๋์์ธ', title: 'iOS ๋คํฌ๋ชจ๋ ์ปฌ๋ฌ ํ ํฐ ์์ ๋ณธ', time: '์ค์ 09:15' },
{ id: 3, sender: '์ด๋ฐฑ์๋', title: 'ํธ์ ์๋ฆผ FCM ํ ํฐ ์ฐ๋ ์๋ฃ', time: '์ด์ ' },
]);
// 1. ๋น๊ฒจ์ ์๋ก๊ณ ์นจ (Pull to Refresh) ํธ๋ค๋ฌ
const handleRefresh = (event: CustomEvent<RefresherEventDetail>) => {
setTimeout(() => {
setMessages((prev) => [
{ id: Date.now(), sender: '์์คํ
์๋ฆผ', title: '์๋ก์ด ๋ฉ์์ง๊ฐ ๋์ฐฉํ์ต๋๋ค!', time: '๋ฐฉ๊ธ ์ ' },
...prev,
]);
// ์๋ก๊ณ ์นจ ์คํผ๋ ์ข
๋ฃ (ํ์ ํธ์ถ!)
event.detail.complete();
}, 800);
};
// 2. ํ๋จ ๋๋ฌ ์ ๋ฌดํ ์คํฌ๋กค (Infinite Scroll) ํธ๋ค๋ฌ
const handleInfinite = (ev: IonInfiniteScrollCustomEvent<void>) => {
setTimeout(() => {
const nextId = messages.length + 1;
setMessages((prev) => [
...prev,
{ id: nextId, sender: `์ฌ์ฉ์ ${nextId}`, title: `์ด์ ๋ณด๊ด ๋ฉ์์ง #${nextId}`, time: '์ง๋์ฃผ' },
]);
// ๋ก๋ฉ ์๋ฃ ์ ํธ ์ ๋ฌ (ํ์ ํธ์ถ!)
ev.target.complete();
}, 600);
};
// 3. ํญ๋ชฉ ์ญ์
const deleteItem = (id: number) => {
setMessages((prev) => prev.filter((m) => m.id !== id));
};
const filteredMessages = messages.filter(
(m) => m.sender.includes(searchText) || m.title.includes(searchText)
);
return (
<IonPage>
<IonHeader>
<IonToolbar>
<IonTitle>๋ฐ์ ํธ์งํจ</IonTitle>
</IonToolbar>
<IonToolbar>
{/* debounce={300}: ํ์ดํ ๋ฉ์ถ ํ 300ms ๋ค์ ์ด๋ฒคํธ ๋ฐ์ */}
<IonSearchbar
value={searchText}
debounce={300}
placeholder="๋ณด๋ธ ์ฌ๋ ๋๋ ์ ๋ชฉ ๊ฒ์..."
onIonInput={(e) => setSearchText(e.detail.value ?? '')}
/>
</IonToolbar>
</IonHeader>
<IonContent>
{/* ๋น๊ฒจ์ ์๋ก๊ณ ์นจ ์์ญ (IonContent ์ง์ ์ต์๋จ์ ๋ฐฐ์น) */}
<IonRefresher slot="fixed" onIonRefresh={handleRefresh}>
<IonRefresherContent pullingText="๋น๊ฒจ์ ์๋ก๊ณ ์นจ" refreshingSpinner="circles" />
</IonRefresher>
{/* inset={true}: iOS ์ค์ ์ฑ์ฒ๋ผ ๋ฅ๊ทผ ๋ชจ์๋ฆฌ ๊ทธ๋ฃนํ ๋ฆฌ์คํธ ๋ ๋๋ง */}
<IonList inset={true}>
{filteredMessages.map((msg) => (
<IonItemSliding key={msg.id}>
<IonItem button={true} detail={true}>
<IonAvatar slot="start">
<img src={`https://api.dicebear.com/7.x/initials/svg?seed=${msg.sender}`} alt={msg.sender} />
</IonAvatar>
<IonLabel>
<h2>{msg.sender}</h2>
<p>{msg.title}</p>
</IonLabel>
<IonNote slot="end">{msg.time}</IonNote>
</IonItem>
{/* ์ผ์ชฝ์ผ๋ก ๋ฐ์์ ๋ ๋ํ๋๋ ์ก์
๋ฒํผ๋ค */}
<IonItemOptions side="end">
<IonItemOption color="warning">
<IonIcon slot="icon-only" icon={starOutline} />
</IonItemOption>
<IonItemOption color="danger" expandable={true} onClick={() => deleteItem(msg.id)}>
<IonIcon slot="icon-only" icon={trashOutline} />
</IonItemOption>
</IonItemOptions>
</IonItemSliding>
))}
</IonList>
{/* ํ๋จ ๋ฌดํ ์คํฌ๋กค */}
<IonInfiniteScroll onIonInfinite={handleInfinite}>
<IonInfiniteScrollContent loadingText="์ด์ ๋ฉ์์ง ๋ถ๋ฌ์ค๋ ์ค..." loadingSpinner="bubbles" />
</IonInfiniteScroll>
</IonContent>
</IonPage>
);
};
export default MessageListPage;
4.2 ๋ชจ๋ ๋ชจ๋ฐ์ผ ํผ ์ ๋ ฅ ์ปดํฌ๋ํธ (Ionic 8 ์ต์ ๋ฌธ๋ฒ!)
[!IMPORTANT] Ionic 7/8์ ๊ฐ์ฅ ์ค์ํ ๋ณํ (Legacy
<ion-item><ion-label>๋ฌธ๋ฒ ํ๊ธฐ): ๊ณผ๊ฑฐ Ionic 6๊น์ง๋<IonItem>๋ด๋ถ์<IonLabel>๊ณผ<IonInput>์ ๋ฐ๋ก ๋ฃ์์ผ๋, Ionic 7 ๋ฐ 8๋ถํฐ๋IonInput,IonTextarea,IonSelect,IonToggle์ปดํฌ๋ํธ ์์ฒด์label,labelPlacement,fill,helperText,errorText์์ฑ์ ์ง์ ์ ์ธํ๋ ๊ฐ๊ฒฐํ๊ณ ์ ๊ทผ์ฑ(a11y) ๋์ ํ์ค ๋ฌธ๋ฒ์ ์ฌ์ฉํฉ๋๋ค.
import React, { useState } from 'react';
import {
IonList,
IonItem,
IonInput,
IonSelect,
IonSelectOption,
IonToggle,
IonDatetimeButton,
IonModal,
IonDatetime,
} from '@ionic/react';
export const ModernFormExample: React.FC = () => {
const [email, setEmail] = useState('');
const [isInvalid, setIsInvalid] = useState(false);
const validateEmail = (val: string) => {
setEmail(val);
setIsInvalid(val.length > 0 && !val.includes('@'));
};
return (
<IonList inset={true}>
{/* 1. ์ต์ IonInput: label, labelPlacement, helperText, errorText, clearInput ๋ด์ฅ */}
<IonItem>
<IonInput
label="์ด๋ฉ์ผ ์ฃผ์"
labelPlacement="floating"
type="email"
placeholder="user@luckytech.dev"
value={email}
clearInput={true}
counter={true}
maxlength={50}
helperText="๋ก๊ทธ์ธ ๋ฐ ์๋ฆผ ์์ ์ ์ฌ์ฉ๋ฉ๋๋ค."
errorText="์ฌ๋ฐ๋ฅธ ์ด๋ฉ์ผ ํ์์ ์
๋ ฅํด์ฃผ์ธ์."
className={`${isInvalid ? 'ion-invalid' : 'ion-valid'} ion-touched`}
onIonInput={(e) => validateEmail(e.detail.value ?? '')}
/>
</IonItem>
{/* 2. ์ต์ IonSelect: interface="action-sheet" | "popover" | "alert" */}
<IonItem>
<IonSelect
label="์ง๋ฌด ์ ํ"
labelPlacement="stacked"
placeholder="์ง๋ฌด๋ฅผ ์ ํํ์ธ์"
interface="action-sheet"
cancelText="์ทจ์"
>
<IonSelectOption value="frontend">ํ๋ก ํธ์๋ ์์ง๋์ด</IonSelectOption>
<IonSelectOption value="backend">๋ฐฑ์๋ ์์ง๋์ด</IonSelectOption>
<IonSelectOption value="mobile">๋ชจ๋ฐ์ผ ํฌ๋ก์คํ๋ซํผ ๊ฐ๋ฐ์</IonSelectOption>
</IonSelect>
</IonItem>
{/* 3. ์ต์ IonToggle: ์์ ํ
์คํธ๊ฐ ์๋์ผ๋ก ๋ผ๋ฒจ๋ก ๋์ */}
<IonItem>
<IonToggle justify="space-between" checked={true} enableOnOffLabels={true}>
์ผ๊ฐ ํธ์ ์๋ฆผ ํ์ฉ
</IonToggle>
</IonItem>
{/* 4. ๋ชจ๋ฐ์ผ ๋ค์ดํฐ๋ธ ์คํ์ผ ํ /๋ฌ๋ ฅ ํผ์ปค (IonDatetimeButton + IonModal) */}
<IonItem>
<IonInput label="์์ฝ ์ผ์" readonly={true} />
<IonDatetimeButton slot="end" datetime="reservation-datetime" />
<IonModal keepContentsMounted={true}>
<IonDatetime id="reservation-datetime" presentation="date-time" preferWheel={true} />
</IonModal>
</IonItem>
</IonList>
);
};
4.3 ์ค๋ฒ๋ ์ด & ๋ฐํ
์ํธ ๋ชจ๋ฌ (IonModal Sheet & useIonToast / useIonActionSheet)
Ionic์ ๋ช
๋ นํ(Imperative) ์ค๋ฒ๋ ์ด ํ
(useIonToast, useIonAlert, useIonActionSheet, useIonLoading)๊ณผ ์ ์ธํ ๋ฐํ
์ํธ(breakpoints ์์ฑ)๋ฅผ ๋ชจ๋ ์ง์ํฉ๋๋ค.
import React, { useRef } from 'react';
import {
IonButton,
IonModal,
IonHeader,
IonToolbar,
IonTitle,
IonContent,
useIonToast,
useIonActionSheet,
useIonAlert,
} from '@ionic/react';
export const OverlayShowcase: React.FC = () => {
const modalRef = useRef<HTMLIonModalElement>(null);
const [presentToast] = useIonToast();
const [presentActionSheet] = useIonActionSheet();
const [presentAlert] = useIonAlert();
// 1. ํ ์คํธ ์๋ฆผ ๋์ฐ๊ธฐ
const showSuccessToast = () => {
presentToast({
message: '์ค์ ์ด ์์ ํ๊ฒ ์ ์ฅ๋์์ต๋๋ค.',
duration: 2000,
position: 'bottom', // 'top' | 'middle' | 'bottom'
color: 'success',
buttons: [{ text: 'ํ์ธ', role: 'cancel' }],
});
};
// 2. iOS/Android ๋ค์ดํฐ๋ธ ์ก์
์ํธ ๋์ฐ๊ธฐ
const showShareSheet = () => {
presentActionSheet({
header: '์ฝํ
์ธ ์์
์ ํ',
buttons: [
{ text: '๋งํฌ ๊ณต์ ํ๊ธฐ', data: { action: 'share' } },
{ text: '์๊ตฌ ์ญ์ ', role: 'destructive', data: { action: 'delete' } },
{ text: '๋ซ๊ธฐ', role: 'cancel' },
],
onDidDismiss: ({ detail }) => {
if (detail.data?.action === 'delete') {
presentAlert({
header: '์ญ์ ํ์ธ',
message: '์ ๋ง๋ก ์ญ์ ํ์๊ฒ ์ต๋๊น?',
buttons: ['์ทจ์', { text: '์ญ์ ', role: 'destructive' }],
});
}
},
});
};
return (
<div className="ion-padding">
<IonButton expand="block" onClick={showSuccessToast}>
ํ ์คํธ(Toast) ๋์ฐ๊ธฐ
</IonButton>
<IonButton expand="block" color="secondary" className="ion-margin-top" onClick={showShareSheet}>
์ก์
์ํธ(ActionSheet) ์ด๊ธฐ
</IonButton>
{/* id="open-sheet-modal" ๋ฒํผ ํด๋ฆญ ์ ์๋ IonModal์ trigger๊ฐ ์๋ ๊ฐ์งํ์ฌ ์คํ */}
<IonButton id="open-sheet-modal" expand="block" color="tertiary" className="ion-margin-top">
๋ฐํ
์ํธ ๋ชจ๋ฌ(Bottom Sheet) ์ด๊ธฐ
</IonButton>
{/* 3. ๋๋๊ทธํ์ฌ ๋์ด๋ฅผ ์กฐ์ ํ ์ ์๋ ๋ชจ๋ฐ์ผ ๋ฐํ
์ํธ ๋ชจ๋ฌ */}
<IonModal
ref={modalRef}
trigger="open-sheet-modal"
initialBreakpoint={0.5}
breakpoints={[0, 0.25, 0.5, 0.85, 1]}
handleBehavior="cycle"
>
<IonHeader>
<IonToolbar>
<IonTitle>๋๋๊ทธ ๋ฐํ
์ํธ</IonTitle>
</IonToolbar>
</IonHeader>
<IonContent className="ion-padding">
<p>์๋จ ํธ๋ค์ ์์๋๋ก ๋๋๊ทธํ์ฌ 25%, 50%, 85%, 100% ๋์ด๋ก ์กฐ์ ํ ์ ์์ต๋๋ค.</p>
<IonButton expand="block" onClick={() => modalRef.current?.dismiss()}>
์ํธ ๋ซ๊ธฐ
</IonButton>
</IonContent>
</IonModal>
</div>
);
};
5. [3๋จ๊ณ] ์ค๋ฌด ์์ฉ ํจํด: ํญ ๋ผ์ฐํ , ํ ๋ง ์ปค์คํฐ๋ง์ด์ง & Capacitor ์ฐ๋
5.1 ํ๋จ ํญ ๋ฐ(IonTabs) ๋ฐ ๋
๋ฆฝ ๋ค๋น๊ฒ์ด์
์คํ ๊ตฌ์ฑ (App.tsx)
๋ชจ๋ฐ์ผ ์ฑ์์ ๊ฐ ํ๋จ ํญ(ํ, ๊ฒ์, ํ๋กํ)์ ์์ ๋ง์ ๋
๋ฆฝ๋ ํ์คํ ๋ฆฌ ์คํ์ ์ ์งํด์ผ ํฉ๋๋ค.
import React from 'react';
import { Redirect, Route } from 'react-router-dom';
import {
IonApp,
IonIcon,
IonLabel,
IonRouterOutlet,
IonTabBar,
IonTabButton,
IonTabs,
setupIonicReact,
} from '@ionic/react';
import { IonReactRouter } from '@ionic/react-router';
import { homeOutline, mailOutline, personOutline } from 'ionicons/icons';
/* Ionic 8 ํ์ ์ฝ์ด ๋ฐ ์ ํธ๋ฆฌํฐ CSS ์ํฌํธ */
import '@ionic/react/css/core.css';
import '@ionic/react/css/normalize.css';
import '@ionic/react/css/structure.css';
import '@ionic/react/css/typography.css';
import '@ionic/react/css/padding.css';
import '@ionic/react/css/flex-utils.css';
import '@ionic/react/css/display.css';
/* Ionic 8 ๋คํฌ๋ชจ๋ ํ๋ ํธ (์์คํ
์ค์ ์๋ ์ฐ๋) */
import '@ionic/react/css/palettes/dark.system.css';
import Home from './pages/Home';
import MessageListPage from './pages/MessageListPage';
// Ionic ์ ์ญ ์ค์ ์ด๊ธฐํ (ํ์ ์ mode: 'ios' ๋๋ 'md'๋ก ์ ์ฒด ํ๋ซํผ ๋์์ธ ๊ณ ์ ๊ฐ๋ฅ)
setupIonicReact({
rippleEffect: true,
swipeBackEnabled: true, // iOS ํ๋ฉด ์ผ์ชฝ ๋์์ ์ค์์ดํํ์ฌ ๋ค๋ก๊ฐ๊ธฐ ํ์ฑํ
});
const App: React.FC = () => (
<IonApp>
<IonReactRouter>
<IonTabs>
{/* ๊ฐ ํญ์ ํ๋ฉด์ด ๋ ๋๋ง๋๋ ๋ผ์ฐํฐ ์์ธ๋ (ํ์ด์ง ์ ํ ์ ๋๋ฉ์ด์
์ฒ๋ฆฌ) */}
<IonRouterOutlet>
<Route exact path="/home" component={Home} />
<Route exact path="/messages" component={MessageListPage} />
<Route exact path="/">
<Redirect to="/home" />
</Route>
</IonRouterOutlet>
{/* ํ๋จ ๊ณ ์ ํญ ๋ฐ */}
<IonTabBar slot="bottom">
<IonTabButton tab="home" href="/home">
<IonIcon aria-hidden="true" icon={homeOutline} />
<IonLabel>ํ</IonLabel>
</IonTabButton>
<IonTabButton tab="messages" href="/messages">
<IonIcon aria-hidden="true" icon={mailOutline} />
<IonLabel>๋ฉ์์ง</IonLabel>
</IonTabButton>
<IonTabButton tab="profile" href="/profile">
<IonIcon aria-hidden="true" icon={personOutline} />
<IonLabel>๋ด ์ ๋ณด</IonLabel>
</IonTabButton>
</IonTabBar>
</IonTabs>
</IonReactRouter>
</IonApp>
);
export default App;
5.2 Ionic 8 ํ
๋ง ์์คํ
, Shadow Parts(::part) & ๋คํฌ๋ชจ๋ ํ๋ ํธ
Ionic 8์ CSS ๋ณ์(Custom Properties)์ ์น ํ์ค ::part() ์ ํ์๋ฅผ ํตํด Shadow DOM ๋ด๋ถ ์คํ์ผ์ ๊น๋ํ๊ฒ ์ ์ดํ๋ฉฐ, ์๋ก์ด ๋คํฌ๋ชจ๋ ํ๋ ํธ CSS๋ฅผ ๊ธฐ๋ณธ ์ ๊ณตํฉ๋๋ค.
/* src/theme/variables.css */
/* 1. ๋ธ๋๋ ์ปฌ๋ฌ ํ ํฐ ์ปค์คํฐ๋ง์ด์ง */
:root {
--ion-color-primary: #10b981;
--ion-color-primary-rgb: 16, 185, 129;
--ion-color-primary-contrast: #ffffff;
--ion-color-primary-contrast-rgb: 255, 255, 255;
--ion-color-primary-shade: #0ea372;
--ion-color-primary-tint: #28c08e;
/* ์ ์ญ ํฐํธ ํจ๋ฐ๋ฆฌ ์ง์ */
--ion-font-family: 'Pretendard', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
}
/* 2. Shadow DOM ์ปดํฌ๋ํธ ์ปค์คํฐ๋ง์ด์ง: CSS ๋ณ์ & ::part() ํ์ฉ */
ion-button.custom-gradient-btn {
--background: linear-gradient(135deg, #10b981 0%, #059669 100%);
--border-radius: 12px;
--box-shadow: 0 4px 14px rgba(16, 185, 129, 0.35);
}
/* Shadow DOM ๋ด๋ถ์ ์ค์ native button ์์์ ์ง์ ์ ๊ทผํ ๋ ::part(native) ์ฌ์ฉ */
ion-button.custom-gradient-btn::part(native) {
font-weight: 700;
letter-spacing: -0.02em;
}
๐ Ionic 8์ 3๊ฐ์ง ๋คํฌ๋ชจ๋ ํ์ฑํ ์ ๋ต
Ionic 8๋ถํฐ๋ ๋ณต์กํ ๋ฏธ๋์ด ์ฟผ๋ฆฌ๋ฅผ ์ง์ ์์ฑํ ํ์ ์์ด, ๋ด์ฅ ํ๋ ํธ CSS ํ์ผ 1์ค๋ง ์ํฌํธํ๋ฉด ๋ฉ๋๋ค:
// ์ ๋ต 1: OS ์์คํ
๋คํฌ๋ชจ๋ ์ค์ (prefers-color-scheme: dark)์ ์๋์ผ๋ก ๋ฐ๋ผ๊ฐ
import '@ionic/react/css/palettes/dark.system.css';
// ์ ๋ต 2: ์ฑ ๋ด ํ ๊ธ ์ค์์น๋ก ์๋ ์ ์ด (document.documentElement.classList.toggle('ion-palette-dark', isDark) ์ ์ด)
import '@ionic/react/css/palettes/dark.class.css';
// ์ ๋ต 3: ํญ์ ๋คํฌ๋ชจ๋๋ก ๊ณ ์ ์คํ
import '@ionic/react/css/palettes/dark.always.css';
5.3 ๋ฐ์ํ 12์ด ๊ทธ๋ฆฌ๋(IonGrid) ๋ฐ ๋ด์ฅ CSS ์ ํธ๋ฆฌํฐ ํด๋์ค
๋ณ๋์ CSS ํ์ผ ์์ฑ ์์ด ํ๊ทธ์ className์ ๋ถ์ฌํ์ฌ ์ฌ๋ฐฑ, ์ ๋ ฌ, ๋ฐ์ํ ๋
ธ์ถ์ ์ฆ์ ์ ์ดํ๋ ํต์ฌ ์ ํธ๋ฆฌํฐ์
๋๋ค:
| ์นดํ ๊ณ ๋ฆฌ | ํด๋์ค๋ช | ๋์ ์ค๋ช |
|---|---|---|
| ํจ๋ฉ (Padding) | ion-padding, ion-no-padding | ์ ์ฒด 16px ๊ธฐ๋ณธ ์ฌ๋ฐฑ ๋ถ์ฌ ๋๋ ํจ๋ฉ ์ ๊ฑฐ (-top, -bottom, -start, -end, -horizontal, -vertical ์กฐํฉ ๊ฐ๋ฅ) |
| ๋ง์ง (Margin) | ion-margin, ion-no-margin | ์ ์ฒด 16px ์ธ๋ถ ์ฌ๋ฐฑ ๋ถ์ฌ ๋๋ ๋ง์ง ์ ๊ฑฐ (ion-margin-top, ion-margin-bottom ๋ฑ) |
| ํ ์คํธ ์ ๋ ฌ | ion-text-center, ion-text-start, ion-text-end | ์ข์ฐ ๋ฐฉํฅ(LTR/RTL)์ ๋ง์ถ ํ
์คํธ ์ ๋ ฌ ๋ฐ ion-text-wrap(์ค๋ฐ๊ฟ ํ์ฉ), ion-text-nowrap(๋ง์ค์ํ) |
| Flexbox ์ ๋ ฌ | ion-justify-content-between, ion-align-items-center | Flex ์ปจํ ์ด๋ ์ฃผ์ถ ๋ฐ ๊ต์ฐจ์ถ ์ ๋ ฌ ์ ์ด |
| ๋ฐ์ํ ์จ๊น | ion-hide-sm-down, ion-hide-md-up | ํ๋ฉด ๋ธ๋ ์ดํฌํฌ์ธํธ(xs, sm, md, lg, xl) ๊ธฐ์ค ์์ ํ์/์จ๊น |
5.4 Capacitor 7 ์ฐ๋ ๋ฐ iOS / Android ๋ค์ดํฐ๋ธ ์ฑ ๋น๋ ๋ช ๋ น์ด
Ionic CLI๋ ๋ด๋ถ์ ์ผ๋ก Capacitor CLI์ ์๋ฒฝํ ํตํฉ๋์ด ์์ด, ์น ๋น๋๋ถํฐ ๋ค์ดํฐ๋ธ IDE ์คํ ๋ฐ ๋ฌด์ ๋ผ์ด๋ธ ๋ฆฌ๋ก๋๊น์ง ๋จ์ผ ๋ช ๋ น์ผ๋ก ์ฒ๋ฆฌํฉ๋๋ค.
# 1. ํ์ฌ ์น ํ๋ก์ ํธ์ Capacitor ํตํฉ ํ์ฑํ (์ด๊ธฐ ์์ฑ ์ ๋๋ฝํ ๊ฒฝ์ฐ)
ionic integrations enable capacitor
# 2. iOS ๋ฐ Android ๋ค์ดํฐ๋ธ ํ๋ก์ ํธ ํด๋ ์์ฑ
ionic cap add android
ionic cap add ios
# 3. ํ๋ก ํธ์๋ ํ๋ก๋์
๋น๋(dist/) ํ ๋ค์ดํฐ๋ธ ํ๋ก์ ํธ(android/, ios/)์ ๋๊ธฐํ
ionic cap build android
ionic cap build ios
# 4. ์ฝ๋ ์์ ํ ์น ๋น๋ + ๋ค์ดํฐ๋ธ ํ๋ฌ๊ทธ์ธ ๋๊ธฐํ ์ผ๊ด ์คํ
ionic build && npx cap sync
# 5. ๐ฅ ์ค๊ธฐ๊ธฐ/์๋ฎฌ๋ ์ดํฐ ๋ฌด์ ์ค์๊ฐ Live Reload ์คํ (์ฝ๋ ์ ์ฅ ์ ์ฑ ํ๋ฉด 0.5์ด ์ฆ์ ๊ฐฑ์ !)
ionic cap run android -l --external
ionic cap run ios -l --external
6. ์ค๋ฌด ์ฃผ์์ฌํญ & ํ๋ก๋์ ์ฒดํฌ๋ฆฌ์คํธ (Best Practices & Troubleshooting)
โ ๏ธ ์ด๋ณด์๊ฐ ํํ ๊ฒช๋ ์ค์ & ํธ๋ฌ๋ธ์ํ
- ํ๋ฉด์ด ํ์๊ฒ ๋์ค๊ฑฐ๋ ์คํฌ๋กค์ด ์ ํ ์๋ํ์ง ์๋ ํ์:
- ์์ธ: ๋ผ์ฐํธ ๋์ ์ปดํฌ๋ํธ๋ฅผ
<IonPage>๋ก ๊ฐ์ธ์ง ์์๊ฑฐ๋, ๋ณธ๋ฌธ์<IonContent>๋์ ์ผ๋ฐ<div>๋ก ์์ฑํ ๊ฒฝ์ฐ์ ๋๋ค. Ionic์ ๋ ์ด์์ ์์ง์IonPageโIonHeader+IonContent+IonFooter๊ณ์ธต์ ๊ธฐ์ค์ผ๋ก ์ ๋ ์์น์ ์คํฌ๋กค ์ปจํ ์ด๋ ๋์ด๋ฅผ ๊ณ์ฐํฉ๋๋ค. - ํด๊ฒฐ: ๋ชจ๋ ๋ผ์ฐํธ ํ์ด์ง์ ์ต์์ ๋ฃจํธ ํ๊ทธ๋ ๋ฐ๋์
<IonPage>์ฌ์ผ ํ๋ฉฐ, ์คํฌ๋กค ์์ญ์<IonContent>๋ก ๊ฐ์ธ์ผ ํฉ๋๋ค.
- ์์ธ: ๋ผ์ฐํธ ๋์ ์ปดํฌ๋ํธ๋ฅผ
- ๋ค๋ก๊ฐ๊ธฐ ํ ์ฌ์ง์
์ ๋ฐ์ดํฐ๊ฐ ๊ฐฑ์ ๋์ง ์๋ ๋ฌธ์ :
- ์์ธ: ๋ชจ๋ฐ์ผ ๋ค๋น๊ฒ์ด์
์คํ ํน์ฑ์ ์ด์ ํ์ด์ง๊ฐ DOM์ ์บ์๋์ด ๋จ์ ์์ผ๋ฏ๋ก React์
useEffect(..., [])๋ Vue์onMounted()๋ ์ฌ์คํ๋์ง ์์ต๋๋ค. - ํด๊ฒฐ: ํ๋ฉด ์ง์
์๋ง๋ค ์ต์ ๋ฐ์ดํฐ๋ฅผ ๋ถ๋ฌ์์ผ ํ๋ค๋ฉด ๋ฐ๋์
useIonViewWillEnter๋๋useIonViewDidEnterํ ์ ์ฌ์ฉํ์ธ์.
- ์์ธ: ๋ชจ๋ฐ์ผ ๋ค๋น๊ฒ์ด์
์คํ ํน์ฑ์ ์ด์ ํ์ด์ง๊ฐ DOM์ ์บ์๋์ด ๋จ์ ์์ผ๋ฏ๋ก React์
- Shadow DOM ๋ด๋ถ ์์์ ์ผ๋ฐ CSS ์ ํ์๊ฐ ๋จนํ์ง ์๋ ๋ฌธ์ :
- ์์ธ:
ion-button,ion-input,ion-card๋ฑ์ Web Components์ Shadow DOM์ผ๋ก ์คํ์ผ์ด ๊ฒฉ๋ฆฌ๋์ด ์์ด.my-btn button { padding: 20px; }์ ๊ฐ์ ํ์ ํ๊ทธ ์ ํ์๋ก ์ ๊ทผํ ์ ์์ต๋๋ค. - ํด๊ฒฐ: ๊ณต์ ๋ฌธ์์ ์ ์๋ CSS Custom Properties(
--background,--padding-start,--border-radius)๋ฅผ ์ฐ์ ์ฌ์ฉํ๊ณ , ๋ด๋ถ ์์ ์ง์ ์ ์ด๊ฐ ํ์ํ ๋๋::part(native)์ ํ์๋ฅผ ์ฌ์ฉํ์ธ์.
- ์์ธ:
- ๋ชจ๋ฐ์ผ ํค๋ณด๋๊ฐ ์ฌ๋ผ์ฌ ๋ ํ๋จ ์
๋ ฅ์ฐฝ์ด ๊ฐ๋ ค์ง๋ ํ์:
- ํด๊ฒฐ:
<IonInput>์ ๋ฐ๋์<IonContent>๋ด๋ถ์ ๋ฐฐ์นํ๋ฉด Ionic์ด ํค๋ณด๋ ๋์ด๋ฅผ ๊ฐ์งํด ์๋์ผ๋ก ํด๋น ์ ๋ ฅ์ฐฝ ์์น๋ก ํ๋ฉด์ ์คํฌ๋กคํด ์ค๋๋ค. ๋ํ Capacitor์@capacitor/keyboardํ๋ฌ๊ทธ์ธ ์ค์ ์ ํตํด ๋ฆฌ์ฌ์ด์ฆ ๋ชจ๋๋ฅผ ์ ๋ฐ ์ ์ดํ ์ ์์ต๋๋ค.
- ํด๊ฒฐ:
โ ํ๋ก๋์ ์คํ ์ด ๋ฐฐํฌ ์ ํ์ ์ฒดํฌ๋ฆฌ์คํธ
- ๋
ธ์น ๋ฐ ๋ค์ด๋ด๋ฏน ์์ผ๋๋ Safe Area ํ์ธ:
index.html์<meta name="viewport">ํ๊ทธ์viewport-fit=cover๊ฐ ํฌํจ๋์ด ์๋์ง ํ์ธํ๋๊ฐ? - ํ๋์จ์ด ๋ค๋ก๊ฐ๊ธฐ ๋ฒํผ ์ฒ๋ฆฌ (Android): Android ๋ฌผ๋ฆฌ ๋ค๋ก๊ฐ๊ธฐ ๋ฒํผ ํด๋ฆญ ์ ๋ชจ๋ฌ์ด ๋จผ์ ๋ซํ๊ฑฐ๋ ํ ํ๋ฉด์์ ์ข
๋ฃ ํ์ธ ํ ์คํธ๊ฐ ๋จ๋๋ก
ionBackButton์ด๋ฒคํธ ๋ฆฌ์ค๋๋ฅผ ๊ตฌ์ฑํ๋๊ฐ? - ํญ ์ ํ ์ ๋ถํ์ํ ๋ฆฌ๋ ๋๋ง ๋ฐ ๋ฉ๋ชจ๋ฆฌ ๋์ ์ ๊ฒ:
useIonViewDidLeave์์ ์นด๋ฉ๋ผ ์คํธ๋ฆผ, ์์น ์ถ์ (Geolocation.watchPosition), ํ์ด๋จธ๊ฐ ํ์คํ ํด์ ๋๋๊ฐ? - ์์ด์ฝ ํธ๋ฆฌ์์ดํน ํ์ธ:
ionicons/icons์์ ์ฌ์ฉํ๋ ์์ด์ฝ๋ง Named Import(import { homeOutline } from 'ionicons/icons')ํ์ฌ ๋ฒ๋ค ํฌ๊ธฐ๋ฅผ ์ต์ ํํ๋๊ฐ? - ์คํ๋ผ์ธ ๋ฐ ๋คํธ์ํฌ ์ํ ๋์: ๋ชจ๋ฐ์ผ ์์ ์ง์ญ ์ง์
์
@capacitor/network์useIonToast๋ฅผ ์ฐ๋ํ์ฌ ์คํ๋ผ์ธ ์๋ด ๋ฐฐ๋๋ฅผ ํ์ํ๋๊ฐ?
์๊ฒฌ ๋ฐ ์ง๋ฌธ
0์์ง ๋ฑ๋ก๋ ์๊ฒฌ์ด ์์ต๋๋ค. ์ฒซ ๋ฒ์งธ ๋๊ธ์ ๋จ๊ฒจ๋ณด์ธ์!
๋๊ธ ์์
๋๊ธ ์ญ์