commit 807df3d67856410fef0dc197a8cd2d65bdf5fa44 Author: kihong.kim Date: Sat Jan 24 19:41:19 2026 +0900 Initial commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..3b95ea2 --- /dev/null +++ b/.gitignore @@ -0,0 +1,28 @@ +.DS_Store + +# Node +backend/node_modules +backend/npm-debug.log +backend/.env +backend/.env.* +backend/.npmrc + +# Flutter +flutter_app/.dart_tool +flutter_app/build +flutter_app/.flutter-plugins +flutter_app/.flutter-plugins-dependencies +flutter_app/.packages +flutter_app/android/.gradle +flutter_app/android/local.properties +flutter_app/android/app/debug.keystore +flutter_app/ios/Flutter/Flutter.framework +flutter_app/ios/Flutter/Flutter.podspec +flutter_app/ios/Flutter/Generated.xcconfig +flutter_app/ios/Flutter/ephemeral +flutter_app/ios/Pods +flutter_app/ios/.symlinks + +# IDE +.idea +.vscode diff --git a/README.md b/README.md new file mode 100644 index 0000000..5a6d01a --- /dev/null +++ b/README.md @@ -0,0 +1,55 @@ +# Bini Google TV Dashboard + +Google TV용 대시보드 앱과 백엔드 API 프로젝트입니다. + +## 구성 +- `backend`: Node.js + Express + MongoDB API +- `flutter_app`: Flutter Google TV 앱 + +## 백엔드 실행 (로컬) +```bash +cd backend +cp .env.example .env +# .env에 OPENWEATHER_API_KEY 등 필요한 값 설정 +npm install +npm start +``` + +### MongoDB +로컬 MongoDB가 필요합니다. +- 기본 연결: `mongodb://localhost:27017/google-tv-dashboard` +- 변경 시 `backend/.env`의 `MONGODB_URI` 수정 + +## 백엔드 실행 (Docker) +```bash +docker compose up -d +``` + +## Flutter 빌드 +```bash +cd flutter_app +flutter build apk --release +``` + +### 서버 주소 주입 +Google TV에서 로컬 백엔드로 연결하려면 Mac의 IP를 사용하세요. +```bash +flutter build apk --release --dart-define=API_BASE_URL=http://:4000 +``` + +## APK 설치 +생성된 APK 경로: +`flutter_app/build/app/outputs/flutter-apk/app-release.apk` + +### Google TV 설치 (USB 메모리) +1. APK를 USB 메모리에 복사 +2. TV에 USB 꽂기 +3. 파일 관리자 앱에서 APK 실행 → 설치 + +## 어드민 +관리 화면에서 성경 말씀을 등록할 수 있습니다. +- 랜덤 노출 +- 날짜 지정은 옵션 + +## 환경 변수 +`backend/.env.example` 참고 diff --git a/backend/.dockerignore b/backend/.dockerignore new file mode 100644 index 0000000..f8938d3 --- /dev/null +++ b/backend/.dockerignore @@ -0,0 +1,14 @@ +node_modules +npm-debug.log +.npmrc +.env +.env.* +.git +.gitignore +Dockerfile +*.md +coverage +tests +docs +build +dist diff --git a/backend/Dockerfile b/backend/Dockerfile new file mode 100644 index 0000000..2b2acad --- /dev/null +++ b/backend/Dockerfile @@ -0,0 +1,13 @@ +FROM node:20-alpine + +WORKDIR /app + +COPY package.json ./ + +RUN npm install --omit=dev + +COPY . . + +EXPOSE 4000 + +CMD ["npm", "start"] diff --git a/backend/config/api.js b/backend/config/api.js new file mode 100644 index 0000000..dd35a6d --- /dev/null +++ b/backend/config/api.js @@ -0,0 +1,13 @@ +const weatherBaseUrl = "https://api.openweathermap.org/data/2.5"; + +const config = { + weather: { + baseUrl: weatherBaseUrl, + apiKey: process.env.OPENWEATHER_API_KEY || "", + city: process.env.WEATHER_CITY || "Seoul", + units: process.env.WEATHER_UNITS || "metric", + language: process.env.WEATHER_LANG || "en", + }, +}; + +module.exports = config; diff --git a/backend/config/db.js b/backend/config/db.js new file mode 100644 index 0000000..e0ef318 --- /dev/null +++ b/backend/config/db.js @@ -0,0 +1,14 @@ +const mongoose = require("mongoose"); + +const connectDb = async () => { + const mongoUri = process.env.MONGODB_URI; + if (!mongoUri) { + throw new Error("MONGODB_URI is not set"); + } + + mongoose.set("strictQuery", true); + await mongoose.connect(mongoUri); + return mongoose.connection; +}; + +module.exports = connectDb; diff --git a/backend/models/Announcement.js b/backend/models/Announcement.js new file mode 100644 index 0000000..f0f0fe2 --- /dev/null +++ b/backend/models/Announcement.js @@ -0,0 +1,13 @@ +const mongoose = require("mongoose"); + +const announcementSchema = new mongoose.Schema( + { + title: { type: String, required: true }, + content: { type: String }, + priority: { type: Number, default: 0 }, + active: { type: Boolean, default: true }, + }, + { timestamps: true } +); + +module.exports = mongoose.model("Announcement", announcementSchema); diff --git a/backend/models/BibleVerse.js b/backend/models/BibleVerse.js new file mode 100644 index 0000000..21aafb4 --- /dev/null +++ b/backend/models/BibleVerse.js @@ -0,0 +1,13 @@ +const mongoose = require("mongoose"); + +const bibleVerseSchema = new mongoose.Schema( + { + text: { type: String, required: true }, + reference: { type: String, required: true }, + date: { type: String, trim: true }, + active: { type: Boolean, default: true }, + }, + { timestamps: true } +); + +module.exports = mongoose.model("BibleVerse", bibleVerseSchema); diff --git a/backend/models/FamilyMember.js b/backend/models/FamilyMember.js new file mode 100644 index 0000000..74f80b4 --- /dev/null +++ b/backend/models/FamilyMember.js @@ -0,0 +1,13 @@ +const mongoose = require("mongoose"); + +const familyMemberSchema = new mongoose.Schema( + { + name: { type: String, required: true }, + emoji: { type: String, required: true }, + color: { type: String, required: true }, + order: { type: Number, default: 0 }, + }, + { timestamps: true } +); + +module.exports = mongoose.model("FamilyMember", familyMemberSchema); diff --git a/backend/models/Photo.js b/backend/models/Photo.js new file mode 100644 index 0000000..2e4d0e8 --- /dev/null +++ b/backend/models/Photo.js @@ -0,0 +1,12 @@ +const mongoose = require("mongoose"); + +const photoSchema = new mongoose.Schema( + { + url: { type: String, required: true }, + caption: { type: String }, + active: { type: Boolean, default: true }, + }, + { timestamps: true } +); + +module.exports = mongoose.model("Photo", photoSchema); diff --git a/backend/models/Schedule.js b/backend/models/Schedule.js new file mode 100644 index 0000000..b0adb7f --- /dev/null +++ b/backend/models/Schedule.js @@ -0,0 +1,15 @@ +const mongoose = require("mongoose"); + +const scheduleSchema = new mongoose.Schema( + { + title: { type: String, required: true }, + description: { type: String }, + startDate: { type: Date, required: true }, + endDate: { type: Date, required: true }, + familyMemberId: { type: mongoose.Schema.Types.ObjectId, ref: "FamilyMember" }, + isAllDay: { type: Boolean, default: false }, + }, + { timestamps: true } +); + +module.exports = mongoose.model("Schedule", scheduleSchema); diff --git a/backend/models/Setting.js b/backend/models/Setting.js new file mode 100644 index 0000000..e14b9a9 --- /dev/null +++ b/backend/models/Setting.js @@ -0,0 +1,11 @@ +const mongoose = require("mongoose"); + +const settingSchema = new mongoose.Schema( + { + key: { type: String, required: true, unique: true }, + value: { type: mongoose.Schema.Types.Mixed }, + }, + { timestamps: true } +); + +module.exports = mongoose.model("Setting", settingSchema); diff --git a/backend/models/Todo.js b/backend/models/Todo.js new file mode 100644 index 0000000..9215f94 --- /dev/null +++ b/backend/models/Todo.js @@ -0,0 +1,13 @@ +const mongoose = require("mongoose"); + +const todoSchema = new mongoose.Schema( + { + familyMemberId: { type: mongoose.Schema.Types.ObjectId, ref: "FamilyMember" }, + title: { type: String, required: true }, + completed: { type: Boolean, default: false }, + dueDate: { type: Date }, + }, + { timestamps: true } +); + +module.exports = mongoose.model("Todo", todoSchema); diff --git a/backend/package-lock.json b/backend/package-lock.json new file mode 100644 index 0000000..6801fc2 --- /dev/null +++ b/backend/package-lock.json @@ -0,0 +1,1213 @@ +{ + "name": "bini-google-tv-backend", + "version": "0.1.0", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "bini-google-tv-backend", + "version": "0.1.0", + "dependencies": { + "axios": "^1.7.9", + "cors": "^2.8.5", + "dotenv": "^16.4.7", + "express": "^4.19.2", + "mongoose": "^8.9.0" + } + }, + "node_modules/@mongodb-js/saslprep": { + "version": "1.4.5", + "resolved": "https://registry.npmjs.org/@mongodb-js/saslprep/-/saslprep-1.4.5.tgz", + "integrity": "sha512-k64Lbyb7ycCSXHSLzxVdb2xsKGPMvYZfCICXvDsI8Z65CeWQzTEKS4YmGbnqw+U9RBvLPTsB6UCmwkgsDTGWIw==", + "license": "MIT", + "dependencies": { + "sparse-bitfield": "^3.0.3" + } + }, + "node_modules/@types/webidl-conversions": { + "version": "7.0.3", + "resolved": "https://registry.npmjs.org/@types/webidl-conversions/-/webidl-conversions-7.0.3.tgz", + "integrity": "sha512-CiJJvcRtIgzadHCYXw7dqEnMNRjhGZlYK05Mj9OyktqV8uVT8fD2BFOB7S1uwBE3Kj2Z+4UyPmFw/Ixgw/LAlA==", + "license": "MIT" + }, + "node_modules/@types/whatwg-url": { + "version": "11.0.5", + "resolved": "https://registry.npmjs.org/@types/whatwg-url/-/whatwg-url-11.0.5.tgz", + "integrity": "sha512-coYR071JRaHa+xoEvvYqvnIHaVqaYrLPbsufM9BF63HkwI5Lgmy2QR8Q5K/lYDYo5AK82wOvSOS0UsLTpTG7uQ==", + "license": "MIT", + "dependencies": { + "@types/webidl-conversions": "*" + } + }, + "node_modules/accepts": { + "version": "1.3.8", + "resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.8.tgz", + "integrity": "sha512-PYAthTa2m2VKxuvSD3DPC/Gy+U+sOA1LAuT8mkmRuvw+NACSaeXEQ+NHcVF7rONl6qcaxV3Uuemwawk+7+SJLw==", + "license": "MIT", + "dependencies": { + "mime-types": "~2.1.34", + "negotiator": "0.6.3" + }, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/array-flatten": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz", + "integrity": "sha512-PCVAQswWemu6UdxsDFFX/+gVeYqKAod3D3UVm91jHwynguOwAvYPhx8nNlM++NqRcK6CxxpUafjmhIdKiHibqg==", + "license": "MIT" + }, + "node_modules/asynckit": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", + "integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==", + "license": "MIT" + }, + "node_modules/axios": { + "version": "1.13.2", + "resolved": "https://registry.npmjs.org/axios/-/axios-1.13.2.tgz", + "integrity": "sha512-VPk9ebNqPcy5lRGuSlKx752IlDatOjT9paPlm8A7yOuW2Fbvp4X3JznJtT4f0GzGLLiWE9W8onz51SqLYwzGaA==", + "license": "MIT", + "dependencies": { + "follow-redirects": "^1.15.6", + "form-data": "^4.0.4", + "proxy-from-env": "^1.1.0" + } + }, + "node_modules/body-parser": { + "version": "1.20.4", + "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.20.4.tgz", + "integrity": "sha512-ZTgYYLMOXY9qKU/57FAo8F+HA2dGX7bqGc71txDRC1rS4frdFI5R7NhluHxH6M0YItAP0sHB4uqAOcYKxO6uGA==", + "license": "MIT", + "dependencies": { + "bytes": "~3.1.2", + "content-type": "~1.0.5", + "debug": "2.6.9", + "depd": "2.0.0", + "destroy": "~1.2.0", + "http-errors": "~2.0.1", + "iconv-lite": "~0.4.24", + "on-finished": "~2.4.1", + "qs": "~6.14.0", + "raw-body": "~2.5.3", + "type-is": "~1.6.18", + "unpipe": "~1.0.0" + }, + "engines": { + "node": ">= 0.8", + "npm": "1.2.8000 || >= 1.4.16" + } + }, + "node_modules/bson": { + "version": "6.10.4", + "resolved": "https://registry.npmjs.org/bson/-/bson-6.10.4.tgz", + "integrity": "sha512-WIsKqkSC0ABoBJuT1LEX+2HEvNmNKKgnTAyd0fL8qzK4SH2i9NXg+t08YtdZp/V9IZ33cxe3iV4yM0qg8lMQng==", + "license": "Apache-2.0", + "engines": { + "node": ">=16.20.1" + } + }, + "node_modules/bytes": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.2.tgz", + "integrity": "sha512-/Nf7TyzTx6S3yRJObOAV7956r8cr2+Oj8AC5dt8wSP3BQAoeX58NoHyCU8P8zGkNXStjTSi6fzO6F0pBdcYbEg==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/call-bind-apply-helpers": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/call-bind-apply-helpers/-/call-bind-apply-helpers-1.0.2.tgz", + "integrity": "sha512-Sp1ablJ0ivDkSzjcaJdxEunN5/XvksFJ2sMBFfq6x0ryhQV/2b/KwFe21cMpmHtPOSij8K99/wSfoEuTObmuMQ==", + "license": "MIT", + "dependencies": { + "es-errors": "^1.3.0", + "function-bind": "^1.1.2" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/call-bound": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/call-bound/-/call-bound-1.0.4.tgz", + "integrity": "sha512-+ys997U96po4Kx/ABpBCqhA9EuxJaQWDQg7295H4hBphv3IZg0boBKuwYpt4YXp6MZ5AmZQnU/tyMTlRpaSejg==", + "license": "MIT", + "dependencies": { + "call-bind-apply-helpers": "^1.0.2", + "get-intrinsic": "^1.3.0" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/combined-stream": { + "version": "1.0.8", + "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz", + "integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==", + "license": "MIT", + "dependencies": { + "delayed-stream": "~1.0.0" + }, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/content-disposition": { + "version": "0.5.4", + "resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.4.tgz", + "integrity": "sha512-FveZTNuGw04cxlAiWbzi6zTAL/lhehaWbTtgluJh4/E95DqMwTmha3KZN1aAWA8cFIhHzMZUvLevkw5Rqk+tSQ==", + "license": "MIT", + "dependencies": { + "safe-buffer": "5.2.1" + }, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/content-type": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/content-type/-/content-type-1.0.5.tgz", + "integrity": "sha512-nTjqfcBFEipKdXCv4YDQWCfmcLZKm81ldF0pAopTvyrFGVbcR6P/VAAd5G7N+0tTr8QqiU0tFadD6FK4NtJwOA==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/cookie": { + "version": "0.7.2", + "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.7.2.tgz", + "integrity": "sha512-yki5XnKuf750l50uGTllt6kKILY4nQ1eNIQatoXEByZ5dWgnKqbnqmTrBE5B4N7lrMJKQ2ytWMiTO2o0v6Ew/w==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/cookie-signature": { + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.0.7.tgz", + "integrity": "sha512-NXdYc3dLr47pBkpUCHtKSwIOQXLVn8dZEuywboCOJY/osA0wFSLlSawr3KN8qXJEyX66FcONTH8EIlVuK0yyFA==", + "license": "MIT" + }, + "node_modules/cors": { + "version": "2.8.6", + "resolved": "https://registry.npmjs.org/cors/-/cors-2.8.6.tgz", + "integrity": "sha512-tJtZBBHA6vjIAaF6EnIaq6laBBP9aq/Y3ouVJjEfoHbRBcHBAHYcMh/w8LDrk2PvIMMq8gmopa5D4V8RmbrxGw==", + "license": "MIT", + "dependencies": { + "object-assign": "^4", + "vary": "^1" + }, + "engines": { + "node": ">= 0.10" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, + "node_modules/debug": { + "version": "2.6.9", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", + "license": "MIT", + "dependencies": { + "ms": "2.0.0" + } + }, + "node_modules/delayed-stream": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", + "integrity": "sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==", + "license": "MIT", + "engines": { + "node": ">=0.4.0" + } + }, + "node_modules/depd": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/depd/-/depd-2.0.0.tgz", + "integrity": "sha512-g7nH6P6dyDioJogAAGprGpCtVImJhpPk/roCzdb3fIh61/s/nPsfR6onyMwkCAR/OlC3yBC0lESvUoQEAssIrw==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/destroy": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/destroy/-/destroy-1.2.0.tgz", + "integrity": "sha512-2sJGJTaXIIaR1w4iJSNoN0hnMY7Gpc/n8D4qSCJw8QqFWXf7cuAgnEHxBpweaVcPevC2l3KpjYCx3NypQQgaJg==", + "license": "MIT", + "engines": { + "node": ">= 0.8", + "npm": "1.2.8000 || >= 1.4.16" + } + }, + "node_modules/dotenv": { + "version": "16.6.1", + "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.6.1.tgz", + "integrity": "sha512-uBq4egWHTcTt33a72vpSG0z3HnPuIl6NqYcTrKEg2azoEyl2hpW0zqlxysq2pK9HlDIHyHyakeYaYnSAwd8bow==", + "license": "BSD-2-Clause", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://dotenvx.com" + } + }, + "node_modules/dunder-proto": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/dunder-proto/-/dunder-proto-1.0.1.tgz", + "integrity": "sha512-KIN/nDJBQRcXw0MLVhZE9iQHmG68qAVIBg9CqmUYjmQIhgij9U5MFvrqkUL5FbtyyzZuOeOt0zdeRe4UY7ct+A==", + "license": "MIT", + "dependencies": { + "call-bind-apply-helpers": "^1.0.1", + "es-errors": "^1.3.0", + "gopd": "^1.2.0" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/ee-first": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz", + "integrity": "sha512-WMwm9LhRUo+WUaRN+vRuETqG89IgZphVSNkdFgeb6sS/E4OrDIN7t48CAewSHXc6C8lefD8KKfr5vY61brQlow==", + "license": "MIT" + }, + "node_modules/encodeurl": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-2.0.0.tgz", + "integrity": "sha512-Q0n9HRi4m6JuGIV1eFlmvJB7ZEVxu93IrMyiMsGC0lrMJMWzRgx6WGquyfQgZVb31vhGgXnfmPNNXmxnOkRBrg==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/es-define-property": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/es-define-property/-/es-define-property-1.0.1.tgz", + "integrity": "sha512-e3nRfgfUZ4rNGL232gUgX06QNyyez04KdjFrF+LTRoOXmrOgFKDg4BCdsjW8EnT69eqdYGmRpJwiPVYNrCaW3g==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/es-errors": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/es-errors/-/es-errors-1.3.0.tgz", + "integrity": "sha512-Zf5H2Kxt2xjTvbJvP2ZWLEICxA6j+hAmMzIlypy4xcBg1vKVnx89Wy0GbS+kf5cwCVFFzdCFh2XSCFNULS6csw==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/es-object-atoms": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/es-object-atoms/-/es-object-atoms-1.1.1.tgz", + "integrity": "sha512-FGgH2h8zKNim9ljj7dankFPcICIK9Cp5bm+c2gQSYePhpaG5+esrLODihIorn+Pe6FGJzWhXQotPv73jTaldXA==", + "license": "MIT", + "dependencies": { + "es-errors": "^1.3.0" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/es-set-tostringtag": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/es-set-tostringtag/-/es-set-tostringtag-2.1.0.tgz", + "integrity": "sha512-j6vWzfrGVfyXxge+O0x5sh6cvxAog0a/4Rdd2K36zCMV5eJ+/+tOAngRO8cODMNWbVRdVlmGZQL2YS3yR8bIUA==", + "license": "MIT", + "dependencies": { + "es-errors": "^1.3.0", + "get-intrinsic": "^1.2.6", + "has-tostringtag": "^1.0.2", + "hasown": "^2.0.2" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/escape-html": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz", + "integrity": "sha512-NiSupZ4OeuGwr68lGIeym/ksIZMJodUGOSCZ/FSnTxcrekbvqrgdUxlJOMpijaKZVjAJrWrGs/6Jy8OMuyj9ow==", + "license": "MIT" + }, + "node_modules/etag": { + "version": "1.8.1", + "resolved": "https://registry.npmjs.org/etag/-/etag-1.8.1.tgz", + "integrity": "sha512-aIL5Fx7mawVa300al2BnEE4iNvo1qETxLrPI/o05L7z6go7fCw1J6EQmbK4FmJ2AS7kgVF/KEZWufBfdClMcPg==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/express": { + "version": "4.22.1", + "resolved": "https://registry.npmjs.org/express/-/express-4.22.1.tgz", + "integrity": "sha512-F2X8g9P1X7uCPZMA3MVf9wcTqlyNp7IhH5qPCI0izhaOIYXaW9L535tGA3qmjRzpH+bZczqq7hVKxTR4NWnu+g==", + "license": "MIT", + "dependencies": { + "accepts": "~1.3.8", + "array-flatten": "1.1.1", + "body-parser": "~1.20.3", + "content-disposition": "~0.5.4", + "content-type": "~1.0.4", + "cookie": "~0.7.1", + "cookie-signature": "~1.0.6", + "debug": "2.6.9", + "depd": "2.0.0", + "encodeurl": "~2.0.0", + "escape-html": "~1.0.3", + "etag": "~1.8.1", + "finalhandler": "~1.3.1", + "fresh": "~0.5.2", + "http-errors": "~2.0.0", + "merge-descriptors": "1.0.3", + "methods": "~1.1.2", + "on-finished": "~2.4.1", + "parseurl": "~1.3.3", + "path-to-regexp": "~0.1.12", + "proxy-addr": "~2.0.7", + "qs": "~6.14.0", + "range-parser": "~1.2.1", + "safe-buffer": "5.2.1", + "send": "~0.19.0", + "serve-static": "~1.16.2", + "setprototypeof": "1.2.0", + "statuses": "~2.0.1", + "type-is": "~1.6.18", + "utils-merge": "1.0.1", + "vary": "~1.1.2" + }, + "engines": { + "node": ">= 0.10.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, + "node_modules/finalhandler": { + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-1.3.2.tgz", + "integrity": "sha512-aA4RyPcd3badbdABGDuTXCMTtOneUCAYH/gxoYRTZlIJdF0YPWuGqiAsIrhNnnqdXGswYk6dGujem4w80UJFhg==", + "license": "MIT", + "dependencies": { + "debug": "2.6.9", + "encodeurl": "~2.0.0", + "escape-html": "~1.0.3", + "on-finished": "~2.4.1", + "parseurl": "~1.3.3", + "statuses": "~2.0.2", + "unpipe": "~1.0.0" + }, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/follow-redirects": { + "version": "1.15.11", + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.11.tgz", + "integrity": "sha512-deG2P0JfjrTxl50XGCDyfI97ZGVCxIpfKYmfyrQ54n5FO/0gfIES8C/Psl6kWVDolizcaaxZJnTS0QSMxvnsBQ==", + "funding": [ + { + "type": "individual", + "url": "https://github.com/sponsors/RubenVerborgh" + } + ], + "license": "MIT", + "engines": { + "node": ">=4.0" + }, + "peerDependenciesMeta": { + "debug": { + "optional": true + } + } + }, + "node_modules/form-data": { + "version": "4.0.5", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.5.tgz", + "integrity": "sha512-8RipRLol37bNs2bhoV67fiTEvdTrbMUYcFTiy3+wuuOnUog2QBHCZWXDRijWQfAkhBj2Uf5UnVaiWwA5vdd82w==", + "license": "MIT", + "dependencies": { + "asynckit": "^0.4.0", + "combined-stream": "^1.0.8", + "es-set-tostringtag": "^2.1.0", + "hasown": "^2.0.2", + "mime-types": "^2.1.12" + }, + "engines": { + "node": ">= 6" + } + }, + "node_modules/forwarded": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.2.0.tgz", + "integrity": "sha512-buRG0fpBtRHSTCOASe6hD258tEubFoRLb4ZNA6NxMVHNw2gOcwHo9wyablzMzOA5z9xA9L1KNjk/Nt6MT9aYow==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/fresh": { + "version": "0.5.2", + "resolved": "https://registry.npmjs.org/fresh/-/fresh-0.5.2.tgz", + "integrity": "sha512-zJ2mQYM18rEFOudeV4GShTGIQ7RbzA7ozbU9I/XBpm7kqgMywgmylMwXHxZJmkVoYkna9d2pVXVXPdYTP9ej8Q==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/function-bind": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz", + "integrity": "sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==", + "license": "MIT", + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/get-intrinsic": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.3.0.tgz", + "integrity": "sha512-9fSjSaos/fRIVIp+xSJlE6lfwhES7LNtKaCBIamHsjr2na1BiABJPo0mOjjz8GJDURarmCPGqaiVg5mfjb98CQ==", + "license": "MIT", + "dependencies": { + "call-bind-apply-helpers": "^1.0.2", + "es-define-property": "^1.0.1", + "es-errors": "^1.3.0", + "es-object-atoms": "^1.1.1", + "function-bind": "^1.1.2", + "get-proto": "^1.0.1", + "gopd": "^1.2.0", + "has-symbols": "^1.1.0", + "hasown": "^2.0.2", + "math-intrinsics": "^1.1.0" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/get-proto": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/get-proto/-/get-proto-1.0.1.tgz", + "integrity": "sha512-sTSfBjoXBp89JvIKIefqw7U2CCebsc74kiY6awiGogKtoSGbgjYE/G/+l9sF3MWFPNc9IcoOC4ODfKHfxFmp0g==", + "license": "MIT", + "dependencies": { + "dunder-proto": "^1.0.1", + "es-object-atoms": "^1.0.0" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/gopd": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/gopd/-/gopd-1.2.0.tgz", + "integrity": "sha512-ZUKRh6/kUFoAiTAtTYPZJ3hw9wNxx+BIBOijnlG9PnrJsCcSjs1wyyD6vJpaYtgnzDrKYRSqf3OO6Rfa93xsRg==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/has-symbols": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.1.0.tgz", + "integrity": "sha512-1cDNdwJ2Jaohmb3sg4OmKaMBwuC48sYni5HUw2DvsC8LjGTLK9h+eb1X6RyuOHe4hT0ULCW68iomhjUoKUqlPQ==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/has-tostringtag": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/has-tostringtag/-/has-tostringtag-1.0.2.tgz", + "integrity": "sha512-NqADB8VjPFLM2V0VvHUewwwsw0ZWBaIdgo+ieHtK3hasLz4qeCRjYcqfB6AQrBggRKppKF8L52/VqdVsO47Dlw==", + "license": "MIT", + "dependencies": { + "has-symbols": "^1.0.3" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/hasown": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.2.tgz", + "integrity": "sha512-0hJU9SCPvmMzIBdZFqNPXWa6dqh7WdH0cII9y+CyS8rG3nL48Bclra9HmKhVVUHyPWNH5Y7xDwAB7bfgSjkUMQ==", + "license": "MIT", + "dependencies": { + "function-bind": "^1.1.2" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/http-errors": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-2.0.1.tgz", + "integrity": "sha512-4FbRdAX+bSdmo4AUFuS0WNiPz8NgFt+r8ThgNWmlrjQjt1Q7ZR9+zTlce2859x4KSXrwIsaeTqDoKQmtP8pLmQ==", + "license": "MIT", + "dependencies": { + "depd": "~2.0.0", + "inherits": "~2.0.4", + "setprototypeof": "~1.2.0", + "statuses": "~2.0.2", + "toidentifier": "~1.0.1" + }, + "engines": { + "node": ">= 0.8" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, + "node_modules/iconv-lite": { + "version": "0.4.24", + "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz", + "integrity": "sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==", + "license": "MIT", + "dependencies": { + "safer-buffer": ">= 2.1.2 < 3" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/inherits": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", + "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", + "license": "ISC" + }, + "node_modules/ipaddr.js": { + "version": "1.9.1", + "resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.9.1.tgz", + "integrity": "sha512-0KI/607xoxSToH7GjN1FfSbLoU0+btTicjsQSWQlh/hZykN8KpmMf7uYwPW3R+akZ6R/w18ZlXSHBYXiYUPO3g==", + "license": "MIT", + "engines": { + "node": ">= 0.10" + } + }, + "node_modules/kareem": { + "version": "2.6.3", + "resolved": "https://registry.npmjs.org/kareem/-/kareem-2.6.3.tgz", + "integrity": "sha512-C3iHfuGUXK2u8/ipq9LfjFfXFxAZMQJJq7vLS45r3D9Y2xQ/m4S8zaR4zMLFWh9AsNPXmcFfUDhTEO8UIC/V6Q==", + "license": "Apache-2.0", + "engines": { + "node": ">=12.0.0" + } + }, + "node_modules/math-intrinsics": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/math-intrinsics/-/math-intrinsics-1.1.0.tgz", + "integrity": "sha512-/IXtbwEk5HTPyEwyKX6hGkYXxM9nbj64B+ilVJnC/R6B0pH5G4V3b0pVbL7DBj4tkhBAppbQUlf6F6Xl9LHu1g==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/media-typer": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz", + "integrity": "sha512-dq+qelQ9akHpcOl/gUVRTxVIOkAJ1wR3QAvb4RsVjS8oVoFjDGTc679wJYmUmknUF5HwMLOgb5O+a3KxfWapPQ==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/memory-pager": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/memory-pager/-/memory-pager-1.5.0.tgz", + "integrity": "sha512-ZS4Bp4r/Zoeq6+NLJpP+0Zzm0pR8whtGPf1XExKLJBAczGMnSi3It14OiNCStjQjM6NU1okjQGSxgEZN8eBYKg==", + "license": "MIT" + }, + "node_modules/merge-descriptors": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-1.0.3.tgz", + "integrity": "sha512-gaNvAS7TZ897/rVaZ0nMtAyxNyi/pdbjbAwUpFQpN70GqnVfOiXpeUUMKRBmzXaSQ8DdTX4/0ms62r2K+hE6mQ==", + "license": "MIT", + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/methods": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/methods/-/methods-1.1.2.tgz", + "integrity": "sha512-iclAHeNqNm68zFtnZ0e+1L2yUIdvzNoauKU4WBA3VvH/vPFieF7qfRlwUZU+DA9P9bPXIS90ulxoUoCH23sV2w==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/mime": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/mime/-/mime-1.6.0.tgz", + "integrity": "sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg==", + "license": "MIT", + "bin": { + "mime": "cli.js" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/mime-db": { + "version": "1.52.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz", + "integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/mime-types": { + "version": "2.1.35", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz", + "integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==", + "license": "MIT", + "dependencies": { + "mime-db": "1.52.0" + }, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/mongodb": { + "version": "6.20.0", + "resolved": "https://registry.npmjs.org/mongodb/-/mongodb-6.20.0.tgz", + "integrity": "sha512-Tl6MEIU3K4Rq3TSHd+sZQqRBoGlFsOgNrH5ltAcFBV62Re3Fd+FcaVf8uSEQFOJ51SDowDVttBTONMfoYWrWlQ==", + "license": "Apache-2.0", + "dependencies": { + "@mongodb-js/saslprep": "^1.3.0", + "bson": "^6.10.4", + "mongodb-connection-string-url": "^3.0.2" + }, + "engines": { + "node": ">=16.20.1" + }, + "peerDependencies": { + "@aws-sdk/credential-providers": "^3.188.0", + "@mongodb-js/zstd": "^1.1.0 || ^2.0.0", + "gcp-metadata": "^5.2.0", + "kerberos": "^2.0.1", + "mongodb-client-encryption": ">=6.0.0 <7", + "snappy": "^7.3.2", + "socks": "^2.7.1" + }, + "peerDependenciesMeta": { + "@aws-sdk/credential-providers": { + "optional": true + }, + "@mongodb-js/zstd": { + "optional": true + }, + "gcp-metadata": { + "optional": true + }, + "kerberos": { + "optional": true + }, + "mongodb-client-encryption": { + "optional": true + }, + "snappy": { + "optional": true + }, + "socks": { + "optional": true + } + } + }, + "node_modules/mongodb-connection-string-url": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/mongodb-connection-string-url/-/mongodb-connection-string-url-3.0.2.tgz", + "integrity": "sha512-rMO7CGo/9BFwyZABcKAWL8UJwH/Kc2x0g72uhDWzG48URRax5TCIcJ7Rc3RZqffZzO/Gwff/jyKwCU9TN8gehA==", + "license": "Apache-2.0", + "dependencies": { + "@types/whatwg-url": "^11.0.2", + "whatwg-url": "^14.1.0 || ^13.0.0" + } + }, + "node_modules/mongoose": { + "version": "8.21.1", + "resolved": "https://registry.npmjs.org/mongoose/-/mongoose-8.21.1.tgz", + "integrity": "sha512-1LhrVeHwiyAGxwSaYSq2uf32izQD+qoM2c8wq63W8MIsJBxKQDBnMkhJct55m0qqCsm2Maq8aPpIIfOHSYAqxg==", + "license": "MIT", + "dependencies": { + "bson": "^6.10.4", + "kareem": "2.6.3", + "mongodb": "~6.20.0", + "mpath": "0.9.0", + "mquery": "5.0.0", + "ms": "2.1.3", + "sift": "17.1.3" + }, + "engines": { + "node": ">=16.20.1" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/mongoose" + } + }, + "node_modules/mongoose/node_modules/ms": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", + "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", + "license": "MIT" + }, + "node_modules/mpath": { + "version": "0.9.0", + "resolved": "https://registry.npmjs.org/mpath/-/mpath-0.9.0.tgz", + "integrity": "sha512-ikJRQTk8hw5DEoFVxHG1Gn9T/xcjtdnOKIU1JTmGjZZlg9LST2mBLmcX3/ICIbgJydT2GOc15RnNy5mHmzfSew==", + "license": "MIT", + "engines": { + "node": ">=4.0.0" + } + }, + "node_modules/mquery": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/mquery/-/mquery-5.0.0.tgz", + "integrity": "sha512-iQMncpmEK8R8ncT8HJGsGc9Dsp8xcgYMVSbs5jgnm1lFHTZqMJTUWTDx1LBO8+mK3tPNZWFLBghQEIOULSTHZg==", + "license": "MIT", + "dependencies": { + "debug": "4.x" + }, + "engines": { + "node": ">=14.0.0" + } + }, + "node_modules/mquery/node_modules/debug": { + "version": "4.4.3", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.4.3.tgz", + "integrity": "sha512-RGwwWnwQvkVfavKVt22FGLw+xYSdzARwm0ru6DhTVA3umU5hZc28V3kO4stgYryrTlLpuvgI9GiijltAjNbcqA==", + "license": "MIT", + "dependencies": { + "ms": "^2.1.3" + }, + "engines": { + "node": ">=6.0" + }, + "peerDependenciesMeta": { + "supports-color": { + "optional": true + } + } + }, + "node_modules/mquery/node_modules/ms": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", + "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", + "license": "MIT" + }, + "node_modules/ms": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==", + "license": "MIT" + }, + "node_modules/negotiator": { + "version": "0.6.3", + "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.3.tgz", + "integrity": "sha512-+EUsqGPLsM+j/zdChZjsnX51g4XrHFOIXwfnCVPGlQk/k5giakcKsuxCObBRu6DSm9opw/O6slWbJdghQM4bBg==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/object-assign": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", + "integrity": "sha512-rJgTQnkUnH1sFw8yT6VSU3zD3sWmu6sZhIseY8VX+GRu3P6F7Fu+JNDoXfklElbLJSnc3FUQHVe4cU5hj+BcUg==", + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/object-inspect": { + "version": "1.13.4", + "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.13.4.tgz", + "integrity": "sha512-W67iLl4J2EXEGTbfeHCffrjDfitvLANg0UlX3wFUUSTx92KXRFegMHUVgSqE+wvhAbi4WqjGg9czysTV2Epbew==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/on-finished": { + "version": "2.4.1", + "resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.4.1.tgz", + "integrity": "sha512-oVlzkg3ENAhCk2zdv7IJwd/QUD4z2RxRwpkcGY8psCVcCYZNq4wYnVWALHM+brtuJjePWiYF/ClmuDr8Ch5+kg==", + "license": "MIT", + "dependencies": { + "ee-first": "1.1.1" + }, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/parseurl": { + "version": "1.3.3", + "resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.3.tgz", + "integrity": "sha512-CiyeOxFT/JZyN5m0z9PfXw4SCBJ6Sygz1Dpl0wqjlhDEGGBP1GnsUVEL0p63hoG1fcj3fHynXi9NYO4nWOL+qQ==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/path-to-regexp": { + "version": "0.1.12", + "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.12.tgz", + "integrity": "sha512-RA1GjUVMnvYFxuqovrEqZoxxW5NUZqbwKtYz/Tt7nXerk0LbLblQmrsgdeOxV5SFHf0UDggjS/bSeOZwt1pmEQ==", + "license": "MIT" + }, + "node_modules/proxy-addr": { + "version": "2.0.7", + "resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.7.tgz", + "integrity": "sha512-llQsMLSUDUPT44jdrU/O37qlnifitDP+ZwrmmZcoSKyLKvtZxpyV0n2/bD/N4tBAAZ/gJEdZU7KMraoK1+XYAg==", + "license": "MIT", + "dependencies": { + "forwarded": "0.2.0", + "ipaddr.js": "1.9.1" + }, + "engines": { + "node": ">= 0.10" + } + }, + "node_modules/proxy-from-env": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-1.1.0.tgz", + "integrity": "sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg==", + "license": "MIT" + }, + "node_modules/punycode": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.1.tgz", + "integrity": "sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg==", + "license": "MIT", + "engines": { + "node": ">=6" + } + }, + "node_modules/qs": { + "version": "6.14.1", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.14.1.tgz", + "integrity": "sha512-4EK3+xJl8Ts67nLYNwqw/dsFVnCf+qR7RgXSK9jEEm9unao3njwMDdmsdvoKBKHzxd7tCYz5e5M+SnMjdtXGQQ==", + "license": "BSD-3-Clause", + "dependencies": { + "side-channel": "^1.1.0" + }, + "engines": { + "node": ">=0.6" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/range-parser": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.1.tgz", + "integrity": "sha512-Hrgsx+orqoygnmhFbKaHE6c296J+HTAQXoxEF6gNupROmmGJRoyzfG3ccAveqCBrwr/2yxQ5BVd/GTl5agOwSg==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/raw-body": { + "version": "2.5.3", + "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.5.3.tgz", + "integrity": "sha512-s4VSOf6yN0rvbRZGxs8Om5CWj6seneMwK3oDb4lWDH0UPhWcxwOWw5+qk24bxq87szX1ydrwylIOp2uG1ojUpA==", + "license": "MIT", + "dependencies": { + "bytes": "~3.1.2", + "http-errors": "~2.0.1", + "iconv-lite": "~0.4.24", + "unpipe": "~1.0.0" + }, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/safe-buffer": { + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", + "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "license": "MIT" + }, + "node_modules/safer-buffer": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", + "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==", + "license": "MIT" + }, + "node_modules/send": { + "version": "0.19.2", + "resolved": "https://registry.npmjs.org/send/-/send-0.19.2.tgz", + "integrity": "sha512-VMbMxbDeehAxpOtWJXlcUS5E8iXh6QmN+BkRX1GARS3wRaXEEgzCcB10gTQazO42tpNIya8xIyNx8fll1OFPrg==", + "license": "MIT", + "dependencies": { + "debug": "2.6.9", + "depd": "2.0.0", + "destroy": "1.2.0", + "encodeurl": "~2.0.0", + "escape-html": "~1.0.3", + "etag": "~1.8.1", + "fresh": "~0.5.2", + "http-errors": "~2.0.1", + "mime": "1.6.0", + "ms": "2.1.3", + "on-finished": "~2.4.1", + "range-parser": "~1.2.1", + "statuses": "~2.0.2" + }, + "engines": { + "node": ">= 0.8.0" + } + }, + "node_modules/send/node_modules/ms": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", + "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", + "license": "MIT" + }, + "node_modules/serve-static": { + "version": "1.16.3", + "resolved": "https://registry.npmjs.org/serve-static/-/serve-static-1.16.3.tgz", + "integrity": "sha512-x0RTqQel6g5SY7Lg6ZreMmsOzncHFU7nhnRWkKgWuMTu5NN0DR5oruckMqRvacAN9d5w6ARnRBXl9xhDCgfMeA==", + "license": "MIT", + "dependencies": { + "encodeurl": "~2.0.0", + "escape-html": "~1.0.3", + "parseurl": "~1.3.3", + "send": "~0.19.1" + }, + "engines": { + "node": ">= 0.8.0" + } + }, + "node_modules/setprototypeof": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.2.0.tgz", + "integrity": "sha512-E5LDX7Wrp85Kil5bhZv46j8jOeboKq5JMmYM3gVGdGH8xFpPWXUMsNrlODCrkoxMEeNi/XZIwuRvY4XNwYMJpw==", + "license": "ISC" + }, + "node_modules/side-channel": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/side-channel/-/side-channel-1.1.0.tgz", + "integrity": "sha512-ZX99e6tRweoUXqR+VBrslhda51Nh5MTQwou5tnUDgbtyM0dBgmhEDtWGP/xbKn6hqfPRHujUNwz5fy/wbbhnpw==", + "license": "MIT", + "dependencies": { + "es-errors": "^1.3.0", + "object-inspect": "^1.13.3", + "side-channel-list": "^1.0.0", + "side-channel-map": "^1.0.1", + "side-channel-weakmap": "^1.0.2" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/side-channel-list": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/side-channel-list/-/side-channel-list-1.0.0.tgz", + "integrity": "sha512-FCLHtRD/gnpCiCHEiJLOwdmFP+wzCmDEkc9y7NsYxeF4u7Btsn1ZuwgwJGxImImHicJArLP4R0yX4c2KCrMrTA==", + "license": "MIT", + "dependencies": { + "es-errors": "^1.3.0", + "object-inspect": "^1.13.3" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/side-channel-map": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/side-channel-map/-/side-channel-map-1.0.1.tgz", + "integrity": "sha512-VCjCNfgMsby3tTdo02nbjtM/ewra6jPHmpThenkTYh8pG9ucZ/1P8So4u4FGBek/BjpOVsDCMoLA/iuBKIFXRA==", + "license": "MIT", + "dependencies": { + "call-bound": "^1.0.2", + "es-errors": "^1.3.0", + "get-intrinsic": "^1.2.5", + "object-inspect": "^1.13.3" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/side-channel-weakmap": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/side-channel-weakmap/-/side-channel-weakmap-1.0.2.tgz", + "integrity": "sha512-WPS/HvHQTYnHisLo9McqBHOJk2FkHO/tlpvldyrnem4aeQp4hai3gythswg6p01oSoTl58rcpiFAjF2br2Ak2A==", + "license": "MIT", + "dependencies": { + "call-bound": "^1.0.2", + "es-errors": "^1.3.0", + "get-intrinsic": "^1.2.5", + "object-inspect": "^1.13.3", + "side-channel-map": "^1.0.1" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/sift": { + "version": "17.1.3", + "resolved": "https://registry.npmjs.org/sift/-/sift-17.1.3.tgz", + "integrity": "sha512-Rtlj66/b0ICeFzYTuNvX/EF1igRbbnGSvEyT79McoZa/DeGhMyC5pWKOEsZKnpkqtSeovd5FL/bjHWC3CIIvCQ==", + "license": "MIT" + }, + "node_modules/sparse-bitfield": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/sparse-bitfield/-/sparse-bitfield-3.0.3.tgz", + "integrity": "sha512-kvzhi7vqKTfkh0PZU+2D2PIllw2ymqJKujUcyPMd9Y75Nv4nPbGJZXNhxsgdQab2BmlDct1YnfQCguEvHr7VsQ==", + "license": "MIT", + "dependencies": { + "memory-pager": "^1.0.2" + } + }, + "node_modules/statuses": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/statuses/-/statuses-2.0.2.tgz", + "integrity": "sha512-DvEy55V3DB7uknRo+4iOGT5fP1slR8wQohVdknigZPMpMstaKJQWhwiYBACJE3Ul2pTnATihhBYnRhZQHGBiRw==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/toidentifier": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.1.tgz", + "integrity": "sha512-o5sSPKEkg/DIQNmH43V0/uerLrpzVedkUh8tGNvaeXpfpuwjKenlSox/2O/BTlZUtEe+JG7s5YhEz608PlAHRA==", + "license": "MIT", + "engines": { + "node": ">=0.6" + } + }, + "node_modules/tr46": { + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/tr46/-/tr46-5.1.1.tgz", + "integrity": "sha512-hdF5ZgjTqgAntKkklYw0R03MG2x/bSzTtkxmIRw/sTNV8YXsCJ1tfLAX23lhxhHJlEf3CRCOCGGWw3vI3GaSPw==", + "license": "MIT", + "dependencies": { + "punycode": "^2.3.1" + }, + "engines": { + "node": ">=18" + } + }, + "node_modules/type-is": { + "version": "1.6.18", + "resolved": "https://registry.npmjs.org/type-is/-/type-is-1.6.18.tgz", + "integrity": "sha512-TkRKr9sUTxEH8MdfuCSP7VizJyzRNMjj2J2do2Jr3Kym598JVdEksuzPQCnlFPW4ky9Q+iA+ma9BGm06XQBy8g==", + "license": "MIT", + "dependencies": { + "media-typer": "0.3.0", + "mime-types": "~2.1.24" + }, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/unpipe": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz", + "integrity": "sha512-pjy2bYhSsufwWlKwPc+l3cN7+wuJlK6uz0YdJEOlQDbl6jo/YlPi4mb8agUkVC8BF7V8NuzeyPNqRksA3hztKQ==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/utils-merge": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/utils-merge/-/utils-merge-1.0.1.tgz", + "integrity": "sha512-pMZTvIkT1d+TFGvDOqodOclx0QWkkgi6Tdoa8gC8ffGAAqz9pzPTZWAybbsHHoED/ztMtkv/VoYTYyShUn81hA==", + "license": "MIT", + "engines": { + "node": ">= 0.4.0" + } + }, + "node_modules/vary": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz", + "integrity": "sha512-BNGbWLfd0eUPabhkXUVm0j8uuvREyTh5ovRa/dyow/BqAbZJyC+5fU+IzQOzmAKzYqYRAISoRhdQr3eIZ/PXqg==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/webidl-conversions": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-7.0.0.tgz", + "integrity": "sha512-VwddBukDzu71offAQR975unBIGqfKZpM+8ZX6ySk8nYhVoo5CYaZyzt3YBvYtRtO+aoGlqxPg/B87NGVZ/fu6g==", + "license": "BSD-2-Clause", + "engines": { + "node": ">=12" + } + }, + "node_modules/whatwg-url": { + "version": "14.2.0", + "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-14.2.0.tgz", + "integrity": "sha512-De72GdQZzNTUBBChsXueQUnPKDkg/5A5zp7pFDuQAj5UFoENpiACU0wlCvzpAGnTkj++ihpKwKyYewn/XNUbKw==", + "license": "MIT", + "dependencies": { + "tr46": "^5.1.0", + "webidl-conversions": "^7.0.0" + }, + "engines": { + "node": ">=18" + } + } + } +} diff --git a/backend/package.json b/backend/package.json new file mode 100644 index 0000000..84ebe76 --- /dev/null +++ b/backend/package.json @@ -0,0 +1,20 @@ +{ + "name": "bini-google-tv-backend", + "version": "0.1.0", + "private": true, + "main": "server.js", + "type": "commonjs", + "scripts": { + "start": "node server.js", + "dev": "node server.js", + "seed": "node scripts/seed.js", + "demo": "node scripts/demo.js" + }, + "dependencies": { + "axios": "^1.7.9", + "cors": "^2.8.5", + "dotenv": "^16.4.7", + "express": "^4.19.2", + "mongoose": "^8.9.0" + } +} diff --git a/backend/routes/announcements.js b/backend/routes/announcements.js new file mode 100644 index 0000000..573c031 --- /dev/null +++ b/backend/routes/announcements.js @@ -0,0 +1,69 @@ +const express = require("express"); +const Announcement = require("../models/Announcement"); + +const router = express.Router(); + +router.get("/", async (req, res) => { + try { + const filter = {}; + if (req.query.active === "true") { + filter.active = true; + } + const announcements = await Announcement.find(filter).sort({ + priority: -1, + createdAt: -1, + }); + res.json(announcements); + } catch (error) { + res.status(500).json({ message: "Failed to fetch announcements" }); + } +}); + +router.post("/", async (req, res) => { + try { + const announcement = await Announcement.create(req.body); + res.status(201).json(announcement); + } catch (error) { + res.status(400).json({ message: "Failed to create announcement" }); + } +}); + +router.get("/:id", async (req, res) => { + try { + const announcement = await Announcement.findById(req.params.id); + if (!announcement) { + return res.status(404).json({ message: "Announcement not found" }); + } + res.json(announcement); + } catch (error) { + res.status(400).json({ message: "Failed to fetch announcement" }); + } +}); + +router.put("/:id", async (req, res) => { + try { + const announcement = await Announcement.findByIdAndUpdate(req.params.id, req.body, { + new: true, + }); + if (!announcement) { + return res.status(404).json({ message: "Announcement not found" }); + } + res.json(announcement); + } catch (error) { + res.status(400).json({ message: "Failed to update announcement" }); + } +}); + +router.delete("/:id", async (req, res) => { + try { + const announcement = await Announcement.findByIdAndDelete(req.params.id); + if (!announcement) { + return res.status(404).json({ message: "Announcement not found" }); + } + res.json({ ok: true }); + } catch (error) { + res.status(400).json({ message: "Failed to delete announcement" }); + } +}); + +module.exports = router; diff --git a/backend/routes/bible.js b/backend/routes/bible.js new file mode 100644 index 0000000..cf88017 --- /dev/null +++ b/backend/routes/bible.js @@ -0,0 +1,94 @@ +const express = require("express"); +const BibleVerse = require("../models/BibleVerse"); + +const router = express.Router(); + +const pickRandomVerse = async (filter) => { + const results = await BibleVerse.aggregate([ + { $match: filter }, + { $sample: { size: 1 } }, + ]); + return results[0] || null; +}; + +router.get("/today", async (req, res) => { + try { + const targetDate = req.query.date || new Date().toISOString().slice(0, 10); + const datedVerse = await pickRandomVerse({ + active: true, + date: targetDate, + }); + if (datedVerse) { + return res.json(datedVerse); + } + + const undatedVerse = await pickRandomVerse({ + active: true, + $or: [{ date: { $exists: false } }, { date: null }, { date: "" }], + }); + if (undatedVerse) { + return res.json(undatedVerse); + } + + const anyVerse = await pickRandomVerse({ active: true }); + if (!anyVerse) { + return res.status(404).json({ message: "No bible verses available" }); + } + return res.json(anyVerse); + } catch (error) { + res.status(500).json({ message: "Failed to fetch bible verse" }); + } +}); + +router.get("/verses", async (req, res) => { + try { + const filter = {}; + if (req.query.active === "true") { + filter.active = true; + } + const verses = await BibleVerse.find(filter).sort({ + date: -1, + createdAt: -1, + }); + res.json(verses); + } catch (error) { + res.status(500).json({ message: "Failed to fetch bible verses" }); + } +}); + +router.post("/verses", async (req, res) => { + try { + const verse = await BibleVerse.create(req.body); + res.status(201).json(verse); + } catch (error) { + res.status(400).json({ message: "Failed to create bible verse" }); + } +}); + +router.put("/verses/:id", async (req, res) => { + try { + const verse = await BibleVerse.findByIdAndUpdate(req.params.id, req.body, { + new: true, + }); + if (!verse) { + return res.status(404).json({ message: "Bible verse not found" }); + } + res.json(verse); + } catch (error) { + res.status(400).json({ message: "Failed to update bible verse" }); + } +}); + +router.delete("/verses/:id", async (req, res) => { + try { + const verse = await BibleVerse.findByIdAndDelete(req.params.id); + if (!verse) { + return res.status(404).json({ message: "Bible verse not found" }); + } + res.json({ ok: true }); + } catch (error) { + res.status(400).json({ message: "Failed to delete bible verse" }); + } +}); + +module.exports = router; diff --git a/backend/routes/family.js b/backend/routes/family.js new file mode 100644 index 0000000..4c0d6bf --- /dev/null +++ b/backend/routes/family.js @@ -0,0 +1,62 @@ +const express = require("express"); +const FamilyMember = require("../models/FamilyMember"); + +const router = express.Router(); + +router.get("/", async (req, res) => { + try { + const members = await FamilyMember.find().sort({ order: 1, createdAt: 1 }); + res.json(members); + } catch (error) { + res.status(500).json({ message: "Failed to fetch family members" }); + } +}); + +router.post("/", async (req, res) => { + try { + const member = await FamilyMember.create(req.body); + res.status(201).json(member); + } catch (error) { + res.status(400).json({ message: "Failed to create family member" }); + } +}); + +router.get("/:id", async (req, res) => { + try { + const member = await FamilyMember.findById(req.params.id); + if (!member) { + return res.status(404).json({ message: "Family member not found" }); + } + res.json(member); + } catch (error) { + res.status(400).json({ message: "Failed to fetch family member" }); + } +}); + +router.put("/:id", async (req, res) => { + try { + const member = await FamilyMember.findByIdAndUpdate(req.params.id, req.body, { + new: true, + }); + if (!member) { + return res.status(404).json({ message: "Family member not found" }); + } + res.json(member); + } catch (error) { + res.status(400).json({ message: "Failed to update family member" }); + } +}); + +router.delete("/:id", async (req, res) => { + try { + const member = await FamilyMember.findByIdAndDelete(req.params.id); + if (!member) { + return res.status(404).json({ message: "Family member not found" }); + } + res.json({ ok: true }); + } catch (error) { + res.status(400).json({ message: "Failed to delete family member" }); + } +}); + +module.exports = router; diff --git a/backend/routes/photos.js b/backend/routes/photos.js new file mode 100644 index 0000000..1b29356 --- /dev/null +++ b/backend/routes/photos.js @@ -0,0 +1,40 @@ +const express = require("express"); +const Photo = require("../models/Photo"); + +const router = express.Router(); + +router.get("/", async (req, res) => { + try { + const filter = {}; + if (req.query.active === "true") { + filter.active = true; + } + const photos = await Photo.find(filter).sort({ createdAt: -1 }); + res.json(photos); + } catch (error) { + res.status(500).json({ message: "Failed to fetch photos" }); + } +}); + +router.post("/", async (req, res) => { + try { + const photo = await Photo.create(req.body); + res.status(201).json(photo); + } catch (error) { + res.status(400).json({ message: "Failed to create photo" }); + } +}); + +router.delete("/:id", async (req, res) => { + try { + const photo = await Photo.findByIdAndDelete(req.params.id); + if (!photo) { + return res.status(404).json({ message: "Photo not found" }); + } + res.json({ ok: true }); + } catch (error) { + res.status(400).json({ message: "Failed to delete photo" }); + } +}); + +module.exports = router; diff --git a/backend/routes/schedules.js b/backend/routes/schedules.js new file mode 100644 index 0000000..3ac46fc --- /dev/null +++ b/backend/routes/schedules.js @@ -0,0 +1,115 @@ +const express = require("express"); +const Schedule = require("../models/Schedule"); + +const router = express.Router(); + +const startOfWeek = (date = new Date()) => { + const copy = new Date(date); + const day = copy.getDay(); + const diff = day === 0 ? -6 : 1 - day; + copy.setDate(copy.getDate() + diff); + copy.setHours(0, 0, 0, 0); + return copy; +}; + +const endOfWeek = (date = new Date()) => { + const start = startOfWeek(date); + const end = new Date(start); + end.setDate(end.getDate() + 6); + end.setHours(23, 59, 59, 999); + return end; +}; + +const startOfMonth = (date = new Date()) => { + return new Date(date.getFullYear(), date.getMonth(), 1, 0, 0, 0, 0); +}; + +const endOfMonth = (date = new Date()) => { + return new Date(date.getFullYear(), date.getMonth() + 1, 0, 23, 59, 59, 999); +}; + +router.get("/", async (req, res) => { + try { + const schedules = await Schedule.find().sort({ startDate: 1 }); + res.json(schedules); + } catch (error) { + res.status(500).json({ message: "Failed to fetch schedules" }); + } +}); + +router.get("/week", async (req, res) => { + try { + const start = startOfWeek(); + const end = endOfWeek(); + const schedules = await Schedule.find({ + startDate: { $lte: end }, + endDate: { $gte: start }, + }).sort({ startDate: 1 }); + res.json(schedules); + } catch (error) { + res.status(500).json({ message: "Failed to fetch weekly schedules" }); + } +}); + +router.get("/month", async (req, res) => { + try { + const start = startOfMonth(); + const end = endOfMonth(); + const schedules = await Schedule.find({ + startDate: { $lte: end }, + endDate: { $gte: start }, + }).sort({ startDate: 1 }); + res.json(schedules); + } catch (error) { + res.status(500).json({ message: "Failed to fetch monthly schedules" }); + } +}); + +router.post("/", async (req, res) => { + try { + const schedule = await Schedule.create(req.body); + res.status(201).json(schedule); + } catch (error) { + res.status(400).json({ message: "Failed to create schedule" }); + } +}); + +router.get("/:id", async (req, res) => { + try { + const schedule = await Schedule.findById(req.params.id); + if (!schedule) { + return res.status(404).json({ message: "Schedule not found" }); + } + res.json(schedule); + } catch (error) { + res.status(400).json({ message: "Failed to fetch schedule" }); + } +}); + +router.put("/:id", async (req, res) => { + try { + const schedule = await Schedule.findByIdAndUpdate(req.params.id, req.body, { + new: true, + }); + if (!schedule) { + return res.status(404).json({ message: "Schedule not found" }); + } + res.json(schedule); + } catch (error) { + res.status(400).json({ message: "Failed to update schedule" }); + } +}); + +router.delete("/:id", async (req, res) => { + try { + const schedule = await Schedule.findByIdAndDelete(req.params.id); + if (!schedule) { + return res.status(404).json({ message: "Schedule not found" }); + } + res.json({ ok: true }); + } catch (error) { + res.status(400).json({ message: "Failed to delete schedule" }); + } +}); + +module.exports = router; diff --git a/backend/routes/todos.js b/backend/routes/todos.js new file mode 100644 index 0000000..fe74127 --- /dev/null +++ b/backend/routes/todos.js @@ -0,0 +1,81 @@ +const express = require("express"); +const Todo = require("../models/Todo"); + +const router = express.Router(); + +const getDayRange = (date = new Date()) => { + const start = new Date(date); + start.setHours(0, 0, 0, 0); + const end = new Date(date); + end.setHours(23, 59, 59, 999); + return { start, end }; +}; + +router.get("/", async (req, res) => { + try { + const todos = await Todo.find().sort({ dueDate: 1, createdAt: -1 }); + res.json(todos); + } catch (error) { + res.status(500).json({ message: "Failed to fetch todos" }); + } +}); + +router.get("/today", async (req, res) => { + try { + const { start, end } = getDayRange(); + const todos = await Todo.find({ dueDate: { $gte: start, $lte: end } }).sort({ + dueDate: 1, + createdAt: -1, + }); + res.json(todos); + } catch (error) { + res.status(500).json({ message: "Failed to fetch today todos" }); + } +}); + +router.post("/", async (req, res) => { + try { + const todo = await Todo.create(req.body); + res.status(201).json(todo); + } catch (error) { + res.status(400).json({ message: "Failed to create todo" }); + } +}); + +router.get("/:id", async (req, res) => { + try { + const todo = await Todo.findById(req.params.id); + if (!todo) { + return res.status(404).json({ message: "Todo not found" }); + } + res.json(todo); + } catch (error) { + res.status(400).json({ message: "Failed to fetch todo" }); + } +}); + +router.put("/:id", async (req, res) => { + try { + const todo = await Todo.findByIdAndUpdate(req.params.id, req.body, { new: true }); + if (!todo) { + return res.status(404).json({ message: "Todo not found" }); + } + res.json(todo); + } catch (error) { + res.status(400).json({ message: "Failed to update todo" }); + } +}); + +router.delete("/:id", async (req, res) => { + try { + const todo = await Todo.findByIdAndDelete(req.params.id); + if (!todo) { + return res.status(404).json({ message: "Todo not found" }); + } + res.json({ ok: true }); + } catch (error) { + res.status(400).json({ message: "Failed to delete todo" }); + } +}); + +module.exports = router; diff --git a/backend/routes/weather.js b/backend/routes/weather.js new file mode 100644 index 0000000..7178b4a --- /dev/null +++ b/backend/routes/weather.js @@ -0,0 +1,35 @@ +const express = require("express"); +const axios = require("axios"); +const config = require("../config/api"); + +const router = express.Router(); + +router.get("/", async (req, res) => { + try { + const { apiKey, baseUrl, city, units, language } = config.weather; + if (!apiKey) { + return res.status(400).json({ message: "OPENWEATHER_API_KEY is not set" }); + } + + const { q, lat, lon } = req.query; + const params = { + appid: apiKey, + units, + lang: language, + }; + + if (lat && lon) { + params.lat = lat; + params.lon = lon; + } else { + params.q = q || city; + } + + const response = await axios.get(`${baseUrl}/weather`, { params }); + res.json(response.data); + } catch (error) { + res.status(500).json({ message: "Failed to fetch weather" }); + } +}); + +module.exports = router; diff --git a/backend/scripts/demo.js b/backend/scripts/demo.js new file mode 100644 index 0000000..383412a --- /dev/null +++ b/backend/scripts/demo.js @@ -0,0 +1,29 @@ +const path = require("path"); +const { spawn } = require("child_process"); + +const run = (command, args) => + new Promise((resolve, reject) => { + const child = spawn(command, args, { stdio: "inherit" }); + child.on("close", (code) => { + if (code === 0) { + resolve(); + return; + } + reject(new Error(`Command failed: ${command} ${args.join(" ")}`)); + }); + }); + +const start = async () => { + const seedPath = path.join(__dirname, "seed.js"); + const serverPath = path.join(__dirname, "..", "server.js"); + + await run("node", [seedPath]); + + const server = spawn("node", [serverPath], { stdio: "inherit" }); + server.on("close", (code) => process.exit(code ?? 0)); +}; + +start().catch((error) => { + console.error("Demo failed", error); + process.exit(1); +}); diff --git a/backend/scripts/seed.js b/backend/scripts/seed.js new file mode 100644 index 0000000..f7dbfdc --- /dev/null +++ b/backend/scripts/seed.js @@ -0,0 +1,132 @@ +const dotenv = require("dotenv"); +const mongoose = require("mongoose"); + +const FamilyMember = require("../models/FamilyMember"); +const Todo = require("../models/Todo"); +const Schedule = require("../models/Schedule"); +const Announcement = require("../models/Announcement"); +const Photo = require("../models/Photo"); + +dotenv.config(); + +const connect = async () => { + const mongoUri = process.env.MONGODB_URI; + if (!mongoUri) { + throw new Error("MONGODB_URI is not set"); + } + mongoose.set("strictQuery", true); + await mongoose.connect(mongoUri); +}; + +const seed = async () => { + await Promise.all([ + FamilyMember.deleteMany({}), + Todo.deleteMany({}), + Schedule.deleteMany({}), + Announcement.deleteMany({}), + Photo.deleteMany({}), + ]); + + const family = await FamilyMember.insertMany([ + { name: "Dad", emoji: ":)", color: "#0F766E", order: 1 }, + { name: "Mom", emoji: "<3", color: "#C2410C", order: 2 }, + { name: "Son", emoji: ":D", color: "#1D4ED8", order: 3 }, + { name: "Daughter", emoji: ":-)", color: "#7C3AED", order: 4 }, + ]); + + const now = new Date(); + const today = new Date(now.getFullYear(), now.getMonth(), now.getDate(), 9, 0); + const tomorrow = new Date(today); + tomorrow.setDate(today.getDate() + 1); + + await Todo.insertMany([ + { + familyMemberId: family[0]._id, + title: "Grocery run", + completed: false, + dueDate: today, + }, + { + familyMemberId: family[1]._id, + title: "Team meeting", + completed: false, + dueDate: today, + }, + { + familyMemberId: family[2]._id, + title: "Math homework", + completed: false, + dueDate: today, + }, + { + familyMemberId: family[3]._id, + title: "Piano lesson", + completed: false, + dueDate: tomorrow, + }, + ]); + + await Schedule.insertMany([ + { + title: "Family dinner", + description: "Everyone at home", + startDate: today, + endDate: new Date(today.getTime() + 2 * 60 * 60 * 1000), + familyMemberId: family[0]._id, + isAllDay: false, + }, + { + title: "Soccer practice", + description: "School field", + startDate: new Date(today.getTime() + 4 * 60 * 60 * 1000), + endDate: new Date(today.getTime() + 5 * 60 * 60 * 1000), + familyMemberId: family[2]._id, + isAllDay: false, + }, + ]); + + await Announcement.insertMany([ + { + title: "Weekend trip", + content: "Pack light and be ready by 8 AM", + priority: 2, + active: true, + }, + { + title: "Trash day", + content: "Take out bins tonight", + priority: 1, + active: true, + }, + ]); + + await Photo.insertMany([ + { + url: "https://picsum.photos/1200/800?random=10", + caption: "Summer vacation", + active: true, + }, + { + url: "https://picsum.photos/1200/800?random=11", + caption: "Family hike", + active: true, + }, + { + url: "https://picsum.photos/1200/800?random=12", + caption: "Birthday party", + active: true, + }, + ]); +}; + +connect() + .then(seed) + .then(() => { + console.log("Seed data inserted"); + return mongoose.disconnect(); + }) + .then(() => process.exit(0)) + .catch((error) => { + console.error("Seed failed", error); + process.exit(1); + }); diff --git a/backend/server.js b/backend/server.js new file mode 100644 index 0000000..a047a60 --- /dev/null +++ b/backend/server.js @@ -0,0 +1,43 @@ +const express = require("express"); +const cors = require("cors"); +const dotenv = require("dotenv"); + +const connectDb = require("./config/db"); +const familyRoutes = require("./routes/family"); +const todoRoutes = require("./routes/todos"); +const scheduleRoutes = require("./routes/schedules"); +const announcementRoutes = require("./routes/announcements"); +const weatherRoutes = require("./routes/weather"); +const bibleRoutes = require("./routes/bible"); +const photoRoutes = require("./routes/photos"); + +dotenv.config(); + +const app = express(); +const port = process.env.PORT || 4000; + +app.use(cors()); +app.use(express.json({ limit: "2mb" })); + +app.get("/health", (req, res) => { + res.json({ ok: true }); +}); + +app.use("/api/family", familyRoutes); +app.use("/api/todos", todoRoutes); +app.use("/api/schedules", scheduleRoutes); +app.use("/api/announcements", announcementRoutes); +app.use("/api/weather", weatherRoutes); +app.use("/api/bible", bibleRoutes); +app.use("/api/photos", photoRoutes); + +connectDb() + .then(() => { + app.listen(port, () => { + console.log(`Server listening on ${port}`); + }); + }) + .catch((error) => { + console.error("Failed to start server", error); + process.exit(1); + }); diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..9030f22 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,27 @@ +version: "3.9" + +services: + backend: + build: + context: ./backend + ports: + - "4000:4000" + environment: + PORT: "4000" + MONGODB_URI: "mongodb://mongo:27017/google-tv-dashboard" + env_file: + - ./backend/.env + depends_on: + - mongo + restart: unless-stopped + + mongo: + image: mongo:7 + ports: + - "27017:27017" + volumes: + - mongo-data:/data/db + restart: unless-stopped + +volumes: + mongo-data: diff --git a/docs/project-plan.md b/docs/project-plan.md new file mode 100644 index 0000000..bbd3b77 --- /dev/null +++ b/docs/project-plan.md @@ -0,0 +1,291 @@ +# Google TV Family Dashboard App - Project Plan + +Google TV용 가족 대시보드 앱 구현 계획입니다. TV 화면에서 일일 정보(달력, 날씨, 할일, 성경 말씀)를 표시하고, Flutter 앱을 통해 데이터를 입력/관리할 수 있는 시스템입니다. + +--- + +## System Architecture + +``` +┌─────────────────────────────────────────────────────────────────┐ +│ Google TV │ +│ Flutter TV App (APK) │ +└──────────────────────────┬──────────────────────────────────────┘ + │ + ▼ +┌─────────────────────────────────────────────────────────────────┐ +│ Backend Server │ +│ Node.js + Express API │ +│ MongoDB │ +└──────────────────────────┬──────────────────────────────────────┘ + │ + ┌──────────────┼──────────────┐ + ▼ ▼ ▼ + ┌───────────┐ ┌───────────┐ ┌───────────┐ + │ Weather │ │ Bible │ │ Flutter │ + │ API │ │ API │ │ Mobile │ + └───────────┘ └───────────┘ └───────────┘ +``` + +--- + +## Key Decisions + +| 항목 | 선택 | 비고 | +|------|------|------| +| **TV App** | Flutter for Android TV | 모바일 앱과 코드 공유, APK로 TV 설치 | +| **DB** | MongoDB | 확장성, 유연한 스키마 | +| **Weather API** | OpenWeatherMap | 무료 1000 calls/day, 환경변수로 변경 가능 | +| **Bible API** | bible-api.com | 영어+한글 동시 표시, 환경변수로 변경 가능 | +| **가족 구성원** | Admin 기능으로 관리 | Flutter 앱 내 설정에서 추가/수정/삭제 | +| **사진 갤러리** | Admin에서 업로드 | TV 화면에 랜덤 슬라이드쇼로 표시 | + +--- + +## TV Screen Specifications (43인치 기준) + +| 항목 | 값 | 설명 | +|------|-----|------| +| **해상도** | 1920 x 1080 px | Full HD 기준 (4K TV도 호환) | +| **화면 비율** | 16:9 | 표준 와이드스크린 | +| **실제 크기** | 95.3cm x 53.6cm | 43인치 대각선 기준 | +| **Safe Zone** | 90% 영역 사용 | 가장자리 5% 여백 권장 | + +### UI 레이아웃 가이드 + +``` +┌────────────────────────────────────────────────────────────────────────┐ +│ 1920px (16:9 @ 1080p) │ +├────────────────────────────────────────────────────────────────────────┤ +│ ┌────────────────────────────────────────────────────────────────┐ │ +│ │ Safe Zone (90%) │ │ +│ │ ┌─────────────────────────────┬──────────────────────────┐ │ │ +│ │ │ │ │ │ │ +│ │ │ 메인 영역 (65%) │ 사이드바 (35%) │ │ │ +│ │ │ 1248px │ 672px │ │ │ +│ │ │ │ │ │ │ +│ │ │ - 날씨 │ - 월간 달력 │ │ │ +│ │ │ - 오늘의 할일 │ - 주간 일정 │ │ │ +│ │ │ - 오늘의 말씀 │ - 공지사항 │ │ │ +│ │ │ │ │ │ │ +│ │ └─────────────────────────────┴──────────────────────────┘ │ │ +│ └────────────────────────────────────────────────────────────────┘ │ +│ │ 1080px +└────────────────────────────────────────────────────────────────────────┘ +``` + +### 폰트 크기 권장 (시청 거리 2~3m 기준) + +| 요소 | 크기 | 용도 | +|------|------|------| +| 헤더/시간 | 48-64px | 날짜, 현재 시간 | +| 제목 | 32-40px | 섹션 제목 | +| 본문 | 24-28px | 할일, 일정 내용 | +| 보조 텍스트 | 18-20px | 부가 정보 | + +--- + +## TV Display Layout (Single Usage Dashboard) + +모든 정보와 기능을 한 화면에서 볼 수 있는 통합 대시보드 레이아웃입니다. + +``` +┌────────────────────────────────────────────────────────────────────────┐ +│ 📅 2026.01.24 (금) 15:43:36 🌤️ 서울 12°C 맑음 │ +├──────────────────────┬─────────────────────────┬───────────────────────┤ +│ [📅 월간 달력] │ [🖼️ 가족 사진 앨범] │ [✅ 오늘의 할일] │ +│ │ │ │ +│ 1 2 3 4 5 6 7 │ (랜덤 슬라이드쇼) │ 👨 아빠: 마트, 운동 │ +│ 8 9 10 11 12 13 14 │ (30초 간격 전환) │ 👩 엄마: 회의 │ +│ 15 16 17 18 19 20 21 │ │ 👦 아들: 수학 숙제 │ +│ 22 23 24 25 26 27 28 │ │ 👧 딸: 피아노 가기 │ +│ 29 30 31 │ │ │ +├──────────────────────┤ ├───────────────────────┤ +│ [📋 주간 일정] │ │ [📖 오늘의 말씀] │ +│ │ │ │ +│ 금: 가족 모임 │ │ "The fear of the LORD │ +│ 토: 결혼식 참석 │ │ is the beginning..." │ +│ 일: 교회 예배 │ │ │ +│ │ │ "여호와를 경외하는..." │ +├──────────────────────┤ │ - 잠언 1:7 │ +│ [📢 공지사항] │ │ │ +│ • 다음 주 여행 계획 │ │ │ +└──────────────────────┴─────────────────────────┴───────────────────────┘ +``` + +### 위젯 구성 +1. **Header**: 날짜, 시간, 실시간 날씨 (Top Bar) +2. **Left Column (Plan)**: + - 월간 달력 (이번 달 전체 뷰) + - 주간 주요 일정 (리스트) + - 공지사항 (텍스트 롤링) +3. **Center Column (Memory)**: + - **가족 사진 위젯**: Admin에서 업로드한 사진들을 랜덤하게 표시 (디지털 액자 기능) +4. **Right Column (Focus)**: + - 가족별 오늘의 할일 (아바타와 함께 표시) + - 오늘의 말씀 (한글/영어 병기) + +--- + +## MongoDB Collections (Updated) + +### photos +```javascript +{ + _id: ObjectId, + url: "https://.../photo.jpg", // 또는 base64 (저장 용량 고려 필요) + caption: "2025 여름 휴가", + active: true, + createdAt: Date +} +``` + +### family_members (기존 동일) +... + +--- + +## API Endpoints (Updated) + +| Method | Endpoint | Description | +|--------|----------|-------------| +| GET/POST | `/api/photos` | 사진 목록 조회/업로드 | +| DELETE | `/api/photos/:id` | 사진 삭제 | +| ... | ... | (기존 API 동일) | + + +``` +bini-google-tv/ +├── docs/ +│ └── project-plan.md +├── backend/ +│ ├── server.js +│ ├── config/ +│ │ ├── db.js +│ │ └── api.js +│ ├── models/ +│ │ ├── FamilyMember.js +│ │ ├── Todo.js +│ │ ├── Schedule.js +│ │ ├── Announcement.js +│ │ └── Setting.js +│ ├── routes/ +│ │ ├── family.js +│ │ ├── todos.js +│ │ ├── schedules.js +│ │ ├── announcements.js +│ │ ├── weather.js +│ │ └── bible.js +│ ├── .env.example +│ └── package.json +└── flutter_app/ + ├── lib/ + │ ├── main.dart + │ ├── config/ + │ ├── models/ + │ ├── services/ + │ ├── screens/ + │ │ ├── tv/ + │ │ ├── mobile/ + │ │ └── admin/ + │ └── widgets/ + └── pubspec.yaml +``` + +--- + +## MongoDB Collections + +### family_members +```javascript +{ + _id: ObjectId, + name: "아빠", + emoji: "👨", + color: "#3498db", + order: 1, + createdAt: Date +} +``` + +### todos +```javascript +{ + _id: ObjectId, + familyMemberId: ObjectId, + title: "마트 장보기", + completed: false, + dueDate: Date, + createdAt: Date +} +``` + +### schedules +```javascript +{ + _id: ObjectId, + title: "가족 모임", + description: "할머니 댁 방문", + startDate: Date, + endDate: Date, + familyMemberId: ObjectId, + isAllDay: true, + createdAt: Date +} +``` + +### announcements +```javascript +{ + _id: ObjectId, + title: "이번 주 외식", + content: "금요일 저녁 외식 예정", + priority: 1, + active: true, + createdAt: Date +} +``` + +--- + +## API Endpoints + +| Method | Endpoint | Description | +|--------|----------|-------------| +| GET/POST | `/api/family` | 가족 구성원 조회/추가 | +| GET/PUT/DELETE | `/api/family/:id` | 특정 구성원 조회/수정/삭제 | +| GET/POST | `/api/todos` | 할일 조회/추가 | +| GET/PUT/DELETE | `/api/todos/:id` | 특정 할일 조회/수정/삭제 | +| GET | `/api/todos/today` | 오늘의 할일 조회 | +| GET/POST | `/api/schedules` | 일정 조회/추가 | +| GET | `/api/schedules/week` | 주간 일정 조회 | +| GET | `/api/schedules/month` | 월간 일정 조회 | +| GET/POST | `/api/announcements` | 공지사항 조회/추가 | +| GET | `/api/weather` | 현재 날씨 조회 | +| GET | `/api/bible/today` | 오늘의 말씀 조회 | + +--- + +## Development Phases + +| Phase | 내용 | 예상 시간 | +|-------|------|----------| +| 1 | Backend + MongoDB 설정 | 2-3시간 | +| 2 | REST API 구현 | 3-4시간 | +| 3 | Flutter 공통 구조 + 모델 | 2시간 | +| 4 | TV Display 화면 | 3-4시간 | +| 5 | Mobile 입력 화면 | 4-5시간 | +| 6 | Admin (가족구성원/설정) | 2시간 | +| 7 | 통합 + TV APK 빌드 | 2-3시간 | + +**총 예상 시간: 18-23시간** + +--- + +## TV App Installation + +1. **Flutter 빌드**: `flutter build apk --release` +2. **TV에 설치**: + - USB로 APK 전송 후 파일 관리자에서 설치 + - 또는 ADB 사용: `adb install app-release.apk` +3. **TV 홈에서 앱 실행** diff --git a/flutter_app/.gitignore b/flutter_app/.gitignore new file mode 100644 index 0000000..3820a95 --- /dev/null +++ b/flutter_app/.gitignore @@ -0,0 +1,45 @@ +# Miscellaneous +*.class +*.log +*.pyc +*.swp +.DS_Store +.atom/ +.build/ +.buildlog/ +.history +.svn/ +.swiftpm/ +migrate_working_dir/ + +# IntelliJ related +*.iml +*.ipr +*.iws +.idea/ + +# The .vscode folder contains launch configuration and tasks you configure in +# VS Code which you may wish to be included in version control, so this line +# is commented out by default. +#.vscode/ + +# Flutter/Dart/Pub related +**/doc/api/ +**/ios/Flutter/.last_build_id +.dart_tool/ +.flutter-plugins-dependencies +.pub-cache/ +.pub/ +/build/ +/coverage/ + +# Symbolication related +app.*.symbols + +# Obfuscation related +app.*.map.json + +# Android Studio will place build artifacts here +/android/app/debug +/android/app/profile +/android/app/release diff --git a/flutter_app/.metadata b/flutter_app/.metadata new file mode 100644 index 0000000..7ad3ada --- /dev/null +++ b/flutter_app/.metadata @@ -0,0 +1,30 @@ +# This file tracks properties of this Flutter project. +# Used by Flutter tool to assess capabilities and perform upgrades etc. +# +# This file should be version controlled and should not be manually edited. + +version: + revision: "f6ff1529fd6d8af5f706051d9251ac9231c83407" + channel: "stable" + +project_type: app + +# Tracks metadata for the flutter migrate command +migration: + platforms: + - platform: root + create_revision: f6ff1529fd6d8af5f706051d9251ac9231c83407 + base_revision: f6ff1529fd6d8af5f706051d9251ac9231c83407 + - platform: android + create_revision: f6ff1529fd6d8af5f706051d9251ac9231c83407 + base_revision: f6ff1529fd6d8af5f706051d9251ac9231c83407 + + # User provided section + + # List of Local paths (relative to this file) that should be + # ignored by the migrate tool. + # + # Files that are not part of the templates will be ignored by default. + unmanaged_files: + - 'lib/main.dart' + - 'ios/Runner.xcodeproj/project.pbxproj' diff --git a/flutter_app/README.md b/flutter_app/README.md new file mode 100644 index 0000000..d3b4013 --- /dev/null +++ b/flutter_app/README.md @@ -0,0 +1,16 @@ +# google_tv_dashboard + +A new Flutter project. + +## Getting Started + +This project is a starting point for a Flutter application. + +A few resources to get you started if this is your first Flutter project: + +- [Lab: Write your first Flutter app](https://docs.flutter.dev/get-started/codelab) +- [Cookbook: Useful Flutter samples](https://docs.flutter.dev/cookbook) + +For help getting started with Flutter development, view the +[online documentation](https://docs.flutter.dev/), which offers tutorials, +samples, guidance on mobile development, and a full API reference. diff --git a/flutter_app/analysis_options.yaml b/flutter_app/analysis_options.yaml new file mode 100644 index 0000000..0d29021 --- /dev/null +++ b/flutter_app/analysis_options.yaml @@ -0,0 +1,28 @@ +# This file configures the analyzer, which statically analyzes Dart code to +# check for errors, warnings, and lints. +# +# The issues identified by the analyzer are surfaced in the UI of Dart-enabled +# IDEs (https://dart.dev/tools#ides-and-editors). The analyzer can also be +# invoked from the command line by running `flutter analyze`. + +# The following line activates a set of recommended lints for Flutter apps, +# packages, and plugins designed to encourage good coding practices. +include: package:flutter_lints/flutter.yaml + +linter: + # The lint rules applied to this project can be customized in the + # section below to disable rules from the `package:flutter_lints/flutter.yaml` + # included above or to enable additional rules. A list of all available lints + # and their documentation is published at https://dart.dev/lints. + # + # Instead of disabling a lint rule for the entire project in the + # section below, it can also be suppressed for a single line of code + # or a specific dart file by using the `// ignore: name_of_lint` and + # `// ignore_for_file: name_of_lint` syntax on the line or in the file + # producing the lint. + rules: + # avoid_print: false # Uncomment to disable the `avoid_print` rule + # prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule + +# Additional information about this file can be found at +# https://dart.dev/guides/language/analysis-options diff --git a/flutter_app/android/.gitignore b/flutter_app/android/.gitignore new file mode 100644 index 0000000..be3943c --- /dev/null +++ b/flutter_app/android/.gitignore @@ -0,0 +1,14 @@ +gradle-wrapper.jar +/.gradle +/captures/ +/gradlew +/gradlew.bat +/local.properties +GeneratedPluginRegistrant.java +.cxx/ + +# Remember to never publicly share your keystore. +# See https://flutter.dev/to/reference-keystore +key.properties +**/*.keystore +**/*.jks diff --git a/flutter_app/android/app/build.gradle.kts b/flutter_app/android/app/build.gradle.kts new file mode 100644 index 0000000..00da66b --- /dev/null +++ b/flutter_app/android/app/build.gradle.kts @@ -0,0 +1,44 @@ +plugins { + id("com.android.application") + id("kotlin-android") + // The Flutter Gradle Plugin must be applied after the Android and Kotlin Gradle plugins. + id("dev.flutter.flutter-gradle-plugin") +} + +android { + namespace = "com.example.google_tv_dashboard" + compileSdk = flutter.compileSdkVersion + ndkVersion = flutter.ndkVersion + + compileOptions { + sourceCompatibility = JavaVersion.VERSION_17 + targetCompatibility = JavaVersion.VERSION_17 + } + + kotlinOptions { + jvmTarget = JavaVersion.VERSION_17.toString() + } + + defaultConfig { + // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). + applicationId = "com.example.google_tv_dashboard" + // You can update the following values to match your application needs. + // For more information, see: https://flutter.dev/to/review-gradle-config. + minSdk = flutter.minSdkVersion + targetSdk = flutter.targetSdkVersion + versionCode = flutter.versionCode + versionName = flutter.versionName + } + + buildTypes { + release { + // TODO: Add your own signing config for the release build. + // Signing with the debug keys for now, so `flutter run --release` works. + signingConfig = signingConfigs.getByName("debug") + } + } +} + +flutter { + source = "../.." +} diff --git a/flutter_app/android/app/src/debug/AndroidManifest.xml b/flutter_app/android/app/src/debug/AndroidManifest.xml new file mode 100644 index 0000000..399f698 --- /dev/null +++ b/flutter_app/android/app/src/debug/AndroidManifest.xml @@ -0,0 +1,7 @@ + + + + diff --git a/flutter_app/android/app/src/main/AndroidManifest.xml b/flutter_app/android/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..0b0fc45 --- /dev/null +++ b/flutter_app/android/app/src/main/AndroidManifest.xml @@ -0,0 +1,45 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/flutter_app/android/app/src/main/kotlin/com/example/google_tv_dashboard/MainActivity.kt b/flutter_app/android/app/src/main/kotlin/com/example/google_tv_dashboard/MainActivity.kt new file mode 100644 index 0000000..28ec66e --- /dev/null +++ b/flutter_app/android/app/src/main/kotlin/com/example/google_tv_dashboard/MainActivity.kt @@ -0,0 +1,5 @@ +package com.example.google_tv_dashboard + +import io.flutter.embedding.android.FlutterActivity + +class MainActivity : FlutterActivity() diff --git a/flutter_app/android/app/src/main/res/drawable-v21/launch_background.xml b/flutter_app/android/app/src/main/res/drawable-v21/launch_background.xml new file mode 100644 index 0000000..f74085f --- /dev/null +++ b/flutter_app/android/app/src/main/res/drawable-v21/launch_background.xml @@ -0,0 +1,12 @@ + + + + + + + + diff --git a/flutter_app/android/app/src/main/res/drawable/launch_background.xml b/flutter_app/android/app/src/main/res/drawable/launch_background.xml new file mode 100644 index 0000000..304732f --- /dev/null +++ b/flutter_app/android/app/src/main/res/drawable/launch_background.xml @@ -0,0 +1,12 @@ + + + + + + + + diff --git a/flutter_app/android/app/src/main/res/mipmap-hdpi/ic_launcher.png b/flutter_app/android/app/src/main/res/mipmap-hdpi/ic_launcher.png new file mode 100644 index 0000000..db77bb4 Binary files /dev/null and b/flutter_app/android/app/src/main/res/mipmap-hdpi/ic_launcher.png differ diff --git a/flutter_app/android/app/src/main/res/mipmap-mdpi/ic_launcher.png b/flutter_app/android/app/src/main/res/mipmap-mdpi/ic_launcher.png new file mode 100644 index 0000000..17987b7 Binary files /dev/null and b/flutter_app/android/app/src/main/res/mipmap-mdpi/ic_launcher.png differ diff --git a/flutter_app/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png b/flutter_app/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png new file mode 100644 index 0000000..09d4391 Binary files /dev/null and b/flutter_app/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png differ diff --git a/flutter_app/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png b/flutter_app/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png new file mode 100644 index 0000000..d5f1c8d Binary files /dev/null and b/flutter_app/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png differ diff --git a/flutter_app/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/flutter_app/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png new file mode 100644 index 0000000..4d6372e Binary files /dev/null and b/flutter_app/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png differ diff --git a/flutter_app/android/app/src/main/res/values-night/styles.xml b/flutter_app/android/app/src/main/res/values-night/styles.xml new file mode 100644 index 0000000..06952be --- /dev/null +++ b/flutter_app/android/app/src/main/res/values-night/styles.xml @@ -0,0 +1,18 @@ + + + + + + + diff --git a/flutter_app/android/app/src/main/res/values/styles.xml b/flutter_app/android/app/src/main/res/values/styles.xml new file mode 100644 index 0000000..cb1ef88 --- /dev/null +++ b/flutter_app/android/app/src/main/res/values/styles.xml @@ -0,0 +1,18 @@ + + + + + + + diff --git a/flutter_app/android/app/src/profile/AndroidManifest.xml b/flutter_app/android/app/src/profile/AndroidManifest.xml new file mode 100644 index 0000000..399f698 --- /dev/null +++ b/flutter_app/android/app/src/profile/AndroidManifest.xml @@ -0,0 +1,7 @@ + + + + diff --git a/flutter_app/android/build.gradle.kts b/flutter_app/android/build.gradle.kts new file mode 100644 index 0000000..dbee657 --- /dev/null +++ b/flutter_app/android/build.gradle.kts @@ -0,0 +1,24 @@ +allprojects { + repositories { + google() + mavenCentral() + } +} + +val newBuildDir: Directory = + rootProject.layout.buildDirectory + .dir("../../build") + .get() +rootProject.layout.buildDirectory.value(newBuildDir) + +subprojects { + val newSubprojectBuildDir: Directory = newBuildDir.dir(project.name) + project.layout.buildDirectory.value(newSubprojectBuildDir) +} +subprojects { + project.evaluationDependsOn(":app") +} + +tasks.register("clean") { + delete(rootProject.layout.buildDirectory) +} diff --git a/flutter_app/android/gradle.properties b/flutter_app/android/gradle.properties new file mode 100644 index 0000000..fbee1d8 --- /dev/null +++ b/flutter_app/android/gradle.properties @@ -0,0 +1,2 @@ +org.gradle.jvmargs=-Xmx8G -XX:MaxMetaspaceSize=4G -XX:ReservedCodeCacheSize=512m -XX:+HeapDumpOnOutOfMemoryError +android.useAndroidX=true diff --git a/flutter_app/android/gradle/wrapper/gradle-wrapper.properties b/flutter_app/android/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000..e4ef43f --- /dev/null +++ b/flutter_app/android/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,5 @@ +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-8.14-all.zip diff --git a/flutter_app/android/settings.gradle.kts b/flutter_app/android/settings.gradle.kts new file mode 100644 index 0000000..ca7fe06 --- /dev/null +++ b/flutter_app/android/settings.gradle.kts @@ -0,0 +1,26 @@ +pluginManagement { + val flutterSdkPath = + run { + val properties = java.util.Properties() + file("local.properties").inputStream().use { properties.load(it) } + val flutterSdkPath = properties.getProperty("flutter.sdk") + require(flutterSdkPath != null) { "flutter.sdk not set in local.properties" } + flutterSdkPath + } + + includeBuild("$flutterSdkPath/packages/flutter_tools/gradle") + + repositories { + google() + mavenCentral() + gradlePluginPortal() + } +} + +plugins { + id("dev.flutter.flutter-plugin-loader") version "1.0.0" + id("com.android.application") version "8.11.1" apply false + id("org.jetbrains.kotlin.android") version "2.2.20" apply false +} + +include(":app") diff --git a/flutter_app/lib/config/api_config.dart b/flutter_app/lib/config/api_config.dart new file mode 100644 index 0000000..f7deb0d --- /dev/null +++ b/flutter_app/lib/config/api_config.dart @@ -0,0 +1,20 @@ +class ApiConfig { + static const String baseUrl = String.fromEnvironment( + "API_BASE_URL", + defaultValue: "http://localhost:4000", + ); + + static const bool useMockData = bool.fromEnvironment( + "USE_MOCK_DATA", + defaultValue: false, + ); + + static const String family = "/api/family"; + static const String todos = "/api/todos"; + static const String schedules = "/api/schedules"; + static const String announcements = "/api/announcements"; + static const String weather = "/api/weather"; + static const String bibleToday = "/api/bible/today"; + static const String bibleVerses = "/api/bible/verses"; + static const String photos = "/api/photos"; +} diff --git a/flutter_app/lib/main.dart b/flutter_app/lib/main.dart new file mode 100644 index 0000000..bd62a14 --- /dev/null +++ b/flutter_app/lib/main.dart @@ -0,0 +1,132 @@ +import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; +import 'package:google_fonts/google_fonts.dart'; +import 'package:intl/date_symbol_data_local.dart'; +import 'package:provider/provider.dart'; + +import 'config/api_config.dart'; +import 'screens/admin/admin_screen.dart'; +import 'screens/mobile/mobile_home_screen.dart'; +import 'screens/tv/tv_dashboard_screen.dart'; +import 'services/announcement_service.dart'; +import 'services/api_client.dart'; +import 'services/bible_service.dart'; +import 'services/bible_verse_service.dart'; +import 'services/family_service.dart'; +import 'services/photo_service.dart'; +import 'services/schedule_service.dart'; +import 'services/todo_service.dart'; +import 'services/weather_service.dart'; + +Future main() async { + WidgetsFlutterBinding.ensureInitialized(); + // Hide status bar for TV immersive experience + SystemChrome.setEnabledSystemUIMode(SystemUiMode.immersiveSticky); + + await initializeDateFormatting(); + + runApp(const MyApp()); +} + +class MyApp extends StatelessWidget { + const MyApp({super.key}); + + @override + Widget build(BuildContext context) { + // Shared ApiClient instance + final apiClient = ApiClient(); + + return MultiProvider( + providers: [ + Provider.value(value: apiClient), + Provider(create: (_) => WeatherService(apiClient)), + Provider(create: (_) => BibleService(apiClient)), + Provider( + create: (_) => BibleVerseService(apiClient), + ), + Provider(create: (_) => TodoService(apiClient)), + Provider(create: (_) => ScheduleService(apiClient)), + Provider( + create: (_) => AnnouncementService(apiClient), + ), + Provider(create: (_) => PhotoService(apiClient)), + Provider(create: (_) => FamilyService(apiClient)), + ], + child: MaterialApp( + title: 'Bini Google TV Dashboard', + debugShowCheckedModeBanner: false, + theme: ThemeData( + useMaterial3: true, + brightness: Brightness.dark, + scaffoldBackgroundColor: const Color( + 0xFF0F172A, + ), // Deep Midnight Navy + colorScheme: const ColorScheme.dark( + primary: Color(0xFFFFD700), // Cinema Gold + onPrimary: Colors.black, + secondary: Color(0xFF4FC3F7), // Sky Blue + onSecondary: Colors.black, + surface: Color(0xFF1E293B), // Slate 800 + onSurface: Colors.white, + background: Color(0xFF0F172A), + onBackground: Colors.white, + error: Color(0xFFFF6E40), // Deep Orange + ), + cardTheme: CardThemeData( + color: const Color(0xFF1E293B), + elevation: 4, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(16), + ), + ), + textTheme: TextTheme( + displayLarge: GoogleFonts.outfit( + fontSize: 64, + fontWeight: FontWeight.bold, + color: Colors.white, + ), // Header time + displayMedium: GoogleFonts.outfit( + fontSize: 40, + fontWeight: FontWeight.w600, + color: const Color(0xFFF1F5F9), + ), // Section titles + bodyLarge: GoogleFonts.mulish( + fontSize: 24, + color: const Color(0xFFE2E8F0), + ), // Main content + bodyMedium: GoogleFonts.mulish( + fontSize: 18, + color: const Color(0xFFCBD5E1), + ), // Secondary content + displaySmall: GoogleFonts.outfit( + fontSize: 32, + fontWeight: FontWeight.bold, + color: Colors.white, + ), // Clock usage + headlineSmall: GoogleFonts.outfit( + fontSize: 24, + fontWeight: FontWeight.bold, + color: Colors.white, + ), + titleLarge: GoogleFonts.outfit( + fontSize: 22, + fontWeight: FontWeight.w600, + color: Colors.white, + ), + titleMedium: GoogleFonts.outfit( + fontSize: 16, + fontWeight: FontWeight.w500, + color: const Color(0xFFF1F5F9), + ), + ), + ), + initialRoute: '/', + routes: { + '/': (context) => const TvDashboardScreen(), + '/mobile': (context) => const MobileHomeScreen(), + '/admin': (context) => const AdminScreen(), + }, + ), + ); + } +} diff --git a/flutter_app/lib/models/announcement.dart b/flutter_app/lib/models/announcement.dart new file mode 100644 index 0000000..9354a34 --- /dev/null +++ b/flutter_app/lib/models/announcement.dart @@ -0,0 +1,34 @@ +class Announcement { + final String id; + final String title; + final String content; + final int priority; + final bool active; + + const Announcement({ + required this.id, + required this.title, + required this.content, + required this.priority, + required this.active, + }); + + factory Announcement.fromJson(Map json) { + return Announcement( + id: json["_id"] as String? ?? "", + title: json["title"] as String? ?? "", + content: json["content"] as String? ?? "", + priority: (json["priority"] as num?)?.toInt() ?? 0, + active: json["active"] as bool? ?? true, + ); + } + + Map toJson() { + return { + "title": title, + "content": content, + "priority": priority, + "active": active, + }; + } +} diff --git a/flutter_app/lib/models/bible_verse.dart b/flutter_app/lib/models/bible_verse.dart new file mode 100644 index 0000000..27d1466 --- /dev/null +++ b/flutter_app/lib/models/bible_verse.dart @@ -0,0 +1,34 @@ +class BibleVerse { + final String id; + final String text; + final String reference; + final String? date; + final bool active; + + const BibleVerse({ + required this.id, + required this.text, + required this.reference, + required this.date, + required this.active, + }); + + factory BibleVerse.fromJson(Map json) { + return BibleVerse( + id: json["_id"] as String? ?? "", + text: json["text"] as String? ?? "", + reference: json["reference"] as String? ?? "", + date: json["date"] as String?, + active: json["active"] as bool? ?? true, + ); + } + + Map toJson() { + return { + "text": text, + "reference": reference, + "date": date, + "active": active, + }; + } +} diff --git a/flutter_app/lib/models/family_member.dart b/flutter_app/lib/models/family_member.dart new file mode 100644 index 0000000..ff86d9a --- /dev/null +++ b/flutter_app/lib/models/family_member.dart @@ -0,0 +1,29 @@ +class FamilyMember { + final String id; + final String name; + final String emoji; + final String color; + final int order; + + const FamilyMember({ + required this.id, + required this.name, + required this.emoji, + required this.color, + required this.order, + }); + + factory FamilyMember.fromJson(Map json) { + return FamilyMember( + id: json["_id"] as String? ?? "", + name: json["name"] as String? ?? "", + emoji: json["emoji"] as String? ?? "", + color: json["color"] as String? ?? "", + order: (json["order"] as num?)?.toInt() ?? 0, + ); + } + + Map toJson() { + return {"name": name, "emoji": emoji, "color": color, "order": order}; + } +} diff --git a/flutter_app/lib/models/photo.dart b/flutter_app/lib/models/photo.dart new file mode 100644 index 0000000..8057350 --- /dev/null +++ b/flutter_app/lib/models/photo.dart @@ -0,0 +1,26 @@ +class Photo { + final String id; + final String url; + final String caption; + final bool active; + + const Photo({ + required this.id, + required this.url, + required this.caption, + required this.active, + }); + + factory Photo.fromJson(Map json) { + return Photo( + id: json["_id"] as String? ?? "", + url: json["url"] as String? ?? "", + caption: json["caption"] as String? ?? "", + active: json["active"] as bool? ?? true, + ); + } + + Map toJson() { + return {"url": url, "caption": caption, "active": active}; + } +} diff --git a/flutter_app/lib/models/schedule_item.dart b/flutter_app/lib/models/schedule_item.dart new file mode 100644 index 0000000..69106ef --- /dev/null +++ b/flutter_app/lib/models/schedule_item.dart @@ -0,0 +1,45 @@ +class ScheduleItem { + final String id; + final String title; + final String description; + final DateTime startDate; + final DateTime endDate; + final String familyMemberId; + final bool isAllDay; + + const ScheduleItem({ + required this.id, + required this.title, + required this.description, + required this.startDate, + required this.endDate, + required this.familyMemberId, + required this.isAllDay, + }); + + factory ScheduleItem.fromJson(Map json) { + return ScheduleItem( + id: json["_id"] as String? ?? "", + title: json["title"] as String? ?? "", + description: json["description"] as String? ?? "", + startDate: + DateTime.tryParse(json["startDate"] as String? ?? "") ?? + DateTime.now(), + endDate: + DateTime.tryParse(json["endDate"] as String? ?? "") ?? DateTime.now(), + familyMemberId: json["familyMemberId"] as String? ?? "", + isAllDay: json["isAllDay"] as bool? ?? false, + ); + } + + Map toJson() { + return { + "title": title, + "description": description, + "startDate": startDate.toIso8601String(), + "endDate": endDate.toIso8601String(), + "familyMemberId": familyMemberId, + "isAllDay": isAllDay, + }; + } +} diff --git a/flutter_app/lib/models/todo_item.dart b/flutter_app/lib/models/todo_item.dart new file mode 100644 index 0000000..c910296 --- /dev/null +++ b/flutter_app/lib/models/todo_item.dart @@ -0,0 +1,36 @@ +class TodoItem { + final String id; + final String familyMemberId; + final String title; + final bool completed; + final DateTime? dueDate; + + const TodoItem({ + required this.id, + required this.familyMemberId, + required this.title, + required this.completed, + required this.dueDate, + }); + + factory TodoItem.fromJson(Map json) { + return TodoItem( + id: json["_id"] as String? ?? "", + familyMemberId: json["familyMemberId"] as String? ?? "", + title: json["title"] as String? ?? "", + completed: json["completed"] as bool? ?? false, + dueDate: json["dueDate"] != null + ? DateTime.tryParse(json["dueDate"] as String) + : null, + ); + } + + Map toJson() { + return { + "familyMemberId": familyMemberId, + "title": title, + "completed": completed, + "dueDate": dueDate?.toIso8601String(), + }; + } +} diff --git a/flutter_app/lib/models/weather_info.dart b/flutter_app/lib/models/weather_info.dart new file mode 100644 index 0000000..fc3943e --- /dev/null +++ b/flutter_app/lib/models/weather_info.dart @@ -0,0 +1,25 @@ +class WeatherInfo { + final String description; + final double temperature; + final String icon; + final String city; + + const WeatherInfo({ + required this.description, + required this.temperature, + required this.icon, + required this.city, + }); + + factory WeatherInfo.fromJson(Map json) { + final weather = (json["weather"] as List? ?? []).isNotEmpty + ? json["weather"][0] as Map + : {}; + return WeatherInfo( + description: weather["description"] as String? ?? "", + temperature: (json["main"]?["temp"] as num?)?.toDouble() ?? 0, + icon: weather["icon"] as String? ?? "", + city: json["name"] as String? ?? "", + ); + } +} diff --git a/flutter_app/lib/screens/admin/admin_screen.dart b/flutter_app/lib/screens/admin/admin_screen.dart new file mode 100644 index 0000000..b5c045f --- /dev/null +++ b/flutter_app/lib/screens/admin/admin_screen.dart @@ -0,0 +1,450 @@ +import 'package:flutter/material.dart'; +import 'package:provider/provider.dart'; +import '../../models/bible_verse.dart'; +import '../../models/family_member.dart'; +import '../../models/photo.dart'; +import '../../services/bible_verse_service.dart'; +import '../../services/family_service.dart'; +import '../../services/photo_service.dart'; + +class AdminScreen extends StatefulWidget { + const AdminScreen({super.key}); + + @override + State createState() => _AdminScreenState(); +} + +class _AdminScreenState extends State { + @override + Widget build(BuildContext context) { + return DefaultTabController( + length: 3, + child: Scaffold( + appBar: AppBar( + title: const Text('Admin Settings'), + bottom: const TabBar( + tabs: [ + Tab(text: 'Family Members'), + Tab(text: 'Photos'), + Tab(text: 'Bible Verses'), + ], + ), + ), + body: const TabBarView( + children: [ + FamilyManagerTab(), + PhotoManagerTab(), + BibleVerseManagerTab(), + ], + ), + ), + ); + } +} + +class FamilyManagerTab extends StatefulWidget { + const FamilyManagerTab({super.key}); + + @override + State createState() => _FamilyManagerTabState(); +} + +class _FamilyManagerTabState extends State { + @override + Widget build(BuildContext context) { + return Scaffold( + floatingActionButton: FloatingActionButton( + onPressed: () => _showAddMemberDialog(context), + child: const Icon(Icons.add), + ), + body: FutureBuilder>( + future: Provider.of(context).fetchFamilyMembers(), + builder: (context, snapshot) { + if (!snapshot.hasData) + return const Center(child: CircularProgressIndicator()); + final members = snapshot.data!; + return ListView.builder( + itemCount: members.length, + itemBuilder: (context, index) { + final member = members[index]; + Color memberColor; + try { + memberColor = Color( + int.parse(member.color.replaceAll('#', '0xFF')), + ); + } catch (_) { + memberColor = Colors.grey; + } + + return ListTile( + leading: CircleAvatar( + backgroundColor: memberColor, + child: Text( + member.emoji, + style: const TextStyle(fontSize: 20), + ), + ), + title: Text(member.name), + subtitle: Text('Order: ${member.order}'), + trailing: IconButton( + icon: const Icon(Icons.delete, color: Colors.red), + onPressed: () async { + await Provider.of( + context, + listen: false, + ).deleteFamilyMember(member.id); + setState(() {}); + }, + ), + ); + }, + ); + }, + ), + ); + } + + void _showAddMemberDialog(BuildContext context) { + final nameController = TextEditingController(); + final emojiController = TextEditingController(text: '👤'); + final colorController = TextEditingController(text: '0xFFFFD700'); + final orderController = TextEditingController(text: '1'); + + showDialog( + context: context, + builder: (context) => AlertDialog( + title: const Text('Add Family Member'), + content: SingleChildScrollView( + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ + TextField( + controller: nameController, + decoration: const InputDecoration(labelText: 'Name'), + ), + TextField( + controller: emojiController, + decoration: const InputDecoration(labelText: 'Emoji'), + ), + TextField( + controller: colorController, + decoration: const InputDecoration( + labelText: 'Color (Hex 0xAARRGGBB)', + ), + ), + TextField( + controller: orderController, + decoration: const InputDecoration(labelText: 'Order'), + keyboardType: TextInputType.number, + ), + ], + ), + ), + actions: [ + TextButton( + onPressed: () => Navigator.pop(context), + child: const Text('Cancel'), + ), + TextButton( + onPressed: () async { + if (nameController.text.isNotEmpty) { + await Provider.of( + context, + listen: false, + ).createFamilyMember( + FamilyMember( + id: '', + name: nameController.text, + emoji: emojiController.text, + color: colorController.text.replaceFirst( + '0xFF', + '#', + ), // Simple conversion + order: int.tryParse(orderController.text) ?? 1, + ), + ); + if (mounted) { + Navigator.pop(context); + setState(() {}); + } + } + }, + child: const Text('Add'), + ), + ], + ), + ); + } +} + +class PhotoManagerTab extends StatefulWidget { + const PhotoManagerTab({super.key}); + + @override + State createState() => _PhotoManagerTabState(); +} + +class _PhotoManagerTabState extends State { + @override + Widget build(BuildContext context) { + return Scaffold( + floatingActionButton: FloatingActionButton( + onPressed: () => _showAddPhotoDialog(context), + child: const Icon(Icons.add_a_photo), + ), + body: FutureBuilder>( + future: Provider.of(context).fetchPhotos(), + builder: (context, snapshot) { + if (!snapshot.hasData) + return const Center(child: CircularProgressIndicator()); + final photos = snapshot.data!; + return GridView.builder( + padding: const EdgeInsets.all(8), + gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount( + crossAxisCount: 3, + crossAxisSpacing: 8, + mainAxisSpacing: 8, + ), + itemCount: photos.length, + itemBuilder: (context, index) { + final photo = photos[index]; + return GridTile( + footer: GridTileBar( + backgroundColor: Colors.black54, + title: Text(photo.caption), + trailing: IconButton( + icon: const Icon(Icons.delete, color: Colors.white), + onPressed: () async { + await Provider.of( + context, + listen: false, + ).deletePhoto(photo.id); + setState(() {}); + }, + ), + ), + child: Image.network( + photo.url, + fit: BoxFit.cover, + errorBuilder: (_, __, ___) => + const Center(child: Icon(Icons.broken_image)), + ), + ); + }, + ); + }, + ), + ); + } + + void _showAddPhotoDialog(BuildContext context) { + final urlController = TextEditingController(); + final captionController = TextEditingController(); + + showDialog( + context: context, + builder: (context) => AlertDialog( + title: const Text('Add Photo URL'), + content: Column( + mainAxisSize: MainAxisSize.min, + children: [ + TextField( + controller: urlController, + decoration: const InputDecoration(labelText: 'Image URL'), + ), + TextField( + controller: captionController, + decoration: const InputDecoration(labelText: 'Caption'), + ), + ], + ), + actions: [ + TextButton( + onPressed: () => Navigator.pop(context), + child: const Text('Cancel'), + ), + TextButton( + onPressed: () async { + if (urlController.text.isNotEmpty) { + await Provider.of( + context, + listen: false, + ).createPhoto( + Photo( + id: '', + url: urlController.text, + caption: captionController.text, + active: true, + ), + ); + if (mounted) { + Navigator.pop(context); + setState(() {}); + } + } + }, + child: const Text('Add'), + ), + ], + ), + ); + } +} + +class BibleVerseManagerTab extends StatefulWidget { + const BibleVerseManagerTab({super.key}); + + @override + State createState() => _BibleVerseManagerTabState(); +} + +class _BibleVerseManagerTabState extends State { + @override + Widget build(BuildContext context) { + return Scaffold( + floatingActionButton: FloatingActionButton( + onPressed: () => _showAddVerseDialog(context), + child: const Icon(Icons.menu_book), + ), + body: FutureBuilder>( + future: Provider.of(context).fetchVerses(), + builder: (context, snapshot) { + if (!snapshot.hasData) { + return const Center(child: CircularProgressIndicator()); + } + final verses = snapshot.data!; + if (verses.isEmpty) { + return const Center( + child: Text( + 'No verses added yet', + style: TextStyle(color: Colors.grey), + ), + ); + } + return ListView.builder( + itemCount: verses.length, + itemBuilder: (context, index) { + final verse = verses[index]; + return ListTile( + title: Text(verse.reference), + subtitle: Text( + verse.text, + maxLines: 1, + overflow: TextOverflow.ellipsis, + ), + trailing: Row( + mainAxisSize: MainAxisSize.min, + children: [ + if (verse.date != null && verse.date!.isNotEmpty) + Text( + verse.date!, + style: + const TextStyle(fontSize: 12, color: Colors.grey), + ), + IconButton( + icon: const Icon(Icons.delete, color: Colors.red), + onPressed: () async { + await Provider.of( + context, + listen: false, + ).deleteVerse(verse.id); + setState(() {}); + }, + ), + ], + ), + ); + }, + ); + }, + ), + ); + } + + void _showAddVerseDialog(BuildContext context) { + final textController = TextEditingController(); + final referenceController = TextEditingController(); + final dateController = TextEditingController(); + bool isActive = true; + + showDialog( + context: context, + builder: (context) => StatefulBuilder( + builder: (context, setDialogState) => AlertDialog( + title: const Text('Add Bible Verse'), + content: SingleChildScrollView( + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ + TextField( + controller: referenceController, + decoration: const InputDecoration( + labelText: 'Reference (e.g., Psalms 23:1)', + ), + ), + const SizedBox(height: 8), + TextField( + controller: textController, + decoration: const InputDecoration( + labelText: 'Verse Text (Korean)', + ), + maxLines: 3, + ), + const SizedBox(height: 8), + TextField( + controller: dateController, + decoration: const InputDecoration( + labelText: 'Date (YYYY-MM-DD) - Optional', + hintText: '2024-01-01', + ), + ), + const SizedBox(height: 8), + SwitchListTile( + title: const Text('Active'), + value: isActive, + onChanged: (value) { + setDialogState(() { + isActive = value; + }); + }, + ), + ], + ), + ), + actions: [ + TextButton( + onPressed: () => Navigator.pop(context), + child: const Text('Cancel'), + ), + TextButton( + onPressed: () async { + if (textController.text.isNotEmpty && + referenceController.text.isNotEmpty) { + await Provider.of( + context, + listen: false, + ).createVerse( + BibleVerse( + id: '', + text: textController.text, + reference: referenceController.text, + date: dateController.text.isEmpty + ? null + : dateController.text, + active: isActive, + ), + ); + if (mounted) { + Navigator.pop(context); + setState(() {}); + } + } + }, + child: const Text('Add'), + ), + ], + ), + ), + ); + } +} diff --git a/flutter_app/lib/screens/mobile/mobile_home_screen.dart b/flutter_app/lib/screens/mobile/mobile_home_screen.dart new file mode 100644 index 0000000..beac42f --- /dev/null +++ b/flutter_app/lib/screens/mobile/mobile_home_screen.dart @@ -0,0 +1,431 @@ +import 'package:flutter/material.dart'; +import 'package:provider/provider.dart'; +import 'package:intl/intl.dart'; +import '../../models/todo_item.dart'; +import '../../models/schedule_item.dart'; +import '../../models/announcement.dart'; +import '../../models/family_member.dart'; +import '../../services/todo_service.dart'; +import '../../services/schedule_service.dart'; +import '../../services/announcement_service.dart'; +import '../../services/family_service.dart'; + +class MobileHomeScreen extends StatefulWidget { + const MobileHomeScreen({super.key}); + + @override + State createState() => _MobileHomeScreenState(); +} + +class _MobileHomeScreenState extends State { + int _currentIndex = 0; + + final List _screens = [ + const MobileTodoScreen(), + const MobileScheduleScreen(), + const MobileAnnouncementScreen(), + ]; + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar( + title: const Text('Bini Family Manager'), + actions: [ + IconButton( + icon: const Icon(Icons.settings), + onPressed: () { + Navigator.pushNamed(context, '/admin'); + }, + ), + ], + ), + body: _screens[_currentIndex], + bottomNavigationBar: BottomNavigationBar( + currentIndex: _currentIndex, + onTap: (index) { + setState(() { + _currentIndex = index; + }); + }, + items: const [ + BottomNavigationBarItem(icon: Icon(Icons.check_box), label: 'Todos'), + BottomNavigationBarItem( + icon: Icon(Icons.calendar_today), + label: 'Schedule', + ), + BottomNavigationBarItem(icon: Icon(Icons.campaign), label: 'Notices'), + ], + ), + ); + } +} + +class MobileTodoScreen extends StatefulWidget { + const MobileTodoScreen({super.key}); + + @override + State createState() => _MobileTodoScreenState(); +} + +class _MobileTodoScreenState extends State { + @override + Widget build(BuildContext context) { + return Scaffold( + floatingActionButton: FloatingActionButton( + onPressed: () => _showAddTodoDialog(context), + child: const Icon(Icons.add), + ), + body: FutureBuilder>( + future: Provider.of( + context, + ).fetchTodos(), // Fetch all or today? Let's fetch all for manager + builder: (context, snapshot) { + if (!snapshot.hasData) + return const Center(child: CircularProgressIndicator()); + final todos = snapshot.data!; + return ListView.builder( + itemCount: todos.length, + itemBuilder: (context, index) { + final todo = todos[index]; + return ListTile( + title: Text(todo.title), + subtitle: Text( + todo.dueDate != null + ? DateFormat('MM/dd').format(todo.dueDate!) + : 'No date', + ), + trailing: Checkbox( + value: todo.completed, + onChanged: (val) async { + await Provider.of( + context, + listen: false, + ).updateTodo( + TodoItem( + id: todo.id, + familyMemberId: todo.familyMemberId, + title: todo.title, + completed: val ?? false, + dueDate: todo.dueDate, + ), + ); + setState(() {}); + }, + ), + onLongPress: () async { + await Provider.of( + context, + listen: false, + ).deleteTodo(todo.id); + setState(() {}); + }, + ); + }, + ); + }, + ), + ); + } + + void _showAddTodoDialog(BuildContext context) async { + final titleController = TextEditingController(); + final familyMembers = await Provider.of( + context, + listen: false, + ).fetchFamilyMembers(); + String? selectedMemberId = + familyMembers.isNotEmpty ? familyMembers.first.id : null; + + showDialog( + context: context, + builder: (context) => AlertDialog( + title: const Text('Add Todo'), + content: Column( + mainAxisSize: MainAxisSize.min, + children: [ + TextField( + controller: titleController, + decoration: const InputDecoration(labelText: 'Task'), + ), + DropdownButtonFormField( + value: selectedMemberId, + items: familyMembers + .map( + (m) => DropdownMenuItem(value: m.id, child: Text(m.name)), + ) + .toList(), + onChanged: (val) => selectedMemberId = val, + decoration: const InputDecoration(labelText: 'Assign to'), + ), + ], + ), + actions: [ + TextButton( + onPressed: () => Navigator.pop(context), + child: const Text('Cancel'), + ), + TextButton( + onPressed: () async { + if (selectedMemberId != null && titleController.text.isNotEmpty) { + await Provider.of( + context, + listen: false, + ).createTodo( + TodoItem( + id: '', + familyMemberId: selectedMemberId!, + title: titleController.text, + completed: false, + dueDate: DateTime.now(), + ), + ); + if (mounted) { + Navigator.pop(context); + setState(() {}); + } + } + }, + child: const Text('Add'), + ), + ], + ), + ); + } +} + +class MobileScheduleScreen extends StatefulWidget { + const MobileScheduleScreen({super.key}); + + @override + State createState() => _MobileScheduleScreenState(); +} + +class _MobileScheduleScreenState extends State { + @override + Widget build(BuildContext context) { + return Scaffold( + floatingActionButton: FloatingActionButton( + onPressed: () => _showAddScheduleDialog(context), + child: const Icon(Icons.add), + ), + body: FutureBuilder>( + future: Provider.of(context).fetchSchedules(), + builder: (context, snapshot) { + if (!snapshot.hasData) + return const Center(child: CircularProgressIndicator()); + final schedules = snapshot.data!; + return ListView.builder( + itemCount: schedules.length, + itemBuilder: (context, index) { + final item = schedules[index]; + return ListTile( + title: Text(item.title), + subtitle: Text( + '${DateFormat('MM/dd HH:mm').format(item.startDate)} - ${item.description}', + ), + onLongPress: () async { + await Provider.of( + context, + listen: false, + ).deleteSchedule(item.id); + setState(() {}); + }, + ); + }, + ); + }, + ), + ); + } + + void _showAddScheduleDialog(BuildContext context) async { + final titleController = TextEditingController(); + final descController = TextEditingController(); + final familyMembers = await Provider.of( + context, + listen: false, + ).fetchFamilyMembers(); + String? selectedMemberId = + familyMembers.isNotEmpty ? familyMembers.first.id : null; + + showDialog( + context: context, + builder: (context) => AlertDialog( + title: const Text('Add Schedule'), + content: Column( + mainAxisSize: MainAxisSize.min, + children: [ + TextField( + controller: titleController, + decoration: const InputDecoration(labelText: 'Title'), + ), + TextField( + controller: descController, + decoration: const InputDecoration(labelText: 'Description'), + ), + DropdownButtonFormField( + value: selectedMemberId, + items: familyMembers + .map( + (m) => DropdownMenuItem(value: m.id, child: Text(m.name)), + ) + .toList(), + onChanged: (val) => selectedMemberId = val, + decoration: const InputDecoration(labelText: 'For whom?'), + ), + ], + ), + actions: [ + TextButton( + onPressed: () => Navigator.pop(context), + child: const Text('Cancel'), + ), + TextButton( + onPressed: () async { + if (selectedMemberId != null && titleController.text.isNotEmpty) { + await Provider.of( + context, + listen: false, + ).createSchedule( + ScheduleItem( + id: '', + title: titleController.text, + description: descController.text, + startDate: DateTime.now(), + endDate: DateTime.now().add(const Duration(hours: 1)), + familyMemberId: selectedMemberId!, + isAllDay: false, + ), + ); + if (mounted) { + Navigator.pop(context); + setState(() {}); + } + } + }, + child: const Text('Add'), + ), + ], + ), + ); + } +} + +class MobileAnnouncementScreen extends StatefulWidget { + const MobileAnnouncementScreen({super.key}); + + @override + State createState() => + _MobileAnnouncementScreenState(); +} + +class _MobileAnnouncementScreenState extends State { + @override + Widget build(BuildContext context) { + return Scaffold( + floatingActionButton: FloatingActionButton( + onPressed: () => _showAddAnnouncementDialog(context), + child: const Icon(Icons.add), + ), + body: FutureBuilder>( + future: Provider.of(context).fetchAnnouncements(), + builder: (context, snapshot) { + if (!snapshot.hasData) + return const Center(child: CircularProgressIndicator()); + final items = snapshot.data!; + return ListView.builder( + itemCount: items.length, + itemBuilder: (context, index) { + final item = items[index]; + return ListTile( + title: Text(item.title), + subtitle: Text(item.content), + trailing: Switch( + value: item.active, + onChanged: (val) async { + await Provider.of( + context, + listen: false, + ).updateAnnouncement( + Announcement( + id: item.id, + title: item.title, + content: item.content, + priority: item.priority, + active: val, + ), + ); + setState(() {}); + }, + ), + onLongPress: () async { + await Provider.of( + context, + listen: false, + ).deleteAnnouncement(item.id); + setState(() {}); + }, + ); + }, + ); + }, + ), + ); + } + + void _showAddAnnouncementDialog(BuildContext context) { + final titleController = TextEditingController(); + final contentController = TextEditingController(); + + showDialog( + context: context, + builder: (context) => AlertDialog( + title: const Text('Add Announcement'), + content: Column( + mainAxisSize: MainAxisSize.min, + children: [ + TextField( + controller: titleController, + decoration: const InputDecoration(labelText: 'Title'), + ), + TextField( + controller: contentController, + decoration: const InputDecoration(labelText: 'Content'), + maxLines: 3, + ), + ], + ), + actions: [ + TextButton( + onPressed: () => Navigator.pop(context), + child: const Text('Cancel'), + ), + TextButton( + onPressed: () async { + if (titleController.text.isNotEmpty) { + await Provider.of( + context, + listen: false, + ).createAnnouncement( + Announcement( + id: '', + title: titleController.text, + content: contentController.text, + priority: 1, + active: true, + ), + ); + if (mounted) { + Navigator.pop(context); + setState(() {}); + } + } + }, + child: const Text('Add'), + ), + ], + ), + ); + } +} diff --git a/flutter_app/lib/screens/tv/tv_dashboard_screen.dart b/flutter_app/lib/screens/tv/tv_dashboard_screen.dart new file mode 100644 index 0000000..588a7d7 --- /dev/null +++ b/flutter_app/lib/screens/tv/tv_dashboard_screen.dart @@ -0,0 +1,133 @@ +import 'dart:async'; +import 'package:flutter/material.dart'; +import 'package:provider/provider.dart'; + +import '../../widgets/digital_clock_widget.dart'; +import '../../widgets/weather_widget.dart'; +import '../../widgets/calendar_widget.dart'; +import '../../widgets/schedule_list_widget.dart'; +import '../../widgets/announcement_widget.dart'; +import '../../widgets/photo_slideshow_widget.dart'; +import '../../widgets/todo_list_widget.dart'; +import '../../widgets/bible_verse_widget.dart'; + +class TvDashboardScreen extends StatefulWidget { + const TvDashboardScreen({super.key}); + + @override + State createState() => _TvDashboardScreenState(); +} + +class _TvDashboardScreenState extends State { + // Timer for periodic refresh (every 5 minutes for data, 1 second for clock) + Timer? _dataRefreshTimer; + + @override + void initState() { + super.initState(); + // Initial data fetch could be triggered here or within widgets + _startDataRefresh(); + } + + void _startDataRefresh() { + _dataRefreshTimer = Timer.periodic(const Duration(minutes: 5), (timer) { + // Trigger refreshes if needed, or let widgets handle their own polling + // For simplicity, we assume widgets or providers handle their data + setState(() {}); // Rebuild to refresh UI state if needed + }); + } + + @override + void dispose() { + _dataRefreshTimer?.cancel(); + super.dispose(); + } + + @override + Widget build(BuildContext context) { + // 1920x1080 reference + return Scaffold( + body: SafeArea( + child: Padding( + padding: const EdgeInsets.all(32.0), // Outer margin safe zone + child: Column( + children: [ + // Header: Time and Weather + SizedBox( + height: 100, + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [const DigitalClockWidget(), const WeatherWidget()], + ), + ), + const SizedBox(height: 24), + // Main Content Grid + Expanded( + child: Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + // Left Column: Calendar, Schedule, Announcement + Expanded( + flex: 3, + child: Column( + children: [ + const Expanded(flex: 4, child: CalendarWidget()), + const SizedBox(height: 16), + const Expanded(flex: 4, child: ScheduleListWidget()), + const SizedBox(height: 16), + const Expanded(flex: 2, child: AnnouncementWidget()), + ], + ), + ), + const SizedBox(width: 24), + // Center Column: Photo Slideshow + Expanded( + flex: 4, + child: Container( + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(16), + boxShadow: [ + BoxShadow( + color: Colors.black.withOpacity(0.5), + blurRadius: 20, + offset: const Offset(0, 10), + ), + ], + ), + clipBehavior: Clip.antiAlias, + child: const PhotoSlideshowWidget(), + ), + ), + const SizedBox(width: 24), + // Right Column: Todos, Bible Verse + Expanded( + flex: 3, + child: Column( + children: [ + const Expanded(flex: 6, child: TodoListWidget()), + const SizedBox(height: 16), + const Expanded(flex: 3, child: BibleVerseWidget()), + ], + ), + ), + ], + ), + ), + // Hidden trigger for admin/mobile view (e.g. long press corner) + GestureDetector( + onLongPress: () { + Navigator.of(context).pushNamed('/admin'); + }, + child: Container( + width: 50, + height: 50, + color: Colors.transparent, + ), + ), + ], + ), + ), + ), + ); + } +} diff --git a/flutter_app/lib/services/announcement_service.dart b/flutter_app/lib/services/announcement_service.dart new file mode 100644 index 0000000..446df62 --- /dev/null +++ b/flutter_app/lib/services/announcement_service.dart @@ -0,0 +1,71 @@ +import "../config/api_config.dart"; +import "../models/announcement.dart"; +import "api_client.dart"; +import "mock_data.dart"; + +class AnnouncementService { + final ApiClient _client; + + AnnouncementService(this._client); + + Future> fetchAnnouncements({ + bool activeOnly = false, + }) async { + if (ApiConfig.useMockData) { + final items = List.from(MockDataStore.announcements); + if (activeOnly) { + return items.where((item) => item.active).toList(); + } + return items; + } + final query = activeOnly ? {"active": "true"} : null; + final data = await _client.getList(ApiConfig.announcements, query: query); + return data + .map((item) => Announcement.fromJson(item as Map)) + .toList(); + } + + Future createAnnouncement(Announcement announcement) async { + if (ApiConfig.useMockData) { + final created = Announcement( + id: "announcement-${DateTime.now().millisecondsSinceEpoch}", + title: announcement.title, + content: announcement.content, + priority: announcement.priority, + active: announcement.active, + ); + MockDataStore.announcements.add(created); + return created; + } + final data = await _client.post( + ApiConfig.announcements, + announcement.toJson(), + ); + return Announcement.fromJson(data); + } + + Future updateAnnouncement(Announcement announcement) async { + if (ApiConfig.useMockData) { + final index = MockDataStore.announcements.indexWhere( + (item) => item.id == announcement.id, + ); + if (index != -1) { + MockDataStore.announcements[index] = announcement; + } + return announcement; + } + final data = await _client.put( + "${ApiConfig.announcements}/${announcement.id}", + announcement.toJson(), + ); + return Announcement.fromJson(data); + } + + Future deleteAnnouncement(String id) async { + if (ApiConfig.useMockData) { + MockDataStore.announcements.removeWhere((item) => item.id == id); + return; + } + await _client.delete("${ApiConfig.announcements}/$id"); + } +} diff --git a/flutter_app/lib/services/api_client.dart b/flutter_app/lib/services/api_client.dart new file mode 100644 index 0000000..727e46c --- /dev/null +++ b/flutter_app/lib/services/api_client.dart @@ -0,0 +1,71 @@ +import "dart:convert"; +import "package:http/http.dart" as http; +import "../config/api_config.dart"; + +class ApiClient { + final http.Client _client; + + ApiClient({http.Client? client}) : _client = client ?? http.Client(); + + Uri _uri(String path, [Map? query]) { + return Uri.parse(ApiConfig.baseUrl).replace( + path: path, + queryParameters: query?.map((key, value) => MapEntry(key, "$value")), + ); + } + + Future> getList( + String path, { + Map? query, + }) async { + final response = await _client.get(_uri(path, query)); + _ensureSuccess(response); + return jsonDecode(response.body) as List; + } + + Future> getMap( + String path, { + Map? query, + }) async { + final response = await _client.get(_uri(path, query)); + _ensureSuccess(response); + return jsonDecode(response.body) as Map; + } + + Future> post( + String path, + Map body, + ) async { + final response = await _client.post( + _uri(path), + headers: {"Content-Type": "application/json"}, + body: jsonEncode(body), + ); + _ensureSuccess(response); + return jsonDecode(response.body) as Map; + } + + Future> put( + String path, + Map body, + ) async { + final response = await _client.put( + _uri(path), + headers: {"Content-Type": "application/json"}, + body: jsonEncode(body), + ); + _ensureSuccess(response); + return jsonDecode(response.body) as Map; + } + + Future delete(String path) async { + final response = await _client.delete(_uri(path)); + _ensureSuccess(response); + } + + void _ensureSuccess(http.Response response) { + if (response.statusCode < 200 || response.statusCode >= 300) { + throw Exception("Request failed: ${response.statusCode}"); + } + } +} diff --git a/flutter_app/lib/services/bible_service.dart b/flutter_app/lib/services/bible_service.dart new file mode 100644 index 0000000..63d2a56 --- /dev/null +++ b/flutter_app/lib/services/bible_service.dart @@ -0,0 +1,26 @@ +import "../config/api_config.dart"; +import "../models/bible_verse.dart"; +import "api_client.dart"; +import "mock_data.dart"; + +class BibleService { + final ApiClient _client; + + BibleService(this._client); + + Future fetchTodayVerse({String? date}) async { + if (ApiConfig.useMockData) { + final verses = MockDataStore.bibleVerses; + if (verses.isEmpty) { + return MockDataStore.bible; + } + verses.shuffle(); + return verses.first; + } + final data = await _client.getMap( + ApiConfig.bibleToday, + query: date == null ? null : {"date": date}, + ); + return BibleVerse.fromJson(data); + } +} diff --git a/flutter_app/lib/services/bible_verse_service.dart b/flutter_app/lib/services/bible_verse_service.dart new file mode 100644 index 0000000..812f1b2 --- /dev/null +++ b/flutter_app/lib/services/bible_verse_service.dart @@ -0,0 +1,66 @@ +import "../config/api_config.dart"; +import "../models/bible_verse.dart"; +import "api_client.dart"; +import "mock_data.dart"; + +class BibleVerseService { + final ApiClient _client; + + BibleVerseService(this._client); + + Future> fetchVerses({bool activeOnly = false}) async { + if (ApiConfig.useMockData) { + final items = List.from(MockDataStore.bibleVerses); + if (activeOnly) { + return items.where((item) => item.active).toList(); + } + return items; + } + final query = activeOnly ? {"active": "true"} : null; + final data = await _client.getList(ApiConfig.bibleVerses, query: query); + return data + .map((item) => BibleVerse.fromJson(item as Map)) + .toList(); + } + + Future createVerse(BibleVerse verse) async { + if (ApiConfig.useMockData) { + final created = BibleVerse( + id: "bible-${DateTime.now().millisecondsSinceEpoch}", + text: verse.text, + reference: verse.reference, + date: verse.date, + active: verse.active, + ); + MockDataStore.bibleVerses.add(created); + return created; + } + final data = await _client.post(ApiConfig.bibleVerses, verse.toJson()); + return BibleVerse.fromJson(data); + } + + Future updateVerse(BibleVerse verse) async { + if (ApiConfig.useMockData) { + final index = MockDataStore.bibleVerses.indexWhere( + (item) => item.id == verse.id, + ); + if (index != -1) { + MockDataStore.bibleVerses[index] = verse; + } + return verse; + } + final data = await _client.put( + "${ApiConfig.bibleVerses}/${verse.id}", + verse.toJson(), + ); + return BibleVerse.fromJson(data); + } + + Future deleteVerse(String id) async { + if (ApiConfig.useMockData) { + MockDataStore.bibleVerses.removeWhere((item) => item.id == id); + return; + } + await _client.delete("${ApiConfig.bibleVerses}/$id"); + } +} diff --git a/flutter_app/lib/services/family_service.dart b/flutter_app/lib/services/family_service.dart new file mode 100644 index 0000000..97e8b3c --- /dev/null +++ b/flutter_app/lib/services/family_service.dart @@ -0,0 +1,71 @@ +import "../config/api_config.dart"; +import "../models/family_member.dart"; +import "api_client.dart"; +import "mock_data.dart"; + +class FamilyService { + final ApiClient _client; + + FamilyService(this._client); + + Future> fetchFamilyMembers() async { + if (ApiConfig.useMockData) { + return List.from(MockDataStore.familyMembers); + } + final data = await _client.getList(ApiConfig.family); + return data + .map((item) => FamilyMember.fromJson(item as Map)) + .toList(); + } + + Future createFamilyMember(FamilyMember member) async { + if (ApiConfig.useMockData) { + final created = FamilyMember( + id: "family-${DateTime.now().millisecondsSinceEpoch}", + name: member.name, + emoji: member.emoji, + color: member.color, + order: member.order, + ); + MockDataStore.familyMembers.add(created); + return created; + } + final data = await _client.post(ApiConfig.family, member.toJson()); + return FamilyMember.fromJson(data); + } + + Future updateFamilyMember(FamilyMember member) async { + if (ApiConfig.useMockData) { + final index = MockDataStore.familyMembers.indexWhere( + (item) => item.id == member.id, + ); + if (index != -1) { + MockDataStore.familyMembers[index] = member; + } + return member; + } + final data = await _client.put( + "${ApiConfig.family}/${member.id}", + member.toJson(), + ); + return FamilyMember.fromJson(data); + } + + Future deleteFamilyMember(String id) async { + if (ApiConfig.useMockData) { + MockDataStore.familyMembers.removeWhere((item) => item.id == id); + return; + } + await _client.delete("${ApiConfig.family}/$id"); + } + + Future> fetchMembers() => fetchFamilyMembers(); + + Future createMember(FamilyMember member) => + createFamilyMember(member); + + Future updateMember(FamilyMember member) => + updateFamilyMember(member); + + Future deleteMember(String id) => deleteFamilyMember(id); +} diff --git a/flutter_app/lib/services/mock_data.dart b/flutter_app/lib/services/mock_data.dart new file mode 100644 index 0000000..a041039 --- /dev/null +++ b/flutter_app/lib/services/mock_data.dart @@ -0,0 +1,149 @@ +import "../models/announcement.dart"; +import "../models/bible_verse.dart"; +import "../models/family_member.dart"; +import "../models/photo.dart"; +import "../models/schedule_item.dart"; +import "../models/todo_item.dart"; +import "../models/weather_info.dart"; + +class MockDataStore { + static final List familyMembers = [ + const FamilyMember( + id: "family-1", + name: "Dad", + emoji: ":)", + color: "#0F766E", + order: 1, + ), + const FamilyMember( + id: "family-2", + name: "Mom", + emoji: "<3", + color: "#C2410C", + order: 2, + ), + const FamilyMember( + id: "family-3", + name: "Son", + emoji: ":D", + color: "#1D4ED8", + order: 3, + ), + const FamilyMember( + id: "family-4", + name: "Daughter", + emoji: ":-)", + color: "#7C3AED", + order: 4, + ), + ]; + + static final List todos = [ + TodoItem( + id: "todo-1", + familyMemberId: "family-1", + title: "Grocery run", + completed: false, + dueDate: DateTime.now(), + ), + TodoItem( + id: "todo-2", + familyMemberId: "family-2", + title: "Team meeting", + completed: false, + dueDate: DateTime.now(), + ), + TodoItem( + id: "todo-3", + familyMemberId: "family-3", + title: "Math homework", + completed: false, + dueDate: DateTime.now(), + ), + TodoItem( + id: "todo-4", + familyMemberId: "family-4", + title: "Piano lesson", + completed: false, + dueDate: DateTime.now().add(const Duration(days: 1)), + ), + ]; + + static final List schedules = [ + ScheduleItem( + id: "schedule-1", + title: "Family dinner", + description: "Everyone at home", + startDate: DateTime.now(), + endDate: DateTime.now().add(const Duration(hours: 2)), + familyMemberId: "family-1", + isAllDay: false, + ), + ScheduleItem( + id: "schedule-2", + title: "Soccer practice", + description: "School field", + startDate: DateTime.now().add(const Duration(hours: 3)), + endDate: DateTime.now().add(const Duration(hours: 4)), + familyMemberId: "family-3", + isAllDay: false, + ), + ]; + + static final List announcements = [ + const Announcement( + id: "announcement-1", + title: "Weekend trip", + content: "Pack light and be ready by 8 AM", + priority: 2, + active: true, + ), + const Announcement( + id: "announcement-2", + title: "Trash day", + content: "Take out bins tonight", + priority: 1, + active: true, + ), + ]; + + static final List photos = [ + const Photo( + id: "photo-1", + url: "https://picsum.photos/1200/800?random=21", + caption: "Summer vacation", + active: true, + ), + const Photo( + id: "photo-2", + url: "https://picsum.photos/1200/800?random=22", + caption: "Family hike", + active: true, + ), + const Photo( + id: "photo-3", + url: "https://picsum.photos/1200/800?random=23", + caption: "Birthday party", + active: true, + ), + ]; + + static WeatherInfo weather = const WeatherInfo( + description: "clear sky", + temperature: 12, + icon: "01d", + city: "Seoul", + ); + + static final List bibleVerses = [ + const BibleVerse( + id: "bible-1", + text: "여호와를 경외하는 것이 지식의 근본이니라.", + reference: "잠언 1:7", + date: null, + active: true, + ), + ]; + + static BibleVerse bible = bibleVerses.first; +} diff --git a/flutter_app/lib/services/photo_service.dart b/flutter_app/lib/services/photo_service.dart new file mode 100644 index 0000000..5a918e8 --- /dev/null +++ b/flutter_app/lib/services/photo_service.dart @@ -0,0 +1,48 @@ +import "../config/api_config.dart"; +import "../models/photo.dart"; +import "api_client.dart"; +import "mock_data.dart"; + +class PhotoService { + final ApiClient _client; + + PhotoService(this._client); + + Future> fetchPhotos({bool activeOnly = false}) async { + if (ApiConfig.useMockData) { + final items = List.from(MockDataStore.photos); + if (activeOnly) { + return items.where((item) => item.active).toList(); + } + return items; + } + final query = activeOnly ? {"active": "true"} : null; + final data = await _client.getList(ApiConfig.photos, query: query); + return data + .map((item) => Photo.fromJson(item as Map)) + .toList(); + } + + Future createPhoto(Photo photo) async { + if (ApiConfig.useMockData) { + final created = Photo( + id: "photo-${DateTime.now().millisecondsSinceEpoch}", + url: photo.url, + caption: photo.caption, + active: photo.active, + ); + MockDataStore.photos.add(created); + return created; + } + final data = await _client.post(ApiConfig.photos, photo.toJson()); + return Photo.fromJson(data); + } + + Future deletePhoto(String id) async { + if (ApiConfig.useMockData) { + MockDataStore.photos.removeWhere((item) => item.id == id); + return; + } + await _client.delete("${ApiConfig.photos}/$id"); + } +} diff --git a/flutter_app/lib/services/schedule_service.dart b/flutter_app/lib/services/schedule_service.dart new file mode 100644 index 0000000..96d94ba --- /dev/null +++ b/flutter_app/lib/services/schedule_service.dart @@ -0,0 +1,83 @@ +import "../config/api_config.dart"; +import "../models/schedule_item.dart"; +import "api_client.dart"; +import "mock_data.dart"; + +class ScheduleService { + final ApiClient _client; + + ScheduleService(this._client); + + Future> fetchSchedules() async { + if (ApiConfig.useMockData) { + return List.from(MockDataStore.schedules); + } + final data = await _client.getList(ApiConfig.schedules); + return data + .map((item) => ScheduleItem.fromJson(item as Map)) + .toList(); + } + + Future> fetchWeeklySchedules() async { + if (ApiConfig.useMockData) { + return List.from(MockDataStore.schedules); + } + final data = await _client.getList("${ApiConfig.schedules}/week"); + return data + .map((item) => ScheduleItem.fromJson(item as Map)) + .toList(); + } + + Future> fetchMonthlySchedules() async { + if (ApiConfig.useMockData) { + return List.from(MockDataStore.schedules); + } + final data = await _client.getList("${ApiConfig.schedules}/month"); + return data + .map((item) => ScheduleItem.fromJson(item as Map)) + .toList(); + } + + Future createSchedule(ScheduleItem schedule) async { + if (ApiConfig.useMockData) { + final created = ScheduleItem( + id: "schedule-${DateTime.now().millisecondsSinceEpoch}", + title: schedule.title, + description: schedule.description, + startDate: schedule.startDate, + endDate: schedule.endDate, + familyMemberId: schedule.familyMemberId, + isAllDay: schedule.isAllDay, + ); + MockDataStore.schedules.add(created); + return created; + } + final data = await _client.post(ApiConfig.schedules, schedule.toJson()); + return ScheduleItem.fromJson(data); + } + + Future updateSchedule(ScheduleItem schedule) async { + if (ApiConfig.useMockData) { + final index = MockDataStore.schedules.indexWhere( + (item) => item.id == schedule.id, + ); + if (index != -1) { + MockDataStore.schedules[index] = schedule; + } + return schedule; + } + final data = await _client.put( + "${ApiConfig.schedules}/${schedule.id}", + schedule.toJson(), + ); + return ScheduleItem.fromJson(data); + } + + Future deleteSchedule(String id) async { + if (ApiConfig.useMockData) { + MockDataStore.schedules.removeWhere((item) => item.id == id); + return; + } + await _client.delete("${ApiConfig.schedules}/$id"); + } +} diff --git a/flutter_app/lib/services/todo_service.dart b/flutter_app/lib/services/todo_service.dart new file mode 100644 index 0000000..7c250df --- /dev/null +++ b/flutter_app/lib/services/todo_service.dart @@ -0,0 +1,79 @@ +import "../config/api_config.dart"; +import "../models/todo_item.dart"; +import "api_client.dart"; +import "mock_data.dart"; + +class TodoService { + final ApiClient _client; + + TodoService(this._client); + + Future> fetchTodos() async { + if (ApiConfig.useMockData) { + return List.from(MockDataStore.todos); + } + final data = await _client.getList(ApiConfig.todos); + return data + .map((item) => TodoItem.fromJson(item as Map)) + .toList(); + } + + Future> fetchTodayTodos() async { + if (ApiConfig.useMockData) { + final today = DateTime.now(); + return MockDataStore.todos.where((todo) => todo.dueDate != null).where(( + todo, + ) { + final date = todo.dueDate!; + return date.year == today.year && + date.month == today.month && + date.day == today.day; + }).toList(); + } + final data = await _client.getList("${ApiConfig.todos}/today"); + return data + .map((item) => TodoItem.fromJson(item as Map)) + .toList(); + } + + Future createTodo(TodoItem todo) async { + if (ApiConfig.useMockData) { + final created = TodoItem( + id: "todo-${DateTime.now().millisecondsSinceEpoch}", + familyMemberId: todo.familyMemberId, + title: todo.title, + completed: todo.completed, + dueDate: todo.dueDate, + ); + MockDataStore.todos.add(created); + return created; + } + final data = await _client.post(ApiConfig.todos, todo.toJson()); + return TodoItem.fromJson(data); + } + + Future updateTodo(TodoItem todo) async { + if (ApiConfig.useMockData) { + final index = MockDataStore.todos.indexWhere( + (item) => item.id == todo.id, + ); + if (index != -1) { + MockDataStore.todos[index] = todo; + } + return todo; + } + final data = await _client.put( + "${ApiConfig.todos}/${todo.id}", + todo.toJson(), + ); + return TodoItem.fromJson(data); + } + + Future deleteTodo(String id) async { + if (ApiConfig.useMockData) { + MockDataStore.todos.removeWhere((item) => item.id == id); + return; + } + await _client.delete("${ApiConfig.todos}/$id"); + } +} diff --git a/flutter_app/lib/services/weather_service.dart b/flutter_app/lib/services/weather_service.dart new file mode 100644 index 0000000..8d34e85 --- /dev/null +++ b/flutter_app/lib/services/weather_service.dart @@ -0,0 +1,19 @@ +import "../config/api_config.dart"; +import "../models/weather_info.dart"; +import "api_client.dart"; +import "mock_data.dart"; + +class WeatherService { + final ApiClient _client; + + WeatherService(this._client); + + Future fetchWeather({String? city}) async { + if (ApiConfig.useMockData) { + return MockDataStore.weather; + } + final query = city != null ? {"q": city} : null; + final data = await _client.getMap(ApiConfig.weather, query: query); + return WeatherInfo.fromJson(data); + } +} diff --git a/flutter_app/lib/widgets/announcement_widget.dart b/flutter_app/lib/widgets/announcement_widget.dart new file mode 100644 index 0000000..ffa059c --- /dev/null +++ b/flutter_app/lib/widgets/announcement_widget.dart @@ -0,0 +1,169 @@ +import 'dart:async'; +import 'package:flutter/material.dart'; +import 'package:provider/provider.dart'; +import '../models/announcement.dart'; +import '../services/announcement_service.dart'; + +class AnnouncementWidget extends StatefulWidget { + const AnnouncementWidget({super.key}); + + @override + State createState() => _AnnouncementWidgetState(); +} + +class _AnnouncementWidgetState extends State { + final PageController _pageController = PageController(); + Timer? _timer; + int _currentPage = 0; + List _announcements = []; + + @override + void initState() { + super.initState(); + _fetchAnnouncements(); + } + + void _fetchAnnouncements() async { + try { + final data = await Provider.of( + context, + listen: false, + ).fetchAnnouncements(activeOnly: true); + if (mounted) { + setState(() { + _announcements = data; + }); + _startAutoScroll(); + } + } catch (e) { + // Handle error + } + } + + void _startAutoScroll() { + _timer?.cancel(); + if (_announcements.length > 1) { + _timer = Timer.periodic(const Duration(seconds: 10), (timer) { + if (_pageController.hasClients) { + _currentPage++; + if (_currentPage >= _announcements.length) { + _currentPage = 0; + } + _pageController.animateToPage( + _currentPage, + duration: const Duration(milliseconds: 800), + curve: Curves.easeInOut, + ); + } + }); + } + } + + @override + void dispose() { + _timer?.cancel(); + _pageController.dispose(); + super.dispose(); + } + + @override + Widget build(BuildContext context) { + if (_announcements.isEmpty) { + // Show default placeholder if no announcements + return Container( + decoration: BoxDecoration( + color: Theme.of(context).cardTheme.color, + borderRadius: BorderRadius.circular(16), + border: Border.all(color: Colors.white10), + ), + padding: const EdgeInsets.all(16), + child: const Center( + child: Text( + 'Welcome Home! Have a great day.', + style: TextStyle(color: Colors.white70, fontSize: 18), + ), + ), + ); + } + + return Container( + decoration: BoxDecoration( + color: Theme.of( + context, + ).cardTheme.color, // Slightly lighter/distinct background + borderRadius: BorderRadius.circular(16), + ), + child: Stack( + children: [ + PageView.builder( + controller: _pageController, + itemCount: _announcements.length, + itemBuilder: (context, index) { + final item = _announcements[index]; + return Padding( + padding: const EdgeInsets.all(24.0), + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Row( + children: [ + Icon( + Icons.campaign, + color: Theme.of(context).colorScheme.secondary, + size: 32, + ), + const SizedBox(width: 12), + Text( + item.title, + style: Theme.of(context) + .textTheme + .headlineSmall + ?.copyWith( + color: Theme.of(context).colorScheme.secondary, + fontWeight: FontWeight.bold, + ), + ), + ], + ), + const SizedBox(height: 12), + Text( + item.content, + style: Theme.of( + context, + ).textTheme.bodyLarge?.copyWith(color: Colors.white), + maxLines: 3, + overflow: TextOverflow.ellipsis, + ), + ], + ), + ); + }, + ), + // Page Indicator + if (_announcements.length > 1) + Positioned( + bottom: 16, + right: 16, + child: Row( + children: List.generate(_announcements.length, (index) { + return AnimatedContainer( + duration: const Duration(milliseconds: 300), + margin: const EdgeInsets.symmetric(horizontal: 4), + width: 8, + height: 8, + decoration: BoxDecoration( + shape: BoxShape.circle, + color: _currentPage == index + ? Theme.of(context).colorScheme.secondary + : Colors.white24, + ), + ); + }), + ), + ), + ], + ), + ); + } +} diff --git a/flutter_app/lib/widgets/bible_verse_widget.dart b/flutter_app/lib/widgets/bible_verse_widget.dart new file mode 100644 index 0000000..6f8c8d8 --- /dev/null +++ b/flutter_app/lib/widgets/bible_verse_widget.dart @@ -0,0 +1,83 @@ +import 'package:flutter/material.dart'; +import 'package:provider/provider.dart'; +import '../models/bible_verse.dart'; +import '../services/bible_service.dart'; + +class BibleVerseWidget extends StatelessWidget { + const BibleVerseWidget({super.key}); + + @override + Widget build(BuildContext context) { + return Container( + width: double.infinity, + decoration: BoxDecoration( + gradient: LinearGradient( + colors: [ + Theme.of(context).cardTheme.color!.withOpacity(0.8), + Theme.of(context).cardTheme.color!, + ], + begin: Alignment.topLeft, + end: Alignment.bottomRight, + ), + borderRadius: BorderRadius.circular(16), + border: Border.all(color: Colors.white10), + ), + padding: const EdgeInsets.all(24), + child: FutureBuilder( + future: Provider.of( + context, + listen: false, + ).fetchTodayVerse(), + builder: (context, snapshot) { + if (snapshot.connectionState == ConnectionState.waiting) { + return const Center(child: CircularProgressIndicator()); + } + + if (snapshot.hasError) { + return const Center( + child: Text( + 'Verse Unavailable', + style: TextStyle(color: Colors.white54), + ), + ); + } + + if (!snapshot.hasData) { + return const SizedBox.shrink(); + } + + final verse = snapshot.data!; + + return Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + const Icon( + Icons.format_quote, + color: Color(0xFFBB86FC), + size: 32, + ), + const SizedBox(height: 12), + Text( + verse.text, + textAlign: TextAlign.center, + style: Theme.of(context).textTheme.bodyLarge?.copyWith( + color: Colors.white, + height: 1.5, + fontStyle: FontStyle.italic, + ), + ), + const SizedBox(height: 8), + Text( + verse.reference, + style: TextStyle( + color: Theme.of(context).colorScheme.primary, + fontWeight: FontWeight.bold, + ), + ), + ], + ); + }, + ), + ); + } +} diff --git a/flutter_app/lib/widgets/calendar_widget.dart b/flutter_app/lib/widgets/calendar_widget.dart new file mode 100644 index 0000000..192326d --- /dev/null +++ b/flutter_app/lib/widgets/calendar_widget.dart @@ -0,0 +1,112 @@ +import 'package:flutter/material.dart'; +import 'package:intl/intl.dart'; + +class CalendarWidget extends StatelessWidget { + const CalendarWidget({super.key}); + + @override + Widget build(BuildContext context) { + final now = DateTime.now(); + final firstDayOfMonth = DateTime(now.year, now.month, 1); + final lastDayOfMonth = DateTime(now.year, now.month + 1, 0); + final daysInMonth = lastDayOfMonth.day; + final startingWeekday = firstDayOfMonth.weekday; // Mon=1, Sun=7 + + // Simple calendar logic + // We need to pad the beginning with empty slots + // If week starts on Sunday, adjust accordingly. Let's assume Mon start for now or use locale. + // Let's assume standard Sun-Sat or Mon-Sun. Let's go with Sun-Sat for standard calendar view often seen in KR/US. + // DateTime.weekday: Mon=1, Sun=7. + // If we want Sun start: Sun=0, Mon=1... + // Let's adjust so Sunday is first. + + int offset = + startingWeekday % + 7; // If startingWeekday is 7 (Sun), offset is 0. If 1 (Mon), offset is 1. + + return Container( + padding: const EdgeInsets.all(16), + decoration: BoxDecoration( + color: Theme.of(context).cardTheme.color, + borderRadius: BorderRadius.circular(16), + ), + child: Column( + children: [ + // Header + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text( + DateFormat('MMMM yyyy').format(now), + style: Theme.of(context).textTheme.titleLarge?.copyWith( + fontWeight: FontWeight.bold, + color: Colors.white, + ), + ), + const Icon(Icons.calendar_today, color: Colors.white54), + ], + ), + const SizedBox(height: 16), + // Days Header + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: ['S', 'M', 'T', 'W', 'T', 'F', 'S'].map((day) { + return Expanded( + child: Center( + child: Text( + day, + style: const TextStyle( + color: Colors.white54, + fontWeight: FontWeight.bold, + ), + ), + ), + ); + }).toList(), + ), + const SizedBox(height: 8), + // Days Grid + Expanded( + child: GridView.builder( + physics: const NeverScrollableScrollPhysics(), + gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount( + crossAxisCount: 7, + childAspectRatio: 1.0, + ), + itemCount: 42, // 6 rows max to be safe + itemBuilder: (context, index) { + final dayNumber = index - offset + 1; + if (dayNumber < 1 || dayNumber > daysInMonth) { + return const SizedBox.shrink(); + } + + final isToday = dayNumber == now.day; + + return Container( + margin: const EdgeInsets.all(4), + decoration: isToday + ? BoxDecoration( + color: Theme.of(context).colorScheme.primary, + shape: BoxShape.circle, + ) + : null, + child: Center( + child: Text( + '$dayNumber', + style: TextStyle( + color: isToday ? Colors.black : Colors.white, + fontWeight: isToday + ? FontWeight.bold + : FontWeight.normal, + ), + ), + ), + ); + }, + ), + ), + ], + ), + ); + } +} diff --git a/flutter_app/lib/widgets/digital_clock_widget.dart b/flutter_app/lib/widgets/digital_clock_widget.dart new file mode 100644 index 0000000..555c4f2 --- /dev/null +++ b/flutter_app/lib/widgets/digital_clock_widget.dart @@ -0,0 +1,53 @@ +import 'dart:async'; +import 'package:flutter/material.dart'; +import 'package:intl/intl.dart'; + +class DigitalClockWidget extends StatefulWidget { + const DigitalClockWidget({super.key}); + + @override + State createState() => _DigitalClockWidgetState(); +} + +class _DigitalClockWidgetState extends State { + DateTime _now = DateTime.now(); + Timer? _timer; + + @override + void initState() { + super.initState(); + _timer = Timer.periodic(const Duration(seconds: 1), (timer) { + setState(() { + _now = DateTime.now(); + }); + }); + } + + @override + void dispose() { + _timer?.cancel(); + super.dispose(); + } + + @override + Widget build(BuildContext context) { + // Format: 2026.01.24 (Sat) 15:43:36 + final dateStr = DateFormat('yyyy.MM.dd (E)', 'ko_KR').format(_now); + final timeStr = DateFormat('HH:mm:ss').format(_now); + + return Column( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Text( + '$dateStr $timeStr', + style: Theme.of(context).textTheme.displaySmall?.copyWith( + color: Colors.white, + fontWeight: FontWeight.bold, + letterSpacing: 1.2, + ), + ), + ], + ); + } +} diff --git a/flutter_app/lib/widgets/photo_slideshow_widget.dart b/flutter_app/lib/widgets/photo_slideshow_widget.dart new file mode 100644 index 0000000..e6259fc --- /dev/null +++ b/flutter_app/lib/widgets/photo_slideshow_widget.dart @@ -0,0 +1,144 @@ +import 'dart:async'; +import 'package:flutter/material.dart'; +import 'package:provider/provider.dart'; +import '../models/photo.dart'; +import '../services/photo_service.dart'; + +class PhotoSlideshowWidget extends StatefulWidget { + const PhotoSlideshowWidget({super.key}); + + @override + State createState() => _PhotoSlideshowWidgetState(); +} + +class _PhotoSlideshowWidgetState extends State { + List _photos = []; + int _currentIndex = 0; + Timer? _timer; + + @override + void initState() { + super.initState(); + _fetchPhotos(); + } + + void _fetchPhotos() async { + try { + final photos = await Provider.of( + context, + listen: false, + ).fetchPhotos(activeOnly: true); + if (mounted) { + setState(() { + _photos = photos; + }); + _startSlideshow(); + } + } catch (e) { + // Handle error + } + } + + void _startSlideshow() { + _timer?.cancel(); + if (_photos.length > 1) { + _timer = Timer.periodic(const Duration(seconds: 30), (timer) { + if (mounted) { + setState(() { + _currentIndex = (_currentIndex + 1) % _photos.length; + }); + } + }); + } + } + + @override + void dispose() { + _timer?.cancel(); + super.dispose(); + } + + @override + Widget build(BuildContext context) { + if (_photos.isEmpty) { + return Container( + color: Colors.black, + child: const Center( + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Icon(Icons.photo_library, size: 64, color: Colors.white24), + SizedBox(height: 16), + Text( + 'No Photos Available', + style: TextStyle(color: Colors.white54, fontSize: 24), + ), + ], + ), + ), + ); + } + + final currentPhoto = _photos[_currentIndex]; + + return Stack( + fit: StackFit.expand, + children: [ + AnimatedSwitcher( + duration: const Duration(milliseconds: 1000), + child: Image.network( + currentPhoto.url, + key: ValueKey(currentPhoto.id), + fit: BoxFit.cover, + width: double.infinity, + height: double.infinity, + errorBuilder: (context, error, stackTrace) { + return Container( + color: Colors.grey[900], + child: const Center( + child: Icon( + Icons.broken_image, + color: Colors.white54, + size: 48, + ), + ), + ); + }, + ), + ), + // Gradient overlay for caption + Positioned( + left: 0, + right: 0, + bottom: 0, + child: Container( + decoration: const BoxDecoration( + gradient: LinearGradient( + begin: Alignment.topCenter, + end: Alignment.bottomCenter, + colors: [Colors.transparent, Colors.black87], + ), + ), + padding: const EdgeInsets.all(24.0), + child: Text( + currentPhoto.caption, + style: const TextStyle( + color: Colors.white, + fontSize: 20, + fontWeight: FontWeight.w500, + shadows: [ + Shadow( + color: Colors.black45, + blurRadius: 4, + offset: Offset(1, 1), + ), + ], + ), + textAlign: TextAlign.center, + ), + ), + ), + ], + ); + } +} diff --git a/flutter_app/lib/widgets/schedule_list_widget.dart b/flutter_app/lib/widgets/schedule_list_widget.dart new file mode 100644 index 0000000..a70e4e9 --- /dev/null +++ b/flutter_app/lib/widgets/schedule_list_widget.dart @@ -0,0 +1,129 @@ +import 'package:flutter/material.dart'; +import 'package:provider/provider.dart'; +import 'package:intl/intl.dart'; +import '../models/schedule_item.dart'; +import '../services/schedule_service.dart'; + +class ScheduleListWidget extends StatelessWidget { + const ScheduleListWidget({super.key}); + + @override + Widget build(BuildContext context) { + return Container( + decoration: BoxDecoration( + color: Theme.of(context).cardTheme.color, + borderRadius: BorderRadius.circular(16), + ), + padding: const EdgeInsets.all(16), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + 'Weekly Schedule', + style: Theme.of(context).textTheme.titleLarge?.copyWith( + color: Colors.white, + fontWeight: FontWeight.bold, + ), + ), + const SizedBox(height: 12), + Expanded( + child: FutureBuilder>( + future: Provider.of( + context, + listen: false, + ).fetchWeeklySchedules(), + builder: (context, snapshot) { + if (snapshot.connectionState == ConnectionState.waiting) { + return const Center(child: CircularProgressIndicator()); + } + + if (snapshot.hasError) { + return const Center( + child: Text( + 'Failed to load schedules', + style: TextStyle(color: Colors.white54), + ), + ); + } + + if (!snapshot.hasData || snapshot.data!.isEmpty) { + return const Center( + child: Text( + 'No schedules this week', + style: TextStyle(color: Colors.white54), + ), + ); + } + + final schedules = snapshot.data!; + // Sort by date + schedules.sort((a, b) => a.startDate.compareTo(b.startDate)); + + return ListView.separated( + itemCount: schedules.length, + separatorBuilder: (context, index) => + const Divider(color: Colors.white10), + itemBuilder: (context, index) { + final item = schedules[index]; + final dateStr = DateFormat( + 'E, MMM d', + ).format(item.startDate); + final timeStr = item.isAllDay + ? 'All Day' + : DateFormat('HH:mm').format(item.startDate); + + return ListTile( + contentPadding: EdgeInsets.zero, + leading: Container( + padding: const EdgeInsets.symmetric( + horizontal: 12, + vertical: 8, + ), + decoration: BoxDecoration( + color: Colors.white10, + borderRadius: BorderRadius.circular(8), + ), + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + mainAxisSize: MainAxisSize.min, + children: [ + Text( + DateFormat('d').format(item.startDate), + style: const TextStyle( + color: Colors.white, + fontWeight: FontWeight.bold, + fontSize: 18, + ), + ), + Text( + DateFormat('E').format(item.startDate), + style: const TextStyle( + color: Colors.white70, + fontSize: 12, + ), + ), + ], + ), + ), + title: Text( + item.title, + style: const TextStyle( + color: Colors.white, + fontWeight: FontWeight.w500, + ), + ), + subtitle: Text( + timeStr, + style: const TextStyle(color: Colors.white54), + ), + ); + }, + ); + }, + ), + ), + ], + ), + ); + } +} diff --git a/flutter_app/lib/widgets/todo_list_widget.dart b/flutter_app/lib/widgets/todo_list_widget.dart new file mode 100644 index 0000000..029ca92 --- /dev/null +++ b/flutter_app/lib/widgets/todo_list_widget.dart @@ -0,0 +1,174 @@ +import 'package:flutter/material.dart'; +import 'package:provider/provider.dart'; +import '../models/todo_item.dart'; +import '../models/family_member.dart'; +import '../services/todo_service.dart'; +import '../services/family_service.dart'; + +class TodoListWidget extends StatelessWidget { + const TodoListWidget({super.key}); + + @override + Widget build(BuildContext context) { + return Container( + decoration: BoxDecoration( + color: Theme.of(context).cardTheme.color, + borderRadius: BorderRadius.circular(16), + ), + padding: const EdgeInsets.all(16), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text( + "Today's Todos", + style: Theme.of(context).textTheme.titleLarge?.copyWith( + color: Colors.white, + fontWeight: FontWeight.bold, + ), + ), + Icon( + Icons.check_circle_outline, + color: Theme.of(context).colorScheme.secondary, + ), + ], + ), + const SizedBox(height: 12), + Expanded( + child: FutureBuilder>( + future: Future.wait([ + Provider.of( + context, + listen: false, + ).fetchTodayTodos(), + Provider.of( + context, + listen: false, + ).fetchFamilyMembers(), + ]), + builder: (context, snapshot) { + if (snapshot.connectionState == ConnectionState.waiting) { + return const Center(child: CircularProgressIndicator()); + } + + if (snapshot.hasError) { + return const Center( + child: Text( + 'Failed to load todos', + style: TextStyle(color: Colors.white54), + ), + ); + } + + if (!snapshot.hasData) { + return const Center( + child: Text( + 'No todos today', + style: TextStyle(color: Colors.white54), + ), + ); + } + + final todos = snapshot.data![0] as List; + final members = snapshot.data![1] as List; + + if (todos.isEmpty) { + return const Center( + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Icon(Icons.thumb_up, color: Colors.white24, size: 32), + SizedBox(height: 8), + Text( + 'All done for today!', + style: TextStyle(color: Colors.white54), + ), + ], + ), + ); + } + + return ListView.separated( + itemCount: todos.length, + separatorBuilder: (context, index) => + const Divider(color: Colors.white10), + itemBuilder: (context, index) { + final todo = todos[index]; + final member = members.firstWhere( + (m) => m.id == todo.familyMemberId, + orElse: () => const FamilyMember( + id: '', + name: 'Unknown', + emoji: '👤', + color: '#888888', + order: 0, + ), + ); + + // Parse color + Color memberColor; + try { + memberColor = Color( + int.parse(member.color.replaceAll('#', '0xFF')), + ); + } catch (_) { + memberColor = Colors.grey; + } + + return ListTile( + contentPadding: EdgeInsets.zero, + leading: CircleAvatar( + backgroundColor: memberColor.withOpacity(0.2), + child: Text( + member.emoji, + style: const TextStyle(fontSize: 20), + ), + ), + title: Text( + todo.title, + style: TextStyle( + color: todo.completed ? Colors.white54 : Colors.white, + decoration: todo.completed + ? TextDecoration.lineThrough + : null, + decorationColor: Colors.white54, + ), + ), + trailing: Checkbox( + value: todo.completed, + onChanged: (val) async { + // Toggle completion + final updated = TodoItem( + id: todo.id, + familyMemberId: todo.familyMemberId, + title: todo.title, + completed: val ?? false, + dueDate: todo.dueDate, + ); + await Provider.of( + context, + listen: false, + ).updateTodo(updated); + // Force rebuild? In a real app we'd use a reactive state. + // Here we rely on the parent or timer to refresh, or we could convert this to StatefulWidget. + // For now, let's just let the next refresh cycle pick it up, or if the user interacts, maybe we should optimistic update? + // Given it's a TV dashboard, interaction might be rare, but if it is interactive: + (context as Element) + .markNeedsBuild(); // HACK to refresh + }, + activeColor: Theme.of(context).colorScheme.secondary, + checkColor: Colors.black, + ), + ); + }, + ); + }, + ), + ), + ], + ), + ); + } +} diff --git a/flutter_app/lib/widgets/weather_widget.dart b/flutter_app/lib/widgets/weather_widget.dart new file mode 100644 index 0000000..0b01866 --- /dev/null +++ b/flutter_app/lib/widgets/weather_widget.dart @@ -0,0 +1,86 @@ +import 'package:flutter/material.dart'; +import 'package:provider/provider.dart'; +import 'package:flutter/foundation.dart'; +import '../config/api_config.dart'; +import '../models/weather_info.dart'; +import '../services/weather_service.dart'; + +class WeatherWidget extends StatelessWidget { + const WeatherWidget({super.key}); + + @override + Widget build(BuildContext context) { + return FutureBuilder( + future: Provider.of( + context, + listen: false, + ).fetchWeather(), + builder: (context, snapshot) { + if (snapshot.connectionState == ConnectionState.waiting) { + return const Center( + child: SizedBox( + width: 20, + height: 20, + child: CircularProgressIndicator(strokeWidth: 2), + ), + ); + } + + if (snapshot.hasError) { + return const Text( + 'Weather Unavailable', + style: TextStyle(color: Colors.white54), + ); + } + + if (!snapshot.hasData) { + return const SizedBox.shrink(); + } + + final weather = snapshot.data!; + // Assuming OpenWeatherMap icon format + final iconUrl = (ApiConfig.useMockData || kIsWeb) + ? null + : (weather.icon.isNotEmpty + ? "http://openweathermap.org/img/wn/${weather.icon}@2x.png" + : null); + + return Row( + mainAxisSize: MainAxisSize.min, + children: [ + if (iconUrl != null) + Image.network( + iconUrl, + width: 50, + height: 50, + errorBuilder: (_, __, ___) => + const Icon(Icons.wb_sunny, color: Colors.amber), + ) + else + const Icon(Icons.wb_sunny, color: Colors.amber, size: 40), + const SizedBox(width: 12), + Column( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Text( + '${weather.temperature.round()}°C', + style: Theme.of(context).textTheme.headlineSmall?.copyWith( + color: Colors.white, + fontWeight: FontWeight.bold, + ), + ), + Text( + '${weather.city} · ${weather.description}', + style: Theme.of( + context, + ).textTheme.bodyMedium?.copyWith(color: Colors.white70), + ), + ], + ), + ], + ); + }, + ); + } +} diff --git a/flutter_app/pubspec.lock b/flutter_app/pubspec.lock new file mode 100644 index 0000000..f14f79f --- /dev/null +++ b/flutter_app/pubspec.lock @@ -0,0 +1,421 @@ +# Generated by pub +# See https://dart.dev/tools/pub/glossary#lockfile +packages: + async: + dependency: transitive + description: + name: async + sha256: "758e6d74e971c3e5aceb4110bfd6698efc7f501675bcfe0c775459a8140750eb" + url: "https://pub.dev" + source: hosted + version: "2.13.0" + boolean_selector: + dependency: transitive + description: + name: boolean_selector + sha256: "8aab1771e1243a5063b8b0ff68042d67334e3feab9e95b9490f9a6ebf73b42ea" + url: "https://pub.dev" + source: hosted + version: "2.1.2" + characters: + dependency: transitive + description: + name: characters + sha256: f71061c654a3380576a52b451dd5532377954cf9dbd272a78fc8479606670803 + url: "https://pub.dev" + source: hosted + version: "1.4.0" + clock: + dependency: transitive + description: + name: clock + sha256: fddb70d9b5277016c77a80201021d40a2247104d9f4aa7bab7157b7e3f05b84b + url: "https://pub.dev" + source: hosted + version: "1.1.2" + code_assets: + dependency: transitive + description: + name: code_assets + sha256: "83ccdaa064c980b5596c35dd64a8d3ecc68620174ab9b90b6343b753aa721687" + url: "https://pub.dev" + source: hosted + version: "1.0.0" + collection: + dependency: transitive + description: + name: collection + sha256: "2f5709ae4d3d59dd8f7cd309b4e023046b57d8a6c82130785d2b0e5868084e76" + url: "https://pub.dev" + source: hosted + version: "1.19.1" + crypto: + dependency: transitive + description: + name: crypto + sha256: c8ea0233063ba03258fbcf2ca4d6dadfefe14f02fab57702265467a19f27fadf + url: "https://pub.dev" + source: hosted + version: "3.0.7" + cupertino_icons: + dependency: "direct main" + description: + name: cupertino_icons + sha256: ba631d1c7f7bef6b729a622b7b752645a2d076dba9976925b8f25725a30e1ee6 + url: "https://pub.dev" + source: hosted + version: "1.0.8" + fake_async: + dependency: transitive + description: + name: fake_async + sha256: "5368f224a74523e8d2e7399ea1638b37aecfca824a3cc4dfdf77bf1fa905ac44" + url: "https://pub.dev" + source: hosted + version: "1.3.3" + ffi: + dependency: transitive + description: + name: ffi + sha256: d07d37192dbf97461359c1518788f203b0c9102cfd2c35a716b823741219542c + url: "https://pub.dev" + source: hosted + version: "2.1.5" + file: + dependency: transitive + description: + name: file + sha256: a3b4f84adafef897088c160faf7dfffb7696046cb13ae90b508c2cbc95d3b8d4 + url: "https://pub.dev" + source: hosted + version: "7.0.1" + flutter: + dependency: "direct main" + description: flutter + source: sdk + version: "0.0.0" + flutter_test: + dependency: "direct dev" + description: flutter + source: sdk + version: "0.0.0" + glob: + dependency: transitive + description: + name: glob + sha256: c3f1ee72c96f8f78935e18aa8cecced9ab132419e8625dc187e1c2408efc20de + url: "https://pub.dev" + source: hosted + version: "2.1.3" + google_fonts: + dependency: "direct main" + description: + name: google_fonts + sha256: ba03d03bcaa2f6cb7bd920e3b5027181db75ab524f8891c8bc3aa603885b8055 + url: "https://pub.dev" + source: hosted + version: "6.3.3" + hooks: + dependency: transitive + description: + name: hooks + sha256: "5d309c86e7ce34cd8e37aa71cb30cb652d3829b900ab145e4d9da564b31d59f7" + url: "https://pub.dev" + source: hosted + version: "1.0.0" + http: + dependency: "direct main" + description: + name: http + sha256: "87721a4a50b19c7f1d49001e51409bddc46303966ce89a65af4f4e6004896412" + url: "https://pub.dev" + source: hosted + version: "1.6.0" + http_parser: + dependency: transitive + description: + name: http_parser + sha256: "178d74305e7866013777bab2c3d8726205dc5a4dd935297175b19a23a2e66571" + url: "https://pub.dev" + source: hosted + version: "4.1.2" + intl: + dependency: "direct main" + description: + name: intl + sha256: d6f56758b7d3014a48af9701c085700aac781a92a87a62b1333b46d8879661cf + url: "https://pub.dev" + source: hosted + version: "0.19.0" + leak_tracker: + dependency: transitive + description: + name: leak_tracker + sha256: "33e2e26bdd85a0112ec15400c8cbffea70d0f9c3407491f672a2fad47915e2de" + url: "https://pub.dev" + source: hosted + version: "11.0.2" + leak_tracker_flutter_testing: + dependency: transitive + description: + name: leak_tracker_flutter_testing + sha256: "1dbc140bb5a23c75ea9c4811222756104fbcd1a27173f0c34ca01e16bea473c1" + url: "https://pub.dev" + source: hosted + version: "3.0.10" + leak_tracker_testing: + dependency: transitive + description: + name: leak_tracker_testing + sha256: "8d5a2d49f4a66b49744b23b018848400d23e54caf9463f4eb20df3eb8acb2eb1" + url: "https://pub.dev" + source: hosted + version: "3.0.2" + logging: + dependency: transitive + description: + name: logging + sha256: c8245ada5f1717ed44271ed1c26b8ce85ca3228fd2ffdb75468ab01979309d61 + url: "https://pub.dev" + source: hosted + version: "1.3.0" + matcher: + dependency: transitive + description: + name: matcher + sha256: dc58c723c3c24bf8d3e2d3ad3f2f9d7bd9cf43ec6feaa64181775e60190153f2 + url: "https://pub.dev" + source: hosted + version: "0.12.17" + material_color_utilities: + dependency: transitive + description: + name: material_color_utilities + sha256: f7142bb1154231d7ea5f96bc7bde4bda2a0945d2806bb11670e30b850d56bdec + url: "https://pub.dev" + source: hosted + version: "0.11.1" + meta: + dependency: transitive + description: + name: meta + sha256: "23f08335362185a5ea2ad3a4e597f1375e78bce8a040df5c600c8d3552ef2394" + url: "https://pub.dev" + source: hosted + version: "1.17.0" + native_toolchain_c: + dependency: transitive + description: + name: native_toolchain_c + sha256: "89e83885ba09da5fdf2cdacc8002a712ca238c28b7f717910b34bcd27b0d03ac" + url: "https://pub.dev" + source: hosted + version: "0.17.4" + nested: + dependency: transitive + description: + name: nested + sha256: "03bac4c528c64c95c722ec99280375a6f2fc708eec17c7b3f07253b626cd2a20" + url: "https://pub.dev" + source: hosted + version: "1.0.0" + objective_c: + dependency: transitive + description: + name: objective_c + sha256: "7fd0c4d8ac8980011753b9bdaed2bf15111365924cdeeeaeb596214ea2b03537" + url: "https://pub.dev" + source: hosted + version: "9.2.4" + path: + dependency: transitive + description: + name: path + sha256: "75cca69d1490965be98c73ceaea117e8a04dd21217b37b292c9ddbec0d955bc5" + url: "https://pub.dev" + source: hosted + version: "1.9.1" + path_provider: + dependency: transitive + description: + name: path_provider + sha256: "50c5dd5b6e1aaf6fb3a78b33f6aa3afca52bf903a8a5298f53101fdaee55bbcd" + url: "https://pub.dev" + source: hosted + version: "2.1.5" + path_provider_android: + dependency: transitive + description: + name: path_provider_android + sha256: f2c65e21139ce2c3dad46922be8272bb5963516045659e71bb16e151c93b580e + url: "https://pub.dev" + source: hosted + version: "2.2.22" + path_provider_foundation: + dependency: transitive + description: + name: path_provider_foundation + sha256: "2a376b7d6392d80cd3705782d2caa734ca4727776db0b6ec36ef3f1855197699" + url: "https://pub.dev" + source: hosted + version: "2.6.0" + path_provider_linux: + dependency: transitive + description: + name: path_provider_linux + sha256: f7a1fe3a634fe7734c8d3f2766ad746ae2a2884abe22e241a8b301bf5cac3279 + url: "https://pub.dev" + source: hosted + version: "2.2.1" + path_provider_platform_interface: + dependency: transitive + description: + name: path_provider_platform_interface + sha256: "88f5779f72ba699763fa3a3b06aa4bf6de76c8e5de842cf6f29e2e06476c2334" + url: "https://pub.dev" + source: hosted + version: "2.1.2" + path_provider_windows: + dependency: transitive + description: + name: path_provider_windows + sha256: bd6f00dbd873bfb70d0761682da2b3a2c2fccc2b9e84c495821639601d81afe7 + url: "https://pub.dev" + source: hosted + version: "2.3.0" + platform: + dependency: transitive + description: + name: platform + sha256: "5d6b1b0036a5f331ebc77c850ebc8506cbc1e9416c27e59b439f917a902a4984" + url: "https://pub.dev" + source: hosted + version: "3.1.6" + plugin_platform_interface: + dependency: transitive + description: + name: plugin_platform_interface + sha256: "4820fbfdb9478b1ebae27888254d445073732dae3d6ea81f0b7e06d5dedc3f02" + url: "https://pub.dev" + source: hosted + version: "2.1.8" + provider: + dependency: "direct main" + description: + name: provider + sha256: "4e82183fa20e5ca25703ead7e05de9e4cceed1fbd1eadc1ac3cb6f565a09f272" + url: "https://pub.dev" + source: hosted + version: "6.1.5+1" + pub_semver: + dependency: transitive + description: + name: pub_semver + sha256: "5bfcf68ca79ef689f8990d1160781b4bad40a3bd5e5218ad4076ddb7f4081585" + url: "https://pub.dev" + source: hosted + version: "2.2.0" + sky_engine: + dependency: transitive + description: flutter + source: sdk + version: "0.0.0" + source_span: + dependency: transitive + description: + name: source_span + sha256: "254ee5351d6cb365c859e20ee823c3bb479bf4a293c22d17a9f1bf144ce86f7c" + url: "https://pub.dev" + source: hosted + version: "1.10.1" + stack_trace: + dependency: transitive + description: + name: stack_trace + sha256: "8b27215b45d22309b5cddda1aa2b19bdfec9df0e765f2de506401c071d38d1b1" + url: "https://pub.dev" + source: hosted + version: "1.12.1" + stream_channel: + dependency: transitive + description: + name: stream_channel + sha256: "969e04c80b8bcdf826f8f16579c7b14d780458bd97f56d107d3950fdbeef059d" + url: "https://pub.dev" + source: hosted + version: "2.1.4" + string_scanner: + dependency: transitive + description: + name: string_scanner + sha256: "921cd31725b72fe181906c6a94d987c78e3b98c2e205b397ea399d4054872b43" + url: "https://pub.dev" + source: hosted + version: "1.4.1" + term_glyph: + dependency: transitive + description: + name: term_glyph + sha256: "7f554798625ea768a7518313e58f83891c7f5024f88e46e7182a4558850a4b8e" + url: "https://pub.dev" + source: hosted + version: "1.2.2" + test_api: + dependency: transitive + description: + name: test_api + sha256: ab2726c1a94d3176a45960b6234466ec367179b87dd74f1611adb1f3b5fb9d55 + url: "https://pub.dev" + source: hosted + version: "0.7.7" + typed_data: + dependency: transitive + description: + name: typed_data + sha256: f9049c039ebfeb4cf7a7104a675823cd72dba8297f264b6637062516699fa006 + url: "https://pub.dev" + source: hosted + version: "1.4.0" + vector_math: + dependency: transitive + description: + name: vector_math + sha256: d530bd74fea330e6e364cda7a85019c434070188383e1cd8d9777ee586914c5b + url: "https://pub.dev" + source: hosted + version: "2.2.0" + vm_service: + dependency: transitive + description: + name: vm_service + sha256: "45caa6c5917fa127b5dbcfbd1fa60b14e583afdc08bfc96dda38886ca252eb60" + url: "https://pub.dev" + source: hosted + version: "15.0.2" + web: + dependency: transitive + description: + name: web + sha256: "868d88a33d8a87b18ffc05f9f030ba328ffefba92d6c127917a2ba740f9cfe4a" + url: "https://pub.dev" + source: hosted + version: "1.1.1" + xdg_directories: + dependency: transitive + description: + name: xdg_directories + sha256: "7a3f37b05d989967cdddcbb571f1ea834867ae2faa29725fd085180e0883aa15" + url: "https://pub.dev" + source: hosted + version: "1.1.0" + yaml: + dependency: transitive + description: + name: yaml + sha256: b9da305ac7c39faa3f030eccd175340f968459dae4af175130b3fc47e40d76ce + url: "https://pub.dev" + source: hosted + version: "3.1.3" +sdks: + dart: ">=3.10.3 <4.0.0" + flutter: ">=3.38.4" diff --git a/flutter_app/pubspec.yaml b/flutter_app/pubspec.yaml new file mode 100644 index 0000000..646bdbe --- /dev/null +++ b/flutter_app/pubspec.yaml @@ -0,0 +1,23 @@ +name: google_tv_dashboard +description: Family dashboard for Google TV and mobile admin. +publish_to: "none" +version: 0.1.0 + +environment: + sdk: ">=3.3.0 <4.0.0" + +dependencies: + flutter: + sdk: flutter + cupertino_icons: ^1.0.6 + http: ^1.2.2 + intl: ^0.19.0 + provider: ^6.1.2 + google_fonts: ^6.1.0 + +dev_dependencies: + flutter_test: + sdk: flutter + +flutter: + uses-material-design: true diff --git a/flutter_app/test/widget_test.dart b/flutter_app/test/widget_test.dart new file mode 100644 index 0000000..74cbdde --- /dev/null +++ b/flutter_app/test/widget_test.dart @@ -0,0 +1,30 @@ +// This is a basic Flutter widget test. +// +// To perform an interaction with a widget in your test, use the WidgetTester +// utility in the flutter_test package. For example, you can send tap and scroll +// gestures. You can also use WidgetTester to find child widgets in the widget +// tree, read text, and verify that the values of widget properties are correct. + +import 'package:flutter/material.dart'; +import 'package:flutter_test/flutter_test.dart'; + +import 'package:google_tv_dashboard/main.dart'; + +void main() { + testWidgets('Counter increments smoke test', (WidgetTester tester) async { + // Build our app and trigger a frame. + await tester.pumpWidget(const MyApp()); + + // Verify that our counter starts at 0. + expect(find.text('0'), findsOneWidget); + expect(find.text('1'), findsNothing); + + // Tap the '+' icon and trigger a frame. + await tester.tap(find.byIcon(Icons.add)); + await tester.pump(); + + // Verify that our counter has incremented. + expect(find.text('0'), findsNothing); + expect(find.text('1'), findsOneWidget); + }); +} diff --git a/flutter_app/web/favicon.png b/flutter_app/web/favicon.png new file mode 100644 index 0000000..8aaa46a Binary files /dev/null and b/flutter_app/web/favicon.png differ diff --git a/flutter_app/web/icons/Icon-192.png b/flutter_app/web/icons/Icon-192.png new file mode 100644 index 0000000..b749bfe Binary files /dev/null and b/flutter_app/web/icons/Icon-192.png differ diff --git a/flutter_app/web/icons/Icon-512.png b/flutter_app/web/icons/Icon-512.png new file mode 100644 index 0000000..88cfd48 Binary files /dev/null and b/flutter_app/web/icons/Icon-512.png differ diff --git a/flutter_app/web/icons/Icon-maskable-192.png b/flutter_app/web/icons/Icon-maskable-192.png new file mode 100644 index 0000000..eb9b4d7 Binary files /dev/null and b/flutter_app/web/icons/Icon-maskable-192.png differ diff --git a/flutter_app/web/icons/Icon-maskable-512.png b/flutter_app/web/icons/Icon-maskable-512.png new file mode 100644 index 0000000..d69c566 Binary files /dev/null and b/flutter_app/web/icons/Icon-maskable-512.png differ diff --git a/flutter_app/web/index.html b/flutter_app/web/index.html new file mode 100644 index 0000000..09179c1 --- /dev/null +++ b/flutter_app/web/index.html @@ -0,0 +1,38 @@ + + + + + + + + + + + + + + + + + + + + google_tv_dashboard + + + + + + diff --git a/flutter_app/web/manifest.json b/flutter_app/web/manifest.json new file mode 100644 index 0000000..fbf0e00 --- /dev/null +++ b/flutter_app/web/manifest.json @@ -0,0 +1,35 @@ +{ + "name": "google_tv_dashboard", + "short_name": "google_tv_dashboard", + "start_url": ".", + "display": "standalone", + "background_color": "#0175C2", + "theme_color": "#0175C2", + "description": "A new Flutter project.", + "orientation": "portrait-primary", + "prefer_related_applications": false, + "icons": [ + { + "src": "icons/Icon-192.png", + "sizes": "192x192", + "type": "image/png" + }, + { + "src": "icons/Icon-512.png", + "sizes": "512x512", + "type": "image/png" + }, + { + "src": "icons/Icon-maskable-192.png", + "sizes": "192x192", + "type": "image/png", + "purpose": "maskable" + }, + { + "src": "icons/Icon-maskable-512.png", + "sizes": "512x512", + "type": "image/png", + "purpose": "maskable" + } + ] +}