Compare commits
3
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7dcb40df78 | ||
|
|
07290597a0 | ||
|
|
7451599727 |
No files matched your search
@@ -147,6 +147,15 @@
|
||||
| [x] | 좋아요·댓글이 전국 공통 — 포스트가 (날짜, 자리) 하나로 전국에 하나뿐이라, 구마다 내용이 다른 카드(오늘 날씨·각 1~3위·노을·미세먼지·행사)도 댓글·좋아요를 전국이 같이 씀. 예: 강남의 "1위 산책각"과 부산의 "1위 빨래각"이 같은 댓글창. 안: 지역 데이터 카드만 시도(17) 단위로 나누고 계절·상식·명언은 전국 공통 유지 | 사용자 질문 (10/8) | `backend/postgres-init/init.sql` (`uq_post_feed`), `backend/services/feed_service.py` (`build_day`, `_gak`) |
|
||||
| [ ] | **[결정 필요]** 포스트 시도 단위가 17이 아니라 16 — `region.code` 앞 2자리에서 광주·전남이 둘 다 `12`(전남광주통합특별시)라 같은 댓글창을 씀. 그대로 둘지, 이름 앞머리로 광주·전남을 나눌지 | 포스트 시도 나누기 (10/8) | `backend/services/feed_service.py` (`sido_of`), `backend/seed/region.csv` |
|
||||
| [ ] | 광주·전남 구는 행사가 안 잡힐 수 있음 — 구 코드 시도는 `12`인데 행사 수집·`event.sido_code`는 `29`(광주)·`46`(전남). 좌표 없는 행사는 `is_nearby`·`nearby_sidos`에서 빠짐 | 포스트 시도 나누기 중 발견 (10/8) | `backend/services/week_service.py:125,144`, `backend/services/external/culture_api.py:28` |
|
||||
| [ ] | **[결정 필요]** 앱인토스 입점 여부 — 검토안은 "웹 출시 후 보기 전용 토스판으로 시험, 첫 달 포인트·알림 20~30만 원, 5주차에 포인트 없는 주의 7일 재방문율 20%를 기준으로 계속/중단" (https://claude.ai/artifact/QgA7iq3CCesTRYcFyZck71) | 앱인토스 검토 | |
|
||||
| [ ] | **[결정 필요]** 토스판 광고 — 앱인토스 수익은 토스 광고·인앱결제뿐인데 웹은 '광고 없음'으로 정함. 안 붙이면 토스판은 비용만 드는 홍보 채널 | 앱인토스 검토 | |
|
||||
| [ ] | 앱인토스 사전 확인 — 시간대별 밤 배경이 '라이트 모드' 규칙에 걸리는지, 네이버 지도 링크가 '단순 정보 확인' 예외인지 채널톡 문의 | 앱인토스 검토 | `frontend/src/b/BLayout.tsx`, `frontend/src/b/ui.tsx` |
|
||||
| [ ] | **[결정 필요]** 각 34개 정리 — 계절 밖 각(10월 물놀이·냉면) 노출 막기(각별 '보여 줄 달'), 나쁜 일 예고 각(택시대란·배달폭주·김서림·화장붕괴)을 순위에서 빼고 '조심' 카드로, 날씨 관계 약한 재미 각(공부·넷플릭스·짬뽕·막걸리·뜨아·군밤·집콕) 축소 또는 '재미' 표시 (https://claude.ai/artifact/4WgpUjdNqdSNnMN4ASB4BB) | 토스판 전략 검토 | `backend/seed/index_definition.json`, `backend/services/index_service.py` |
|
||||
| [ ] | 글 재고 부족 — 25편(한 문장 8·시 3·상식 4·계절 9)이라 매일 보면 1~2주 안에 반복, 계절 글은 10월분뿐. 기획의 'AI 주 1회 생성'이 스케줄러에 없음. 8주치 재고 또는 생성·검토 파이프라인 | 토스판 전략 검토 | `backend/seed/article.json`, `backend/scheduler/jobs.py` |
|
||||
| [ ] | **[결정 필요]** 노을 알림 재검토 — 10/2에 제외했지만 토스 알림은 정보성만 허용돼 "오늘 노을 좋음"이 가장 맞는 알림. 토스판 핵심 후보 | 토스판 전략 검토 | |
|
||||
| [ ] | **[결정 필요]** 히어로 숫자 5개(기온·체감·불쾌지수·날씨 점수·1위 각 점수) — 불쾌지수 여름만, 날씨 점수 유지 여부 | 토스판 전략 검토 | `frontend/src/b/TodayPage.tsx` |
|
||||
| [x] | 토스판 방식 — WebView로 결정(10/12). 별도 프로젝트 없이 `frontend/`에 토스 빌드 모드 추가, RN은 독립 앱만 | 토스판 전략 검토 | `frontend/` |
|
||||
| [x] | 앱인토스 appName 정식 이름으로 교체 — 콘솔 앱 `nalssigak`으로 맞춤(10/13). 정식 앱 등록 후 두 곳을 같이 바꾸고 `npm run build:toss` 다시 실행 | 콘솔 테스트 앱으로 먼저 등록 | `frontend/apps-in-toss.config.ts`, `frontend/src/lib/platform.ts` |
|
||||
| [x] | 전체 날씨 점수 기준 강화 — 100점은 '1년에 하루' 수준으로만 → 각과 같은 계산에 기준만 좁힘(체감 21±0.5°·습도 45~55%·해 90%↑·바람 1m/s↓·초미세먼지 10↓, 사용자 결정 '기준만 좁히기'). 실제 연 몇 번 나오는지는 미확인 (`docs/점수_계산식.md` 3) | 10/8 회의 결정 | `backend/services/index_service.py:203` |
|
||||
| [x] | 각 점수를 아침·낮·저녁·밤 시간대별로 → 지금 구간 점수로 순위, 안 겹치는 각은 순위·피드에서 빼고 스토리·전체엔 '지금 아님'. 히어로는 '지금 날씨 점수'(지금 구간). 운영 DB에 `index_score.slots` 칸 추가 필요(배포 때 `init.sql`의 ALTER) | 10/8 회의 결정 | `backend/services/calc/index_calc.py:297` |
|
||||
| [x] | 히어로에 습도·불쾌지수 항상 표시 → 4칸(지금·습도·불쾌지수·상황 1칸, 사용자 결정). 불쾌지수 75 이상이면 경고 색, 상황 칸 후보에서 불쾌지수 뺌 | 10/8 회의 결정 | `frontend/src/b/TodayPage.tsx` (`HeroStat`) |
|
||||
|
||||
@@ -323,9 +323,6 @@ class FeedService:
|
||||
async with redis_lock("lock:feed:build", ttl_sec=20):
|
||||
await build_feed_day(day, self.crud, self.season_crud, self.regions)
|
||||
res, partial = await self._assemble(region, now, day, slot, sunset_at)
|
||||
# 각을 못 낸 피드는 저장하지 않는다. 처음 온 지역은 예보를 받는 중이라 다음 요청에서 바로 채운다
|
||||
if not res.bands.top5:
|
||||
return ErrorType.SUCCESS, res
|
||||
try:
|
||||
await REDIS.conn.set(key, res.model_dump_json(), ex=_PARTIAL_TTL if partial else feed_ttl_sec(now, sunset_at))
|
||||
except RedisError as e:
|
||||
|
||||
@@ -25,7 +25,7 @@ from services.external.data_go_kr import DataGoKrNotConfigured, DataGoKrRequestF
|
||||
from services.external.kma import day_start_base, fetch_mid, fetch_ultra, fetch_vilage, latest_mid_base, parse_mid, parse_ultra, parse_vilage
|
||||
|
||||
SLOT_HOURS = range(0, 24, 3)
|
||||
_WAIT_STEPS, _WAIT_SEC = 75, 0.2 # 처음 온 지역은 다른 요청이 예보를 받아 오는 동안 최대 15초 기다린다
|
||||
_WAIT_STEPS, _WAIT_SEC = 15, 0.2
|
||||
# 단기예보 끝날 몇 시간만 있는 날은 하루 값을 만들지 않는다 (중기예보 값을 덮어쓰지 않게).
|
||||
_MIN_DAY_HOURS = 8
|
||||
MID_DAYS = 11 # 중기예보가 닿는 오늘+10일까지
|
||||
|
||||
@@ -204,7 +204,7 @@ def test_gak_key_handles_sunset_window():
|
||||
|
||||
|
||||
@pytest.mark.anyio
|
||||
async def test_feed_missing_gak_is_not_cached(offline, monkeypatch):
|
||||
async def test_feed_missing_gak_is_cached_only_briefly(offline, monkeypatch):
|
||||
from common.cache.redis_client import REDIS
|
||||
from common.enums import ErrorType
|
||||
from services.index_service import IndexService
|
||||
@@ -216,7 +216,8 @@ async def test_feed_missing_gak_is_not_cached(offline, monkeypatch):
|
||||
async with AsyncClient(transport=ASGITransport(app=app), base_url="http://test") as client:
|
||||
body = (await client.get("/v1/feed", params={"region": REGION})).json()
|
||||
assert PostType.GAK.value not in [p["post_type"] for p in body["posts"]]
|
||||
assert [k async for k in REDIS.conn.scan_iter(f"feed:{REGION}:*")] == []
|
||||
keys = [k async for k in REDIS.conn.scan_iter(f"feed:{REGION}:*")]
|
||||
assert keys and 0 < await REDIS.conn.ttl(keys[0]) <= 60
|
||||
|
||||
|
||||
def _alert_ctx(warnings=(), rain_prob=0):
|
||||
|
||||
@@ -0,0 +1,99 @@
|
||||
# 앱인토스 진행 계획
|
||||
|
||||
기준: 2026-10-12. 근거 문서는 [입점 검토](https://claude.ai/artifact/QgA7iq3CCesTRYcFyZck71), [토스판 전략](https://claude.ai/artifact/4WgpUjdNqdSNnMN4ASB4BB).
|
||||
|
||||
## 정한 것
|
||||
|
||||
- 토스판은 **WebView**로 만든다. React Native(Granite)는 쓰지 않는다. RN은 토스와 무관한 독립 앱으로만 진행한다.
|
||||
- 프로젝트를 따로 만들지 않는다. 지금 `frontend/` 하나에서 **웹 빌드**와 **토스 빌드** 두 가지를 낸다.
|
||||
- 웹을 먼저 출시하고, 토스판은 그 뒤에 낸다.
|
||||
- 토스판 1차는 **보기 전용**이다. 로그인·좋아요·댓글은 끈다.
|
||||
|
||||
## 구조
|
||||
|
||||
```
|
||||
frontend/
|
||||
apps-in-toss.config.ts 토스 앱 설정 (appName, brand, permissions, navigationBar, webBundleDir=dist-toss)
|
||||
.env.toss 로컬 전용, 커밋 안 함. VITE_API_BASE_URL·VITE_SITE_URL=https://weather.o2o.kr
|
||||
src/lib/platform.ts 웹/토스 차이를 모으는 유일한 곳
|
||||
```
|
||||
|
||||
- 빌드: 웹은 `npm run build`, 토스는 `npm run build:toss`. 토스 빌드는 `vite build --mode toss --outDir dist-toss`를 돌린 뒤 `ait build`로 `weather-gak-test.ait`를 만든다. 지금 appName은 테스트용 `weather-gak-test`다. 정식 앱으로 바꿀 때는 `apps-in-toss.config.ts`와 `src/lib/platform.ts`(`intoss://` 주소) 두 곳을 같이 고친다.
|
||||
- SDK 3.x는 설정 파일이 `apps-in-toss.config.ts`다. 문서에 나오는 `granite.config.ts`는 2.x 방식이다.
|
||||
- 토스 빌드에서 `.env.toss`에 HTTPS 주소가 없으면 `vite.config.ts`가 빌드를 멈춘다.
|
||||
- `platform.ts`는 `import.meta.env.MODE === 'toss'`로 갈린다. SDK는 토스 모드에서만 동적으로 import하므로 웹 번들에는 들어가지 않는다. 웹 빌드 결과에 SDK 조각이 없는 것을 확인했다.
|
||||
- 화면 코드는 `platform.ts`의 함수만 부른다. 화면 곳곳에 `if (토스)`를 두지 않는다.
|
||||
- 백엔드는 고치지 않는다. CORS는 이미 전부 허용(`backend/router/router.py:34`)이고, API 주소는 `VITE_API_BASE_URL`로 받는다(`frontend/src/api/setup.ts:4`).
|
||||
|
||||
## 웹과 토스가 다른 점
|
||||
|
||||
| 기능 | 웹 | 토스 | 파일 |
|
||||
|---|---|---|---|
|
||||
| 공유 | `navigator.share` (이미지 카드 + 링크) | 이미지는 기기에 저장(`File.saveBase64`), 링크는 `Share.createLink` + `Share.sendMessage`. SDK 공유는 글만 보낼 수 있다 | `frontend/src/b/Sheets.tsx` |
|
||||
| 위치 | `navigator.geolocation` | `Device.getLocation`. 처음 들어올 때는 권한 창을 띄우지 않고, 이미 허용한 사람만 위치로 맞춘다. '내 위치' 버튼을 누를 때 권한 창을 띄운다 | `frontend/src/b/region.tsx` |
|
||||
| 로그인·좋아요·댓글 | 있음 | 숨김 (상단 로그인, 카드의 하트·댓글·좋아요 수, 두 번 눌러 좋아요, 지역 창 아래 로그인 줄) | `frontend/src/b/Post.tsx`, `frontend/src/b/Sheets.tsx`, `frontend/src/b/BLayout.tsx` |
|
||||
| 네이버 지도 링크 | 있음 | 장소 이름만 표시. Q4 답이 '예외 해당'이면 되돌린다 | `frontend/src/b/ui.tsx` (`MapLink`) |
|
||||
| 밤 배경 | 어두운 남색 | Q3 답 보고 결정 | `frontend/src/b/BLayout.tsx` |
|
||||
| GA4 | `index.html`에 태그 | Q2 답 보고 결정 | `frontend/index.html`, `frontend/src/lib/analytics.ts` |
|
||||
| 라우터 | `BrowserRouter` | Q1 답 보고 결정 (안 되면 `HashRouter`) | `frontend/src/App.tsx` |
|
||||
| AI 글 표시 | 없음 | 계절 소식 등에 표시 (문구는 검토받은 뒤) | 글 시트 |
|
||||
|
||||
## 토스에 물어볼 것 (채널톡 · 개발자 커뮤니티)
|
||||
|
||||
| # | 질문 | 답 |
|
||||
|---|---|---|
|
||||
| Q1 | WebView에서 `BrowserRouter`(주소 경로)로 화면을 나눠도 되는가 | |
|
||||
| Q2 | 미니앱 안에서 GA4(`gtag.js`)를 써도 되는가 | |
|
||||
| Q3 | 시간대에 따라 밤에 어두운 배경을 쓰면 '라이트 모드' 규칙에 걸리는가 | |
|
||||
| Q4 | 장소 이름을 누르면 네이버 지도로 가는 링크가 '단순 정보 확인' 예외에 해당하는가 | |
|
||||
| Q5 | 공유창으로 이미지 파일(공유 카드)을 보낼 수 있는가 | SDK 기준 불가(`Share.sendMessage`는 글만). 지금은 이미지를 저장하고 링크를 보낸다 |
|
||||
| Q6 | TDS는 '강력 권장'인데 React 19 프로젝트도 TDS 없이 검수를 통과하는가 (TDS는 React 18 필요) | |
|
||||
| Q7 | 카테고리 목록. '나들이·여가' 같은 분류가 있는가 | |
|
||||
|
||||
## 단계
|
||||
|
||||
각 단계가 끝나면 확인을 받고 다음 단계로 간다. 작업 브랜치는 `feat/apps-in-toss`.
|
||||
|
||||
### 0. 사전 준비 — 사람이 할 일
|
||||
|
||||
- [ ] 앱인토스 콘솔 가입, 앱 등록 → `appName` 확정 (https://apps-in-toss.toss.im)
|
||||
- [ ] 사업자 정보 등록 (영업일 기준 약 1일)
|
||||
- [ ] 위 Q1~Q7 문의
|
||||
- [ ] 샌드박스 앱을 테스트 폰에 설치
|
||||
|
||||
### 1. 토스 빌드 뼈대
|
||||
|
||||
- [x] `@apps-in-toss/web-framework@3.8.0` 설치 (버전 고정)
|
||||
- [x] `apps-in-toss.config.ts`, `.env.toss`(로컬), `package.json`에 `build:toss` 추가 → `weather-gak-test.ait` 생성 확인
|
||||
- [ ] 샌드박스 앱에서 피드가 뜨는지 확인 — 콘솔 앱 등록·샌드박스 설치 뒤
|
||||
|
||||
완료 기준: 웹 빌드 결과가 바뀌지 않고, 샌드박스에서 피드가 열린다.
|
||||
|
||||
### 2. 플랫폼 분기
|
||||
|
||||
- [x] `src/lib/platform.ts`: `IS_TOSS`, `SOCIAL`, `tossShare`, `tossLocation`
|
||||
- [x] 공유·위치·로그인·좋아요·댓글·지도 링크를 토스에서 분기
|
||||
- [ ] Q1~Q3 답에 따라 라우터·GA4·밤 배경을 처리한다 (지금은 웹과 같음)
|
||||
|
||||
완료 기준: 웹은 지금과 똑같이 동작한다. 토스에서는 로그인 관련 화면이 하나도 보이지 않는다.
|
||||
|
||||
### 3. 토스판 피드 줄이기 — 결정 대기
|
||||
|
||||
TODO.md의 '각 34개 정리', '히어로 숫자 5개'가 결정되면 진행한다. 목표는 피드 8~10칸, 첫 화면에 한 줄 판정이다. 문구는 목록으로 검토받은 뒤 반영한다.
|
||||
|
||||
### 4. 검증
|
||||
|
||||
- [x] `npm run lint`, `npm run build`, `npm run build:toss` 모두 통과 (10/12)
|
||||
- [ ] 샌드박스 실기기 확인: 첫 화면 뒤로가기를 누르면 앱이 닫힌다, 진입하자마자 바텀시트가 뜨지 않는다, 상단 바 버튼이 1개다, 위치 권한을 거부해도 지역 선택으로 쓸 수 있다
|
||||
- [ ] [비게임 검수 체크리스트](https://developers-apps-in-toss.toss.im/checklist/app-nongame.md)와 항목별로 대조
|
||||
- [ ] 토스 공식 `project-validator` 스킬로 점검 (https://github.com/toss/apps-in-toss-skills)
|
||||
|
||||
### 5. 출시
|
||||
|
||||
- [ ] 웹 출시가 끝났는지 확인
|
||||
- [ ] `.ait` 번들을 콘솔에 올리고 검수 요청 (3~5영업일, 반려 시 다시 3~5일)
|
||||
|
||||
### 6. 출시 후 — 별도 결정
|
||||
|
||||
- 스마트 발송(알림): 금요일 주말 판정, 노을 좋은 날. 노을 알림은 TODO.md에서 결정 대기 중이다.
|
||||
- 포인트: 출시 후 2주만 쓰고 끊는다. 포인트를 끊은 주의 재방문율로 계속할지 판단한다.
|
||||
@@ -5,3 +5,6 @@ dist
|
||||
.DS_Store
|
||||
Dockerfile
|
||||
.dockerignore
|
||||
dist-toss
|
||||
*.ait
|
||||
.env.toss
|
||||
@@ -22,3 +22,6 @@ dist-ssr
|
||||
*.njsproj
|
||||
*.sln
|
||||
*.sw?
|
||||
|
||||
dist-toss
|
||||
*.ait
|
||||
@@ -0,0 +1,10 @@
|
||||
import { defineConfig } from '@apps-in-toss/web-framework/config'
|
||||
|
||||
// appName 은 앱인토스 콘솔에 등록한 이름과 같아야 한다
|
||||
export default defineConfig({
|
||||
appName: 'nalssigak',
|
||||
brand: { primaryColor: '#ff7a45' },
|
||||
permissions: [{ name: 'geolocation', access: 'access' }],
|
||||
navigationBar: { withBackButton: true, withHomeButton: true },
|
||||
webBundleDir: 'dist-toss',
|
||||
})
|
||||
Generated
+1437
-18
File diff suppressed because it is too large.
Load diff
@@ -8,9 +8,11 @@
|
||||
"build": "tsc -b && vite build",
|
||||
"lint": "oxlint",
|
||||
"preview": "vite preview",
|
||||
"api": "openapi-ts"
|
||||
"api": "openapi-ts",
|
||||
"build:toss": "tsc -b && vite build --mode toss --outDir dist-toss && ait build"
|
||||
},
|
||||
"dependencies": {
|
||||
"@apps-in-toss/web-framework": "3.8.0",
|
||||
"@tailwindcss/vite": "^4.3.3",
|
||||
"@tanstack/react-query": "^5.104.0",
|
||||
"embla-carousel-react": "^8.6.0",
|
||||
|
||||
@@ -2,6 +2,7 @@ import { useCallback, useEffect, useMemo, useState, type ReactNode } from 'react
|
||||
import { NavLink, Outlet, useLocation } from 'react-router'
|
||||
import { useIsFetching, useQuery } from '@tanstack/react-query'
|
||||
import { getSeasonWeekOptions } from '../api/client/@tanstack/react-query.gen'
|
||||
import { SOCIAL } from '../lib/platform'
|
||||
import { cx } from '../lib/utils'
|
||||
import { kindOfHour, kst, seasonOf, type TimeKind } from './lib'
|
||||
import './b.css'
|
||||
@@ -60,7 +61,7 @@ function TopBar() {
|
||||
<PinIcon className="size-3.5" />
|
||||
{locateStatus === 'locating' ? <Skel className="w-[72px]" /> : region.name}
|
||||
</button>
|
||||
{mePending ? (
|
||||
{SOCIAL && (mePending ? (
|
||||
<Skel shape className="size-9 shrink-0 rounded-full" />
|
||||
) : me ? (
|
||||
<button type="button" onClick={() => open({ type: 'me' })} aria-label={`내 정보, ${me.nickname}`} className="shrink-0 cursor-pointer rounded-full shadow-[0_6px_12px_rgb(40_48_74/0.12)]">
|
||||
@@ -70,7 +71,7 @@ function TopBar() {
|
||||
<button type="button" onClick={() => open({ type: 'login' })} className="shrink-0 cursor-pointer rounded-full bg-(--ink) px-3 py-1.5 text-[13px] font-extrabold text-white">
|
||||
로그인
|
||||
</button>
|
||||
)}
|
||||
))}
|
||||
</header>
|
||||
)
|
||||
}
|
||||
|
||||
+18
-11
@@ -1,6 +1,7 @@
|
||||
import { useEffect, useRef, useState, type CSSProperties, type MouseEvent, type ReactNode } from 'react'
|
||||
import { createPortal } from 'react-dom'
|
||||
import { PostType, SlotTone, type GakSlide, type HoursSlide, type PlanSlide, type PostData, type ResFeed, type RowsSlide, type SunsetSlide, type WeekSlide } from '../api/client/types.gen'
|
||||
import { SOCIAL } from '../lib/platform'
|
||||
import { cx } from '../lib/utils'
|
||||
import { cardBg, clockShort, fall } from './lib'
|
||||
import type { SlideBg } from './types'
|
||||
@@ -360,7 +361,7 @@ function FullCard({ post }: PostProps) {
|
||||
}
|
||||
|
||||
const onTap = (e: MouseEvent<HTMLDivElement>) => {
|
||||
if ((e.target as HTMLElement).closest('button')) return
|
||||
if (!SOCIAL || (e.target as HTMLElement).closest('button')) return
|
||||
const now = Date.now()
|
||||
if (now - lastTap.current < 320) {
|
||||
if (liked && loggedIn) setPop((p) => p + 1)
|
||||
@@ -435,24 +436,30 @@ function FullCard({ post }: PostProps) {
|
||||
)}
|
||||
</div>
|
||||
<div className="flex items-center gap-3.5 px-3 pt-2.5 pb-1 [&_svg]:size-[26px] [&_svg]:stroke-[1.9]">
|
||||
<button type="button" onClick={() => setLike(!liked)} aria-pressed={liked} aria-label="좋아요" className={cx('relative grid size-7 cursor-pointer place-items-center', TAP44)}>
|
||||
<HeartIcon className={liked ? 'fill-(--heart) stroke-(--heart)' : 'fill-none stroke-(--ink)'} />
|
||||
</button>
|
||||
<button type="button" onClick={comments} aria-label="댓글 보기" className={cx('relative grid size-7 cursor-pointer place-items-center', TAP44)}>
|
||||
<CommentIcon className="fill-none stroke-(--ink) [stroke-linejoin:round]" />
|
||||
</button>
|
||||
{SOCIAL && (
|
||||
<>
|
||||
<button type="button" onClick={() => setLike(!liked)} aria-pressed={liked} aria-label="좋아요" className={cx('relative grid size-7 cursor-pointer place-items-center', TAP44)}>
|
||||
<HeartIcon className={liked ? 'fill-(--heart) stroke-(--heart)' : 'fill-none stroke-(--ink)'} />
|
||||
</button>
|
||||
<button type="button" onClick={comments} aria-label="댓글 보기" className={cx('relative grid size-7 cursor-pointer place-items-center', TAP44)}>
|
||||
<CommentIcon className="fill-none stroke-(--ink) [stroke-linejoin:round]" />
|
||||
</button>
|
||||
</>
|
||||
)}
|
||||
<button type="button" onClick={share} aria-label="보내기" className={cx('relative grid size-7 cursor-pointer place-items-center', TAP44)}>
|
||||
<SendIcon className="fill-none stroke-(--ink) [stroke-linecap:round] [stroke-linejoin:round]" />
|
||||
</button>
|
||||
</div>
|
||||
<p className="px-3 py-0.5 text-sm font-extrabold">좋아요 {likeCount.toLocaleString()}개</p>
|
||||
{SOCIAL && <p className="px-3 py-0.5 text-sm font-extrabold">좋아요 {likeCount.toLocaleString()}개</p>}
|
||||
<p className="px-3 py-0.5 text-sm">
|
||||
<b className="mr-[5px] font-extrabold">날씨각</b>
|
||||
{post.caption}
|
||||
</p>
|
||||
<button type="button" onClick={comments} className="block cursor-pointer px-3 pt-[3px] text-sm font-semibold text-(--ink3)">
|
||||
{post.comment_count ? `댓글 ${post.comment_count}개 모두 보기` : '첫 댓글 남기기'}
|
||||
</button>
|
||||
{SOCIAL && (
|
||||
<button type="button" onClick={comments} className="block cursor-pointer px-3 pt-[3px] text-sm font-semibold text-(--ink3)">
|
||||
{post.comment_count ? `댓글 ${post.comment_count}개 모두 보기` : '첫 댓글 남기기'}
|
||||
</button>
|
||||
)}
|
||||
<p className="px-3 pt-1 pb-3 text-[11.5px] font-semibold text-(--ink3)">오늘</p>
|
||||
</article>
|
||||
)
|
||||
|
||||
@@ -21,6 +21,7 @@ import {
|
||||
} from '../api/client/@tanstack/react-query.gen'
|
||||
import type { CommentData, Factor, ResAuth, ResCommentList, ResIndexDetail } from '../api/client/types.gen'
|
||||
import { track } from '../lib/analytics'
|
||||
import { IS_TOSS, SOCIAL, tossShare } from '../lib/platform'
|
||||
import { cx } from '../lib/utils'
|
||||
import { useAuth } from './authContext'
|
||||
import { ago, ARTICLE_CAT, articleMeta, AVATAR_COLORS, cardBg, CHARACTERS, dateRange, loadOf, MOODS, shortDay } from './lib'
|
||||
@@ -550,6 +551,19 @@ function ShareSheet({ share }: { share: SharePayload }) {
|
||||
const send = () => {
|
||||
if (!image) return
|
||||
const file = new File([image.blob], `nalssigak-${SHARE_SIZES[size].ratio.replace(':', 'x')}.png`, { type: 'image/png' })
|
||||
if (IS_TOSS) {
|
||||
tossShare(image.blob, file.name, share.title).then(
|
||||
(r) => {
|
||||
setToast(r === 'saved' ? '이미지를 저장하고 링크를 보냈어요' : '링크를 보냈어요')
|
||||
track('share', { content_type: 'image', item_id: share.title, method: 'share_sheet', ratio: SHARE_SIZES[size].ratio })
|
||||
},
|
||||
(e: unknown) => {
|
||||
console.error('[share] toss', e)
|
||||
setToast('보내지 못했어요. 한 번 더 눌러 주세요')
|
||||
},
|
||||
)
|
||||
return
|
||||
}
|
||||
if (navigator.canShare?.({ files: [file], text })) {
|
||||
navigator.share({ files: [file], title: share.title, text }).then(
|
||||
() => {
|
||||
@@ -1034,12 +1048,14 @@ function RegionSheet({ onDone }: { onDone: () => void }) {
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
<p className="mt-4 flex items-center justify-center gap-2 text-[13px] font-bold text-(--ink2)">
|
||||
{me ? `${me.nickname}(으)로 로그인했어요` : '로그인하면 좋아요·댓글을 쓸 수 있어요'}
|
||||
<button type="button" onClick={me ? logout : () => open({ type: 'login' })} className="cursor-pointer font-extrabold text-(--rain)">
|
||||
{me ? '로그아웃' : '로그인'}
|
||||
</button>
|
||||
</p>
|
||||
{SOCIAL && (
|
||||
<p className="mt-4 flex items-center justify-center gap-2 text-[13px] font-bold text-(--ink2)">
|
||||
{me ? `${me.nickname}(으)로 로그인했어요` : '로그인하면 좋아요·댓글을 쓸 수 있어요'}
|
||||
<button type="button" onClick={me ? logout : () => open({ type: 'login' })} className="cursor-pointer font-extrabold text-(--rain)">
|
||||
{me ? '로그아웃' : '로그인'}
|
||||
</button>
|
||||
</p>
|
||||
)}
|
||||
</Body>
|
||||
)
|
||||
}
|
||||
+30
-13
@@ -2,6 +2,7 @@ import { useCallback, useEffect, useMemo, useState, type ReactNode } from 'react
|
||||
import { nearestRegion } from '../api/client/sdk.gen'
|
||||
import type { RegionData } from '../api/client/types.gen'
|
||||
import { track } from '../lib/analytics'
|
||||
import { IS_TOSS, tossLocation } from '../lib/platform'
|
||||
import { DEFAULT_REGION, RegionContext, type LocateStatus } from './regionContext'
|
||||
|
||||
const KEY = 'nalssigak.b.region'
|
||||
@@ -28,7 +29,7 @@ function writeStored(r: RegionData) {
|
||||
export function RegionProvider({ children }: { children: ReactNode }) {
|
||||
const [stored] = useState(readStored)
|
||||
const [region, setRegionState] = useState<RegionData>(stored ?? DEFAULT_REGION)
|
||||
const canLocate = typeof navigator !== 'undefined' && 'geolocation' in navigator
|
||||
const canLocate = IS_TOSS || (typeof navigator !== 'undefined' && 'geolocation' in navigator)
|
||||
const [locateStatus, setLocateStatus] = useState<LocateStatus>(!stored && canLocate ? 'locating' : 'idle')
|
||||
|
||||
const setRegion = useCallback((r: RegionData) => {
|
||||
@@ -36,23 +37,39 @@ export function RegionProvider({ children }: { children: ReactNode }) {
|
||||
writeStored(r)
|
||||
}, [])
|
||||
|
||||
const fromCoords = useCallback((lat: number, lon: number, onFound?: () => void) => {
|
||||
nearestRegion({ query: { lat, lon } })
|
||||
.then(({ data: res }) => {
|
||||
if (!res.region) throw new Error('가까운 구를 찾지 못함')
|
||||
setRegion(res.region)
|
||||
setLocateStatus('idle')
|
||||
track('region_change', { region_name: res.region.name, method: 'location' })
|
||||
onFound?.()
|
||||
})
|
||||
.catch(() => setLocateStatus('error'))
|
||||
}, [setRegion])
|
||||
|
||||
const findNearest = useCallback((onFound?: () => void) => {
|
||||
if (IS_TOSS) {
|
||||
tossLocation(true).then(
|
||||
(loc) => {
|
||||
if (loc === null) setLocateStatus('idle')
|
||||
else if (loc === 'denied') setLocateStatus('denied')
|
||||
else fromCoords(loc.lat, loc.lon, onFound)
|
||||
},
|
||||
(e: unknown) => {
|
||||
console.error('[region] toss location', e)
|
||||
setLocateStatus('error')
|
||||
},
|
||||
)
|
||||
return
|
||||
}
|
||||
navigator.geolocation.getCurrentPosition(
|
||||
(pos) => {
|
||||
nearestRegion({ query: { lat: pos.coords.latitude, lon: pos.coords.longitude } })
|
||||
.then(({ data: res }) => {
|
||||
if (!res.region) throw new Error('가까운 구를 찾지 못함')
|
||||
setRegion(res.region)
|
||||
setLocateStatus('idle')
|
||||
track('region_change', { region_name: res.region.name, method: 'location' })
|
||||
onFound?.()
|
||||
})
|
||||
.catch(() => setLocateStatus('error'))
|
||||
},
|
||||
(pos) => fromCoords(pos.coords.latitude, pos.coords.longitude, onFound),
|
||||
(err) => setLocateStatus(err.code === err.PERMISSION_DENIED ? 'denied' : 'error'),
|
||||
{ timeout: 10000, maximumAge: 600000 },
|
||||
)
|
||||
}, [setRegion])
|
||||
}, [fromCoords])
|
||||
|
||||
const locate = useCallback((onFound?: () => void) => {
|
||||
if (!canLocate) {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { useState, type CSSProperties, type ReactNode } from 'react'
|
||||
import { Link } from 'react-router'
|
||||
import { IS_TOSS } from '../lib/platform'
|
||||
import { cx } from '../lib/utils'
|
||||
import { useCarousel, type Carousel } from './carousel'
|
||||
import { AVATAR_COLORS, iconSrc, moodEmoji, naverMap, type Load } from './lib'
|
||||
@@ -202,6 +203,8 @@ export function StateBox({ load, onRetry, empty, className, hold }: StateProps)
|
||||
/** 줄 목록 (라벨 · 값) */
|
||||
/** 위치가 정해진 장소 이름. 누르면 네이버 지도가 새 탭으로 열린다 */
|
||||
export function MapLink({ place, children, className }: { place: string; children: ReactNode; className?: string }) {
|
||||
// 앱인토스는 외부 이동을 막는다
|
||||
if (IS_TOSS) return <span className={className}>{children}</span>
|
||||
return (
|
||||
<a href={naverMap(place)} target="_blank" rel="noopener noreferrer" aria-label={`${place}, 네이버 지도에서 보기`} className={cx('underline decoration-dotted decoration-1 underline-offset-[3px]', className)}>
|
||||
{children}
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
/** 웹/앱인토스 차이를 모으는 곳. 토스 SDK 는 토스 빌드(`vite build --mode toss`)에서만 불러온다 */
|
||||
export const IS_TOSS = import.meta.env.MODE === 'toss'
|
||||
|
||||
/** 로그인·좋아요·댓글. 토스판 1차는 보기 전용이라 끈다 */
|
||||
export const SOCIAL = !IS_TOSS
|
||||
|
||||
const TOSS_APP = 'intoss://nalssigak'
|
||||
|
||||
// 웹 빌드에서는 이 분기가 지워져 SDK 가 번들에 들어가지 않는다
|
||||
const sdk = () => (import.meta.env.MODE === 'toss' ? import('@apps-in-toss/web-framework') : Promise.reject(new Error('토스 앱 밖에서는 쓸 수 없어요')))
|
||||
|
||||
function toBase64(blob: Blob): Promise<string> {
|
||||
return new Promise((resolve, reject) => {
|
||||
const reader = new FileReader()
|
||||
reader.onload = () => resolve(String(reader.result).split(',')[1] ?? '')
|
||||
reader.onerror = () => reject(reader.error)
|
||||
reader.readAsDataURL(blob)
|
||||
})
|
||||
}
|
||||
|
||||
/** 토스: 이미지를 기기에 저장하고 토스 앱 링크를 공유창으로 보낸다 */
|
||||
export async function tossShare(image: Blob, fileName: string, title: string): Promise<'saved' | 'link-only'> {
|
||||
const { File, Share } = await sdk()
|
||||
let saved = false
|
||||
if (File.saveBase64.isSupported()) {
|
||||
await File.saveBase64({ data: await toBase64(image), fileName, mimeType: image.type })
|
||||
saved = true
|
||||
}
|
||||
const link = await Share.createLink({ path: TOSS_APP })
|
||||
await Share.sendMessage({ message: `${title} · 날씨각 ${link}` })
|
||||
return saved ? 'saved' : 'link-only'
|
||||
}
|
||||
|
||||
export type TossLocation = { lat: number; lon: number } | 'denied'
|
||||
|
||||
/** 토스: 위치를 읽는다. 권한이 없으면 ask 일 때만 권한 창을 띄운다 */
|
||||
export async function tossLocation(ask: boolean): Promise<TossLocation | null> {
|
||||
const { Accuracy, Device } = await sdk()
|
||||
let status = await Device.getLocation.getPermission()
|
||||
if (status !== 'allowed' && ask) status = await Device.getLocation.openPermissionDialog()
|
||||
if (status !== 'allowed') return ask ? 'denied' : null
|
||||
const { coords } = await Device.getLocation({ accuracy: Accuracy.Balanced })
|
||||
return { lat: coords.latitude, lon: coords.longitude }
|
||||
}
|
||||
@@ -19,5 +19,5 @@
|
||||
"erasableSyntaxOnly": true,
|
||||
"noFallthroughCasesInSwitch": true
|
||||
},
|
||||
"include": ["vite.config.ts"]
|
||||
"include": ["vite.config.ts", "apps-in-toss.config.ts"]
|
||||
}
|
||||
+15
-3
@@ -2,7 +2,7 @@ import { readFileSync, writeFileSync } from 'node:fs'
|
||||
import { resolve } from 'node:path'
|
||||
import tailwindcss from '@tailwindcss/vite'
|
||||
import react from '@vitejs/plugin-react'
|
||||
import { defineConfig, type Plugin } from 'vite'
|
||||
import { defineConfig, loadEnv, type Plugin } from 'vite'
|
||||
|
||||
type Gak = { name: string; description: string }
|
||||
|
||||
@@ -65,7 +65,19 @@ function seoPages(): Plugin {
|
||||
}
|
||||
}
|
||||
|
||||
// 토스 빌드는 토스 도메인에서 열리므로 API·사이트 주소를 HTTPS 절대 주소로 받아야 한다
|
||||
function checkTossEnv(mode: string) {
|
||||
if (mode !== 'toss') return
|
||||
const env = loadEnv(mode, process.cwd())
|
||||
for (const key of ['VITE_API_BASE_URL', 'VITE_SITE_URL']) {
|
||||
if (!env[key]?.startsWith('https://')) throw new Error(`토스 빌드: ${key} 에 https:// 주소가 필요해요 (frontend/.env.toss)`)
|
||||
}
|
||||
}
|
||||
|
||||
// https://vite.dev/config/
|
||||
export default defineConfig({
|
||||
plugins: [react(), tailwindcss(), seoPages()],
|
||||
export default defineConfig(({ mode }) => {
|
||||
checkTossEnv(mode)
|
||||
return {
|
||||
plugins: [react(), tailwindcss(), ...(mode === 'toss' ? [] : [seoPages()])],
|
||||
}
|
||||
})
|
||||
@@ -1,15 +1,3 @@
|
||||
import com.google.android.wearable.watchface.validator.client.DwfValidatorFactory
|
||||
|
||||
// 스킨 APK 검증·토큰 발급기 (Watch Face Push). 의존성 하나가 jitpack 에만 있다
|
||||
buildscript {
|
||||
repositories {
|
||||
google()
|
||||
mavenCentral()
|
||||
maven("https://jitpack.io") { content { includeGroup("com.github.xgouchet") } }
|
||||
}
|
||||
dependencies { classpath("com.google.android.wearable.watchface.validator:validator-push:1.0.0-alpha09") }
|
||||
}
|
||||
|
||||
plugins {
|
||||
id("com.android.application")
|
||||
id("org.jetbrains.kotlin.plugin.compose")
|
||||
@@ -21,13 +9,10 @@ android {
|
||||
|
||||
defaultConfig {
|
||||
applicationId = "kr.o2o.nalssigak"
|
||||
// Wear OS 6+ 만. 앱 설치 때 스킨을 같이 깔고 시계 화면으로 바꾸는 Watch Face Push 가 API 36 부터다
|
||||
minSdk = 36
|
||||
targetSdk = 36
|
||||
minSdk = 30
|
||||
targetSdk = 34
|
||||
versionCode = 1
|
||||
versionName = "0.1"
|
||||
// 앱에 실은 스킨 버전. 워치에 깔린 스킨이 이보다 낮으면 앱이 바꿔 끼운다 (MainActivity.useSkin)
|
||||
buildConfigField("int", "SKIN_VERSION", providers.gradleProperty("NALSSIGAK_SKIN_VERSION").get())
|
||||
}
|
||||
buildTypes {
|
||||
// 에뮬레이터에서 본 맥의 로컬 백엔드 (compose 포트 9810)
|
||||
@@ -53,36 +38,4 @@ dependencies {
|
||||
implementation("androidx.wear.tiles:tiles:1.6.2")
|
||||
implementation("androidx.concurrent:concurrent-futures:1.3.0")
|
||||
implementation("androidx.wear.watchface:watchface-complications-data-source-ktx:1.3.0")
|
||||
implementation("androidx.wear.watchfacepush:watchfacepush:1.0.0")
|
||||
}
|
||||
|
||||
// 앱을 깔면 스킨(:watchface)도 같이 깔리게 한다 (Wear OS 6+ 기본 워치 페이스).
|
||||
// 같은 빌드 타입의 스킨 APK 를 assets/default_watchface.apk 로 싣고, 검증 토큰을 문자열 리소스로 만든다
|
||||
androidComponents.onVariants { variant ->
|
||||
val name = variant.name.replaceFirstChar(Char::titlecase)
|
||||
val skinApks = project(":watchface").layout.buildDirectory.dir("outputs/apk/${variant.name}")
|
||||
val assetsDir = layout.buildDirectory.dir("generated/skinAssets/${variant.name}")
|
||||
val resDir = layout.buildDirectory.dir("generated/skinToken/${variant.name}")
|
||||
val appId = variant.applicationId
|
||||
variant.sources.assets?.addStaticSourceDirectory(assetsDir.get().asFile.path)
|
||||
variant.sources.res?.addStaticSourceDirectory(resDir.get().asFile.path)
|
||||
val bundle = tasks.register("bundleSkin$name") {
|
||||
dependsOn(":watchface:assemble$name")
|
||||
inputs.dir(skinApks)
|
||||
outputs.dirs(assetsDir, resDir)
|
||||
doLast {
|
||||
val apk = skinApks.get().asFile.listFiles { f -> f.extension == "apk" }!!.single()
|
||||
// 서명 없는 스킨은 워치가 설치를 거부한다. 업로드 키 설정은 루트 build.gradle.kts 참고
|
||||
if (apk.name.endsWith("-unsigned.apk")) throw GradleException("스킨 APK 가 서명되지 않았습니다. ~/.gradle/gradle.properties 에 NALSSIGAK_STORE_* 를 넣고 다시 빌드하세요")
|
||||
val result = DwfValidatorFactory.create().validate(apk, appId.get())
|
||||
if (result.failures().isNotEmpty()) throw GradleException("스킨 검증 실패: ${result.failures()}")
|
||||
apk.copyTo(assetsDir.get().file("default_watchface.apk").asFile, overwrite = true)
|
||||
resDir.get().file("values/skin_token.xml").asFile.apply { parentFile.mkdirs() }
|
||||
.writeText(
|
||||
"""<resources xmlns:tools="http://schemas.android.com/tools">""" +
|
||||
"""<string name="default_wf_token" translatable="false" tools:ignore="Typos">${result.validationToken()}</string></resources>""" + "\n"
|
||||
)
|
||||
}
|
||||
}
|
||||
afterEvaluate { tasks.named("pre${name}Build") { dependsOn(bundle) } }
|
||||
}
|
||||
@@ -4,9 +4,6 @@
|
||||
<uses-feature android:name="android.hardware.type.watch" />
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
|
||||
<!-- 앱과 같이 깔리는 날씨각 스킨을 시계 화면으로 바꾸는 권한 (Watch Face Push) -->
|
||||
<uses-permission android:name="com.google.wear.permission.PUSH_WATCH_FACES" />
|
||||
<uses-permission android:name="com.google.wear.permission.SET_PUSHED_WATCH_FACE_AS_ACTIVE" />
|
||||
|
||||
<application
|
||||
android:icon="@drawable/ic_gak"
|
||||
@@ -16,11 +13,6 @@
|
||||
<!-- 폰 앱 없이 워치에서 단독으로 동작 -->
|
||||
<meta-data android:name="com.google.android.wearable.standalone" android:value="true" />
|
||||
|
||||
<!-- 앱 설치 때 assets/default_watchface.apk(스킨)도 같이 설치된다. 토큰은 빌드가 만든다 (build.gradle.kts) -->
|
||||
<meta-data
|
||||
android:name="com.google.android.wearable.marketplace.DEFAULT_WATCHFACE_VALIDATION_TOKEN"
|
||||
android:value="@string/default_wf_token" />
|
||||
|
||||
<activity android:name=".MainActivity" android:exported="true" android:taskAffinity="">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
@@ -134,7 +126,7 @@
|
||||
<meta-data android:name="android.support.wearable.complications.UPDATE_PERIOD_SECONDS" android:value="1800" />
|
||||
</service>
|
||||
|
||||
<!-- 워치 스킨 숨은 칸용: 날씨(비·눈·천둥)·기온·가운데 1위 -->
|
||||
<!-- 워치 스킨 숨은 칸용: 비·눈 여부 -->
|
||||
<service
|
||||
android:name=".RainComplicationService"
|
||||
android:exported="true"
|
||||
@@ -144,7 +136,7 @@
|
||||
<intent-filter>
|
||||
<action android:name="android.support.wearable.complications.ACTION_COMPLICATION_UPDATE_REQUEST" />
|
||||
</intent-filter>
|
||||
<meta-data android:name="android.support.wearable.complications.SUPPORTED_TYPES" android:value="RANGED_VALUE" />
|
||||
<meta-data android:name="android.support.wearable.complications.SUPPORTED_TYPES" android:value="SHORT_TEXT" />
|
||||
<meta-data android:name="android.support.wearable.complications.UPDATE_PERIOD_SECONDS" android:value="1800" />
|
||||
</service>
|
||||
|
||||
|
||||
@@ -3,8 +3,6 @@ package kr.o2o.nalssigak
|
||||
import android.Manifest
|
||||
import android.content.pm.PackageManager
|
||||
import android.os.Bundle
|
||||
import android.os.ParcelFileDescriptor
|
||||
import android.util.Log
|
||||
import androidx.activity.ComponentActivity
|
||||
import androidx.activity.compose.setContent
|
||||
import androidx.activity.result.contract.ActivityResultContracts
|
||||
@@ -18,85 +16,29 @@ import androidx.compose.runtime.remember
|
||||
import androidx.compose.runtime.setValue
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
import androidx.wear.compose.foundation.pager.VerticalPager
|
||||
import androidx.wear.compose.foundation.pager.rememberPagerState
|
||||
import androidx.wear.compose.material3.MaterialTheme
|
||||
import androidx.wear.compose.material3.VerticalPageIndicator
|
||||
import androidx.wear.watchfacepush.WatchFacePushManager
|
||||
import androidx.wear.watchfacepush.WatchFacePushManagerFactory
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.delay
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.withContext
|
||||
import java.io.File
|
||||
import java.time.Instant
|
||||
import kotlin.concurrent.thread
|
||||
|
||||
/** 컴플리케이션 탭이 실어 보내는 각 코드 */
|
||||
const val EXTRA_GAK = "gak"
|
||||
|
||||
/** 앱과 같이 깔린 스킨을 시계 화면으로 바꾸는 권한. 사용자가 한 번 거절하면 다시 묻지 못한다 */
|
||||
private const val SET_SKIN = "com.google.wear.permission.SET_PUSHED_WATCH_FACE_AS_ACTIVE"
|
||||
private const val TAG = "MainActivity"
|
||||
|
||||
class MainActivity : ComponentActivity() {
|
||||
private var summary by mutableStateOf<Summary?>(null)
|
||||
private var loading by mutableStateOf(true)
|
||||
|
||||
private val askPermissions = registerForActivityResult(ActivityResultContracts.RequestMultiplePermissions()) {
|
||||
load()
|
||||
useSkin()
|
||||
}
|
||||
private val askLocation = registerForActivityResult(ActivityResultContracts.RequestPermission()) { load() }
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
val opened = intent.getStringExtra(EXTRA_GAK)
|
||||
setContent { MaterialTheme { App(summary, loading, opened) { load(force = true) } } }
|
||||
// 위치와 스킨 적용을 한 번에 묻는다
|
||||
val missing = listOf(Manifest.permission.ACCESS_COARSE_LOCATION, SET_SKIN).filter { checkSelfPermission(it) != PackageManager.PERMISSION_GRANTED }
|
||||
if (missing.isEmpty()) {
|
||||
load()
|
||||
useSkin()
|
||||
} else askPermissions.launch(missing.toTypedArray())
|
||||
}
|
||||
|
||||
/**
|
||||
* 앱 설치 때 같이 깔린 날씨각 스킨을 챙긴다.
|
||||
* 앱 업데이트로 새 스킨이 실려 왔으면 바꿔 끼우고(기본 스킨은 처음 설치 때만 깔린다), 허락받았으면 시계 화면으로 바꾼다(시스템이 앱마다 한 번만 허락한다).
|
||||
*/
|
||||
private fun useSkin() {
|
||||
lifecycleScope.launch {
|
||||
val push = WatchFacePushManagerFactory.createWatchFacePushManager(this@MainActivity)
|
||||
try {
|
||||
// 기본 스킨 설치가 아직 안 끝났으면 다음 실행 때 다시 본다
|
||||
val skin = push.listWatchFaces().installedWatchFaceDetails.firstOrNull() ?: return@launch
|
||||
if (skin.versionCode < BuildConfig.SKIN_VERSION) updateSkin(push, skin.slotId)
|
||||
if (checkSelfPermission(SET_SKIN) == PackageManager.PERMISSION_GRANTED && !push.isWatchFaceActive(skin.packageName)) {
|
||||
push.setWatchFaceAsActive(skin.slotId)
|
||||
}
|
||||
} catch (e: WatchFacePushManager.ListWatchFacesException) {
|
||||
Log.w(TAG, "스킨 목록을 못 읽음", e)
|
||||
} catch (e: WatchFacePushManager.UpdateWatchFaceException) {
|
||||
Log.w(TAG, "스킨을 새 버전으로 못 바꿈", e)
|
||||
} catch (e: WatchFacePushManager.IsWatchFaceActiveException) {
|
||||
Log.w(TAG, "스킨 사용 여부를 못 읽음", e)
|
||||
} catch (e: WatchFacePushManager.SetWatchFaceAsActiveException) {
|
||||
// 이미 한 번 바꾼 뒤 사용자가 다른 화면으로 옮긴 경우. 다시 바꾸지 않는다
|
||||
Log.i(TAG, "스킨을 시계 화면으로 바꾸지 않음", e)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** 앱에 실은 스킨(assets/default_watchface.apk)으로 바꿔 끼운다. 검증 토큰은 빌드가 만든 것 (build.gradle.kts) */
|
||||
private suspend fun updateSkin(push: WatchFacePushManager, slotId: String) {
|
||||
val apk = File(cacheDir, "skin.apk")
|
||||
try {
|
||||
withContext(Dispatchers.IO) { assets.open("default_watchface.apk").use { input -> apk.outputStream().use { input.copyTo(it) } } }
|
||||
ParcelFileDescriptor.open(apk, ParcelFileDescriptor.MODE_READ_ONLY).use { push.updateWatchFace(slotId, it, getString(R.string.default_wf_token)) }
|
||||
} finally {
|
||||
apk.delete()
|
||||
}
|
||||
if (checkSelfPermission(Manifest.permission.ACCESS_COARSE_LOCATION) == PackageManager.PERMISSION_GRANTED) load()
|
||||
else askLocation.launch(Manifest.permission.ACCESS_COARSE_LOCATION)
|
||||
}
|
||||
|
||||
private fun load(force: Boolean = false) {
|
||||
@@ -108,7 +50,7 @@ class MainActivity : ComponentActivity() {
|
||||
}
|
||||
}
|
||||
|
||||
private enum class Page { DETAIL, HOURS, EVENTS, TOP, PICKS, SUNSET }
|
||||
private enum class Page { DETAIL, EVENTS, TOP, PICKS, SUNSET, HOURS }
|
||||
|
||||
@Composable
|
||||
private fun App(s: Summary?, loading: Boolean, opened: String?, onRetry: () -> Unit) {
|
||||
@@ -123,15 +65,15 @@ private fun App(s: Summary?, loading: Boolean, opened: String?, onRetry: () -> U
|
||||
StatePage(loading, onRetry)
|
||||
return
|
||||
}
|
||||
// 스킨 링에서 누른 각이 있으면 그 상세부터, 아니면 오늘 남은 시간 → 주변 축제 → 각 순서
|
||||
// 스킨 링에서 누른 각이 있으면 그 상세부터, 아니면 주변 축제부터 (축제가 없으면 오늘의 각부터)
|
||||
val detail = opened?.let { c -> (s.top + s.picks).firstOrNull { it.code == c } }
|
||||
val pages = buildList {
|
||||
if (detail != null) add(Page.DETAIL)
|
||||
if (s.slots.isNotEmpty()) add(Page.HOURS)
|
||||
if (s.events.isNotEmpty()) add(Page.EVENTS)
|
||||
if (s.top.isNotEmpty()) add(Page.TOP)
|
||||
if (s.picks.isNotEmpty()) add(Page.PICKS)
|
||||
if (s.sunset != null) add(Page.SUNSET)
|
||||
if (s.slots.isNotEmpty()) add(Page.HOURS)
|
||||
}
|
||||
val state = rememberPagerState { pages.size }
|
||||
Box(Modifier.fillMaxSize()) {
|
||||
|
||||
@@ -1,45 +1,27 @@
|
||||
package kr.o2o.nalssigak
|
||||
|
||||
import android.app.PendingIntent
|
||||
import android.content.Intent
|
||||
import androidx.wear.watchface.complications.data.ComplicationData
|
||||
import androidx.wear.watchface.complications.data.ComplicationType
|
||||
import androidx.wear.watchface.complications.data.PlainComplicationText
|
||||
import androidx.wear.watchface.complications.data.RangedValueComplicationData
|
||||
import androidx.wear.watchface.complications.data.ShortTextComplicationData
|
||||
import androidx.wear.watchface.complications.datasource.ComplicationRequest
|
||||
import androidx.wear.watchface.complications.datasource.SuspendingComplicationDataSourceService
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.withContext
|
||||
import kotlin.math.roundToInt
|
||||
|
||||
/**
|
||||
* 워치 스킨 날씨 칸 + 가운데 1위. 스킨 칸이 8개까지라 한 칸에 몰아 준다.
|
||||
* 값 = 날씨 코드(0 맑음·1 비·2 천둥·3 눈) × 1000 + 1위 점수, 글자 = 지금 기온, 제목 = 1위 이름(없으면 빈 글자).
|
||||
*/
|
||||
/** 워치 스킨 아래 칩: 글자 = 지금 기온, 제목 = 비 소식. 스킨은 제목("비 와요"·"곧 비"·"천둥 쳐요"·"눈 와요")을 보고 빗줄기·눈송이와 가운데 구름도 그린다. */
|
||||
class RainComplicationService : SuspendingComplicationDataSourceService() {
|
||||
|
||||
override suspend fun onComplicationRequest(request: ComplicationRequest): ComplicationData? {
|
||||
val s = withContext(Dispatchers.IO) { SummaryRepo.load(this@RainComplicationService) } ?: return null
|
||||
val code = when (s.rainLabel) {
|
||||
"비 와요", "곧 비" -> 1
|
||||
"천둥 쳐요" -> 2
|
||||
"눈 와요" -> 3
|
||||
else -> 0
|
||||
}
|
||||
val top = s.top.firstOrNull()
|
||||
return data(code, top?.score ?: 0, s.tempC?.let { "${it.roundToInt()}°" } ?: "-°", top?.name ?: "")
|
||||
return data(s.tempC?.let { "${it.roundToInt()}°" } ?: "-°", s.rainLabel)
|
||||
}
|
||||
|
||||
override fun getPreviewData(type: ComplicationType): ComplicationData = data(0, 88, "20°", "산책각")
|
||||
override fun getPreviewData(type: ComplicationType): ComplicationData = data("20°", "비 없음")
|
||||
|
||||
private fun data(code: Int, score: Int, temp: String, name: String): ComplicationData {
|
||||
// 가운데 구슬을 누르면 앱 첫 장
|
||||
val open = PendingIntent.getActivity(this, 0, Intent(this, MainActivity::class.java)
|
||||
.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TASK), PendingIntent.FLAG_IMMUTABLE or PendingIntent.FLAG_UPDATE_CURRENT)
|
||||
return RangedValueComplicationData.Builder(code * 1000f + score, 0f, 3100f, PlainComplicationText.Builder("$name $score, $temp").build())
|
||||
.setText(PlainComplicationText.Builder(temp).build())
|
||||
.setTitle(PlainComplicationText.Builder(name).build())
|
||||
.setTapAction(open)
|
||||
.build()
|
||||
}
|
||||
private fun data(temp: String, rain: String) = ShortTextComplicationData.Builder(
|
||||
PlainComplicationText.Builder(temp).build(),
|
||||
PlainComplicationText.Builder("$temp $rain").build(),
|
||||
).setTitle(PlainComplicationText.Builder(rain).build()).build()
|
||||
}
|
||||
@@ -60,7 +60,7 @@ data class Summary(
|
||||
else -> null
|
||||
}
|
||||
|
||||
/** 비 소식. 스킨 날씨 칸(RainComplicationService)이 이 글자로 날씨 코드를 정한다 */
|
||||
/** 스킨 칩의 비 소식. 스킨은 이 글자를 보고 가운데를 비구름·천둥 구름·눈구름으로 바꾼다 */
|
||||
val rainLabel: String get() = when {
|
||||
precip == "snow" -> "눈 와요"
|
||||
thunder == true -> "천둥 쳐요"
|
||||
|
||||
@@ -1,4 +1,2 @@
|
||||
org.gradle.jvmargs=-Xmx2g
|
||||
android.useAndroidX=true
|
||||
# 워치 스킨 버전. 스킨(watchface.xml·리소스)을 바꾸면 1 올린다. 앱은 깔린 스킨이 이보다 낮으면 앱에 실은 스킨으로 바꿔 끼운다
|
||||
NALSSIGAK_SKIN_VERSION=2
|
||||
@@ -9,16 +9,15 @@ android {
|
||||
compileSdk = 37
|
||||
|
||||
defaultConfig {
|
||||
// 앱(:app)이 Watch Face Push 로 같이 설치하려면 "<앱 패키지>.watchfacepush.<이름>" 이어야 한다
|
||||
applicationId = "kr.o2o.nalssigak.watchfacepush.skin"
|
||||
applicationId = "kr.o2o.nalssigak.watchface"
|
||||
// WFF 버전 2 는 Wear OS 5(API 34)부터
|
||||
minSdk = 34
|
||||
targetSdk = 34
|
||||
versionCode = providers.gradleProperty("NALSSIGAK_SKIN_VERSION").get().toInt()
|
||||
versionCode = 1
|
||||
versionName = "0.1"
|
||||
}
|
||||
// 스킨 APK 엔 dex 가 없어야 한다 (Play 번들, 앱에 싣는 Watch Face Push 둘 다). R8 이 R 클래스까지 다 걷어내게
|
||||
buildTypes.all {
|
||||
buildTypes.getByName("release") {
|
||||
// 스킨 번들엔 dex 가 없어야 한다. R8 이 R 클래스까지 다 걷어내게
|
||||
isMinifyEnabled = true
|
||||
// 스킨 XML 이 이름으로만 부르는 아이콘·글꼴을 안 쓰는 걸로 보고 지운다. 켜지 말 것
|
||||
isShrinkResources = false
|
||||
|
||||
@@ -117,19 +117,21 @@ def text(x, y, w, h, family, size, color, expr, amb=False):
|
||||
<Text align="CENTER" ellipsis="TRUE"><Font family="{family}" size="{size}" color="{color}"><Template><![CDATA[%s]]><Parameter expression="{expr}"/></Template></Font></Text>
|
||||
</PartText>'''
|
||||
|
||||
def orb_text():
|
||||
"""해 구슬 위 1위 점수·이름. 날씨 칸 값: 값 = 날씨 코드 × 1000 + 1위 점수, 제목 = 1위 이름 (1위가 없으면 빈 제목)"""
|
||||
def orb_slot():
|
||||
x, y = CX - ORB // 2, CY - ORB // 2
|
||||
body = (text(x, y + int(ORB * .19), ORB, int(ORB * .45), "bagel_fat_one", 50, "#FFFFFFFF", f"round({VALUE} % 1000)")
|
||||
+ text(x + 14, y + int(ORB * .62), ORB - 28, 28, "jua", 19, "#FFFFFFFF", "[COMPLICATION.TITLE]"))
|
||||
return f'''<Condition>
|
||||
<Expressions><Expression name="ranked"><![CDATA[[COMPLICATION.TITLE] != ""]]></Expression></Expressions>
|
||||
<Compare expression="ranked">
|
||||
body = text(0, int(ORB * .19), ORB, int(ORB * .45), "bagel_fat_one", 50, "#FFFFFFFF", "[COMPLICATION.TEXT]") + text(14, int(ORB * .62), ORB - 28, 28, "jua", 19, "#FFFFFFFF", "[COMPLICATION.TITLE]")
|
||||
return f'''<ComplicationSlot slotId="0" x="{x}" y="{y}" width="{ORB}" height="{ORB}" displayName="slot_rank1" supportedTypes="RANGED_VALUE SHORT_TEXT EMPTY" isCustomizable="TRUE">
|
||||
<DefaultProviderPolicy defaultSystemProvider="EMPTY" defaultSystemProviderType="EMPTY" primaryProvider="{APP}/{APP}.Rank1ComplicationService" primaryProviderType="RANGED_VALUE"/>
|
||||
<BoundingOval x="0" y="0" width="{ORB}" height="{ORB}"/>
|
||||
<Complication type="RANGED_VALUE">
|
||||
{body}
|
||||
</Compare>
|
||||
</Condition>'''
|
||||
</Complication>
|
||||
<Complication type="SHORT_TEXT">
|
||||
{body}
|
||||
</Complication>
|
||||
<Complication type="EMPTY"/>
|
||||
</ComplicationSlot>'''
|
||||
|
||||
VALUE = "[COMPLICATION.RANGED_VALUE_VALUE]"
|
||||
PROGRESS = "clamp([COMPLICATION.RANGED_VALUE_VALUE], [COMPLICATION.RANGED_VALUE_MIN], [COMPLICATION.RANGED_VALUE_MAX]) / ([COMPLICATION.RANGED_VALUE_MAX] - [COMPLICATION.RANGED_VALUE_MIN]) * 360"
|
||||
|
||||
def icon_by_title(x, y, size):
|
||||
@@ -180,11 +182,10 @@ def chip(x, w, icon, expr):
|
||||
{text(x + 32, CHIP_Y + 5, w - 38, 30, "jua", 21, INK, expr, amb=True)}'''
|
||||
|
||||
def precip_slot():
|
||||
"""화면 전체를 덮는 숨은 칸. WFF 는 칸이 8개까지라 날씨와 1위를 이 칸 하나로 받는다.
|
||||
날씨각 앱(RainComplicationService)이 값 = 날씨 코드 × 1000 + 1위 점수, 글자 = 기온, 제목 = 1위 이름을 준다.
|
||||
날씨 코드 1(비·곧 비)이면 빗줄기와 비구름, 2(천둥)면 빗줄기와 번개 구름, 3(눈)이면 눈송이와 눈구름을 가운데 해 자리에 그리고,
|
||||
그 위에 1위 점수·이름, 아래에 기온 칩을 그린다. 날씨 값은 이 칸 안에서만 읽혀서 맑을 때 해·달 구슬도 여기서 그린다.
|
||||
터치는 가운데 구슬만 받는다(누르면 앱). 주기는 60 의 약수여야 분이 바뀔 때 튀지 않는다."""
|
||||
"""화면 전체를 덮는 숨은 칸. 날씨각 앱(RainComplicationService)이 글자 = 기온, 제목 = 비 소식을 주면
|
||||
아래에 기온·비 칩을 그리고, 비 소식이 "비 와요"·"곧 비"면 빗줄기와 비구름, "천둥 쳐요"면 빗줄기와 번개 구름,
|
||||
"눈 와요"면 눈송이와 눈구름을 가운데 해 자리에 그린다. 날씨 값은 이 칸 안에서만 읽혀서 맑을 때 해·달 구슬도 여기서 그린다.
|
||||
터치는 막지 않게 BoundingOval 을 1px 로 둔다. 주기는 60 의 약수여야 분이 바뀔 때 튀지 않는다."""
|
||||
import random
|
||||
r = random.Random(7)
|
||||
drops, flakes = [], []
|
||||
@@ -206,16 +207,15 @@ def precip_slot():
|
||||
<Transform target="x" value="{x} + 9 * sin(rad(360 * fract([SECOND_MILLISECOND] / 3 + {ph:.2f})))"/>
|
||||
</PartDraw>''')
|
||||
shade = lambda c: f'<PartDraw x="0" y="0" width="{W}" height="{W}">{AMB0}<Rectangle x="0" y="0" width="{W}" height="{W}"><Fill color="{c}"/></Rectangle></PartDraw>'
|
||||
mode = f"floor({VALUE} / 1000)"
|
||||
return f'''<ComplicationSlot slotId="7" x="0" y="0" width="{W}" height="{W}" displayName="slot_precip" supportedTypes="RANGED_VALUE EMPTY" isCustomizable="FALSE">
|
||||
<DefaultProviderPolicy defaultSystemProvider="EMPTY" defaultSystemProviderType="EMPTY" primaryProvider="{APP}/{APP}.RainComplicationService" primaryProviderType="RANGED_VALUE"/>
|
||||
<BoundingOval x="0" y="0" width="{W}" height="{W}"/>
|
||||
<Complication type="RANGED_VALUE">
|
||||
return f'''<ComplicationSlot slotId="7" x="0" y="0" width="{W}" height="{W}" displayName="slot_precip" supportedTypes="SHORT_TEXT EMPTY" isCustomizable="FALSE">
|
||||
<DefaultProviderPolicy defaultSystemProvider="EMPTY" defaultSystemProviderType="EMPTY" primaryProvider="{APP}/{APP}.RainComplicationService" primaryProviderType="SHORT_TEXT"/>
|
||||
<BoundingOval x="0" y="0" width="1" height="1"/>
|
||||
<Complication type="SHORT_TEXT">
|
||||
<Condition>
|
||||
<Expressions>
|
||||
<Expression name="thunder"><![CDATA[{mode} == 2]]></Expression>
|
||||
<Expression name="rain"><![CDATA[{mode} == 1]]></Expression>
|
||||
<Expression name="snow"><![CDATA[{mode} == 3]]></Expression>
|
||||
<Expression name="thunder"><![CDATA[[COMPLICATION.TITLE] == "천둥 쳐요"]]></Expression>
|
||||
<Expression name="rain"><![CDATA[[COMPLICATION.TITLE] == "비 와요" || [COMPLICATION.TITLE] == "곧 비"]]></Expression>
|
||||
<Expression name="snow"><![CDATA[[COMPLICATION.TITLE] == "눈 와요"]]></Expression>
|
||||
<Expression name="night"><![CDATA[{NIGHT_EXPR}]]></Expression>
|
||||
</Expressions>
|
||||
<Compare expression="thunder">
|
||||
@@ -235,8 +235,8 @@ def precip_slot():
|
||||
</Compare>
|
||||
{sun_or_moon()}
|
||||
</Condition>
|
||||
{chip(CX - 52, 104, "thermo", "[COMPLICATION.TEXT]")}
|
||||
{orb_text()}
|
||||
{chip(108, 104, "thermo", "[COMPLICATION.TEXT]")}
|
||||
{chip(220, 122, "umbrella", "[COMPLICATION.TITLE]")}
|
||||
</Complication>
|
||||
<Complication type="EMPTY">
|
||||
<Condition>
|
||||
@@ -273,7 +273,7 @@ exprs = "\n ".join(f'<Expression name="{k}"><![CDATA[{v[0].replace(">
|
||||
compares = "\n ".join(f'<Compare expression="{k}">\n {mode_block(v[1], v[2], v[3])}\n </Compare>' for k, v in MODES.items())
|
||||
|
||||
xml = f'''<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!-- 날씨각 워치 스킨: 시간대 하늘, 해 구슬(1위, 비·눈·천둥이면 구름), 둘레 링(2~7위), 날짜 밑 근처 축제 한 줄, 아래 기온 칩. 링을 누르면 앱이 그 각 상세로 열린다. 점수는 날씨각 앱의 RankNComplicationService 가 공급한다.
|
||||
<!-- 날씨각 워치 스킨: 시간대 하늘, 해 구슬(1위, 비·눈·천둥이면 구름), 둘레 링(2~7위), 날짜 밑 근처 축제 한 줄, 아래 기온·비 칩. 링을 누르면 앱이 그 각 상세로 열린다. 점수는 날씨각 앱의 RankNComplicationService 가 공급한다.
|
||||
직접 고치지 말고 watch/watchface/gen_watchface.py 를 고친 뒤 다시 만든다: python3 gen_watchface.py src/main/res/raw/watchface.xml -->
|
||||
<WatchFace width="{W}" height="{W}">
|
||||
<Metadata key="CLOCK_TYPE" value="DIGITAL"/>
|
||||
@@ -293,6 +293,7 @@ xml = f'''<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!-- 가운데 해·달·구름은 날씨 칸 안에서 비 막 위에 그린다 -->
|
||||
{precip_slot()}
|
||||
{clock("#FFFFFFFF", ambient_visible=True)}
|
||||
{orb_slot()}
|
||||
{"".join(ring_slot(i, a) for i, a in enumerate(ANGLES))}
|
||||
{event_slot()}
|
||||
</Scene>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!-- 날씨각 워치 스킨: 시간대 하늘, 해 구슬(1위, 비·눈·천둥이면 구름), 둘레 링(2~7위), 날짜 밑 근처 축제 한 줄, 아래 기온 칩. 링을 누르면 앱이 그 각 상세로 열린다. 점수는 날씨각 앱의 RankNComplicationService 가 공급한다.
|
||||
<!-- 날씨각 워치 스킨: 시간대 하늘, 해 구슬(1위, 비·눈·천둥이면 구름), 둘레 링(2~7위), 날짜 밑 근처 축제 한 줄, 아래 기온·비 칩. 링을 누르면 앱이 그 각 상세로 열린다. 점수는 날씨각 앱의 RankNComplicationService 가 공급한다.
|
||||
직접 고치지 말고 watch/watchface/gen_watchface.py 를 고친 뒤 다시 만든다: python3 gen_watchface.py src/main/res/raw/watchface.xml -->
|
||||
<WatchFace width="450" height="450">
|
||||
<Metadata key="CLOCK_TYPE" value="DIGITAL"/>
|
||||
@@ -148,15 +148,15 @@
|
||||
</Condition>
|
||||
<!-- 주의: 칸(ComplicationSlot) 순서·slotId 를 바꿔 덮어 설치하면 기존 기기에서 공급원이 한 칸씩 밀린다 (에뮬레이터에서 확인). 새 칸은 맨 뒤에 붙인다 -->
|
||||
<!-- 가운데 해·달·구름은 날씨 칸 안에서 비 막 위에 그린다 -->
|
||||
<ComplicationSlot slotId="7" x="0" y="0" width="450" height="450" displayName="slot_precip" supportedTypes="RANGED_VALUE EMPTY" isCustomizable="FALSE">
|
||||
<DefaultProviderPolicy defaultSystemProvider="EMPTY" defaultSystemProviderType="EMPTY" primaryProvider="kr.o2o.nalssigak/kr.o2o.nalssigak.RainComplicationService" primaryProviderType="RANGED_VALUE"/>
|
||||
<BoundingOval x="0" y="0" width="450" height="450"/>
|
||||
<Complication type="RANGED_VALUE">
|
||||
<ComplicationSlot slotId="7" x="0" y="0" width="450" height="450" displayName="slot_precip" supportedTypes="SHORT_TEXT EMPTY" isCustomizable="FALSE">
|
||||
<DefaultProviderPolicy defaultSystemProvider="EMPTY" defaultSystemProviderType="EMPTY" primaryProvider="kr.o2o.nalssigak/kr.o2o.nalssigak.RainComplicationService" primaryProviderType="SHORT_TEXT"/>
|
||||
<BoundingOval x="0" y="0" width="1" height="1"/>
|
||||
<Complication type="SHORT_TEXT">
|
||||
<Condition>
|
||||
<Expressions>
|
||||
<Expression name="thunder"><![CDATA[floor([COMPLICATION.RANGED_VALUE_VALUE] / 1000) == 2]]></Expression>
|
||||
<Expression name="rain"><![CDATA[floor([COMPLICATION.RANGED_VALUE_VALUE] / 1000) == 1]]></Expression>
|
||||
<Expression name="snow"><![CDATA[floor([COMPLICATION.RANGED_VALUE_VALUE] / 1000) == 3]]></Expression>
|
||||
<Expression name="thunder"><![CDATA[[COMPLICATION.TITLE] == "천둥 쳐요"]]></Expression>
|
||||
<Expression name="rain"><![CDATA[[COMPLICATION.TITLE] == "비 와요" || [COMPLICATION.TITLE] == "곧 비"]]></Expression>
|
||||
<Expression name="snow"><![CDATA[[COMPLICATION.TITLE] == "눈 와요"]]></Expression>
|
||||
<Expression name="night"><![CDATA[[HOUR_0_23] < 5 || [HOUR_0_23] >= 21]]></Expression>
|
||||
</Expressions>
|
||||
<Compare expression="thunder">
|
||||
@@ -495,24 +495,22 @@
|
||||
<Ellipse x="16" y="84" width="21" height="12"><Fill color="#73FF7A8A"/></Ellipse><Ellipse x="97" y="84" width="21" height="12"><Fill color="#73FF7A8A"/></Ellipse>
|
||||
</PartDraw></Default>
|
||||
</Condition>
|
||||
<PartDraw x="173" y="366" width="104" height="40"><Variant mode="AMBIENT" target="alpha" value="0"/>
|
||||
<PartDraw x="108" y="366" width="104" height="40"><Variant mode="AMBIENT" target="alpha" value="0"/>
|
||||
<RoundRectangle x="0" y="0" width="104" height="40" cornerRadiusX="20" cornerRadiusY="20"><Fill color="#B8FFFFFF"/></RoundRectangle>
|
||||
<RoundRectangle x="0" y="35" width="104" height="5" cornerRadiusX="2" cornerRadiusY="2"><Fill color="#E6D9E5F4"/></RoundRectangle>
|
||||
</PartDraw>
|
||||
<PartImage x="181" y="372" width="26" height="26"><Variant mode="AMBIENT" target="alpha" value="0"/><Image resource="e_thermo"/></PartImage>
|
||||
<PartText x="205" y="371" width="66" height="30"><Variant mode="AMBIENT" target="alpha" value="0"/>
|
||||
<PartImage x="116" y="372" width="26" height="26"><Variant mode="AMBIENT" target="alpha" value="0"/><Image resource="e_thermo"/></PartImage>
|
||||
<PartText x="140" y="371" width="66" height="30"><Variant mode="AMBIENT" target="alpha" value="0"/>
|
||||
<Text align="CENTER" ellipsis="TRUE"><Font family="jua" size="21" color="#FF28304A"><Template><![CDATA[%s]]><Parameter expression="[COMPLICATION.TEXT]"/></Template></Font></Text>
|
||||
</PartText>
|
||||
<Condition>
|
||||
<Expressions><Expression name="ranked"><![CDATA[[COMPLICATION.TITLE] != ""]]></Expression></Expressions>
|
||||
<Compare expression="ranked">
|
||||
<PartText x="157" y="209" width="136" height="61">
|
||||
<Text align="CENTER" ellipsis="TRUE"><Font family="bagel_fat_one" size="50" color="#FFFFFFFF"><Template><![CDATA[%s]]><Parameter expression="round([COMPLICATION.RANGED_VALUE_VALUE] % 1000)"/></Template></Font></Text>
|
||||
</PartText><PartText x="171" y="268" width="108" height="28">
|
||||
<Text align="CENTER" ellipsis="TRUE"><Font family="jua" size="19" color="#FFFFFFFF"><Template><![CDATA[%s]]><Parameter expression="[COMPLICATION.TITLE]"/></Template></Font></Text>
|
||||
<PartDraw x="220" y="366" width="122" height="40"><Variant mode="AMBIENT" target="alpha" value="0"/>
|
||||
<RoundRectangle x="0" y="0" width="122" height="40" cornerRadiusX="20" cornerRadiusY="20"><Fill color="#B8FFFFFF"/></RoundRectangle>
|
||||
<RoundRectangle x="0" y="35" width="122" height="5" cornerRadiusX="2" cornerRadiusY="2"><Fill color="#E6D9E5F4"/></RoundRectangle>
|
||||
</PartDraw>
|
||||
<PartImage x="228" y="372" width="26" height="26"><Variant mode="AMBIENT" target="alpha" value="0"/><Image resource="e_umbrella"/></PartImage>
|
||||
<PartText x="252" y="371" width="84" height="30"><Variant mode="AMBIENT" target="alpha" value="0"/>
|
||||
<Text align="CENTER" ellipsis="TRUE"><Font family="jua" size="21" color="#FF28304A"><Template><![CDATA[%s]]><Parameter expression="[COMPLICATION.TITLE]"/></Template></Font></Text>
|
||||
</PartText>
|
||||
</Compare>
|
||||
</Condition>
|
||||
</Complication>
|
||||
<Complication type="EMPTY">
|
||||
<Condition>
|
||||
@@ -537,6 +535,25 @@
|
||||
<Font family="bagel_fat_one" size="68" color="#FFFFFFFF"/>
|
||||
</TimeText>
|
||||
</DigitalClock>
|
||||
<ComplicationSlot slotId="0" x="157" y="184" width="136" height="136" displayName="slot_rank1" supportedTypes="RANGED_VALUE SHORT_TEXT EMPTY" isCustomizable="TRUE">
|
||||
<DefaultProviderPolicy defaultSystemProvider="EMPTY" defaultSystemProviderType="EMPTY" primaryProvider="kr.o2o.nalssigak/kr.o2o.nalssigak.Rank1ComplicationService" primaryProviderType="RANGED_VALUE"/>
|
||||
<BoundingOval x="0" y="0" width="136" height="136"/>
|
||||
<Complication type="RANGED_VALUE">
|
||||
<PartText x="0" y="25" width="136" height="61">
|
||||
<Text align="CENTER" ellipsis="TRUE"><Font family="bagel_fat_one" size="50" color="#FFFFFFFF"><Template><![CDATA[%s]]><Parameter expression="[COMPLICATION.TEXT]"/></Template></Font></Text>
|
||||
</PartText><PartText x="14" y="84" width="108" height="28">
|
||||
<Text align="CENTER" ellipsis="TRUE"><Font family="jua" size="19" color="#FFFFFFFF"><Template><![CDATA[%s]]><Parameter expression="[COMPLICATION.TITLE]"/></Template></Font></Text>
|
||||
</PartText>
|
||||
</Complication>
|
||||
<Complication type="SHORT_TEXT">
|
||||
<PartText x="0" y="25" width="136" height="61">
|
||||
<Text align="CENTER" ellipsis="TRUE"><Font family="bagel_fat_one" size="50" color="#FFFFFFFF"><Template><![CDATA[%s]]><Parameter expression="[COMPLICATION.TEXT]"/></Template></Font></Text>
|
||||
</PartText><PartText x="14" y="84" width="108" height="28">
|
||||
<Text align="CENTER" ellipsis="TRUE"><Font family="jua" size="19" color="#FFFFFFFF"><Template><![CDATA[%s]]><Parameter expression="[COMPLICATION.TITLE]"/></Template></Font></Text>
|
||||
</PartText>
|
||||
</Complication>
|
||||
<Complication type="EMPTY"/>
|
||||
</ComplicationSlot>
|
||||
<ComplicationSlot slotId="1" x="71" y="149" width="68" height="68" displayName="slot_ring" supportedTypes="RANGED_VALUE SHORT_TEXT EMPTY" isCustomizable="TRUE">
|
||||
<DefaultProviderPolicy defaultSystemProvider="EMPTY" defaultSystemProviderType="EMPTY" primaryProvider="kr.o2o.nalssigak/kr.o2o.nalssigak.Rank2ComplicationService" primaryProviderType="RANGED_VALUE"/>
|
||||
<BoundingOval x="0" y="0" width="68" height="68"/>
|
||||
|
||||
Reference in new issue
Block a user