# Flutter 런타임 템플릿

## 생성 방식

Node 워커는 매번 전체 Flutter 코드를 임의 생성하지 않습니다.

1. `flutter create`로 Android/iOS 표준 프로젝트 생성
2. `flutter_template/overlay` 덮어쓰기
3. `pubspec.yaml.tpl` 자리표시자 치환
4. `assets/config/app.json`에 앱 버전 스냅샷 기록
5. Android Manifest와 iOS Info.plist 권한 패치
6. `flutter pub get`, `flutter analyze`, `flutter test`
7. AAB 또는 IPA 생성

## 런타임 파일

- `lib/main.dart`: 설정 로딩, 테마 생성, 시작 오류 화면
- `lib/models/app_definition.dart`: JSON 모델과 안전한 기본값
- `lib/services/config_service.dart`: 앱 설정 에셋 로딩
- `lib/services/permission_service.dart`: 카메라·위치·알림 권한
- `lib/screens/runtime_shell.dart`: 하단 메뉴와 모듈 라우팅
- `lib/screens/native_home_screen.dart`: 네이티브 홈
- `lib/screens/webview_screen.dart`: 웹뷰와 외부 스킴 처리
- `lib/screens/static_screen.dart`: 정적 안내 화면
- `lib/screens/api_list_screen.dart`: JSON 목록 API 기본 화면

## 앱 설정 예

```json
{
  "schemaVersion": "1.0.0",
  "app": {
    "name": "샘플 앱",
    "packageName": "com.example.sample",
    "bundleId": "com.example.sample",
    "version": "1.0.0",
    "androidVersionCode": 1,
    "iosBuildNumber": 1,
    "defaultLanguage": "ko"
  },
  "theme": {
    "primaryColor": "#335CFF",
    "secondaryColor": "#6B7CFF",
    "backgroundColor": "#F5F7FB",
    "surfaceColor": "#FFFFFF",
    "textColor": "#19213D",
    "darkMode": false,
    "borderRadius": 14
  },
  "navigation": {
    "type": "bottom",
    "items": [
      {"id":"home","title":"홈","icon":"home","module":"native_home"},
      {"id":"web","title":"서비스","icon":"language","module":"webview","url":"https://example.com"},
      {"id":"list","title":"목록","icon":"list","module":"api_list","url":"https://api.example.com/items"}
    ]
  },
  "features": {
    "camera": false,
    "location": false,
    "push": false,
    "fileUpload": true,
    "deepLink": true,
    "externalBrowser": true
  },
  "permissions": {
    "cameraDescription": "사진 촬영을 위해 카메라를 사용합니다.",
    "locationDescription": "주변 정보를 제공하기 위해 위치를 사용합니다.",
    "photoDescription": "사진을 첨부하기 위해 사진 보관함을 사용합니다."
  }
}
```

## 지원 모듈

- `native_home`: 앱명과 활성 네이티브 기능을 보여주는 기본 화면
- `webview`: HTTP/HTTPS 웹뷰와 외부 앱 스킴 처리
- `static`: 설정 JSON의 안내문 표시
- `api_list`: JSON 배열 또는 `{ "data": [] }` 응답 목록

## 패키지

템플릿은 `webview_flutter`, `http`, `url_launcher`, `permission_handler`를 사용합니다. 패키지 버전을 올릴 때는 Android 최소 SDK, iOS 배포 버전, Dart SDK 조건과 실제 빌드를 함께 확인해야 합니다.

## 권한

Node `templateService.js`가 활성 기능에 따라 Android Manifest와 iOS Info.plist를 패치합니다. 런타임에서는 사용자가 기능을 실행하는 시점에 권한을 요청하도록 구성했습니다.

## 템플릿 버전

- 현재 버전: `0.1.0`
- 버전 파일: `flutter_template/VERSION`
- PHP 상수: `AppDefinitionService::TEMPLATE_VERSION`

두 값을 함께 변경하고 과거 앱 설정의 마이그레이션 테스트를 수행하십시오.
