im so tired man
This commit is contained in:
parent
66da2473e1
commit
6272ece15d
3
.gitignore
vendored
3
.gitignore
vendored
@ -43,8 +43,9 @@ build/
|
||||
walkguide-backend/demo/secrets.properties
|
||||
|
||||
walkguide-backend/demo/hs_err_pid*.log
|
||||
walkguide-backend/demo/backend-run*.log
|
||||
walkguide-backend/demo/src/main/resources/firebase/*.json
|
||||
walkguide-mobile/walkguide_app/android/app/google-services.json
|
||||
walkguide-mobile/walkguide_app/android/app/google-services*.json
|
||||
walkguide-mobile/walkguide_app/ios/Runner/GoogleService-Info.plist
|
||||
|
||||
# Android SDK path (generated by Android Studio)
|
||||
|
||||
411
Exam Guide.md
411
Exam Guide.md
@ -1,411 +0,0 @@
|
||||
# 📱 Final Exam: Integrated Mobile Application Project
|
||||
### Flutter × Spring Boot × Object-Oriented Analysis and Design
|
||||
#### Group Assignment (3 Members) — Industry-Grade Level
|
||||
|
||||
---
|
||||
|
||||
## Overview
|
||||
|
||||
This final exam requires your group to design, develop, and deliver a **fully integrated mobile application system** consisting of:
|
||||
|
||||
- A **Flutter mobile frontend** that consumes a RESTful API
|
||||
- A **Spring Boot backend** that exposes the API with proper layering, security, and persistence
|
||||
- A rigorous **OOAD process** — designed before coding, then verified against the final implementation
|
||||
|
||||
The project is evaluated across three distinct dimensions with different grade weights. This is intentional: **design thinking (OOAD) is the foundation**, engineering quality (Flutter + Spring Boot) is the execution.
|
||||
|
||||
---
|
||||
|
||||
## Group Formation & Role Distribution
|
||||
|
||||
Each group consists of **exactly 3 members**. Each member owns one primary pillar but all members must understand and contribute to all three.
|
||||
|
||||
| Role | Primary Pillar | Core Responsibilities |
|
||||
|---|---|---|
|
||||
| **OOAD Lead** | Object-Oriented Analysis & Design | Leads all design artifacts (use case, class, sequence, state diagrams), enforces design pattern compliance across both codebases, owns the design traceability matrix |
|
||||
| **Flutter Engineer** | Mobile Frontend | Clean Architecture implementation, state management, UI/UX, performance benchmarking |
|
||||
| **Backend Engineer** | Spring Boot API | REST API design, service/repository layers, database schema, security (JWT), API documentation, backend testing |
|
||||
|
||||
> **Important:** Role ownership means accountability, not isolation. All members must commit code to both repositories. The OOAD Lead reviews both codebases for pattern compliance — this is a graded responsibility.
|
||||
|
||||
---
|
||||
|
||||
## Project Topic
|
||||
|
||||
Your group is free to choose any application domain, provided it:
|
||||
|
||||
- Models a real-world problem with identifiable actors, use cases, and entities
|
||||
- Requires meaningful backend logic (not just CRUD — include at least one business rule or workflow)
|
||||
- Has a clear primary user and at least one secondary actor (admin, system, or external service)
|
||||
|
||||
**Example domains** *(create your own — do not copy)*:
|
||||
- Hospital appointment and queue management
|
||||
- Campus asset borrowing and return tracking
|
||||
- Community marketplace with seller verification flow
|
||||
- Event ticketing with seat allocation logic
|
||||
- Employee attendance with approval workflow
|
||||
|
||||
---
|
||||
|
||||
## Pillar 1 — Object-Oriented Analysis & Design (OOAD)
|
||||
|
||||
OOAD is evaluated in **two phases**: design artifacts produced before coding, and a traceability audit conducted against the final code.
|
||||
|
||||
### Phase 1A: Pre-Development Design Artifacts
|
||||
|
||||
All diagrams must be produced using **PlantUML, draw.io, or StarUML** and submitted as part of the Week 2–3 checkpoint. Diagrams drawn by hand are not accepted.
|
||||
|
||||
| Artifact | Diagram Type | Requirement |
|
||||
|---|---|---|
|
||||
| Requirements model | Use Case Diagram | All actors, use cases, include/extend relationships |
|
||||
| Structural model | Class Diagram | All domain classes with attributes, methods, visibility, and relationships (association, aggregation, composition, inheritance) |
|
||||
| Behavioral model | Sequence Diagrams | At least 3 key interactions (e.g., login, create resource, approval flow) showing object collaboration |
|
||||
| State model | State Machine Diagram | At least 1 entity with meaningful state transitions (e.g., Order: PENDING → CONFIRMED → COMPLETED → CANCELLED) |
|
||||
| Data model | ERD (Crow's Foot notation) | All entities, PKs/FKs, cardinality — must align with the class diagram |
|
||||
| Architecture model | Component Diagram | Flutter app, Spring Boot layers, database, and external services as components with interfaces |
|
||||
|
||||
### Phase 1B: Design Pattern Compliance
|
||||
|
||||
Your system must implement **at least 4 GoF design patterns** across the full stack, with at least 1 from each category:
|
||||
|
||||
| Category | Required Count | Examples |
|
||||
|---|---|---|
|
||||
| Creational | ≥ 1 | Factory Method, Builder, Singleton |
|
||||
| Structural | ≥ 1 | Adapter, Facade, Decorator, Proxy |
|
||||
| Behavioral | ≥ 2 | Strategy, Observer, Command, Template Method, Chain of Responsibility |
|
||||
|
||||
Each pattern must be documented with:
|
||||
1. Pattern name and category
|
||||
2. Which class/component implements it (with file path)
|
||||
3. UML class diagram showing the pattern in context
|
||||
4. Justification — why this pattern was chosen over alternatives
|
||||
|
||||
### Phase 1C: Design Traceability Audit (Post-Development)
|
||||
|
||||
After development is complete, the OOAD Lead conducts a **traceability audit** comparing the pre-development design to the final code:
|
||||
|
||||
- For each class in the original class diagram: does it exist in code? If not, explain why.
|
||||
- For each design pattern: show the exact code that implements it (file + line reference).
|
||||
- For each sequence diagram: trace the method call chain in the actual code.
|
||||
- Document all **design deviations** — cases where implementation diverged from design — with a written rationale for each deviation.
|
||||
|
||||
> A perfect match between design and code is not required. Thoughtful, documented deviations are acceptable. Undocumented deviations are penalized.
|
||||
|
||||
---
|
||||
|
||||
## Pillar 2 — Flutter Mobile Frontend
|
||||
|
||||
### Technical Requirements
|
||||
|
||||
| Category | Requirement |
|
||||
|---|---|
|
||||
| **Flutter Version** | Flutter 3.x (Stable channel) |
|
||||
| **Architecture** | Clean Architecture — strict 4-layer separation: `domain / data / application / presentation` |
|
||||
| **State Management** | BLoC or Riverpod (consistent throughout; mixing is not allowed) |
|
||||
| **Navigation** | Go Router with at least 6 distinct screens and route guards for authenticated routes |
|
||||
| **API Communication** | `Dio` with interceptors for JWT token injection, refresh token handling, and error normalization |
|
||||
| **Local Persistence** | Hive or SQLite for offline caching of at least one core data entity |
|
||||
| **Authentication** | JWT-based login/register consuming the Spring Boot auth endpoint |
|
||||
| **UI/UX** | Custom widget library (min. 5 reusable widgets), responsive layout, consistent design system |
|
||||
| **Error Handling** | Typed failure classes using `Either` (dartz) or equivalent; no raw `try/catch` in UI layer |
|
||||
|
||||
### Folder Structure (Enforced)
|
||||
|
||||
```
|
||||
lib/
|
||||
├── core/ # shared utilities, theme, constants, error types
|
||||
├── features/
|
||||
│ └── [feature]/
|
||||
│ ├── domain/ # entities, repository interfaces, use cases
|
||||
│ ├── data/ # repository implementations, DTOs, data sources
|
||||
│ └── presentation/ # BLoC/Cubit, pages, widgets
|
||||
└── main.dart
|
||||
```
|
||||
|
||||
Any structure deviating from feature-first modular layout must be approved in writing before Week 4.
|
||||
|
||||
### Advanced Features (Choose at least 2)
|
||||
|
||||
- Real-time updates via WebSocket or Server-Sent Events from Spring Boot
|
||||
- Push notifications triggered by backend events (FCM)
|
||||
- Offline-first with background sync to Spring Boot API
|
||||
- Animated transitions using custom `PageRouteBuilder` or Lottie
|
||||
- Internationalization (i18n) with at least 2 languages
|
||||
- Biometric authentication (fingerprint/face ID) as second factor
|
||||
|
||||
### Flutter Testing & Benchmarking
|
||||
|
||||
#### Functional Testing
|
||||
|
||||
| Type | Tool | Minimum |
|
||||
|---|---|---|
|
||||
| Unit Testing | `flutter_test` | All use cases and repository implementations |
|
||||
| Widget Testing | `flutter_test` | At least 5 core UI components |
|
||||
| Integration Testing | `integration_test` | At least 3 end-to-end flows against the live Spring Boot API |
|
||||
|
||||
#### Performance Benchmarking
|
||||
|
||||
Run all benchmarks on a **physical Android device in profile mode** (`flutter run --profile`). Emulator results alone are not accepted.
|
||||
|
||||
| Metric | Tool | Pass Threshold |
|
||||
|---|---|---|
|
||||
| Memory — baseline | DevTools → Memory tab | Report heap at launch (MB) |
|
||||
| Memory — leak check | DevTools → Memory tab | No steady growth over 10 repeated navigations |
|
||||
| Frame rate / jank | DevTools → Performance tab | ≥ 90% frames < 16ms (60fps target) |
|
||||
| CPU profile | DevTools → CPU Profiler | Flame graph for top 3 CPU-heavy operations |
|
||||
| API latency (client-side) | Dio interceptor logs | All core endpoints < 1500ms |
|
||||
| Cold start time | `--trace-startup --profile` | `timeToFirstFrame` < 3000ms |
|
||||
| APK size | `flutter build apk --analyze-size` | Release APK < 50MB |
|
||||
|
||||
Each benchmark must be reported with: objective, tool, method, results table, threshold comparison, and DevTools screenshot.
|
||||
|
||||
**Regression requirement:** Run benchmarks at Week 5 (mid-sprint) and at Week 7 (final). Submit a delta table comparing both runs. Any metric that degrades > 20% must include a root cause analysis and remediation.
|
||||
|
||||
---
|
||||
|
||||
## Pillar 3 — Spring Boot Backend
|
||||
|
||||
### Technical Requirements
|
||||
|
||||
| Category | Requirement |
|
||||
|---|---|
|
||||
| **Java Version** | Java 17+ |
|
||||
| **Framework** | Spring Boot 3.x |
|
||||
| **Architecture** | Layered: `Controller → Service → Repository` (no logic in Controller, no DB calls in Service) |
|
||||
| **Database** | PostgreSQL or MySQL with JPA/Hibernate; schema migrations via Flyway |
|
||||
| **Security** | Spring Security with JWT (access token + refresh token); role-based access control (RBAC) |
|
||||
| **API Design** | RESTful conventions; versioned endpoints (`/api/v1/...`); proper HTTP status codes |
|
||||
| **Validation** | Bean Validation (`@Valid`) on all request DTOs; global exception handler via `@ControllerAdvice` |
|
||||
| **Documentation** | Swagger/OpenAPI 3.0 via `springdoc-openapi`; all endpoints documented with schemas |
|
||||
| **Configuration** | Environment-separated configs (`application-dev.yml`, `application-prod.yml`); no hardcoded secrets |
|
||||
|
||||
### API Contract Requirements
|
||||
|
||||
- Minimum **10 distinct REST endpoints** covering the full application domain
|
||||
- All endpoints must return a **consistent response envelope**:
|
||||
|
||||
```json
|
||||
{
|
||||
"success": true,
|
||||
"data": {},
|
||||
"message": "Operation successful",
|
||||
"timestamp": "2025-01-01T00:00:00Z"
|
||||
}
|
||||
```
|
||||
|
||||
- Error responses must include: `success: false`, `errorCode`, `message`, and `timestamp`
|
||||
- API contract must be defined as an **OpenAPI 3.0 YAML file** committed to the repository before development begins (design-first)
|
||||
|
||||
### Backend Testing & Benchmarking
|
||||
|
||||
#### Functional Testing
|
||||
|
||||
| Type | Tool | Minimum |
|
||||
|---|---|---|
|
||||
| Unit Testing | JUnit 5 + Mockito | All service classes; mock repository layer |
|
||||
| Integration Testing | `@SpringBootTest` + MockMvc | All controller endpoints; test DB via Testcontainers |
|
||||
| Code Coverage | JaCoCo | ≥ 70% line coverage on `service` and `controller` packages |
|
||||
|
||||
#### Load Benchmarking
|
||||
|
||||
| Metric | Tool | Pass Threshold |
|
||||
|---|---|---|
|
||||
| API throughput | Apache JMeter or k6 | ≥ 100 req/s under 50 concurrent users |
|
||||
| p95 latency | JMeter or k6 | < 500ms under load |
|
||||
| Error rate under load | JMeter or k6 | < 1% at 50 concurrent users |
|
||||
| DB query performance | Spring Actuator + slow query log | No query > 200ms for standard operations |
|
||||
| JVM memory under load | Actuator `/actuator/metrics` | No heap exhaustion during 5-min load test |
|
||||
|
||||
Load test scenario: simulate 50 concurrent users performing a realistic user journey (login → fetch list → create resource → logout) for 5 minutes. Export JMeter `.jtl` report or k6 summary as evidence.
|
||||
|
||||
---
|
||||
|
||||
## Deliverables
|
||||
|
||||
### 1. 📁 GitHub Repositories (2 repos)
|
||||
|
||||
**Flutter Repository** (`[GroupName]-[AppName]-mobile-final`):
|
||||
- Feature-first clean architecture folder structure
|
||||
- GitHub Actions workflow (`.github/workflows/flutter.yml`) — green at submission
|
||||
- `README.md`: setup instructions, environment variables, APK download link
|
||||
- All 3 members must have commits; branching strategy enforced
|
||||
|
||||
**Spring Boot Repository** (`[GroupName]-[AppName]-backend`):
|
||||
- Layered package structure (`controller`, `service`, `repository`, `domain`, `dto`, `config`)
|
||||
- Flyway migration scripts in `resources/db/migration/`
|
||||
- OpenAPI YAML committed before Week 4
|
||||
- `README.md`: setup instructions, environment variables, how to run locally
|
||||
- JaCoCo HTML coverage report committed or published via CI
|
||||
|
||||
### 2. 📦 APK File
|
||||
|
||||
- Release build named `[GroupName]_[AppName]_FinalExam.apk`
|
||||
- Must connect to a **live, publicly deployed** Spring Boot backend (not localhost)
|
||||
- Acceptable deployment platforms: Railway, Render, Fly.io, or any public URL
|
||||
|
||||
### 3. 📄 Written Report
|
||||
|
||||
Format: PDF, minimum **25 pages** (excluding cover and references). Language: English or Bahasa Indonesia.
|
||||
|
||||
| # | Section | Description |
|
||||
|---|---|---|
|
||||
| 1 | Cover Page | System name, group name, member names & student IDs, course name, date |
|
||||
| 2 | Abstract | 200–250 words covering the system, tech stack, and key findings |
|
||||
| 3 | Introduction | Problem background, objectives, target users, scope and limitations |
|
||||
| 4 | OOAD — Pre-Development | All design artifacts (use case, class, sequence, state, ERD, component diagrams) |
|
||||
| 5 | OOAD — Design Patterns | Documentation of all 4+ patterns with UML and code references |
|
||||
| 6 | OOAD — Traceability Audit | Design-to-code mapping table; documented deviations with rationale |
|
||||
| 7 | System Architecture | Flutter Clean Architecture, Spring Boot layers, API communication flow diagram |
|
||||
| 8 | API Contract | OpenAPI summary, endpoint table, request/response examples |
|
||||
| 9 | Flutter Implementation | Key features, state management flow, custom widgets, advanced features |
|
||||
| 10 | Spring Boot Implementation | Service layer logic, security config, DB schema, Flyway migrations |
|
||||
| 11 | Flutter Testing & Benchmarking | Test results, all 7 benchmark metrics with evidence and delta table |
|
||||
| 12 | Backend Testing & Benchmarking | JUnit/integration test results, JMeter/k6 load test report |
|
||||
| 13 | Team Contribution | Per-member task table with percentage, cross-verified with Git commit history |
|
||||
| 14 | Conclusion | Achievements, design lessons learned, challenges, future improvements |
|
||||
| 15 | References | IEEE format |
|
||||
|
||||
### 4. Presentation
|
||||
|
||||
- Duration: **15–20 minutes**
|
||||
- Structure:
|
||||
- Team introduction + system overview (2 min)
|
||||
- OOAD design walkthrough — diagrams and pattern explanation (4–5 min)
|
||||
- Flutter app live demo — all major flows (5–6 min)
|
||||
- Spring Boot API demo — Swagger UI + one live API call (3 min)
|
||||
- Benchmark results summary (2 min)
|
||||
- All 3 members must present a section
|
||||
- Upload to YouTube (unlisted) or Google Drive
|
||||
|
||||
> **Live Session:** Each member will be questioned individually on the section they presented and on OOAD concepts. Individual scores may differ from the group score.
|
||||
|
||||
---
|
||||
|
||||
## Timeline
|
||||
|
||||
| Phase | Activity | Deadline |
|
||||
|---|---|---|
|
||||
| Week 1 | Group registration + topic proposal + actor/use case list | Day 7 |
|
||||
| Week 2–3 | All OOAD Phase 1A artifacts submitted + OpenAPI YAML drafted | Day 21 |
|
||||
| Week 4 | Architecture approved; development sprint begins | Day 28 |
|
||||
| Week 5 | Mid-sprint benchmark run (Flutter + Backend) submitted | Day 35 |
|
||||
| Week 6–7 | Feature freeze; Flutter ↔ Spring Boot integration testing | Day 49 |
|
||||
| Week 7 | Final benchmark run; delta table completed | Day 49 |
|
||||
| Week 8 | OOAD traceability audit completed; report writing + video | Day 56 |
|
||||
| **Final** | **All deliverables submitted** | **Day 60, 23:59** |
|
||||
| Final+1 | Live presentation & individual Q&A | Scheduled by lecturer |
|
||||
|
||||
---
|
||||
|
||||
## Grading Rubric
|
||||
|
||||
Each pillar is graded **independently out of 100 points**. Students receive three separate scores — one per pillar. There is no combined final grade: each score stands on its own and is recorded separately.
|
||||
|
||||
---
|
||||
|
||||
### 🥇 Pillar 1 — OOAD Score (/ 100)
|
||||
|
||||
| Component | Points | Criteria |
|
||||
|---|---|---|
|
||||
| Pre-development design artifacts | 35 | Completeness of all 6 required diagrams, correctness of notation, diagram tool used (no hand-drawn), submitted before coding begins |
|
||||
| Design pattern implementation | 25 | Correct application of ≥ 4 GoF patterns (min 1 per category), UML documented per pattern, each traceable to code with file path |
|
||||
| Traceability audit | 25 | Coverage of class-to-code mapping, quality and honesty of deviation documentation, sequence diagram trace accuracy |
|
||||
| Cross-pillar design consistency | 15 | Alignment between class diagram, ERD, Flutter domain layer entities, and Spring Boot domain/entity classes |
|
||||
|
||||
**OOAD Penalty:**
|
||||
|
||||
| Violation | Deduction |
|
||||
|---|---|
|
||||
| OOAD artifacts submitted after Week 3 (after coding begins) | −20 points |
|
||||
| Diagram produced with unpermitted tool (e.g., hand-drawn, screenshot of AI output) | −15 points |
|
||||
| Design pattern claimed but not traceable in code | −8 points per pattern |
|
||||
| Traceability audit missing for > 30% of class diagram classes | −10 points |
|
||||
|
||||
---
|
||||
|
||||
### 🥈 Pillar 2 — Flutter Mobile Score (/ 100)
|
||||
|
||||
| Component | Points | Criteria |
|
||||
|---|---|---|
|
||||
| Clean Architecture compliance | 25 | Strict 4-layer separation enforced, no cross-layer violations, feature-first folder structure correct, dependency direction correct |
|
||||
| Features & UX quality | 20 | All required screens functional, JWT auth flow works against live API, custom widget library present, error states handled |
|
||||
| Testing — unit & widget | 15 | All use cases and repositories covered, at least 5 widget tests, test quality (meaningful assertions, not just coverage padding) |
|
||||
| Testing — integration | 10 | At least 3 end-to-end flows tested against live Spring Boot API, not mocked |
|
||||
| Performance benchmarking | 20 | All 7 metrics reported on physical device in profile mode, DevTools screenshots provided, delta table (mid vs final), root cause for any regression > 20% |
|
||||
| Report clarity | 10 | Report is complete and have clear explanation |
|
||||
|
||||
**Flutter Penalty:**
|
||||
|
||||
| Violation | Deduction |
|
||||
|---|---|
|
||||
| Responsive Design fail | −10 points |
|
||||
| Benchmarks run on emulator only (no physical device) | −10 points |
|
||||
| Missing delta table (mid-sprint vs final benchmark) | −8 points |
|
||||
| State management inconsistency (mixing BLoC and Riverpod) | −10 points |
|
||||
| Raw `try/catch` found in presentation layer | −5 points per occurrence (max −15) |
|
||||
| APK connects to localhost instead of deployed backend | −15 points |
|
||||
|
||||
---
|
||||
|
||||
### 🥉 Pillar 3 — Spring Boot Score (/ 100)
|
||||
|
||||
| Component | Points | Criteria |
|
||||
|---|---|---|
|
||||
| API design & OpenAPI contract | 25 | ≥ 10 endpoints, consistent response envelope, versioned routes, OpenAPI 3.0 YAML committed before Week 4, Swagger UI accessible |
|
||||
| Layered architecture & security | 25 | Strict Controller → Service → Repository separation, JWT with access + refresh token, RBAC with at least 2 roles, no hardcoded secrets |
|
||||
| Testing — unit & integration | 25 | JUnit 5 + Mockito for all service classes, MockMvc + Testcontainers for all controllers, JaCoCo ≥ 70% on `service` and `controller` packages |
|
||||
| Load benchmarking | 25 | All 5 metrics reported (throughput, p95 latency, error rate, DB query time, JVM heap), JMeter `.jtl` or k6 summary exported, analysis against pass thresholds |
|
||||
|
||||
**Spring Boot Penalty:**
|
||||
|
||||
| Violation | Deduction |
|
||||
|---|---|
|
||||
| Hardcoded secrets (API keys, DB passwords) in any file | −15 points |
|
||||
| JaCoCo coverage below 70% | −10 points |
|
||||
| No Flyway migrations (schema managed manually) | −8 points |
|
||||
| OpenAPI YAML committed after Week 4 | −10 points |
|
||||
| Load test run with < 50 concurrent users | −10 points |
|
||||
| Business logic found directly in Controller class | −8 points per occurrence (max −16) |
|
||||
|
||||
---
|
||||
|
||||
### Universal Penalty (Applied to All Three Pillar Scores)
|
||||
|
||||
| Violation | Deduction |
|
||||
|---|---|
|
||||
| Late submission (per day, applied to all pillars) | −5 points per pillar |
|
||||
| Missing deliverable | −15 points from the relevant pillar |
|
||||
| Plagiarized code (any source) | 0 on all three pillars |
|
||||
| Member with < 10% commits and no other contribution evidence | That member's individual pillar scores reduced by 20 points each |
|
||||
|
||||
---
|
||||
|
||||
## Academic Integrity
|
||||
|
||||
- All code must be original. Open-source libraries are permitted with proper attribution in both READMEs and the report.
|
||||
- Use of AI coding assistants is **permitted but must be disclosed** in a dedicated "AI Tool Usage" section in the report, listing which tools were used, for which tasks, and how outputs were reviewed and understood.
|
||||
- Design artifacts must be produced by the group. AI-generated diagrams submitted without annotation will be identified during the live Q&A.
|
||||
- Plagiarism between groups or from public repositories results in **zero marks for all involved groups**.
|
||||
|
||||
---
|
||||
|
||||
## Submission Checklist
|
||||
|
||||
- [ ] Flutter GitHub repository (Actions pipeline green, branch protection active, 3+ merged PRs)
|
||||
- [ ] Spring Boot GitHub repository (JaCoCo report committed, OpenAPI YAML present, Flyway migrations included)
|
||||
- [ ] APK file connecting to live deployed backend (`[GroupName]_FinalExam.apk`)
|
||||
- [ ] Written report PDF (≥ 25 pages, all 16 sections complete, benchmark delta table included)
|
||||
- [ ] Demo video link (YouTube unlisted or Google Drive, all 3 members presenting)
|
||||
- [ ] OOAD traceability matrix (Section 6 of report)
|
||||
- [ ] Mid-sprint benchmark results (Sections 11 & 12 of report)
|
||||
- [ ] JMeter/k6 load test export (appendix or Drive link)
|
||||
|
||||
---
|
||||
|
||||
## Contact & Questions
|
||||
|
||||
All questions must be submitted through the official course channel. Questions submitted at least **48 hours before any deadline** are guaranteed a response. Design artifact reviews (Week 2–3) require a scheduled appointment — contact the lecturer by Week 1 to book a slot.
|
||||
|
||||
---
|
||||
|
||||
*Build systems you can defend, designs you can explain, and code that reflects your thinking. 🚀*
|
||||
22
README.md
22
README.md
@ -138,17 +138,11 @@ The `ooad-docs/` folder contains traceability and diagrams, including:
|
||||
|
||||
### Backend
|
||||
|
||||
Local/dev config has fallback values so the project can run from an IDE without manually setting every environment variable.
|
||||
Local/dev config imports an optional gitignored file at `walkguide-backend/demo/secrets.properties`.
|
||||
Copy `walkguide-backend/demo/secrets.properties.example` to `secrets.properties` and fill it locally.
|
||||
Tracked config files do not contain DB passwords, JWT secrets, Agora certificates, or Firebase keys.
|
||||
|
||||
`application.properties` and `application-dev.yml` currently default to:
|
||||
|
||||
```properties
|
||||
spring.datasource.url=jdbc:postgresql://202.46.28.160:2002/uas_5803024001
|
||||
spring.datasource.username=5803024001
|
||||
spring.datasource.password=pw5803024001
|
||||
```
|
||||
|
||||
JWT also has a dev fallback secret. Production config remains strict in `application-prod.yml` and expects environment variables:
|
||||
Both dev and production expect these values from environment variables or `secrets.properties`:
|
||||
|
||||
```text
|
||||
DB_URL
|
||||
@ -447,12 +441,12 @@ Swagger UI:
|
||||
http://localhost:8080/swagger-ui.html
|
||||
```
|
||||
|
||||
The local/dev profile has fallback DB and JWT values. If you want to override them:
|
||||
Local/dev configuration reads database and secret values from environment variables or from the gitignored `secrets.properties` file:
|
||||
|
||||
```powershell
|
||||
$env:DB_URL="jdbc:postgresql://202.46.28.160:2002/uas_5803024001"
|
||||
$env:DB_USERNAME="5803024001"
|
||||
$env:DB_PASSWORD="pw5803024001"
|
||||
$env:DB_URL="jdbc:postgresql://<host>:<port>/<database>"
|
||||
$env:DB_USERNAME="<database_username>"
|
||||
$env:DB_PASSWORD="<database_password>"
|
||||
$env:JWT_SECRET="your-base64-secret"
|
||||
```
|
||||
|
||||
|
||||
@ -46,16 +46,14 @@ package "③ Facade Pattern [Structural]" #FFF8E1 {
|
||||
class "VoiceCommandHandler\n<<Facade>>" as VoiceCommandHandler {
|
||||
- _ttsService : TtsService
|
||||
- _sttService : SttService
|
||||
- _router : GoRouter
|
||||
- _walkGuideBloc : WalkGuideBloc
|
||||
- _sosBloc : SosBloc
|
||||
- _notifBloc : NotificationBloc
|
||||
- _router : CommandRouter
|
||||
- _actions : Map<VoiceCommandKey, CommandAction>
|
||||
+ processText(String command) : void
|
||||
- _matchCommand(String) : VoiceCommandKey?
|
||||
- _executeCommand(VoiceCommandKey) : void
|
||||
}
|
||||
|
||||
class "WalkGuideBloc\n<<Client>>" as WalkGuideBlocFacade {
|
||||
class "WalkGuideCubit\n<<Client>>" as WalkGuideCubitFacade {
|
||||
+ onVoiceCommand(String text)
|
||||
}
|
||||
|
||||
@ -69,8 +67,8 @@ package "③ Facade Pattern [Structural]" #FFF8E1 {
|
||||
|
||||
class "SttService " as SttServiceFacade <<Subsystem>>
|
||||
class "TtsService " as TtsServiceFacade <<Subsystem>>
|
||||
class "GoRouter\n<<Router>>" as GoRouterFacade <<Subsystem>>
|
||||
class "SosBloc " as SosBlocFacade <<Subsystem>>
|
||||
class "CommandRouter\n<<Router Adapter>>" as GoRouterFacade <<Subsystem>>
|
||||
class "CommandAction\n<<Cubit Callback>>" as CommandActionFacade <<Subsystem>>
|
||||
|
||||
class "LocationService\n<<Service>>" as LocationService <<Subsystem>>
|
||||
class "ActivityLogService\n<<Service>>" as ActivityService <<Subsystem>>
|
||||
@ -82,11 +80,11 @@ package "③ Facade Pattern [Structural]" #FFF8E1 {
|
||||
' GET /api/v1/guardian/dashboard
|
||||
}
|
||||
|
||||
WalkGuideBlocFacade --> VoiceCommandHandler : processText()
|
||||
WalkGuideCubitFacade --> VoiceCommandHandler : processText()
|
||||
VoiceCommandHandler --> SttServiceFacade : delegates
|
||||
VoiceCommandHandler --> TtsServiceFacade : delegates
|
||||
VoiceCommandHandler --> GoRouterFacade : delegates
|
||||
VoiceCommandHandler --> SosBlocFacade : delegates
|
||||
VoiceCommandHandler --> CommandActionFacade : delegates
|
||||
|
||||
GuardianDashboardController --> GuardianDashboardService : getDashboard()
|
||||
GuardianDashboardService --> LocationService : aggregates
|
||||
|
||||
@ -57,8 +57,8 @@ package "④ Repository Pattern [Structural — Proxy]" #FFF3E0 {
|
||||
}
|
||||
|
||||
class "WalkGuideRepositoryImpl\n<<Proxy>>" as WalkGuideRepoImpl {
|
||||
- _remoteDataSource : WalkGuideRemoteDataSource
|
||||
- _localDataSource : WalkGuideLocalDataSource
|
||||
- _apiClient : ApiClient
|
||||
- _offlineQueue : OfflineQueueService
|
||||
- _connectivity : ConnectivityPlus
|
||||
+ startSession() : Either<Failure, void>
|
||||
+ logObstacle(req) : Either<Failure, void>
|
||||
@ -72,16 +72,16 @@ package "④ Repository Pattern [Structural — Proxy]" #FFF3E0 {
|
||||
+ syncPending() : Either<Failure, void>
|
||||
}
|
||||
|
||||
class "WalkGuideRemoteDataSource\n<<Remote>>" as RemoteDSWalk {
|
||||
class "ApiClient\n<<Remote>>" as RemoteDSWalk {
|
||||
+ startSession() : void
|
||||
+ logObstacle(req) : void
|
||||
' POST /api/v1/user/obstacle
|
||||
}
|
||||
|
||||
class "WalkGuideLocalDataSource\n<<SQLite/Drift>>" as LocalDSWalk {
|
||||
class "OfflineQueueService + LocalDatabase\n<<SQLite Cache>>" as LocalDSWalk {
|
||||
+ cacheObstacle(ObstacleLog) : void
|
||||
+ getPendingLogs() : List<ObstacleLog>
|
||||
' Drift ORM — offline first
|
||||
' SQLite-backed offline first
|
||||
}
|
||||
|
||||
WalkGuideRepo <|.. WalkGuideRepoImpl : implements
|
||||
|
||||
@ -43,30 +43,27 @@ skinparam note {
|
||||
|
||||
package "⑤ Observer Pattern [Behavioral]" #F3E5F5 {
|
||||
|
||||
abstract class "Bloc<Event, State>\n<<Subject>>" as BlocSubject {
|
||||
abstract class "Cubit<State>\n<<Subject>>" as BlocSubject {
|
||||
# stateController : StreamController<State>
|
||||
+ {abstract} on<E>(EventHandler)
|
||||
+ add(Event event)
|
||||
+ emit(State state)
|
||||
+ stream : Stream<State>
|
||||
}
|
||||
|
||||
class "WalkGuideBloc\n<<ConcreteSubject>>" as WalkGuideBlocObs {
|
||||
+ on<StartWalkGuide>(_onStart)
|
||||
+ on<StopWalkGuide>(_onStop)
|
||||
+ on<CameraFrameReceived>(_onFrame)
|
||||
+ on<ObstacleDetected>(_onObstacle)
|
||||
class "WalkGuideCubit\n<<ConcreteSubject>>" as WalkGuideCubitObs {
|
||||
+ start()
|
||||
+ stop()
|
||||
+ logObstacle()
|
||||
- _yoloDetector : YoloDetector
|
||||
- _ttsService : TtsService
|
||||
- _hapticService : HapticService
|
||||
}
|
||||
|
||||
class "BlocBuilder<WalkGuideBloc, WalkGuideState>\n<<Observer / Widget>>" as BlocBuilderWidget {
|
||||
class "BlocBuilder<WalkGuideCubit, WalkGuideState>\n<<Observer / Widget>>" as BlocBuilderWidget {
|
||||
+ builder(ctx, state) : Widget
|
||||
' Rebuilds UI on every state emission
|
||||
}
|
||||
|
||||
class "BlocListener<WalkGuideBloc, WalkGuideState>\n<<Observer / SideEffect>>" as BlocListenerWidget {
|
||||
class "BlocListener<WalkGuideCubit, WalkGuideState>\n<<Observer / SideEffect>>" as BlocListenerWidget {
|
||||
+ listener(ctx, state) : void
|
||||
' Side effects: TTS, haptic, navigation
|
||||
}
|
||||
@ -84,9 +81,9 @@ package "⑤ Observer Pattern [Behavioral]" #F3E5F5 {
|
||||
' Updates flutter_map markers in real-time
|
||||
}
|
||||
|
||||
BlocSubject <|-- WalkGuideBlocObs : extends
|
||||
WalkGuideBlocObs --> BlocBuilderWidget : emits state\n(rebuilds UI)
|
||||
WalkGuideBlocObs --> BlocListenerWidget : emits state\n(side effects)
|
||||
BlocSubject <|-- WalkGuideCubitObs : extends
|
||||
WalkGuideCubitObs --> BlocBuilderWidget : emits state\n(rebuilds UI)
|
||||
WalkGuideCubitObs --> BlocListenerWidget : emits state\n(side effects)
|
||||
WebSocketObs --> GuardianMapObs : notifies\nlive location
|
||||
}
|
||||
|
||||
|
||||
@ -1,7 +0,0 @@
|
||||
Set-Location : A positional parameter cannot be found that accepts argument 'PROGRAM'.
|
||||
At line:1 char:1
|
||||
+ Set-Location C:\COBA PROGRAM SEMESTER 4\UAS FLUTTER FT. SPRINGBOOT da ...
|
||||
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
+ CategoryInfo : InvalidArgument: (:) [Set-Location], ParameterBindingException
|
||||
+ FullyQualifiedErrorId : PositionalParameterNotFound,Microsoft.PowerShell.Commands.SetLocationCommand
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
10
walkguide-backend/demo/secrets.properties.example
Normal file
10
walkguide-backend/demo/secrets.properties.example
Normal file
@ -0,0 +1,10 @@
|
||||
# Copy this file to walkguide-backend/demo/secrets.properties.
|
||||
# secrets.properties is gitignored and is imported by application.properties.
|
||||
|
||||
DB_URL=jdbc:postgresql://<host>:<port>/<database>
|
||||
DB_USERNAME=<database_username>
|
||||
DB_PASSWORD=<database_password>
|
||||
JWT_SECRET=<base64_hs256_secret_at_least_32_bytes>
|
||||
AGORA_APP_ID=<agora_app_id>
|
||||
AGORA_APP_CERTIFICATE=<agora_app_certificate>
|
||||
FIREBASE_CREDENTIALS_PATH=classpath:firebase/google-services-admin.json
|
||||
@ -8,4 +8,5 @@ public class LocationUpdateRequest {
|
||||
private Double accuracy;
|
||||
private Double speed;
|
||||
private Double heading;
|
||||
private Integer batteryLevel;
|
||||
}
|
||||
|
||||
@ -4,6 +4,7 @@ import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.AllArgsConstructor;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@ -22,6 +23,8 @@ public class DashboardResponse {
|
||||
// Status
|
||||
private long unreadSosCount;
|
||||
private long unreadNotifCount;
|
||||
private long obstaclesToday;
|
||||
private Map<String, Object> userStatus;
|
||||
|
||||
// Recent activity (5 terbaru)
|
||||
private List<ActivityLogResponse> recentActivity;
|
||||
|
||||
@ -16,5 +16,6 @@ public class LocationResponse {
|
||||
private Double accuracy;
|
||||
private Double speed;
|
||||
private Double heading;
|
||||
private Integer batteryLevel;
|
||||
private LocalDateTime createdAt;
|
||||
}
|
||||
|
||||
@ -29,6 +29,9 @@ public class LocationHistory {
|
||||
private Double speed; // m/s
|
||||
private Double heading; // derajat 0-360
|
||||
|
||||
@Column(name = "battery_level")
|
||||
private Integer batteryLevel;
|
||||
|
||||
@Column(name = "created_at", nullable = false, updatable = false)
|
||||
private LocalDateTime createdAt;
|
||||
|
||||
|
||||
@ -39,8 +39,13 @@ public class GlobalExceptionHandler {
|
||||
}
|
||||
@ExceptionHandler(RuntimeException.class)
|
||||
public ResponseEntity<ApiResponse<Object>> handleRuntime(RuntimeException ex) {
|
||||
String message = ex.getMessage();
|
||||
if ("Email tidak terdaftar".equals(message) || "Password salah".equals(message)) {
|
||||
return ResponseEntity.status(HttpStatus.UNAUTHORIZED)
|
||||
.body(ApiResponse.error("AUTH_INVALID", message));
|
||||
}
|
||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR)
|
||||
.body(ApiResponse.error("INTERNAL_ERROR", ex.getMessage()));
|
||||
.body(ApiResponse.error("INTERNAL_ERROR", message));
|
||||
}
|
||||
|
||||
@ExceptionHandler(Exception.class)
|
||||
|
||||
@ -4,7 +4,11 @@ import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Repository
|
||||
public interface ObstacleLogRepository extends JpaRepository<ObstacleLog, Long> {
|
||||
Page<ObstacleLog> findByUserIdOrderByCreatedAtDesc(Long userId, Pageable pageable);
|
||||
long countByUserIdAndCreatedAtAfter(Long userId, LocalDateTime createdAt);
|
||||
}
|
||||
|
||||
@ -8,7 +8,10 @@ import io.jsonwebtoken.security.Keys;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.security.Key;
|
||||
import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
@ -82,7 +85,34 @@ public class JwtUtil {
|
||||
}
|
||||
|
||||
private Key getSignInKey() {
|
||||
byte[] keyBytes = Decoders.BASE64.decode(secretKey);
|
||||
byte[] keyBytes = decodeSecret(secretKey);
|
||||
return Keys.hmacShaKeyFor(keyBytes);
|
||||
}
|
||||
|
||||
private byte[] decodeSecret(String configuredSecret) {
|
||||
String trimmed = configuredSecret == null ? "" : configuredSecret.trim();
|
||||
if (trimmed.isEmpty()) {
|
||||
throw new IllegalStateException("JWT secret must not be empty");
|
||||
}
|
||||
|
||||
byte[] keyBytes;
|
||||
try {
|
||||
keyBytes = Decoders.BASE64.decode(trimmed);
|
||||
} catch (RuntimeException base64Error) {
|
||||
try {
|
||||
keyBytes = Decoders.BASE64URL.decode(trimmed);
|
||||
} catch (RuntimeException base64UrlError) {
|
||||
keyBytes = trimmed.getBytes(StandardCharsets.UTF_8);
|
||||
}
|
||||
}
|
||||
|
||||
if (keyBytes.length >= 32) {
|
||||
return keyBytes;
|
||||
}
|
||||
try {
|
||||
return MessageDigest.getInstance("SHA-256").digest(keyBytes);
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
throw new IllegalStateException("SHA-256 is not available", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -8,6 +8,11 @@ import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.LocalTime;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class GuardianDashboardService {
|
||||
@ -17,6 +22,7 @@ public class GuardianDashboardService {
|
||||
private final ActivityLogService activityLogService;
|
||||
private final SosEventRepository sosEventRepository;
|
||||
private final GuardianNotificationRepository notifRepository;
|
||||
private final ObstacleLogRepository obstacleLogRepository;
|
||||
|
||||
public DashboardResponse getDashboard(Long guardianId) {
|
||||
var pairing = pairingRelationRepository
|
||||
@ -40,6 +46,21 @@ public class GuardianDashboardService {
|
||||
long unreadSos = sosEventRepository.findByUserIdOrderByCreatedAtDesc(userId, PageRequest.of(0, 100))
|
||||
.stream().filter(s -> s.getStatus().name().equals("TRIGGERED")).count();
|
||||
long unreadNotif = notifRepository.countByUserIdAndIsReadFalse(userId);
|
||||
long obstaclesToday = obstacleLogRepository.countByUserIdAndCreatedAtAfter(
|
||||
userId,
|
||||
LocalDateTime.of(LocalDateTime.now().toLocalDate(), LocalTime.MIN)
|
||||
);
|
||||
|
||||
Map<String, Object> userStatus = new HashMap<>();
|
||||
userStatus.put("displayName", user.getDisplayName());
|
||||
userStatus.put("email", user.getEmail());
|
||||
userStatus.put("online", lastLocation != null
|
||||
&& lastLocation.getCreatedAt() != null
|
||||
&& lastLocation.getCreatedAt().isAfter(LocalDateTime.now().minusMinutes(2)));
|
||||
userStatus.put("lastSeenAt", lastLocation != null ? lastLocation.getCreatedAt() : null);
|
||||
userStatus.put("battery", lastLocation != null ? lastLocation.getBatteryLevel() : null);
|
||||
userStatus.put("lastSpeed", lastLocation != null ? lastLocation.getSpeed() : null);
|
||||
userStatus.put("obstaclesToday", obstaclesToday);
|
||||
|
||||
return DashboardResponse.builder()
|
||||
.pairedUserId(userId)
|
||||
@ -49,6 +70,8 @@ public class GuardianDashboardService {
|
||||
.lastLocation(lastLocation)
|
||||
.unreadSosCount(unreadSos)
|
||||
.unreadNotifCount(unreadNotif)
|
||||
.obstaclesToday(obstaclesToday)
|
||||
.userStatus(userStatus)
|
||||
.recentActivity(recentActivity)
|
||||
.build();
|
||||
}
|
||||
|
||||
@ -42,6 +42,7 @@ public class LocationService {
|
||||
.accuracy(req.getAccuracy())
|
||||
.speed(req.getSpeed())
|
||||
.heading(req.getHeading())
|
||||
.batteryLevel(req.getBatteryLevel())
|
||||
.build();
|
||||
loc = locationHistoryRepository.save(loc);
|
||||
|
||||
@ -136,6 +137,7 @@ public class LocationService {
|
||||
return LocationResponse.builder()
|
||||
.id(l.getId()).lat(l.getLat()).lng(l.getLng())
|
||||
.accuracy(l.getAccuracy()).speed(l.getSpeed()).heading(l.getHeading())
|
||||
.batteryLevel(l.getBatteryLevel())
|
||||
.createdAt(l.getCreatedAt()).build();
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,35 +1,9 @@
|
||||
# ===================================================
|
||||
# Profile: prod (production)
|
||||
# Aktifkan dengan: --spring.profiles.active=prod
|
||||
# Semua nilai WAJIB diisi via environment variable
|
||||
# Tidak ada default value — akan gagal start jika kosong
|
||||
# ===================================================
|
||||
|
||||
spring:
|
||||
datasource:
|
||||
url: ${DB_URL}
|
||||
username: ${DB_USERNAME}
|
||||
password: ${DB_PASSWORD}
|
||||
|
||||
jpa:
|
||||
show-sql: false
|
||||
properties:
|
||||
hibernate:
|
||||
format_sql: false
|
||||
|
||||
server:
|
||||
port: ${PORT:8080}
|
||||
|
||||
jwt:
|
||||
secret: ${JWT_SECRET}
|
||||
expiration: ${JWT_EXPIRATION:86400000}
|
||||
|
||||
agora:
|
||||
app-id: ${AGORA_APP_ID}
|
||||
app-certificate: ${AGORA_APP_CERTIFICATE}
|
||||
|
||||
logging:
|
||||
level:
|
||||
com.walkguide: INFO
|
||||
org.springframework.messaging: WARN
|
||||
org.springframework.web.socket: WARN
|
||||
DB_URL=jdbc:postgresql://<host>:<port>/<database>
|
||||
DB_USERNAME=<database_username>
|
||||
DB_PASSWORD=<database_password>
|
||||
JWT_SECRET=<base64_hs256_secret_at_least_32_bytes>
|
||||
JWT_EXPIRATION=86400000
|
||||
AGORA_APP_ID=<agora_app_id>
|
||||
AGORA_APP_CERTIFICATE=<agora_app_certificate>
|
||||
FIREBASE_CREDENTIALS_PATH=classpath:firebase/google-services-admin.json
|
||||
FIREBASE_NOTIFICATIONS_COLLECTION=notifications
|
||||
|
||||
@ -6,9 +6,9 @@
|
||||
|
||||
spring:
|
||||
datasource:
|
||||
url: ${DB_URL:jdbc:postgresql://202.46.28.160:2002/uas_5803024001}
|
||||
username: ${DB_USERNAME:5803024001}
|
||||
password: ${DB_PASSWORD:pw5803024001}
|
||||
url: ${DB_URL}
|
||||
username: ${DB_USERNAME}
|
||||
password: ${DB_PASSWORD}
|
||||
hikari:
|
||||
maximum-pool-size: ${DB_POOL_MAX:1}
|
||||
minimum-idle: ${DB_POOL_MIN_IDLE:0}
|
||||
@ -17,7 +17,7 @@ spring:
|
||||
max-lifetime: ${DB_MAX_LIFETIME:120000}
|
||||
|
||||
flyway:
|
||||
enabled: ${FLYWAY_ENABLED:false}
|
||||
enabled: ${FLYWAY_ENABLED:true}
|
||||
|
||||
jpa:
|
||||
show-sql: true
|
||||
@ -26,12 +26,12 @@ spring:
|
||||
format_sql: true
|
||||
|
||||
jwt:
|
||||
secret: ${JWT_SECRET:d2Fsa2d1aWRlLWRldi1qd3Qtc2VjcmV0LWtleS0zMi1ieXRlcy1taW5pbXVt}
|
||||
secret: ${JWT_SECRET}
|
||||
expiration: ${JWT_EXPIRATION:86400000}
|
||||
|
||||
agora:
|
||||
app-id: ${AGORA_APP_ID:e36c2b6592e34cfda1f6ea6432a5e68d}
|
||||
app-certificate: ${AGORA_APP_CERTIFICATE:70a4288475734a8c92ff8686c66cbc77}
|
||||
app-id: ${AGORA_APP_ID:}
|
||||
app-certificate: ${AGORA_APP_CERTIFICATE:}
|
||||
|
||||
logging:
|
||||
level:
|
||||
|
||||
@ -1,12 +1,12 @@
|
||||
# ===== SERVER =====
|
||||
spring.config.import=optional:file:./secrets.properties
|
||||
spring.config.import=optional:file:./secrets.properties,optional:file:walkguide-backend/demo/secrets.properties
|
||||
server.port=${SERVER_PORT:8080}
|
||||
server.address=${SERVER_ADDRESS:0.0.0.0}
|
||||
|
||||
# ===== POSTGRESQL CONNECTION =====
|
||||
spring.datasource.url=${DB_URL:jdbc:postgresql://202.46.28.160:2002/uas_5803024001}
|
||||
spring.datasource.username=${DB_USERNAME:5803024001}
|
||||
spring.datasource.password=${DB_PASSWORD:pw5803024001}
|
||||
spring.datasource.url=${DB_URL}
|
||||
spring.datasource.username=${DB_USERNAME}
|
||||
spring.datasource.password=${DB_PASSWORD}
|
||||
spring.datasource.driver-class-name=org.postgresql.Driver
|
||||
# ===== HIKARI POOL (keep DB classroom slots low) =====
|
||||
spring.datasource.hikari.maximum-pool-size=${DB_POOL_MAX:1}
|
||||
@ -27,7 +27,7 @@ spring.flyway.locations=classpath:db/migration
|
||||
spring.flyway.baseline-on-migrate=true
|
||||
|
||||
# ===== JWT =====
|
||||
jwt.secret=${JWT_SECRET:d2Fsa2d1aWRlLWRldi1qd3Qtc2VjcmV0LWtleS0zMi1ieXRlcy1taW5pbXVt}
|
||||
jwt.secret=${JWT_SECRET}
|
||||
jwt.expiration=${JWT_EXPIRATION:86400000}
|
||||
|
||||
# ===== SWAGGER =====
|
||||
@ -35,7 +35,7 @@ springdoc.swagger-ui.path=/swagger-ui.html
|
||||
springdoc.api-docs.path=/v3/api-docs
|
||||
|
||||
# ===== AGORA RTC =====
|
||||
agora.app-id=${AGORA_APP_ID:e36c2b6592e34cfda1f6ea6432a5e68d}
|
||||
agora.app-id=${AGORA_APP_ID:}
|
||||
agora.app-certificate=${AGORA_APP_CERTIFICATE:}
|
||||
|
||||
# ===== FIREBASE =====
|
||||
|
||||
@ -0,0 +1,2 @@
|
||||
ALTER TABLE location_history
|
||||
ADD COLUMN IF NOT EXISTS battery_level INTEGER;
|
||||
@ -2,6 +2,9 @@
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
<uses-permission android:name="android.permission.CAMERA" />
|
||||
<uses-permission android:name="android.permission.RECORD_AUDIO" />
|
||||
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
|
||||
<uses-permission android:name="android.permission.BLUETOOTH" />
|
||||
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />
|
||||
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
|
||||
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
|
||||
<uses-permission android:name="android.permission.VIBRATE" />
|
||||
@ -13,7 +16,8 @@
|
||||
<application
|
||||
android:label="WalkGuide"
|
||||
android:name="${applicationName}"
|
||||
android:icon="@mipmap/ic_launcher">
|
||||
android:icon="@mipmap/ic_launcher"
|
||||
android:usesCleartextTraffic="true">
|
||||
<activity
|
||||
android:name=".MainActivity"
|
||||
android:exported="true"
|
||||
@ -34,6 +38,9 @@
|
||||
<meta-data
|
||||
android:name="flutterEmbedding"
|
||||
android:value="2" />
|
||||
<meta-data
|
||||
android:name="io.flutter.embedding.android.EnableImpeller"
|
||||
android:value="false" />
|
||||
</application>
|
||||
|
||||
<queries>
|
||||
|
||||
@ -0,0 +1,36 @@
|
||||
<svg width="512" height="512" viewBox="0 0 512 512" xmlns="http://www.w3.org/2000/svg">
|
||||
<defs>
|
||||
<linearGradient id="bg-grad" x1="0%" y1="0%" x2="100%" y2="100%">
|
||||
<stop offset="0%" stop-color="#0B132B"/>
|
||||
<stop offset="100%" stop-color="#1C2541"/>
|
||||
</linearGradient>
|
||||
<linearGradient id="cyan-glow" x1="0%" y1="0%" x2="100%" y2="100%">
|
||||
<stop offset="0%" stop-color="#48CAE4"/>
|
||||
<stop offset="100%" stop-color="#0077B6"/>
|
||||
</linearGradient>
|
||||
<linearGradient id="amber-glow" x1="0%" y1="100%" x2="100%" y2="0%">
|
||||
<stop offset="0%" stop-color="#FFB703"/>
|
||||
<stop offset="100%" stop-color="#FB8500"/>
|
||||
</linearGradient>
|
||||
<filter id="shadow" x="-20%" y="-20%" width="140%" height="140%">
|
||||
<feDropShadow dx="0" dy="12" stdDeviation="16" flood-color="#000000" flood-opacity="0.45"/>
|
||||
</filter>
|
||||
</defs>
|
||||
<rect width="512" height="512" rx="115" fill="url(#bg-grad)"/>
|
||||
<circle cx="256" cy="256" r="180" fill="none" stroke="#48CAE4" stroke-width="2" opacity="0.15" stroke-dasharray="10 14"/>
|
||||
<circle cx="256" cy="256" r="110" fill="none" stroke="#48CAE4" stroke-width="3" opacity="0.3"/>
|
||||
<path d="M 130 180 C 130 320, 180 370, 220 370 C 260 370, 256 270, 256 270"
|
||||
fill="none"
|
||||
stroke="url(#cyan-glow)"
|
||||
stroke-width="52"
|
||||
stroke-linecap="round"
|
||||
filter="url(#shadow)"/>
|
||||
<path d="M 382 180 C 382 320, 332 370, 292 370 C 252 370, 256 270, 256 270"
|
||||
fill="none"
|
||||
stroke="url(#amber-glow)"
|
||||
stroke-width="52"
|
||||
stroke-linecap="round"
|
||||
filter="url(#shadow)"/>
|
||||
<circle cx="256" cy="210" r="36" fill="#FFFFFF" filter="url(#shadow)"/>
|
||||
<circle cx="256" cy="210" r="14" fill="#0B132B"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 1.7 KiB |
@ -1,9 +1,11 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:flutter_localizations/flutter_localizations.dart';
|
||||
import 'package:google_fonts/google_fonts.dart';
|
||||
|
||||
import 'app_cubit.dart';
|
||||
import 'router.dart';
|
||||
import '../core/i18n/app_strings.dart';
|
||||
import '../core/theme/app_colors.dart';
|
||||
|
||||
class WalkGuideApp extends StatelessWidget {
|
||||
@ -15,12 +17,36 @@ class WalkGuideApp extends StatelessWidget {
|
||||
|
||||
return BlocProvider(
|
||||
create: (_) => AppCubit(),
|
||||
child: MaterialApp.router(
|
||||
child: BlocBuilder<AppCubit, AppState>(
|
||||
builder: (context, state) => MaterialApp.router(
|
||||
title: 'WalkGuide',
|
||||
debugShowCheckedModeBanner: false,
|
||||
routerConfig: appRouter,
|
||||
builder: (context, child) {
|
||||
final media = MediaQuery.of(context);
|
||||
return MediaQuery(
|
||||
data: media.copyWith(
|
||||
textScaler: media.textScaler.clamp(
|
||||
minScaleFactor: 0.9,
|
||||
maxScaleFactor: 1.15,
|
||||
),
|
||||
),
|
||||
child: child ?? const SizedBox.shrink(),
|
||||
);
|
||||
},
|
||||
locale: state.localeCode == 'en-US'
|
||||
? const Locale('en', 'US')
|
||||
: const Locale('id', 'ID'),
|
||||
supportedLocales: AppStrings.supportedLocales,
|
||||
localizationsDelegates: const [
|
||||
AppStringsDelegate(),
|
||||
GlobalMaterialLocalizations.delegate,
|
||||
GlobalWidgetsLocalizations.delegate,
|
||||
GlobalCupertinoLocalizations.delegate,
|
||||
],
|
||||
theme: ThemeData(
|
||||
useMaterial3: true,
|
||||
visualDensity: VisualDensity.adaptivePlatformDensity,
|
||||
colorScheme: ColorScheme.fromSeed(
|
||||
seedColor: seed,
|
||||
brightness: Brightness.light,
|
||||
@ -139,6 +165,7 @@ class WalkGuideApp extends StatelessWidget {
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -4,14 +4,26 @@ class AppState {
|
||||
final bool online;
|
||||
final String? role;
|
||||
final String? serverUrl;
|
||||
final String localeCode;
|
||||
|
||||
const AppState({required this.online, this.role, this.serverUrl});
|
||||
const AppState({
|
||||
required this.online,
|
||||
this.role,
|
||||
this.serverUrl,
|
||||
this.localeCode = 'id-ID',
|
||||
});
|
||||
|
||||
AppState copyWith({bool? online, String? role, String? serverUrl}) {
|
||||
AppState copyWith({
|
||||
bool? online,
|
||||
String? role,
|
||||
String? serverUrl,
|
||||
String? localeCode,
|
||||
}) {
|
||||
return AppState(
|
||||
online: online ?? this.online,
|
||||
role: role ?? this.role,
|
||||
serverUrl: serverUrl ?? this.serverUrl,
|
||||
localeCode: localeCode ?? this.localeCode,
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -25,5 +37,7 @@ class AppCubit extends Cubit<AppState> {
|
||||
|
||||
void setOnline(bool value) => emit(state.copyWith(online: value));
|
||||
|
||||
void setLocaleCode(String value) => emit(state.copyWith(localeCode: value));
|
||||
|
||||
void clearSession() => emit(const AppState(online: true));
|
||||
}
|
||||
|
||||
@ -1,6 +1,4 @@
|
||||
import 'package:get_it/get_it.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
|
||||
import '../core/constants/app_constants.dart';
|
||||
import '../core/ai/obstacle_alert_strategy.dart';
|
||||
import '../core/ai/obstacle_analyzer.dart';
|
||||
@ -85,12 +83,5 @@ Future<void> initDependencies() async {
|
||||
}
|
||||
|
||||
await ignoreInitFailure(() => sl<TtsService>().init(), label: 'TTS init');
|
||||
await sl<YoloDetector>().init();
|
||||
if (!kIsWeb) {
|
||||
await ignoreInitFailure(() => sl<SttService>().init(), label: 'STT init');
|
||||
}
|
||||
sl<VoiceCommandHandler>().loadDefaultCommands();
|
||||
if (!kIsWeb) {
|
||||
await sl<FcmService>().init();
|
||||
}
|
||||
}
|
||||
|
||||
@ -22,6 +22,9 @@ class AppConstants {
|
||||
if (!cleaned.startsWith('http://') && !cleaned.startsWith('https://')) {
|
||||
cleaned = 'http://$cleaned';
|
||||
}
|
||||
cleaned = cleaned
|
||||
.replaceFirst('://localhost', '://127.0.0.1')
|
||||
.replaceFirst('://0.0.0.0', '://127.0.0.1');
|
||||
while (cleaned.endsWith('/')) {
|
||||
cleaned = cleaned.substring(0, cleaned.length - 1);
|
||||
}
|
||||
@ -61,7 +64,6 @@ class AppConstants {
|
||||
await prefs.setString(_selectedYoloModelKey, path);
|
||||
}
|
||||
|
||||
// Agora App ID tetap bisa dioverride saat build: --dart-define=AGORA_APP_ID=...
|
||||
static const String agoraAppId = String.fromEnvironment('AGORA_APP_ID',
|
||||
defaultValue: 'e36c2b6592e34cfda1f6ea6432a5e68d');
|
||||
// Set at build time with: --dart-define=AGORA_APP_ID=your_app_id
|
||||
static const String agoraAppId = String.fromEnvironment('AGORA_APP_ID');
|
||||
}
|
||||
|
||||
@ -75,6 +75,8 @@ bool _looksTechnical(String message) {
|
||||
'duplicate key',
|
||||
'constraint',
|
||||
'sql [',
|
||||
'illegal base64',
|
||||
'base64 character',
|
||||
];
|
||||
return blocked.any(lower.contains);
|
||||
}
|
||||
|
||||
@ -1,9 +1,19 @@
|
||||
import 'package:flutter/widgets.dart';
|
||||
|
||||
class AppStrings {
|
||||
final String localeCode;
|
||||
|
||||
const AppStrings(this.localeCode);
|
||||
|
||||
static const supportedLocales = ['id-ID', 'en-US'];
|
||||
static const supportedLocales = [
|
||||
Locale('id', 'ID'),
|
||||
Locale('en', 'US'),
|
||||
];
|
||||
|
||||
static AppStrings of(BuildContext context) {
|
||||
return Localizations.of<AppStrings>(context, AppStrings) ??
|
||||
const AppStrings('id-ID');
|
||||
}
|
||||
|
||||
String get walkGuideStarted => _pick(
|
||||
id: 'WalkGuide dimulai',
|
||||
@ -29,3 +39,21 @@ class AppStrings {
|
||||
return localeCode == 'en-US' ? en : id;
|
||||
}
|
||||
}
|
||||
|
||||
class AppStringsDelegate extends LocalizationsDelegate<AppStrings> {
|
||||
const AppStringsDelegate();
|
||||
|
||||
@override
|
||||
bool isSupported(Locale locale) {
|
||||
return locale.languageCode == 'id' || locale.languageCode == 'en';
|
||||
}
|
||||
|
||||
@override
|
||||
Future<AppStrings> load(Locale locale) async {
|
||||
final code = locale.languageCode == 'en' ? 'en-US' : 'id-ID';
|
||||
return AppStrings(code);
|
||||
}
|
||||
|
||||
@override
|
||||
bool shouldReload(covariant LocalizationsDelegate<AppStrings> old) => false;
|
||||
}
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import '../constants/app_constants.dart';
|
||||
import '../storage/secure_storage.dart';
|
||||
|
||||
@ -24,8 +25,15 @@ class ApiClient {
|
||||
_dio.interceptors.addAll([
|
||||
_AuthInterceptor(_secureStorage, _dio),
|
||||
_ErrorInterceptor(),
|
||||
LogInterceptor(requestBody: true, responseBody: true),
|
||||
]);
|
||||
if (kDebugMode) {
|
||||
_dio.interceptors.add(LogInterceptor(
|
||||
requestBody: false,
|
||||
responseBody: false,
|
||||
requestHeader: false,
|
||||
responseHeader: false,
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
Dio get dio => _dio;
|
||||
@ -42,7 +50,8 @@ class _AuthInterceptor extends Interceptor {
|
||||
_AuthInterceptor(this._storage, this._dio);
|
||||
|
||||
@override
|
||||
void onRequest(RequestOptions options, RequestInterceptorHandler handler) async {
|
||||
void onRequest(
|
||||
RequestOptions options, RequestInterceptorHandler handler) async {
|
||||
final token = await _storage.getAccessToken();
|
||||
if (token != null) {
|
||||
options.headers['Authorization'] = 'Bearer $token';
|
||||
|
||||
@ -166,6 +166,11 @@ class CallService {
|
||||
debugPrint('Agora remote user offline: $remoteUid $reason');
|
||||
_onRemoteUserOffline?.call();
|
||||
},
|
||||
onRemoteAudioStateChanged: (_, remoteUid, state, reason, __) {
|
||||
debugPrint(
|
||||
'Agora remote audio state: uid=$remoteUid state=$state reason=$reason',
|
||||
);
|
||||
},
|
||||
onError: (type, msg) {
|
||||
debugPrint('Agora error: $type $msg');
|
||||
if (!joinCompleter.isCompleted) joinCompleter.complete(false);
|
||||
@ -175,9 +180,18 @@ class CallService {
|
||||
await _engine!.setChannelProfile(
|
||||
ChannelProfileType.channelProfileCommunication,
|
||||
);
|
||||
await _engine!.setClientRole(role: ClientRoleType.clientRoleBroadcaster);
|
||||
await _engine!.setAudioProfile(
|
||||
profile: AudioProfileType.audioProfileDefault,
|
||||
scenario: AudioScenarioType.audioScenarioMeeting,
|
||||
);
|
||||
await _engine!.enableAudio();
|
||||
await _engine!.enableLocalAudio(true);
|
||||
await _engine!.muteAllRemoteAudioStreams(false);
|
||||
await _engine!.muteLocalAudioStream(false);
|
||||
await _engine!.adjustRecordingSignalVolume(100);
|
||||
await _engine!.adjustPlaybackSignalVolume(100);
|
||||
await _engine!.setDefaultAudioRouteToSpeakerphone(true);
|
||||
await _engine!.setEnableSpeakerphone(true);
|
||||
await _engine!.joinChannel(
|
||||
token: token ?? '',
|
||||
|
||||
@ -9,7 +9,6 @@ import '../network/api_client.dart';
|
||||
|
||||
class FcmService {
|
||||
final ApiClient _apiClient;
|
||||
final FirebaseMessaging _messaging = FirebaseMessaging.instance;
|
||||
final FlutterLocalNotificationsPlugin _localNotifications =
|
||||
FlutterLocalNotificationsPlugin();
|
||||
|
||||
@ -18,6 +17,7 @@ class FcmService {
|
||||
Future<void> init() async {
|
||||
if (kIsWeb) return;
|
||||
try {
|
||||
final messaging = FirebaseMessaging.instance;
|
||||
await _localNotifications.initialize(
|
||||
const InitializationSettings(
|
||||
android: AndroidInitializationSettings('@mipmap/ic_launcher'),
|
||||
@ -31,10 +31,10 @@ class FcmService {
|
||||
} catch (_) {}
|
||||
},
|
||||
);
|
||||
await _messaging.requestPermission(alert: true, badge: true, sound: true);
|
||||
final token = await _messaging.getToken();
|
||||
await messaging.requestPermission(alert: true, badge: true, sound: true);
|
||||
final token = await messaging.getToken();
|
||||
if (token != null) await syncToken(token);
|
||||
FirebaseMessaging.instance.onTokenRefresh.listen(syncToken);
|
||||
messaging.onTokenRefresh.listen(syncToken);
|
||||
FirebaseMessaging.onMessage.listen((message) {
|
||||
debugPrint('FCM foreground: ${message.data}');
|
||||
_showLocalNotification(message);
|
||||
@ -55,6 +55,10 @@ class FcmService {
|
||||
|
||||
Future<void> syncToken(String token) async {
|
||||
try {
|
||||
if (_apiClient.baseUrl == null) {
|
||||
debugPrint('FCM token sync skipped: server URL is not ready.');
|
||||
return;
|
||||
}
|
||||
await _apiClient.dio.put('/auth/fcm-token', data: {'fcmToken': token});
|
||||
} catch (e) {
|
||||
debugPrint('FCM token sync skipped: $e');
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:battery_plus/battery_plus.dart';
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:geolocator/geolocator.dart';
|
||||
|
||||
@ -10,6 +11,7 @@ import 'offline_queue_service.dart';
|
||||
class LocationReporterService {
|
||||
final ApiClient _apiClient;
|
||||
final OfflineQueueService _offlineQueue;
|
||||
final Battery _battery = Battery();
|
||||
Timer? _timer;
|
||||
|
||||
LocationReporterService(this._apiClient, this._offlineQueue);
|
||||
@ -32,12 +34,14 @@ class LocationReporterService {
|
||||
try {
|
||||
await Geolocator.requestPermission();
|
||||
final position = await Geolocator.getCurrentPosition();
|
||||
final batteryLevel = await _readBatteryLevel();
|
||||
await _apiClient.dio.post('/user/location', data: {
|
||||
'lat': position.latitude,
|
||||
'lng': position.longitude,
|
||||
'accuracy': position.accuracy,
|
||||
'speed': position.speed,
|
||||
'heading': position.heading,
|
||||
if (batteryLevel != null) 'batteryLevel': batteryLevel,
|
||||
});
|
||||
} on DioException catch (_) {
|
||||
await _offlineQueue.enqueue(OfflineRequest(
|
||||
@ -50,4 +54,12 @@ class LocationReporterService {
|
||||
// GPS permission can be unavailable during desktop/web testing.
|
||||
}
|
||||
}
|
||||
|
||||
Future<int?> _readBatteryLevel() async {
|
||||
try {
|
||||
return await _battery.batteryLevel;
|
||||
} catch (_) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -19,6 +19,8 @@ class VoiceCommand {
|
||||
/// Callback yang dipanggil saat command terdeteksi
|
||||
/// Registered oleh router/screen yang relevan
|
||||
typedef CommandCallback = void Function(VoiceCommandKey key);
|
||||
typedef CommandRouter = void Function(String route);
|
||||
typedef CommandAction = void Function();
|
||||
|
||||
class VoiceCommandHandler {
|
||||
final SttService _stt;
|
||||
@ -26,9 +28,19 @@ class VoiceCommandHandler {
|
||||
|
||||
List<VoiceCommand> _commands = [];
|
||||
CommandCallback? onCommand;
|
||||
CommandRouter? _router;
|
||||
final Map<VoiceCommandKey, CommandAction> _actions = {};
|
||||
|
||||
VoiceCommandHandler(this._stt, this._tts);
|
||||
|
||||
void registerRouter(CommandRouter router) {
|
||||
_router = router;
|
||||
}
|
||||
|
||||
void registerAction(VoiceCommandKey key, CommandAction action) {
|
||||
_actions[key] = action;
|
||||
}
|
||||
|
||||
void loadCommands(List<VoiceCommand> commands) {
|
||||
_commands = commands;
|
||||
_stt.onResult = _processText;
|
||||
@ -66,9 +78,28 @@ class VoiceCommandHandler {
|
||||
}
|
||||
|
||||
void _handleCommand(VoiceCommandKey key) {
|
||||
_routeFor(key);
|
||||
_actions[key]?.call();
|
||||
onCommand?.call(key);
|
||||
// Built-in actions for TTS-only commands
|
||||
if (key == VoiceCommandKey.repeatLast) _tts.repeatLast();
|
||||
if (key == VoiceCommandKey.stopTts) _tts.stop();
|
||||
}
|
||||
|
||||
void _routeFor(VoiceCommandKey key) {
|
||||
final route = switch (key) {
|
||||
VoiceCommandKey.openWalkguide || VoiceCommandKey.startWalkguide =>
|
||||
'/user/walkguide',
|
||||
VoiceCommandKey.openNotification => '/user/notifications',
|
||||
VoiceCommandKey.openSos || VoiceCommandKey.sendSos => '/user/sos',
|
||||
VoiceCommandKey.openActivity => '/user/activity',
|
||||
VoiceCommandKey.openNavigation => '/user/navigation',
|
||||
VoiceCommandKey.openSettings => '/user/settings',
|
||||
VoiceCommandKey.callGuardian => '/call',
|
||||
_ => null,
|
||||
};
|
||||
if (route != null) {
|
||||
_router?.call(route);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,3 @@
|
||||
Activity log application layer.
|
||||
|
||||
This layer is reserved for Cubit/BLoC orchestration between the activity log UI and domain contracts.
|
||||
@ -0,0 +1,3 @@
|
||||
Activity log data layer.
|
||||
|
||||
This layer is reserved for remote/local data sources and repository implementations.
|
||||
@ -0,0 +1,3 @@
|
||||
Activity log domain layer.
|
||||
|
||||
This layer is reserved for entities, repository contracts, and use cases.
|
||||
@ -0,0 +1,3 @@
|
||||
AI benchmark application layer.
|
||||
|
||||
This layer is reserved for benchmark Cubit/BLoC orchestration.
|
||||
@ -0,0 +1,3 @@
|
||||
AI benchmark data layer.
|
||||
|
||||
This layer is reserved for benchmark result persistence and export adapters.
|
||||
@ -0,0 +1,3 @@
|
||||
AI benchmark domain layer.
|
||||
|
||||
This layer is reserved for benchmark entities and use cases.
|
||||
@ -0,0 +1,3 @@
|
||||
Auth application layer.
|
||||
|
||||
This layer is reserved for auth Cubit/BLoC orchestration between auth UI and auth domain contracts.
|
||||
@ -151,7 +151,11 @@ class _AuthFrame extends StatelessWidget {
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
backgroundColor: const Color(0xFFEAF4FF),
|
||||
body: Stack(
|
||||
body: LayoutBuilder(
|
||||
builder: (context, constraints) {
|
||||
final compact =
|
||||
constraints.maxWidth < 480 || constraints.maxHeight < 720;
|
||||
return Stack(
|
||||
children: [
|
||||
const Positioned.fill(
|
||||
child: DecoratedBox(
|
||||
@ -165,31 +169,29 @@ class _AuthFrame extends StatelessWidget {
|
||||
),
|
||||
),
|
||||
Positioned(
|
||||
top: -90,
|
||||
right: -60,
|
||||
child: TweenAnimationBuilder<double>(
|
||||
tween: Tween(begin: 0.85, end: 1),
|
||||
duration: const Duration(milliseconds: 900),
|
||||
curve: Curves.easeOutCubic,
|
||||
builder: (_, value, child) => Transform.scale(
|
||||
scale: value,
|
||||
child: child,
|
||||
),
|
||||
top: compact ? -70 : -90,
|
||||
right: compact ? -70 : -60,
|
||||
child: Container(
|
||||
width: 260,
|
||||
height: 260,
|
||||
width: compact ? 180 : 260,
|
||||
height: compact ? 180 : 260,
|
||||
decoration: BoxDecoration(
|
||||
color: const Color(0xFF2563EB).withValues(alpha: 0.14),
|
||||
color: const Color(0xFF2563EB).withValues(alpha: 0.12),
|
||||
shape: BoxShape.circle,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
Center(
|
||||
child: SingleChildScrollView(
|
||||
padding: const EdgeInsets.all(24),
|
||||
keyboardDismissBehavior:
|
||||
ScrollViewKeyboardDismissBehavior.onDrag,
|
||||
padding: EdgeInsets.fromLTRB(
|
||||
compact ? 14 : 24,
|
||||
compact ? 12 : 24,
|
||||
compact ? 14 : 24,
|
||||
20 + MediaQuery.of(context).viewInsets.bottom,
|
||||
),
|
||||
child: ConstrainedBox(
|
||||
constraints: const BoxConstraints(maxWidth: 430),
|
||||
constraints: BoxConstraints(maxWidth: compact ? 380 : 430),
|
||||
child: TweenAnimationBuilder<double>(
|
||||
tween: Tween(begin: 18, end: 0),
|
||||
duration: const Duration(milliseconds: 520),
|
||||
@ -205,28 +207,34 @@ class _AuthFrame extends StatelessWidget {
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white.withValues(alpha: 0.96),
|
||||
borderRadius: BorderRadius.circular(30),
|
||||
borderRadius:
|
||||
BorderRadius.circular(compact ? 22 : 30),
|
||||
border: Border.all(
|
||||
color: Colors.white.withValues(alpha: 0.8)),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color:
|
||||
const Color(0xFF1E3A8A).withValues(alpha: 0.14),
|
||||
blurRadius: 40,
|
||||
offset: const Offset(0, 20),
|
||||
color: const Color(0xFF1E3A8A)
|
||||
.withValues(alpha: 0.14),
|
||||
blurRadius: compact ? 24 : 40,
|
||||
offset: const Offset(0, 18),
|
||||
),
|
||||
],
|
||||
),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.fromLTRB(24, 26, 24, 24),
|
||||
padding: EdgeInsets.fromLTRB(
|
||||
compact ? 18 : 24,
|
||||
compact ? 18 : 26,
|
||||
compact ? 18 : 24,
|
||||
compact ? 18 : 24,
|
||||
),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
Container(
|
||||
width: 56,
|
||||
height: 56,
|
||||
width: compact ? 44 : 56,
|
||||
height: compact ? 44 : 56,
|
||||
decoration: BoxDecoration(
|
||||
gradient: const LinearGradient(
|
||||
colors: [
|
||||
@ -234,15 +242,18 @@ class _AuthFrame extends StatelessWidget {
|
||||
Color(0xFF0891B2)
|
||||
],
|
||||
),
|
||||
borderRadius: BorderRadius.circular(18),
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
),
|
||||
child: const Icon(Icons.navigation_rounded,
|
||||
color: Colors.white, size: 30),
|
||||
child: Icon(Icons.navigation_rounded,
|
||||
color: Colors.white,
|
||||
size: compact ? 26 : 30),
|
||||
),
|
||||
const SizedBox(width: 12),
|
||||
const Expanded(
|
||||
child: Text(
|
||||
'WalkGuide',
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: TextStyle(
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.w900,
|
||||
@ -252,7 +263,8 @@ class _AuthFrame extends StatelessWidget {
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
SizedBox(height: compact ? 14 : 16),
|
||||
if (!compact)
|
||||
Container(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 10, vertical: 6),
|
||||
@ -277,13 +289,16 @@ class _AuthFrame extends StatelessWidget {
|
||||
],
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 18),
|
||||
if (!compact) const SizedBox(height: 18),
|
||||
Text(
|
||||
title,
|
||||
maxLines: 2,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: Theme.of(context)
|
||||
.textTheme
|
||||
.headlineMedium
|
||||
?.copyWith(
|
||||
fontSize: compact ? 26 : null,
|
||||
fontWeight: FontWeight.w900,
|
||||
color: const Color(0xFF0F172A),
|
||||
),
|
||||
@ -291,12 +306,14 @@ class _AuthFrame extends StatelessWidget {
|
||||
const SizedBox(height: 6),
|
||||
Text(
|
||||
subtitle,
|
||||
maxLines: 2,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: const TextStyle(
|
||||
color: Color(0xFF64748B),
|
||||
height: 1.35,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 26),
|
||||
SizedBox(height: compact ? 18 : 26),
|
||||
child,
|
||||
],
|
||||
),
|
||||
@ -308,6 +325,8 @@ class _AuthFrame extends StatelessWidget {
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@ -299,7 +299,11 @@ class _AuthFrame extends StatelessWidget {
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
backgroundColor: const Color(0xFFEAF4FF),
|
||||
body: Stack(
|
||||
body: LayoutBuilder(
|
||||
builder: (context, constraints) {
|
||||
final compact =
|
||||
constraints.maxWidth < 480 || constraints.maxHeight < 720;
|
||||
return Stack(
|
||||
children: [
|
||||
const Positioned.fill(
|
||||
child: DecoratedBox(
|
||||
@ -313,31 +317,29 @@ class _AuthFrame extends StatelessWidget {
|
||||
),
|
||||
),
|
||||
Positioned(
|
||||
top: -90,
|
||||
right: -60,
|
||||
child: TweenAnimationBuilder<double>(
|
||||
tween: Tween(begin: 0.85, end: 1),
|
||||
duration: const Duration(milliseconds: 900),
|
||||
curve: Curves.easeOutCubic,
|
||||
builder: (_, value, child) => Transform.scale(
|
||||
scale: value,
|
||||
child: child,
|
||||
),
|
||||
top: compact ? -70 : -90,
|
||||
right: compact ? -70 : -60,
|
||||
child: Container(
|
||||
width: 260,
|
||||
height: 260,
|
||||
width: compact ? 180 : 260,
|
||||
height: compact ? 180 : 260,
|
||||
decoration: BoxDecoration(
|
||||
color: const Color(0xFF2563EB).withValues(alpha: 0.14),
|
||||
color: const Color(0xFF2563EB).withValues(alpha: 0.12),
|
||||
shape: BoxShape.circle,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
Center(
|
||||
child: SingleChildScrollView(
|
||||
padding: const EdgeInsets.all(24),
|
||||
keyboardDismissBehavior:
|
||||
ScrollViewKeyboardDismissBehavior.onDrag,
|
||||
padding: EdgeInsets.fromLTRB(
|
||||
compact ? 14 : 24,
|
||||
compact ? 12 : 24,
|
||||
compact ? 14 : 24,
|
||||
20 + MediaQuery.of(context).viewInsets.bottom,
|
||||
),
|
||||
child: ConstrainedBox(
|
||||
constraints: const BoxConstraints(maxWidth: 430),
|
||||
constraints: BoxConstraints(maxWidth: compact ? 380 : 430),
|
||||
child: TweenAnimationBuilder<double>(
|
||||
tween: Tween(begin: 18, end: 0),
|
||||
duration: const Duration(milliseconds: 520),
|
||||
@ -353,39 +355,48 @@ class _AuthFrame extends StatelessWidget {
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white.withValues(alpha: 0.96),
|
||||
borderRadius: BorderRadius.circular(30),
|
||||
borderRadius:
|
||||
BorderRadius.circular(compact ? 22 : 30),
|
||||
border: Border.all(
|
||||
color: Colors.white.withValues(alpha: 0.8)),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color:
|
||||
const Color(0xFF1E3A8A).withValues(alpha: 0.14),
|
||||
blurRadius: 40,
|
||||
offset: const Offset(0, 20),
|
||||
color: const Color(0xFF1E3A8A)
|
||||
.withValues(alpha: 0.14),
|
||||
blurRadius: compact ? 24 : 40,
|
||||
offset: const Offset(0, 18),
|
||||
),
|
||||
],
|
||||
),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.fromLTRB(24, 26, 24, 24),
|
||||
padding: EdgeInsets.fromLTRB(
|
||||
compact ? 18 : 24,
|
||||
compact ? 18 : 26,
|
||||
compact ? 18 : 24,
|
||||
compact ? 18 : 24,
|
||||
),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
Container(
|
||||
width: 56,
|
||||
height: 56,
|
||||
width: compact ? 44 : 56,
|
||||
height: compact ? 44 : 56,
|
||||
decoration: BoxDecoration(
|
||||
color: const Color(0xFF1D4ED8),
|
||||
borderRadius: BorderRadius.circular(18),
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
),
|
||||
child: const Icon(Icons.navigation_rounded,
|
||||
color: Colors.white, size: 30),
|
||||
child: Icon(Icons.navigation_rounded,
|
||||
color: Colors.white,
|
||||
size: compact ? 26 : 30),
|
||||
),
|
||||
const SizedBox(width: 12),
|
||||
const Expanded(
|
||||
child: Text(
|
||||
'WalkGuide',
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: TextStyle(
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.w900,
|
||||
@ -395,13 +406,16 @@ class _AuthFrame extends StatelessWidget {
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 22),
|
||||
SizedBox(height: compact ? 14 : 22),
|
||||
Text(
|
||||
title,
|
||||
maxLines: 2,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: Theme.of(context)
|
||||
.textTheme
|
||||
.headlineMedium
|
||||
?.copyWith(
|
||||
fontSize: compact ? 26 : null,
|
||||
fontWeight: FontWeight.w900,
|
||||
color: const Color(0xFF0F172A),
|
||||
),
|
||||
@ -409,12 +423,14 @@ class _AuthFrame extends StatelessWidget {
|
||||
const SizedBox(height: 6),
|
||||
Text(
|
||||
subtitle,
|
||||
maxLines: 2,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: const TextStyle(
|
||||
color: Color(0xFF64748B),
|
||||
height: 1.35,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 26),
|
||||
SizedBox(height: compact ? 18 : 26),
|
||||
child,
|
||||
],
|
||||
),
|
||||
@ -426,6 +442,8 @@ class _AuthFrame extends StatelessWidget {
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@ -0,0 +1,3 @@
|
||||
Call application layer.
|
||||
|
||||
This layer owns call state orchestration. The current route keeps a compatibility screen while call side effects are delegated to core services.
|
||||
@ -5,6 +5,7 @@ import 'package:flutter/material.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
|
||||
import '../../app/injection_container.dart';
|
||||
import '../../core/errors/friendly_error.dart';
|
||||
import '../../core/services/call_service.dart';
|
||||
import '../../core/services/haptic_service.dart';
|
||||
import '../../core/services/tts_service.dart';
|
||||
@ -63,11 +64,16 @@ class _CallScreenState extends State<CallScreen>
|
||||
unawaited(_finishRemoteEnded());
|
||||
});
|
||||
|
||||
try {
|
||||
final invite = await callService.startPairedCall();
|
||||
final invite = await runFriendly<Map<String, dynamic>>(
|
||||
() => callService.startPairedCall(),
|
||||
onError: _failCall,
|
||||
fallback: 'Panggilan gagal. Server tidak merespons.',
|
||||
);
|
||||
if (!mounted) return;
|
||||
if (invite == null) {
|
||||
if (_phase != _CallPhase.failed) {
|
||||
_failCall('Panggilan gagal. Pastikan sudah pairing dan server aktif.');
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
@ -83,21 +89,21 @@ class _CallScreenState extends State<CallScreen>
|
||||
if (!mounted || _phase == _CallPhase.connected) return;
|
||||
_failCall('Panggilan tidak dijawab.');
|
||||
});
|
||||
} catch (_) {
|
||||
if (!mounted) return;
|
||||
_failCall('Panggilan gagal. Server tidak merespons.');
|
||||
}
|
||||
}
|
||||
|
||||
void _startAcceptedPolling() {
|
||||
_acceptedPoll?.cancel();
|
||||
_acceptedPoll = Timer.periodic(const Duration(seconds: 2), (_) async {
|
||||
if (!mounted || _activeChannel == null) return;
|
||||
try {
|
||||
final state = await sl<CallService>()
|
||||
final state = await runFriendly<Map<String, dynamic>>(
|
||||
() => sl<CallService>()
|
||||
.getCallState(_activeChannel)
|
||||
.timeout(const Duration(seconds: 3));
|
||||
final status = state?['status']?.toString();
|
||||
.timeout(const Duration(seconds: 3)),
|
||||
onError: (_) {},
|
||||
fallback: 'Polling panggilan gagal.',
|
||||
);
|
||||
if (state == null) return;
|
||||
final status = state['status']?.toString();
|
||||
if (status == 'ENDED') {
|
||||
await _finishRemoteEnded();
|
||||
return;
|
||||
@ -107,9 +113,13 @@ class _CallScreenState extends State<CallScreen>
|
||||
return;
|
||||
}
|
||||
|
||||
final accepted = await sl<CallService>()
|
||||
final accepted = await runFriendly<Map<String, dynamic>>(
|
||||
() => sl<CallService>()
|
||||
.getAcceptedCall()
|
||||
.timeout(const Duration(seconds: 3));
|
||||
.timeout(const Duration(seconds: 3)),
|
||||
onError: (_) {},
|
||||
fallback: 'Polling panggilan diterima gagal.',
|
||||
);
|
||||
if (accepted?['type']?.toString() != 'CALL_ACCEPTED') return;
|
||||
final channel = accepted?['channelName']?.toString();
|
||||
if (_activeChannel != null &&
|
||||
@ -119,9 +129,6 @@ class _CallScreenState extends State<CallScreen>
|
||||
return;
|
||||
}
|
||||
_markRemoteConnected();
|
||||
} catch (_) {
|
||||
// Keep ringing; a short network hiccup should not cancel the call UI.
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@ -319,7 +326,12 @@ class _IncomingCallScreenState extends State<IncomingCallScreen> {
|
||||
setState(() => _responding = true);
|
||||
sl<TtsService>().speak('Menerima panggilan.');
|
||||
|
||||
final joined = await _joinIncomingChannel();
|
||||
final joined = await runFriendly<bool>(
|
||||
() => _joinIncomingChannel(),
|
||||
onError: (_) {},
|
||||
fallback: 'Panggilan gagal tersambung.',
|
||||
) ??
|
||||
false;
|
||||
if (!mounted) return;
|
||||
if (!joined || _joinedChannel == null || widget.callerId == null) {
|
||||
setState(() {
|
||||
@ -350,14 +362,16 @@ class _IncomingCallScreenState extends State<IncomingCallScreen> {
|
||||
_statePoll?.cancel();
|
||||
_statePoll = Timer.periodic(const Duration(seconds: 2), (_) async {
|
||||
if (!mounted || _joinedChannel == null) return;
|
||||
try {
|
||||
final state = await sl<CallService>()
|
||||
final state = await runFriendly<Map<String, dynamic>>(
|
||||
() => sl<CallService>()
|
||||
.getCallState(_joinedChannel)
|
||||
.timeout(const Duration(seconds: 3));
|
||||
.timeout(const Duration(seconds: 3)),
|
||||
onError: (_) {},
|
||||
fallback: 'Polling panggilan masuk gagal.',
|
||||
);
|
||||
if (state?['status']?.toString() == 'ENDED') {
|
||||
await _finishIncomingRemoteEnded();
|
||||
}
|
||||
} catch (_) {}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@ -0,0 +1,3 @@
|
||||
Call data layer.
|
||||
|
||||
This layer is reserved for call remote data sources and repository implementations over `/shared/call/**`.
|
||||
@ -0,0 +1,3 @@
|
||||
Call domain layer.
|
||||
|
||||
This layer is reserved for call session entities, repository contracts, and call use cases.
|
||||
@ -0,0 +1,3 @@
|
||||
Guardian dashboard application layer.
|
||||
|
||||
This layer is reserved for dashboard, map, SOS, notification, AI config, shortcut, and geofence Cubits.
|
||||
@ -0,0 +1,3 @@
|
||||
Guardian dashboard data layer.
|
||||
|
||||
This layer is reserved for `/guardian/**` data sources and repository implementations.
|
||||
@ -0,0 +1,3 @@
|
||||
Guardian dashboard domain layer.
|
||||
|
||||
This layer is reserved for Guardian dashboard entities, repository contracts, and use cases.
|
||||
@ -0,0 +1,3 @@
|
||||
Home application layer.
|
||||
|
||||
This layer is reserved for role-specific home state orchestration.
|
||||
@ -0,0 +1,3 @@
|
||||
Home data layer.
|
||||
|
||||
This layer is reserved for home/dashboard data adapters.
|
||||
@ -0,0 +1,3 @@
|
||||
Home domain layer.
|
||||
|
||||
This layer is reserved for home/dashboard domain entities and use cases.
|
||||
@ -41,6 +41,7 @@ class _GuardianDashboardScreenState extends State<GuardianDashboardScreen>
|
||||
// ââ€Âۉâ€Â€ Live location (WebSocket) ââ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Â€
|
||||
LatLng? _liveLatLng;
|
||||
bool _liveConnected = false;
|
||||
DateTime? _lastRealtimeStatusReload;
|
||||
final MapController _mapController = MapController();
|
||||
|
||||
// ââ€Âۉâ€Â€ Pulse animation for live dot ââ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Â€
|
||||
@ -133,12 +134,13 @@ class _GuardianDashboardScreenState extends State<GuardianDashboardScreen>
|
||||
'User',
|
||||
userOnline: userStatus?['online'] as bool? ?? false,
|
||||
userLastSeen: userStatus?['lastSeenAt']?.toString(),
|
||||
battery: userStatus?['battery'] as int?,
|
||||
speed: userStatus?['lastSpeed'] as double?,
|
||||
obstaclesTotal: userStatus?['obstaclesToday'] as int? ??
|
||||
dashboard?['obstaclesToday'] as int? ??
|
||||
battery: (userStatus?['battery'] as num?)?.toInt(),
|
||||
speed: (userStatus?['lastSpeed'] as num?)?.toDouble(),
|
||||
obstaclesTotal: (userStatus?['obstaclesToday'] as num?)?.toInt() ??
|
||||
(dashboard?['obstaclesToday'] as num?)?.toInt() ??
|
||||
0,
|
||||
unreadNotif: dashboard?['unreadNotifCount'] as int? ?? 0,
|
||||
unreadNotif:
|
||||
(dashboard?['unreadNotifCount'] as num?)?.toInt() ?? 0,
|
||||
unreadSos: sosPending,
|
||||
lastLat: lastLoc?['lat'] != null
|
||||
? (lastLoc!['lat'] as num).toDouble()
|
||||
@ -247,6 +249,12 @@ class _GuardianDashboardScreenState extends State<GuardianDashboardScreen>
|
||||
_liveConnected = true;
|
||||
});
|
||||
_moveMapSafely(newPos);
|
||||
final now = DateTime.now();
|
||||
if (_lastRealtimeStatusReload == null ||
|
||||
now.difference(_lastRealtimeStatusReload!).inSeconds >= 15) {
|
||||
_lastRealtimeStatusReload = now;
|
||||
unawaited(_loadAll(silent: true));
|
||||
}
|
||||
});
|
||||
ws.subscribeSos((sosData) {
|
||||
if (!mounted) return;
|
||||
|
||||
@ -3,7 +3,6 @@ import 'package:google_fonts/google_fonts.dart';
|
||||
import 'package:camera/camera.dart';
|
||||
import '../../../core/secure_storage.dart';
|
||||
import '../../auth/presentation/login_screen.dart';
|
||||
import '../../../../main.dart';
|
||||
|
||||
class UserDashboardScreen extends StatefulWidget {
|
||||
const UserDashboardScreen({super.key});
|
||||
@ -12,7 +11,8 @@ class UserDashboardScreen extends StatefulWidget {
|
||||
State<UserDashboardScreen> createState() => _UserDashboardScreenState();
|
||||
}
|
||||
|
||||
class _UserDashboardScreenState extends State<UserDashboardScreen> with TickerProviderStateMixin {
|
||||
class _UserDashboardScreenState extends State<UserDashboardScreen>
|
||||
with TickerProviderStateMixin {
|
||||
CameraController? _camCtrl;
|
||||
late AnimationController _radarCtrl;
|
||||
late Animation<double> _radarAnim;
|
||||
@ -31,8 +31,10 @@ class _UserDashboardScreenState extends State<UserDashboardScreen> with TickerPr
|
||||
}
|
||||
|
||||
Future<void> _initCamera() async {
|
||||
final cameras = await availableCameras();
|
||||
if (cameras.isEmpty) return;
|
||||
_camCtrl = CameraController(cameras[0], ResolutionPreset.high, enableAudio: false);
|
||||
_camCtrl = CameraController(cameras[0], ResolutionPreset.medium,
|
||||
enableAudio: false);
|
||||
await _camCtrl!.initialize();
|
||||
if (mounted) setState(() {});
|
||||
}
|
||||
@ -85,7 +87,8 @@ class _UserDashboardScreenState extends State<UserDashboardScreen> with TickerPr
|
||||
gradient: RadialGradient(
|
||||
colors: [
|
||||
Colors.transparent,
|
||||
const Color(0xFF10B981).withValues(alpha: 0.05 + _radarCtrl.value * 0.08),
|
||||
const Color(0xFF10B981)
|
||||
.withValues(alpha: 0.05 + _radarCtrl.value * 0.08),
|
||||
],
|
||||
stops: const [0.5, 1.0],
|
||||
radius: 1.4,
|
||||
@ -127,7 +130,8 @@ class _UserDashboardScreenState extends State<UserDashboardScreen> with TickerPr
|
||||
),
|
||||
child: Row(children: [
|
||||
Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 14, vertical: 8),
|
||||
padding:
|
||||
const EdgeInsets.symmetric(horizontal: 14, vertical: 8),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.black.withValues(alpha: 0.54),
|
||||
borderRadius: BorderRadius.circular(20),
|
||||
@ -158,7 +162,8 @@ class _UserDashboardScreenState extends State<UserDashboardScreen> with TickerPr
|
||||
const Spacer(),
|
||||
IconButton(
|
||||
onPressed: _logout,
|
||||
icon: const Icon(Icons.power_settings_new, color: Colors.white, size: 26),
|
||||
icon: const Icon(Icons.power_settings_new,
|
||||
color: Colors.white, size: 26),
|
||||
style: IconButton.styleFrom(
|
||||
backgroundColor: Colors.redAccent.withValues(alpha: 0.8),
|
||||
),
|
||||
@ -204,15 +209,19 @@ class _UserDashboardScreenState extends State<UserDashboardScreen> with TickerPr
|
||||
color: const Color(0x33F59E0B),
|
||||
borderRadius: BorderRadius.circular(7),
|
||||
),
|
||||
child: const Icon(Icons.warning_amber_rounded, color: Color(0xFFF59E0B), size: 16),
|
||||
child: const Icon(Icons.warning_amber_rounded,
|
||||
color: Color(0xFFF59E0B), size: 16),
|
||||
),
|
||||
const SizedBox(width: 10),
|
||||
Column(crossAxisAlignment: CrossAxisAlignment.start, children: [
|
||||
Text('Obstacle ahead',
|
||||
style: GoogleFonts.inter(
|
||||
color: Colors.white, fontSize: 13, fontWeight: FontWeight.w500)),
|
||||
color: Colors.white,
|
||||
fontSize: 13,
|
||||
fontWeight: FontWeight.w500)),
|
||||
Text('2.1m — Haptic alert sent',
|
||||
style: GoogleFonts.inter(color: Colors.white60, fontSize: 11)),
|
||||
style:
|
||||
GoogleFonts.inter(color: Colors.white60, fontSize: 11)),
|
||||
]),
|
||||
]),
|
||||
),
|
||||
@ -234,9 +243,12 @@ class _UserDashboardScreenState extends State<UserDashboardScreen> with TickerPr
|
||||
),
|
||||
child: Column(children: [
|
||||
Row(children: [
|
||||
Expanded(child: _bigBtn(const Color(0xCC1A56DB), Icons.mic, () {})),
|
||||
Expanded(
|
||||
child: _bigBtn(const Color(0xCC1A56DB), Icons.mic, () {})),
|
||||
const SizedBox(width: 12),
|
||||
Expanded(child: _bigBtn(const Color(0xCCDC2626), Icons.phone_in_talk, () {})),
|
||||
Expanded(
|
||||
child: _bigBtn(
|
||||
const Color(0xCCDC2626), Icons.phone_in_talk, () {})),
|
||||
]),
|
||||
const SizedBox(height: 8),
|
||||
Text(
|
||||
@ -290,7 +302,8 @@ class _RadarPainter extends CustomPainter {
|
||||
..style = PaintingStyle.stroke
|
||||
..strokeWidth = 1.2;
|
||||
for (final r in [48.0, 34.0, 20.0]) {
|
||||
paint.color = const Color(0xFF60EFAB).withValues(alpha: 0.15 + (50 - r) / 100);
|
||||
paint.color =
|
||||
const Color(0xFF60EFAB).withValues(alpha: 0.15 + (50 - r) / 100);
|
||||
canvas.drawCircle(center, r, paint);
|
||||
}
|
||||
paint
|
||||
|
||||
@ -0,0 +1,3 @@
|
||||
Manual application layer.
|
||||
|
||||
This layer is reserved for manual/TTS instruction state orchestration.
|
||||
@ -0,0 +1,3 @@
|
||||
Manual data layer.
|
||||
|
||||
This layer is reserved for local command and shortcut documentation data sources.
|
||||
@ -0,0 +1,3 @@
|
||||
Manual domain layer.
|
||||
|
||||
This layer is reserved for manual section entities and instruction use cases.
|
||||
@ -0,0 +1,3 @@
|
||||
Manual presentation layer.
|
||||
|
||||
This layer is reserved for manual pages and widgets.
|
||||
@ -0,0 +1,3 @@
|
||||
Navigation mode application layer.
|
||||
|
||||
This layer is reserved for navigation Cubit/BLoC orchestration.
|
||||
@ -0,0 +1,3 @@
|
||||
Navigation mode data layer.
|
||||
|
||||
This layer is reserved for location, OSM, and OSRM data adapters.
|
||||
@ -0,0 +1,3 @@
|
||||
Navigation mode domain layer.
|
||||
|
||||
This layer is reserved for route, waypoint, and navigation use cases.
|
||||
@ -61,12 +61,16 @@ class _NavState extends Cubit<int> {
|
||||
StreamSubscription<Position>? _posStream;
|
||||
|
||||
void _set(_NavPhase p, String status) {
|
||||
if (isClosed) return;
|
||||
phase = p;
|
||||
statusText = status;
|
||||
_notify();
|
||||
}
|
||||
|
||||
void _notify() => emit(state + 1);
|
||||
void _notify() {
|
||||
if (isClosed) return;
|
||||
emit(state + 1);
|
||||
}
|
||||
|
||||
// ── locate ──────────────────────────────────────────────────────────────
|
||||
Future<bool> locate() async {
|
||||
@ -89,7 +93,8 @@ class _NavState extends Cubit<int> {
|
||||
_reportToBackend(pos);
|
||||
return true;
|
||||
},
|
||||
onTimeout: () => _set(_NavPhase.error, 'GPS timeout. Pastikan GPS aktif.'),
|
||||
onTimeout: () =>
|
||||
_set(_NavPhase.error, 'GPS timeout. Pastikan GPS aktif.'),
|
||||
onError: (_) => _set(_NavPhase.error,
|
||||
'Lokasi belum bisa dibaca. Pastikan GPS dan izin lokasi aktif.'),
|
||||
);
|
||||
@ -121,11 +126,14 @@ class _NavState extends Cubit<int> {
|
||||
'format': 'jsonv2',
|
||||
'limit': 6,
|
||||
'addressdetails': 0,
|
||||
if (currentPosition != null) 'viewbox': _viewbox(currentPosition!),
|
||||
if (currentPosition != null)
|
||||
'viewbox': _viewbox(currentPosition!),
|
||||
if (currentPosition != null) 'bounded': 0,
|
||||
},
|
||||
options: Options(
|
||||
headers: {'User-Agent': 'WalkGuide/1.0 (walkguide@campus.ac.id)'},
|
||||
headers: {
|
||||
'User-Agent': 'WalkGuide/1.0 (walkguide@campus.ac.id)'
|
||||
},
|
||||
receiveTimeout: const Duration(seconds: 8),
|
||||
),
|
||||
);
|
||||
@ -139,7 +147,8 @@ class _NavState extends Cubit<int> {
|
||||
);
|
||||
}).toList();
|
||||
},
|
||||
) ?? const [];
|
||||
) ??
|
||||
const [];
|
||||
}
|
||||
|
||||
String _viewbox(LatLng c) =>
|
||||
@ -157,7 +166,9 @@ class _NavState extends Cubit<int> {
|
||||
'format': 'jsonv2',
|
||||
},
|
||||
options: Options(
|
||||
headers: {'User-Agent': 'WalkGuide/1.0 (walkguide@campus.ac.id)'},
|
||||
headers: {
|
||||
'User-Agent': 'WalkGuide/1.0 (walkguide@campus.ac.id)'
|
||||
},
|
||||
receiveTimeout: const Duration(seconds: 6),
|
||||
),
|
||||
);
|
||||
@ -209,8 +220,8 @@ class _NavState extends Cubit<int> {
|
||||
rawSteps.add(_Step(
|
||||
instruction: instruction,
|
||||
distanceM: dist,
|
||||
point:
|
||||
LatLng((loc[1] as num).toDouble(), (loc[0] as num).toDouble()),
|
||||
point: LatLng(
|
||||
(loc[1] as num).toDouble(), (loc[0] as num).toDouble()),
|
||||
));
|
||||
}
|
||||
}
|
||||
@ -289,6 +300,7 @@ class _NavState extends Cubit<int> {
|
||||
distanceFilter: 5,
|
||||
),
|
||||
).listen((pos) {
|
||||
if (isClosed) return;
|
||||
currentPosition = LatLng(pos.latitude, pos.longitude);
|
||||
_reportToBackend(pos);
|
||||
_updateStep();
|
||||
@ -298,6 +310,7 @@ class _NavState extends Cubit<int> {
|
||||
|
||||
void _updateStep() {
|
||||
if (steps.isEmpty || phase != _NavPhase.navigating) return;
|
||||
if (currentPosition == null) return;
|
||||
if (currentStepIndex >= steps.length - 1) return;
|
||||
|
||||
final current = steps[currentStepIndex];
|
||||
@ -317,6 +330,7 @@ class _NavState extends Cubit<int> {
|
||||
}
|
||||
|
||||
void stopNavigation() {
|
||||
if (isClosed) return;
|
||||
_posStream?.cancel();
|
||||
_posStream = null;
|
||||
destination = null;
|
||||
|
||||
@ -0,0 +1,3 @@
|
||||
Pairing application layer.
|
||||
|
||||
This layer is reserved for pairing Cubit/BLoC orchestration.
|
||||
@ -0,0 +1,3 @@
|
||||
Pairing data layer.
|
||||
|
||||
This layer is reserved for `/shared/pairing/**` data sources and repository implementations.
|
||||
@ -0,0 +1,3 @@
|
||||
Pairing domain layer.
|
||||
|
||||
This layer is reserved for pairing entities, repository contracts, and use cases.
|
||||
@ -0,0 +1,3 @@
|
||||
Server connect application layer.
|
||||
|
||||
This layer is reserved for connection testing and save-server-url state orchestration.
|
||||
@ -0,0 +1,3 @@
|
||||
Server connect data layer.
|
||||
|
||||
This layer is reserved for ping data sources and local server URL persistence adapters.
|
||||
@ -0,0 +1,3 @@
|
||||
Server connect domain layer.
|
||||
|
||||
This layer is reserved for server info entities and connection use cases.
|
||||
@ -0,0 +1,3 @@
|
||||
Server connect presentation layer.
|
||||
|
||||
This layer is reserved for first-run connection pages and widgets.
|
||||
@ -37,6 +37,7 @@ class _ServerConnectScreenState extends State<ServerConnectScreen> {
|
||||
await runFriendlyAction(
|
||||
() async {
|
||||
final clean = AppConstants.normalizeServerUrl(_url.text);
|
||||
await sl<ApiClient>().init(clean);
|
||||
final res = await Dio(BaseOptions(
|
||||
connectTimeout: AppConstants.pingTimeout,
|
||||
receiveTimeout: AppConstants.pingTimeout,
|
||||
@ -47,7 +48,8 @@ class _ServerConnectScreenState extends State<ServerConnectScreen> {
|
||||
: 'Server merespons, tetapi format ping tidak valid.';
|
||||
},
|
||||
onError: (message) => _message = message,
|
||||
fallback: 'Tidak bisa terhubung. Periksa URL dan jaringan.',
|
||||
fallback:
|
||||
'Tidak bisa terhubung. Untuk HP via USB, jalankan adb reverse tcp:8080 tcp:8080 lalu pakai http://127.0.0.1:8080.',
|
||||
);
|
||||
if (mounted) setState(() => _loading = false);
|
||||
}
|
||||
@ -60,6 +62,8 @@ class _ServerConnectScreenState extends State<ServerConnectScreen> {
|
||||
}
|
||||
|
||||
void _useUsbUrl() => setState(() => _url.text = 'http://127.0.0.1:8080');
|
||||
void _useAndroidEmulatorUrl() =>
|
||||
setState(() => _url.text = 'http://10.0.2.2:8080');
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@ -96,12 +100,23 @@ class _ServerConnectScreenState extends State<ServerConnectScreen> {
|
||||
SafeArea(
|
||||
child: LayoutBuilder(
|
||||
builder: (context, constraints) {
|
||||
final compact = constraints.maxWidth < 390;
|
||||
final compact =
|
||||
constraints.maxWidth < 480 || constraints.maxHeight < 720;
|
||||
final horizontalPadding =
|
||||
constraints.maxWidth < 480 ? 12.0 : 20.0;
|
||||
return SingleChildScrollView(
|
||||
padding: EdgeInsets.fromLTRB(20, compact ? 20 : 36, 20, 24),
|
||||
keyboardDismissBehavior:
|
||||
ScrollViewKeyboardDismissBehavior.onDrag,
|
||||
padding: EdgeInsets.fromLTRB(
|
||||
horizontalPadding,
|
||||
compact ? 10 : 32,
|
||||
horizontalPadding,
|
||||
20 + MediaQuery.of(context).viewInsets.bottom,
|
||||
),
|
||||
child: Center(
|
||||
child: ConstrainedBox(
|
||||
constraints: const BoxConstraints(maxWidth: 460),
|
||||
constraints:
|
||||
BoxConstraints(maxWidth: compact ? 380 : 520),
|
||||
child: TweenAnimationBuilder<double>(
|
||||
tween: Tween(begin: 18, end: 0),
|
||||
duration: const Duration(milliseconds: 520),
|
||||
@ -114,7 +129,8 @@ class _ServerConnectScreenState extends State<ServerConnectScreen> {
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white.withValues(alpha: 0.96),
|
||||
borderRadius: BorderRadius.circular(28),
|
||||
borderRadius:
|
||||
BorderRadius.circular(compact ? 22 : 28),
|
||||
border: Border.all(
|
||||
color: Colors.white.withValues(alpha: 0.7)),
|
||||
boxShadow: [
|
||||
@ -126,13 +142,18 @@ class _ServerConnectScreenState extends State<ServerConnectScreen> {
|
||||
],
|
||||
),
|
||||
child: ClipRRect(
|
||||
borderRadius: BorderRadius.circular(28),
|
||||
borderRadius:
|
||||
BorderRadius.circular(compact ? 22 : 28),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
Container(
|
||||
padding:
|
||||
const EdgeInsets.fromLTRB(22, 22, 22, 20),
|
||||
padding: EdgeInsets.fromLTRB(
|
||||
compact ? 14 : 22,
|
||||
compact ? 14 : 22,
|
||||
compact ? 14 : 22,
|
||||
compact ? 14 : 20,
|
||||
),
|
||||
decoration: const BoxDecoration(
|
||||
color: Color(0xFF071226),
|
||||
),
|
||||
@ -143,37 +164,38 @@ class _ServerConnectScreenState extends State<ServerConnectScreen> {
|
||||
Row(
|
||||
children: [
|
||||
Container(
|
||||
width: 48,
|
||||
height: 48,
|
||||
width: compact ? 38 : 48,
|
||||
height: compact ? 38 : 48,
|
||||
decoration: BoxDecoration(
|
||||
color: const Color(0xFF2563EB),
|
||||
borderRadius:
|
||||
BorderRadius.circular(16),
|
||||
),
|
||||
child: const Icon(
|
||||
child: Icon(
|
||||
Icons.navigation_rounded,
|
||||
color: Colors.white,
|
||||
size: 28),
|
||||
size: compact ? 24 : 28,
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 12),
|
||||
const Expanded(
|
||||
Expanded(
|
||||
child: Text(
|
||||
'WalkGuide Link',
|
||||
'WalkGuide',
|
||||
style: TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 20,
|
||||
fontSize: compact ? 16 : 20,
|
||||
fontWeight: FontWeight.w900,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 18),
|
||||
const Text(
|
||||
SizedBox(height: compact ? 14 : 18),
|
||||
Text(
|
||||
'Connect to Server',
|
||||
style: TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 30,
|
||||
fontSize: compact ? 22 : 30,
|
||||
fontWeight: FontWeight.w900,
|
||||
height: 1,
|
||||
),
|
||||
@ -191,7 +213,7 @@ class _ServerConnectScreenState extends State<ServerConnectScreen> {
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(22),
|
||||
padding: EdgeInsets.all(compact ? 14 : 22),
|
||||
child: Column(
|
||||
crossAxisAlignment:
|
||||
CrossAxisAlignment.stretch,
|
||||
@ -217,13 +239,18 @@ class _ServerConnectScreenState extends State<ServerConnectScreen> {
|
||||
label: 'USB: 127.0.0.1',
|
||||
onTap: _useUsbUrl,
|
||||
),
|
||||
_HintChip(
|
||||
icon: Icons.phone_android_outlined,
|
||||
label: 'Emulator: 10.0.2.2',
|
||||
onTap: _useAndroidEmulatorUrl,
|
||||
),
|
||||
const _HintChip(
|
||||
icon: Icons.wifi_tethering_outlined,
|
||||
label: 'Wi-Fi: IP laptop',
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
SizedBox(height: compact ? 12 : 16),
|
||||
OutlinedButton.icon(
|
||||
onPressed: _loading ? null : _test,
|
||||
icon: _loading
|
||||
@ -251,6 +278,7 @@ class _ServerConnectScreenState extends State<ServerConnectScreen> {
|
||||
label: const Text('Continue'),
|
||||
),
|
||||
],
|
||||
if (!compact) ...[
|
||||
const SizedBox(height: 18),
|
||||
const Center(
|
||||
child: Text(
|
||||
@ -261,6 +289,7 @@ class _ServerConnectScreenState extends State<ServerConnectScreen> {
|
||||
),
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
|
||||
@ -0,0 +1,3 @@
|
||||
Settings application layer.
|
||||
|
||||
This layer is reserved for settings Cubit/BLoC orchestration.
|
||||
@ -0,0 +1,3 @@
|
||||
Settings data layer.
|
||||
|
||||
This layer is reserved for `/user/settings` and local settings data adapters.
|
||||
@ -0,0 +1,3 @@
|
||||
Settings domain layer.
|
||||
|
||||
This layer is reserved for settings entities, repository contracts, and update use cases.
|
||||
@ -125,6 +125,7 @@ class _UserSettingsScreenState extends State<UserSettingsScreen> {
|
||||
setState(() => _saving = true);
|
||||
// Apply TTS locally dulu
|
||||
await sl<TtsService>().setLanguage(_ttsLanguage);
|
||||
context.read<AppCubit>().setLocaleCode(_ttsLanguage);
|
||||
if (_hapticEnabled) {
|
||||
await sl<HapticService>().success();
|
||||
}
|
||||
|
||||
@ -243,9 +243,18 @@ class _SosScreenState extends State<SosScreen>
|
||||
bloc: _sosCubit,
|
||||
builder: (context, sosState) {
|
||||
final sending = sosState.phase == SosPhase.sending;
|
||||
final size = MediaQuery.sizeOf(context);
|
||||
final compact = size.height < 620;
|
||||
final landscapeTight = size.width > size.height && size.height < 520;
|
||||
final pagePadding = compact ? 12.0 : 16.0;
|
||||
final sectionGap = landscapeTight
|
||||
? 8.0
|
||||
: compact
|
||||
? 12.0
|
||||
: 24.0;
|
||||
return SafeArea(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(16),
|
||||
padding: EdgeInsets.all(pagePadding),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
@ -278,14 +287,14 @@ class _SosScreenState extends State<SosScreen>
|
||||
],
|
||||
),
|
||||
|
||||
const SizedBox(height: 24),
|
||||
SizedBox(height: sectionGap),
|
||||
|
||||
// Active SOS banner
|
||||
if (_hasActiveSos)
|
||||
_ActiveSosBanner(
|
||||
event: _events.first, onRefresh: _loadHistory),
|
||||
|
||||
const SizedBox(height: 24),
|
||||
SizedBox(height: sectionGap),
|
||||
|
||||
// SOS Button
|
||||
Center(
|
||||
@ -312,6 +321,8 @@ class _SosScreenState extends State<SosScreen>
|
||||
? 'SOS aktif — Guardian sudah mendapat notifikasi'
|
||||
: 'Tekan tombol untuk kirim SOS darurat ke Guardian',
|
||||
textAlign: TextAlign.center,
|
||||
maxLines: 2,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: TextStyle(
|
||||
color: _hasActiveSos
|
||||
? const Color(0xFFDC2626)
|
||||
@ -321,22 +332,25 @@ class _SosScreenState extends State<SosScreen>
|
||||
),
|
||||
),
|
||||
|
||||
const SizedBox(height: 28),
|
||||
SizedBox(height: sectionGap),
|
||||
|
||||
// History section
|
||||
if (!landscapeTight) ...[
|
||||
const Text(
|
||||
'Riwayat SOS',
|
||||
style: TextStyle(fontWeight: FontWeight.w800, fontSize: 16),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
|
||||
Expanded(
|
||||
child: _SosHistory(
|
||||
loading: _historyLoading,
|
||||
error: _historyError,
|
||||
events: _events,
|
||||
onRefresh: _loadHistory,
|
||||
)),
|
||||
),
|
||||
),
|
||||
] else
|
||||
const Spacer(),
|
||||
],
|
||||
),
|
||||
),
|
||||
@ -361,8 +375,16 @@ class _SosButton extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final screen = MediaQuery.sizeOf(context);
|
||||
final compact = screen.height < 620;
|
||||
final landscapeTight = screen.width > screen.height && screen.height < 520;
|
||||
final dimension = landscapeTight
|
||||
? 132.0
|
||||
: compact
|
||||
? 154.0
|
||||
: 200.0;
|
||||
return SizedBox.square(
|
||||
dimension: 200,
|
||||
dimension: dimension,
|
||||
child: FilledButton(
|
||||
style: FilledButton.styleFrom(
|
||||
shape: const CircleBorder(),
|
||||
@ -377,14 +399,14 @@ class _SosButton extends StatelessWidget {
|
||||
children: [
|
||||
Icon(
|
||||
active ? Icons.emergency : Icons.emergency_outlined,
|
||||
size: 48,
|
||||
size: dimension < 150 ? 34 : 48,
|
||||
color: Colors.white,
|
||||
),
|
||||
const SizedBox(height: 6),
|
||||
SizedBox(height: dimension < 150 ? 3 : 6),
|
||||
Text(
|
||||
'SOS',
|
||||
style: const TextStyle(
|
||||
fontSize: 38,
|
||||
style: TextStyle(
|
||||
fontSize: dimension < 150 ? 28 : 38,
|
||||
fontWeight: FontWeight.w900,
|
||||
color: Colors.white,
|
||||
letterSpacing: 2,
|
||||
@ -402,8 +424,16 @@ class _SendingIndicator extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final screen = MediaQuery.sizeOf(context);
|
||||
final compact = screen.height < 620;
|
||||
final landscapeTight = screen.width > screen.height && screen.height < 520;
|
||||
final dimension = landscapeTight
|
||||
? 132.0
|
||||
: compact
|
||||
? 154.0
|
||||
: 200.0;
|
||||
return SizedBox.square(
|
||||
dimension: 200,
|
||||
dimension: dimension,
|
||||
child: DecoratedBox(
|
||||
decoration: BoxDecoration(
|
||||
color: const Color(0xFFDC2626).withValues(alpha: 0.15),
|
||||
|
||||
@ -144,6 +144,7 @@ class _WalkGuideScreenState extends State<WalkGuideScreen>
|
||||
() async {
|
||||
final cameras = await availableCameras();
|
||||
if (cameras.isEmpty) return;
|
||||
await sl<YoloDetector>().init();
|
||||
final backCamera = cameras.firstWhere(
|
||||
(camera) => camera.lensDirection == CameraLensDirection.back,
|
||||
orElse: () => cameras.first,
|
||||
@ -808,6 +809,7 @@ class _Page extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final compact = MediaQuery.sizeOf(context).height < 520;
|
||||
return SafeArea(
|
||||
child: DecoratedBox(
|
||||
decoration: const BoxDecoration(
|
||||
@ -818,15 +820,20 @@ class _Page extends StatelessWidget {
|
||||
),
|
||||
),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.fromLTRB(16, 14, 16, 16),
|
||||
padding: EdgeInsets.fromLTRB(
|
||||
compact ? 12 : 16,
|
||||
compact ? 8 : 14,
|
||||
compact ? 12 : 16,
|
||||
compact ? 10 : 16,
|
||||
),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
Container(
|
||||
width: 46,
|
||||
height: 46,
|
||||
width: compact ? 38 : 46,
|
||||
height: compact ? 38 : 46,
|
||||
decoration: BoxDecoration(
|
||||
color: const Color(0xFF2563EB),
|
||||
borderRadius: BorderRadius.circular(14),
|
||||
@ -839,21 +846,24 @@ class _Page extends StatelessWidget {
|
||||
),
|
||||
],
|
||||
),
|
||||
child: const Icon(Icons.navigation_rounded,
|
||||
color: Colors.white, size: 26),
|
||||
child: Icon(Icons.navigation_rounded,
|
||||
color: Colors.white, size: compact ? 22 : 26),
|
||||
),
|
||||
const SizedBox(width: 12),
|
||||
SizedBox(width: compact ? 10 : 12),
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(title,
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: Theme.of(context)
|
||||
.textTheme
|
||||
.headlineSmall
|
||||
?.copyWith(
|
||||
fontWeight: FontWeight.w900,
|
||||
color: const Color(0xFF0F172A),
|
||||
fontSize: compact ? 22 : null,
|
||||
)),
|
||||
if (subtitle != null)
|
||||
Text(subtitle!,
|
||||
@ -866,7 +876,7 @@ class _Page extends StatelessWidget {
|
||||
...?actions,
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
SizedBox(height: compact ? 8 : 16),
|
||||
Expanded(child: child),
|
||||
],
|
||||
),
|
||||
|
||||
@ -1,36 +1,207 @@
|
||||
import 'dart:async';
|
||||
import 'dart:ui';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:camera/camera.dart';
|
||||
import 'package:firebase_core/firebase_core.dart';
|
||||
import 'package:firebase_messaging/firebase_messaging.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'app/injection_container.dart';
|
||||
import 'app/app.dart';
|
||||
import 'core/constants/app_constants.dart';
|
||||
import 'core/utils/init_guard.dart';
|
||||
|
||||
List<CameraDescription> cameras = [];
|
||||
|
||||
@pragma('vm:entry-point')
|
||||
Future<void> _firebaseMessagingBackgroundHandler(RemoteMessage message) async {
|
||||
await Firebase.initializeApp();
|
||||
}
|
||||
|
||||
Future<void> main() async {
|
||||
await runZonedGuarded(
|
||||
() async {
|
||||
WidgetsFlutterBinding.ensureInitialized();
|
||||
|
||||
cameras = await ignoreInitFailure(
|
||||
availableCameras,
|
||||
label: 'Camera init',
|
||||
) ??
|
||||
[];
|
||||
_installGlobalErrorUi();
|
||||
await AppConstants.clearServerUrl();
|
||||
|
||||
if (!kIsWeb) {
|
||||
await ignoreInitFailure(() => Firebase.initializeApp(),
|
||||
label: 'Firebase init');
|
||||
FirebaseMessaging.onBackgroundMessage(_firebaseMessagingBackgroundHandler);
|
||||
final firebaseApp = await ignoreInitFailure(
|
||||
() => Firebase.initializeApp(),
|
||||
label: 'Firebase init',
|
||||
);
|
||||
if (firebaseApp != null) {
|
||||
FirebaseMessaging.onBackgroundMessage(
|
||||
_firebaseMessagingBackgroundHandler,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// Init GetIt dependencies
|
||||
try {
|
||||
await initDependencies();
|
||||
} catch (error, stackTrace) {
|
||||
debugPrint('WalkGuide startup failed: $error\n$stackTrace');
|
||||
runApp(WalkGuideFatalApp(error: error, stackTrace: stackTrace));
|
||||
return;
|
||||
}
|
||||
|
||||
runApp(const WalkGuideApp());
|
||||
},
|
||||
(error, stackTrace) {
|
||||
debugPrint('WalkGuide uncaught error: $error\n$stackTrace');
|
||||
runApp(WalkGuideFatalApp(error: error, stackTrace: stackTrace));
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
void _installGlobalErrorUi() {
|
||||
FlutterError.onError = (details) {
|
||||
FlutterError.presentError(details);
|
||||
debugPrint('WalkGuide Flutter error: ${details.exceptionAsString()}');
|
||||
};
|
||||
|
||||
PlatformDispatcher.instance.onError = (error, stackTrace) {
|
||||
debugPrint('WalkGuide platform error: $error\n$stackTrace');
|
||||
return true;
|
||||
};
|
||||
|
||||
ErrorWidget.builder = (details) {
|
||||
return WalkGuideErrorPanel(
|
||||
title: 'WalkGuide UI Error',
|
||||
message:
|
||||
'A screen failed to render. Please report this message to the developer.',
|
||||
details: details.exceptionAsString(),
|
||||
);
|
||||
};
|
||||
}
|
||||
|
||||
class WalkGuideFatalApp extends StatelessWidget {
|
||||
final Object error;
|
||||
final StackTrace? stackTrace;
|
||||
|
||||
const WalkGuideFatalApp({
|
||||
super.key,
|
||||
required this.error,
|
||||
this.stackTrace,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return MaterialApp(
|
||||
debugShowCheckedModeBanner: false,
|
||||
home: WalkGuideErrorPanel(
|
||||
title: 'WalkGuide Startup Error',
|
||||
message:
|
||||
'The app could not finish startup. Please report this screen to the developer.',
|
||||
details: error.toString(),
|
||||
stackTrace: stackTrace?.toString(),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class WalkGuideErrorPanel extends StatelessWidget {
|
||||
final String title;
|
||||
final String message;
|
||||
final String details;
|
||||
final String? stackTrace;
|
||||
|
||||
const WalkGuideErrorPanel({
|
||||
super.key,
|
||||
required this.title,
|
||||
required this.message,
|
||||
required this.details,
|
||||
this.stackTrace,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final textTheme = Theme.of(context).textTheme;
|
||||
return Scaffold(
|
||||
backgroundColor: const Color(0xFFF8FAFC),
|
||||
body: SafeArea(
|
||||
child: Center(
|
||||
child: SingleChildScrollView(
|
||||
padding: const EdgeInsets.all(24),
|
||||
child: ConstrainedBox(
|
||||
constraints: const BoxConstraints(maxWidth: 520),
|
||||
child: DecoratedBox(
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
border: Border.all(color: const Color(0xFFE2E8F0)),
|
||||
boxShadow: const [
|
||||
BoxShadow(
|
||||
blurRadius: 24,
|
||||
offset: Offset(0, 12),
|
||||
color: Color(0x1A0F172A),
|
||||
),
|
||||
],
|
||||
),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(22),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
const Icon(
|
||||
Icons.error_outline,
|
||||
color: Color(0xFFDC2626),
|
||||
size: 42,
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
Text(
|
||||
title,
|
||||
style: textTheme.headlineSmall?.copyWith(
|
||||
fontWeight: FontWeight.w800,
|
||||
color: const Color(0xFF0F172A),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
Text(
|
||||
message,
|
||||
style: textTheme.bodyMedium?.copyWith(
|
||||
color: const Color(0xFF475569),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 18),
|
||||
Container(
|
||||
width: double.infinity,
|
||||
padding: const EdgeInsets.all(14),
|
||||
decoration: BoxDecoration(
|
||||
color: const Color(0xFFF1F5F9),
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
border: Border.all(color: const Color(0xFFE2E8F0)),
|
||||
),
|
||||
child: SelectableText(
|
||||
_formatDetails(),
|
||||
style: const TextStyle(
|
||||
fontFamily: 'monospace',
|
||||
fontSize: 12,
|
||||
color: Color(0xFF334155),
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
const Text(
|
||||
'Tip: close the app and open it again after fixing the configuration.',
|
||||
style: TextStyle(
|
||||
color: Color(0xFF64748B),
|
||||
fontSize: 12,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
String _formatDetails() {
|
||||
final stack = stackTrace;
|
||||
if (stack == null || stack.isEmpty) return details;
|
||||
final shortStack = stack.split('\n').take(8).join('\n');
|
||||
return '$details\n\n$shortStack';
|
||||
}
|
||||
}
|
||||
|
||||
@ -26,7 +26,9 @@ class _UserShellState extends State<UserShell> {
|
||||
super.initState();
|
||||
_loadVoiceCommands();
|
||||
_startHardwareShortcuts();
|
||||
sl<SttService>().startListening();
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
_startVoiceListening();
|
||||
});
|
||||
sl<VoiceCommandHandler>().onCommand = (key) {
|
||||
if (!mounted) return;
|
||||
switch (key) {
|
||||
@ -64,6 +66,17 @@ class _UserShellState extends State<UserShell> {
|
||||
};
|
||||
}
|
||||
|
||||
Future<void> _startVoiceListening() async {
|
||||
await runFriendlyAction(
|
||||
() async {
|
||||
await sl<SttService>().init();
|
||||
await sl<SttService>().startListening();
|
||||
},
|
||||
onError: (_) {},
|
||||
fallback: 'Voice listener belum bisa dimuat.',
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> _loadVoiceCommands() async {
|
||||
await runFriendlyAction(
|
||||
() async {
|
||||
@ -182,9 +195,10 @@ class _AppShell extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
backgroundColor: AppColors.surface,
|
||||
body: AnimatedSwitcher(
|
||||
return LayoutBuilder(
|
||||
builder: (context, constraints) {
|
||||
final useRail = constraints.maxWidth >= 760;
|
||||
final content = AnimatedSwitcher(
|
||||
duration: const Duration(milliseconds: 180),
|
||||
switchInCurve: Curves.easeOutCubic,
|
||||
switchOutCurve: Curves.easeInCubic,
|
||||
@ -192,8 +206,145 @@ class _AppShell extends StatelessWidget {
|
||||
key: ValueKey(location),
|
||||
child: child,
|
||||
),
|
||||
);
|
||||
|
||||
return Scaffold(
|
||||
backgroundColor: AppColors.surface,
|
||||
body: useRail
|
||||
? Row(
|
||||
children: [
|
||||
_RailNavigation(
|
||||
items: items,
|
||||
selectedIndex: _selectedIndex,
|
||||
),
|
||||
bottomNavigationBar: DecoratedBox(
|
||||
const VerticalDivider(width: 1, color: AppColors.border),
|
||||
Expanded(child: content),
|
||||
],
|
||||
)
|
||||
: content,
|
||||
bottomNavigationBar: useRail
|
||||
? null
|
||||
: _BottomScrollNavigation(
|
||||
items: items,
|
||||
selectedIndex: _selectedIndex,
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
int get _selectedIndex {
|
||||
final index = items.indexWhere((item) => location.startsWith(item.route));
|
||||
return index < 0 ? 0 : index;
|
||||
}
|
||||
}
|
||||
|
||||
class _RailNavigation extends StatelessWidget {
|
||||
final List<_ShellItem> items;
|
||||
final int selectedIndex;
|
||||
|
||||
const _RailNavigation({
|
||||
required this.items,
|
||||
required this.selectedIndex,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return LayoutBuilder(
|
||||
builder: (context, constraints) {
|
||||
final compact = constraints.maxHeight < 520;
|
||||
final width = compact ? 76.0 : 86.0;
|
||||
final itemHeight = compact ? 58.0 : 70.0;
|
||||
|
||||
return DecoratedBox(
|
||||
decoration: const BoxDecoration(color: Colors.white),
|
||||
child: SafeArea(
|
||||
right: false,
|
||||
child: SizedBox(
|
||||
width: width,
|
||||
child: ListView.separated(
|
||||
padding: EdgeInsets.symmetric(
|
||||
horizontal: 8,
|
||||
vertical: compact ? 6 : 12,
|
||||
),
|
||||
itemCount: items.length,
|
||||
separatorBuilder: (_, __) => SizedBox(height: compact ? 2 : 6),
|
||||
itemBuilder: (context, index) {
|
||||
final item = items[index];
|
||||
final selected = index == selectedIndex;
|
||||
return Semantics(
|
||||
button: true,
|
||||
selected: selected,
|
||||
label: item.label,
|
||||
child: InkWell(
|
||||
borderRadius: BorderRadius.circular(18),
|
||||
onTap: () => context.go(items[index].route),
|
||||
child: AnimatedContainer(
|
||||
duration: const Duration(milliseconds: 160),
|
||||
height: itemHeight,
|
||||
padding: const EdgeInsets.symmetric(horizontal: 4),
|
||||
decoration: BoxDecoration(
|
||||
color: selected
|
||||
? const Color(0xFFEFF6FF)
|
||||
: Colors.transparent,
|
||||
borderRadius: BorderRadius.circular(18),
|
||||
),
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Icon(
|
||||
selected ? item.selectedIcon : item.icon,
|
||||
size: compact ? 23 : 25,
|
||||
color: selected
|
||||
? AppColors.primary
|
||||
: const Color(0xFF334155),
|
||||
),
|
||||
SizedBox(height: compact ? 2 : 5),
|
||||
Text(
|
||||
item.label,
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
fontSize: compact ? 10 : 12,
|
||||
height: 1,
|
||||
fontWeight: selected
|
||||
? FontWeight.w800
|
||||
: FontWeight.w600,
|
||||
color: selected
|
||||
? const Color(0xFF1D4ED8)
|
||||
: const Color(0xFF334155),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _BottomScrollNavigation extends StatelessWidget {
|
||||
final List<_ShellItem> items;
|
||||
final int selectedIndex;
|
||||
|
||||
const _BottomScrollNavigation({
|
||||
required this.items,
|
||||
required this.selectedIndex,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final bottom = MediaQuery.of(context).padding.bottom;
|
||||
final extraBottom = bottom > 12 ? 12.0 : bottom;
|
||||
return DecoratedBox(
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
border: const Border(top: BorderSide(color: AppColors.border)),
|
||||
@ -205,25 +356,74 @@ class _AppShell extends StatelessWidget {
|
||||
),
|
||||
],
|
||||
),
|
||||
child: NavigationBar(
|
||||
selectedIndex: _selectedIndex,
|
||||
onDestinationSelected: (index) => context.go(items[index].route),
|
||||
destinations: [
|
||||
for (final item in items)
|
||||
NavigationDestination(
|
||||
icon: Icon(item.icon),
|
||||
selectedIcon: Icon(item.selectedIcon),
|
||||
child: SafeArea(
|
||||
top: false,
|
||||
child: SizedBox(
|
||||
height: 68 + extraBottom,
|
||||
child: ListView.separated(
|
||||
scrollDirection: Axis.horizontal,
|
||||
padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 8),
|
||||
itemCount: items.length,
|
||||
separatorBuilder: (_, __) => const SizedBox(width: 6),
|
||||
itemBuilder: (context, index) {
|
||||
final item = items[index];
|
||||
final selected = index == selectedIndex;
|
||||
return Semantics(
|
||||
button: true,
|
||||
selected: selected,
|
||||
label: item.label,
|
||||
child: InkWell(
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
onTap: () => context.go(item.route),
|
||||
child: AnimatedContainer(
|
||||
duration: const Duration(milliseconds: 160),
|
||||
width: 72,
|
||||
padding: const EdgeInsets.symmetric(horizontal: 6),
|
||||
decoration: BoxDecoration(
|
||||
color: selected
|
||||
? const Color(0xFFEFF6FF)
|
||||
: Colors.transparent,
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
border: Border.all(
|
||||
color: selected
|
||||
? const Color(0xFFBFDBFE)
|
||||
: Colors.transparent,
|
||||
),
|
||||
),
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Icon(
|
||||
selected ? item.selectedIcon : item.icon,
|
||||
color: selected
|
||||
? AppColors.primary
|
||||
: const Color(0xFF64748B),
|
||||
size: 22,
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
Text(
|
||||
item.label,
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: TextStyle(
|
||||
fontSize: 11,
|
||||
fontWeight:
|
||||
selected ? FontWeight.w800 : FontWeight.w600,
|
||||
color: selected
|
||||
? AppColors.primary
|
||||
: const Color(0xFF64748B),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
int get _selectedIndex {
|
||||
final index = items.indexWhere((item) => location.startsWith(item.route));
|
||||
return index < 0 ? 0 : index;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -19,8 +19,24 @@ class FeaturePage extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return SafeArea(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.fromLTRB(16, 14, 16, 16),
|
||||
child: LayoutBuilder(
|
||||
builder: (context, constraints) {
|
||||
final short = constraints.maxHeight < 520;
|
||||
final compact = constraints.maxWidth < 420 || short;
|
||||
final wide = constraints.maxWidth >= 900;
|
||||
final horizontal = compact ? 12.0 : 20.0;
|
||||
return Padding(
|
||||
padding: EdgeInsets.fromLTRB(
|
||||
horizontal,
|
||||
short ? 8 : 12,
|
||||
horizontal,
|
||||
short ? 10 : 14,
|
||||
),
|
||||
child: Center(
|
||||
child: ConstrainedBox(
|
||||
constraints: BoxConstraints(
|
||||
maxWidth: wide ? 1160 : double.infinity,
|
||||
),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
@ -35,18 +51,75 @@ class FeaturePage extends StatelessWidget {
|
||||
child: child,
|
||||
),
|
||||
),
|
||||
child: Row(
|
||||
child: compact
|
||||
? Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
_FeatureHeading(
|
||||
title: title,
|
||||
subtitle: subtitle,
|
||||
compact: compact,
|
||||
),
|
||||
if (trailing != null) ...[
|
||||
const SizedBox(height: 10),
|
||||
Align(
|
||||
alignment: Alignment.centerLeft,
|
||||
child: trailing!,
|
||||
),
|
||||
],
|
||||
],
|
||||
)
|
||||
: Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: Column(
|
||||
child: _FeatureHeading(
|
||||
title: title,
|
||||
subtitle: subtitle,
|
||||
compact: compact,
|
||||
),
|
||||
),
|
||||
if (trailing != null) trailing!,
|
||||
],
|
||||
),
|
||||
),
|
||||
SizedBox(height: short ? 8 : (compact ? 12 : 16)),
|
||||
Expanded(
|
||||
child: child,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _FeatureHeading extends StatelessWidget {
|
||||
final String title;
|
||||
final String subtitle;
|
||||
final bool compact;
|
||||
|
||||
const _FeatureHeading({
|
||||
required this.title,
|
||||
required this.subtitle,
|
||||
required this.compact,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final short = MediaQuery.sizeOf(context).height < 520;
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
title,
|
||||
style: Theme.of(context)
|
||||
.textTheme
|
||||
.headlineSmall
|
||||
?.copyWith(
|
||||
maxLines: short ? 1 : 2,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: Theme.of(context).textTheme.headlineSmall?.copyWith(
|
||||
fontSize: compact ? 22 : null,
|
||||
fontWeight: FontWeight.w900,
|
||||
color: AppColors.text,
|
||||
),
|
||||
@ -54,23 +127,15 @@ class FeaturePage extends StatelessWidget {
|
||||
const SizedBox(height: 2),
|
||||
Text(
|
||||
subtitle,
|
||||
maxLines: short ? 1 : (compact ? 2 : 3),
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: const TextStyle(
|
||||
color: AppColors.muted,
|
||||
fontWeight: FontWeight.w500,
|
||||
height: 1.25,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
if (trailing != null) trailing!,
|
||||
],
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
Expanded(child: child),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -7,6 +7,7 @@ import Foundation
|
||||
|
||||
import agora_rtc_engine
|
||||
import audio_session
|
||||
import battery_plus
|
||||
import connectivity_plus
|
||||
import device_info_plus
|
||||
import firebase_core
|
||||
@ -27,6 +28,7 @@ import sqlite3_flutter_libs
|
||||
func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
|
||||
AgoraRtcNgPlugin.register(with: registry.registrar(forPlugin: "AgoraRtcNgPlugin"))
|
||||
AudioSessionPlugin.register(with: registry.registrar(forPlugin: "AudioSessionPlugin"))
|
||||
BatteryPlusMacosPlugin.register(with: registry.registrar(forPlugin: "BatteryPlusMacosPlugin"))
|
||||
ConnectivityPlusPlugin.register(with: registry.registrar(forPlugin: "ConnectivityPlusPlugin"))
|
||||
DeviceInfoPlusMacosPlugin.register(with: registry.registrar(forPlugin: "DeviceInfoPlusMacosPlugin"))
|
||||
FLTFirebaseCorePlugin.register(with: registry.registrar(forPlugin: "FLTFirebaseCorePlugin"))
|
||||
|
||||
@ -65,6 +65,22 @@ packages:
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.1.25"
|
||||
battery_plus:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: battery_plus
|
||||
sha256: "03d5a6bb36db9d2b977c548f6b0262d5a84c4d5a4cfee2edac4a91d57011b365"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "6.2.3"
|
||||
battery_plus_platform_interface:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: battery_plus_platform_interface
|
||||
sha256: e8342c0f32de4b1dfd0223114b6785e48e579bfc398da9471c9179b907fa4910
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.0.1"
|
||||
bloc:
|
||||
dependency: transitive
|
||||
description:
|
||||
@ -571,6 +587,11 @@ packages:
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "7.2.0"
|
||||
flutter_localizations:
|
||||
dependency: "direct main"
|
||||
description: flutter
|
||||
source: sdk
|
||||
version: "0.0.0"
|
||||
flutter_map:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
@ -1652,6 +1673,14 @@ packages:
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.3.1"
|
||||
upower:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: upower
|
||||
sha256: cf042403154751180affa1d15614db7fa50234bc2373cd21c3db666c38543ebf
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.7.0"
|
||||
uuid:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
||||
@ -9,6 +9,8 @@ environment:
|
||||
dependencies:
|
||||
flutter:
|
||||
sdk: flutter
|
||||
flutter_localizations:
|
||||
sdk: flutter
|
||||
|
||||
# State management
|
||||
flutter_bloc: ^8.1.6
|
||||
@ -50,6 +52,7 @@ dependencies:
|
||||
|
||||
# Location
|
||||
geolocator: ^12.0.0
|
||||
battery_plus: ^6.2.3
|
||||
|
||||
# Agora VoIP
|
||||
agora_rtc_engine: ^6.3.2
|
||||
|
||||
@ -7,6 +7,7 @@
|
||||
#include "generated_plugin_registrant.h"
|
||||
|
||||
#include <agora_rtc_engine/agora_rtc_engine_plugin.h>
|
||||
#include <battery_plus/battery_plus_windows_plugin.h>
|
||||
#include <connectivity_plus/connectivity_plus_windows_plugin.h>
|
||||
#include <firebase_core/firebase_core_plugin_c_api.h>
|
||||
#include <flutter_secure_storage_windows/flutter_secure_storage_windows_plugin.h>
|
||||
@ -21,6 +22,8 @@
|
||||
void RegisterPlugins(flutter::PluginRegistry* registry) {
|
||||
AgoraRtcEnginePluginRegisterWithRegistrar(
|
||||
registry->GetRegistrarForPlugin("AgoraRtcEnginePlugin"));
|
||||
BatteryPlusWindowsPluginRegisterWithRegistrar(
|
||||
registry->GetRegistrarForPlugin("BatteryPlusWindowsPlugin"));
|
||||
ConnectivityPlusWindowsPluginRegisterWithRegistrar(
|
||||
registry->GetRegistrarForPlugin("ConnectivityPlusWindowsPlugin"));
|
||||
FirebaseCorePluginCApiRegisterWithRegistrar(
|
||||
|
||||
@ -4,6 +4,7 @@
|
||||
|
||||
list(APPEND FLUTTER_PLUGIN_LIST
|
||||
agora_rtc_engine
|
||||
battery_plus
|
||||
connectivity_plus
|
||||
firebase_core
|
||||
flutter_secure_storage_windows
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user